From b289864f0a0696c01f059041bfacac070fd66d3e Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 27 Apr 2023 16:04:07 +0200 Subject: [PATCH] wait #5889 @0.5 --- app/Fluidbook/Links.php | 30 +++++++++++++++---- resources/linkeditor/js/linkeditor.toolbar.js | 5 +++- .../link_editor.blade.php | 1 + 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/app/Fluidbook/Links.php b/app/Fluidbook/Links.php index 158b1e432..95e4959a8 100644 --- a/app/Fluidbook/Links.php +++ b/app/Fluidbook/Links.php @@ -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) diff --git a/resources/linkeditor/js/linkeditor.toolbar.js b/resources/linkeditor/js/linkeditor.toolbar.js index 3a5ba9466..c277ce06a 100644 --- a/resources/linkeditor/js/linkeditor.toolbar.js +++ b/resources/linkeditor/js/linkeditor.toolbar.js @@ -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'); + }, } ); } diff --git a/resources/views/fluidbook_publication/link_editor.blade.php b/resources/views/fluidbook_publication/link_editor.blade.php index df32be8f2..a0160db0a 100644 --- a/resources/views/fluidbook_publication/link_editor.blade.php +++ b/resources/views/fluidbook_publication/link_editor.blade.php @@ -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'), -- 2.39.5