]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5889 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 27 Apr 2023 14:04:07 +0000 (16:04 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 27 Apr 2023 14:04:07 +0000 (16:04 +0200)
app/Fluidbook/Links.php
resources/linkeditor/js/linkeditor.toolbar.js
resources/views/fluidbook_publication/link_editor.blade.php

index 158b1e43295b0e47839e981a0ebd28e4caecc4ec..95e4959a8c04db30f5949f5f07d746dae706b843 100644 (file)
@@ -45,7 +45,7 @@ class Links
             'animation' => __('Animation'),
             'group' => __('Groupe'),
             'zindex' => __('Profondeur'),
-            'pdfjs'=>__('Mode PDFJS'),
+            'pdfjs' => __('Mode PDFJS'),
         );
 
         $comments = array();
@@ -294,11 +294,27 @@ class Links
         }
     }
 
+    /**
+     * @param $xls Spreadsheet
+     * @param $links []
+     * @param $rulers []
+     * @return void
+     */
     public static function getLinksFromExcel($xls, &$links, &$rulers)
     {
-        $s = $xls->setActiveSheetIndexByName('Links');
-        $i = 0;
+
+        $rulers = array();
         $links = array();
+        
+        if ($xls->getSheetCount() === 1) {
+            $s = $xls->setActiveSheetIndex(0);
+        } else if (null === $xls->getSheetByName('Links')) {
+            $s = $xls->setActiveSheetIndexByName('Links');
+        } else {
+            throw new \Exception(__('Format du fichier Excel invalide (pas de feuille nommée :name)', ['name' => 'Links']));
+        }
+        $i = 0;
+
         foreach ($s->getRowIterator() as $row) {
             $cellIterator = $row->getCellIterator();
             $cellIterator->setIterateOnlyExistingCells(false);
@@ -324,9 +340,13 @@ class Links
             }
             $i++;
         }
+        self::_fixLinks($links);
 
+
+        if ($xls->getSheetCount() === 1 || null === $xls->getSheetByName('Rulers')) {
+            return;
+        }
         $i = 0;
-        $rulers = array();
         $s = $xls->setActiveSheetIndexByName('Rulers');
         foreach ($s->getRowIterator() as $row) {
             $cellIterator = $row->getCellIterator();
@@ -348,8 +368,6 @@ class Links
             }
             $i++;
         }
-
-        self::_fixLinks($links);
     }
 
     public static function getLinksFromAutobookmarkText($txt, &$links, &$rulers)
index 3a5ba9466ed37741ae96a05098fd3ccc3ca68ac8..c277ce06afeaeba4a12c8de84356507f29bf528c 100644 (file)
@@ -54,6 +54,7 @@ LinkeditorToolbar.prototype = {
     },
 
     submitFormAndReload: function (form) {
+        var $this = this;
         var callback = function () {
             $(form).ajaxSubmit(
                 {
@@ -62,7 +63,9 @@ LinkeditorToolbar.prototype = {
                         setTimeout(function () {
                             window.location.reload();
                         }, 1000);
-                    }
+                    }, error: function (data) {
+                        $this.linkeditor.notification(TRANSLATIONS.error + ' : ' + data.responseJSON.message, 'error');
+                    },
                 }
             );
         }
index df32be8f2323cd0ac2a7a2f1d13ebc82005e276b..a0160db0ac0fc4ea9c49ca4e35c5e08a6bd4afe0 100644 (file)
@@ -35,6 +35,7 @@
     $translations=[
         'success_save'=>__('Liens sauvegardés'),
         'error_save'=>__('Une erreur s\'est produite lors de la sauvegarde des liens'),
+        'error'=>__('Une erreur s\'est produite'),
         'manual_save_message'=>__('Sauvegarde manuelle'),
         'automatic_save_message'=>__('Sauvegarde automatique'),
         'warning_unsaved_changes'=>__('Des données n\'ont pas été sauvegardées'),