From e31b045613d980217bb812ddc18d2b3c8527b2fc Mon Sep 17 00:00:00 2001 From: Arthur Suzuki <arthur.suzuki@biblibre.com> Date: Mon, 5 Sep 2022 11:50:02 +0200 Subject: [PATCH] hotline#158802 : fix asynchronous widget content loading --- VERSIONS_HOTLINE/158802 | 1 + library/Class/Systeme/ModulesAccueil/Null.php | 2 +- library/Class/Systeme/Widget/Menu.php | 2 +- .../View/Helper/Accueil/AbonneAbstract.php | 2 +- library/ZendAfi/View/Helper/Accueil/Base.php | 14 ++++++-------- .../View/Helper/Accueil/BibNumerique.php | 5 +++-- .../ZendAfi/View/Helper/Accueil/Calendar.php | 4 +++- .../Helper/Accueil/ConteneurDeuxColonnes.php | 13 ++++++++----- .../Helper/Accueil/HistoriqueRecherches.php | 9 ++++++--- .../View/Helper/Accueil/IdentityProvider.php | 7 +++++-- .../ZendAfi/View/Helper/Accueil/Kiosque.php | 6 ++++-- .../ZendAfi/View/Helper/Accueil/Library.php | 5 +++-- library/ZendAfi/View/Helper/Accueil/Login.php | 7 +++++-- .../View/Helper/Accueil/MenuVertical.php | 2 +- library/ZendAfi/View/Helper/Accueil/News.php | 4 +++- .../ZendAfi/View/Helper/Accueil/RechSimple.php | 11 +++++------ library/ZendAfi/View/Helper/Accueil/Sito.php | 5 +++-- .../ZendAfi/View/Helper/Telephone/Kiosque.php | 3 ++- .../Intonation/Library/View/Wrapper/Record.php | 5 ++++- .../Library/Widget/Accessibility/View.php | 4 +++- .../Library/Widget/AdminTools/View.php | 2 +- .../Library/Widget/Breadcrumb/View.php | 2 +- .../Library/Widget/Carousel/Agenda/View.php | 2 +- .../Library/Widget/Carousel/Library/View.php | 2 +- .../Library/Widget/Carousel/Menu/View.php | 4 ++-- .../Widget/Carousel/Newsletter/View.php | 3 ++- .../Library/Widget/Carousel/View.php | 18 ++++++++++++++---- .../Intonation/Library/Widget/Login/View.php | 2 +- .../Intonation/Library/Widget/Notify/View.php | 2 +- .../Intonation/Library/Widget/Scroll/View.php | 3 ++- .../Intonation/Library/Widget/Search/View.php | 4 ++-- .../ZendAfi/View/Helper/Accueil/SitoTest.php | 11 +++++++---- .../Templates/TemplatesWidgetCarouselTest.php | 9 +++++++++ 33 files changed, 112 insertions(+), 63 deletions(-) create mode 100644 VERSIONS_HOTLINE/158802 diff --git a/VERSIONS_HOTLINE/158802 b/VERSIONS_HOTLINE/158802 new file mode 100644 index 00000000000..36eb6c3ba4e --- /dev/null +++ b/VERSIONS_HOTLINE/158802 @@ -0,0 +1 @@ + - correctif #158802 : Kiosques : Correction du paramètre "Affichage desynchronisé du contenu". \ No newline at end of file diff --git a/library/Class/Systeme/ModulesAccueil/Null.php b/library/Class/Systeme/ModulesAccueil/Null.php index 415a5cdb624..90400cce564 100644 --- a/library/Class/Systeme/ModulesAccueil/Null.php +++ b/library/Class/Systeme/ModulesAccueil/Null.php @@ -231,7 +231,7 @@ class Class_Systeme_ModulesAccueil_Null { } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return ($widget = ZendAfi_View_Helper_Accueil_Base::getWidget($this->getWidgetContext()->getId(), $this->getWidgetContext()->forForm(), new Zend_View)) diff --git a/library/Class/Systeme/Widget/Menu.php b/library/Class/Systeme/Widget/Menu.php index 2e734da54ed..5719a9b584e 100644 --- a/library/Class/Systeme/Widget/Menu.php +++ b/library/Class/Systeme/Widget/Menu.php @@ -389,7 +389,7 @@ class Class_Systeme_Widget_Menu extends Class_Systeme_Widget_Abstract { } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { if ( $this->isWidget()) return $this->_getWidgetResources()->shouldCacheContent(); diff --git a/library/ZendAfi/View/Helper/Accueil/AbonneAbstract.php b/library/ZendAfi/View/Helper/Accueil/AbonneAbstract.php index 640cc66ba16..265d6d32563 100644 --- a/library/ZendAfi/View/Helper/Accueil/AbonneAbstract.php +++ b/library/ZendAfi/View/Helper/Accueil/AbonneAbstract.php @@ -66,7 +66,7 @@ abstract class ZendAfi_View_Helper_Accueil_AbonneAbstract extends ZendAfi_View_H } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return false; } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Accueil/Base.php b/library/ZendAfi/View/Helper/Accueil/Base.php index aa5f2a4d229..7e40ecb8737 100644 --- a/library/ZendAfi/View/Helper/Accueil/Base.php +++ b/library/ZendAfi/View/Helper/Accueil/Base.php @@ -76,7 +76,6 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac public function performAction($action) { - //@see Admin_WidgetController::widgetActionAction() } @@ -86,12 +85,10 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac } - // Par défaut le contenu de la boîte n'est pas en cache - public function shouldCacheContent() { - if (Class_Users::isCurrentUserCanAccesBackend()) - return false; - - return Class_AdminVar::isCacheEnabled(); + public function shouldCacheContent() : bool { + return Class_Users::isCurrentUserCanAccesBackend() + ? false + : Class_AdminVar::isCacheEnabled(); } @@ -246,7 +243,8 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac } - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn( Class_ScriptLoader $script_loader) : self { + return $this; } diff --git a/library/ZendAfi/View/Helper/Accueil/BibNumerique.php b/library/ZendAfi/View/Helper/Accueil/BibNumerique.php index c245d498181..0ba1baf4b3b 100644 --- a/library/ZendAfi/View/Helper/Accueil/BibNumerique.php +++ b/library/ZendAfi/View/Helper/Accueil/BibNumerique.php @@ -31,14 +31,14 @@ class ZendAfi_View_Helper_Accueil_BibNumerique extends ZendAfi_View_Helper_Accue } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return $this->isPaginatedDisplay() ? false : parent::shouldCacheContent(); } - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn(Class_ScriptLoader $script_loader) : self { if (!array_isset('id_albums', $this->preferences)) return $this; @@ -48,6 +48,7 @@ class ZendAfi_View_Helper_Accueil_BibNumerique extends ZendAfi_View_Helper_Accue if ($this->isDisplayBooklet()) Class_ScriptLoader::getInstance()->loadBooklet($this->preferences['id_albums'], '#booklet_'.$this->id_module); + return $this; } diff --git a/library/ZendAfi/View/Helper/Accueil/Calendar.php b/library/ZendAfi/View/Helper/Accueil/Calendar.php index e4aaaf4d027..f34bfbafc9f 100644 --- a/library/ZendAfi/View/Helper/Accueil/Calendar.php +++ b/library/ZendAfi/View/Helper/Accueil/Calendar.php @@ -22,12 +22,14 @@ class ZendAfi_View_Helper_Accueil_Calendar extends ZendAfi_View_Helper_Accueil_Base { protected $class_calendar; - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn(Class_ScriptLoader $script_loader) : self { $script_loader->addOPACScript('calendrier'); $this->renderScriptForFilters(); if($this->isDisplayDiaporamaNavigation()) $this->renderScriptForDiaporameNavigation($this->preferences); + + return $this; } diff --git a/library/ZendAfi/View/Helper/Accueil/ConteneurDeuxColonnes.php b/library/ZendAfi/View/Helper/Accueil/ConteneurDeuxColonnes.php index c9a71cc2ecc..93a5c49184e 100644 --- a/library/ZendAfi/View/Helper/Accueil/ConteneurDeuxColonnes.php +++ b/library/ZendAfi/View/Helper/Accueil/ConteneurDeuxColonnes.php @@ -18,12 +18,15 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3 - Conteneur sur 2 colonnes pour poser d'autres boîtes -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + class ZendAfi_View_Helper_Accueil_ConteneurDeuxColonnes extends ZendAfi_View_Helper_Accueil_Base { - /* Désactive le cache car si on modifie une sous-boîte le contenu doit être mis à jour*/ - public function shouldCacheContent() { return false; } + + + public function shouldCacheContent() : bool { + return false; + } + public function getHtml() { $this->titre = $this->preferences["titre"]; diff --git a/library/ZendAfi/View/Helper/Accueil/HistoriqueRecherches.php b/library/ZendAfi/View/Helper/Accueil/HistoriqueRecherches.php index 7759f626204..5ba069d3931 100644 --- a/library/ZendAfi/View/Helper/Accueil/HistoriqueRecherches.php +++ b/library/ZendAfi/View/Helper/Accueil/HistoriqueRecherches.php @@ -20,9 +20,12 @@ */ class ZendAfi_View_Helper_Accueil_HistoriqueRecherches extends ZendAfi_View_Helper_Accueil_Base { - public function shouldCacheContent() { - return false; - } + + + public function shouldCacheContent() : bool { + return false; + } + public function getHTML() { $this->titre = $this->view->tagAnchor(['controller' => 'recherche', 'action' => 'saisie'], diff --git a/library/ZendAfi/View/Helper/Accueil/IdentityProvider.php b/library/ZendAfi/View/Helper/Accueil/IdentityProvider.php index b91844e0310..720a5a2849f 100644 --- a/library/ZendAfi/View/Helper/Accueil/IdentityProvider.php +++ b/library/ZendAfi/View/Helper/Accueil/IdentityProvider.php @@ -19,10 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + class ZendAfi_View_Helper_Accueil_IdentityProvider extends ZendAfi_View_Helper_Accueil_Base { - /* Désactive le cache: sinon la boîte n'est pas à jour si on se connecte / déconnecte */ - public function shouldCacheContent() { return false; } + + public function shouldCacheContent() : bool { + return false; + } public function isBoiteVisible() { diff --git a/library/ZendAfi/View/Helper/Accueil/Kiosque.php b/library/ZendAfi/View/Helper/Accueil/Kiosque.php index 2404792a939..e44e69675ab 100644 --- a/library/ZendAfi/View/Helper/Accueil/Kiosque.php +++ b/library/ZendAfi/View/Helper/Accueil/Kiosque.php @@ -30,7 +30,7 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba } - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn(Class_ScriptLoader $script_loader) : self { $script_loader->addJQueryReady('$(".embedcode-button").click(function(){$(this).next().toggle("fast")})'); if($this->isModeMur() || $this->isModeVignettes()){ $this->view->getHelper('ListeNotices_Mur')->loadScript(); @@ -39,10 +39,12 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba if ($this->isModeChrono()) $this->view->getHelper('ListeNotices_Chrono')->loadScript(); + + return $this; } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return parent::shouldCacheContent() && in_array($this->preferences['style_liste'], ['mur', 'vignettes', 'chrono', 'simple_wall']); diff --git a/library/ZendAfi/View/Helper/Accueil/Library.php b/library/ZendAfi/View/Helper/Accueil/Library.php index 550d94bee6e..163ea163c33 100644 --- a/library/ZendAfi/View/Helper/Accueil/Library.php +++ b/library/ZendAfi/View/Helper/Accueil/Library.php @@ -28,7 +28,7 @@ class ZendAfi_View_Helper_Accueil_Library extends ZendAfi_View_Helper_Accueil_Ba $_filter_settings; - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return false; } @@ -249,8 +249,9 @@ class ZendAfi_View_Helper_Accueil_Library extends ZendAfi_View_Helper_Accueil_Ba } - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn(Class_ScriptLoader $script_loader) : self { $this->renderScriptForFilters($this->_filter_settings); + return $this; } diff --git a/library/ZendAfi/View/Helper/Accueil/Login.php b/library/ZendAfi/View/Helper/Accueil/Login.php index 3deaedbbfa2..99576dc301d 100644 --- a/library/ZendAfi/View/Helper/Accueil/Login.php +++ b/library/ZendAfi/View/Helper/Accueil/Login.php @@ -19,10 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + class ZendAfi_View_Helper_Accueil_Login extends ZendAfi_View_Helper_Accueil_Base { - /* Désactive le cache: sinon la boîte n'est pas à jour si on se connecte / déconnecte */ - public function shouldCacheContent() { return false; } + + public function shouldCacheContent() : bool { + return false; + } public function getHtml() { diff --git a/library/ZendAfi/View/Helper/Accueil/MenuVertical.php b/library/ZendAfi/View/Helper/Accueil/MenuVertical.php index 02b616b20ce..ebcb0eff36b 100644 --- a/library/ZendAfi/View/Helper/Accueil/MenuVertical.php +++ b/library/ZendAfi/View/Helper/Accueil/MenuVertical.php @@ -31,7 +31,7 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue private $path_ico; - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return false; } diff --git a/library/ZendAfi/View/Helper/Accueil/News.php b/library/ZendAfi/View/Helper/Accueil/News.php index 4d920e42c28..146df7db927 100644 --- a/library/ZendAfi/View/Helper/Accueil/News.php +++ b/library/ZendAfi/View/Helper/Accueil/News.php @@ -25,7 +25,7 @@ class ZendAfi_View_Helper_Accueil_News extends ZendAfi_View_Helper_Accueil_Base protected $_articles = []; - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn(Class_ScriptLoader $script_loader) : self { if ($this->isDisplayDiaporama()) $this->renderSlideShowScriptsOn($script_loader, sprintf('.news-%d', $this->id_module), @@ -37,6 +37,8 @@ class ZendAfi_View_Helper_Accueil_News extends ZendAfi_View_Helper_Accueil_Base if ($this->isDisplayAccordionList()) $this->renderScriptForAccordionList(); + + return $this; } diff --git a/library/ZendAfi/View/Helper/Accueil/RechSimple.php b/library/ZendAfi/View/Helper/Accueil/RechSimple.php index 8262179ca07..11bd657631b 100644 --- a/library/ZendAfi/View/Helper/Accueil/RechSimple.php +++ b/library/ZendAfi/View/Helper/Accueil/RechSimple.php @@ -20,7 +20,7 @@ */ class ZendAfi_View_Helper_Accueil_RechSimple extends ZendAfi_View_Helper_Accueil_Base { - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn(Class_ScriptLoader $script_loader) : self { $script_loader ->addJQueryReady('$("input.expressionRecherche").attr("x-webkit-speech","x-webkit-speech")'); @@ -59,10 +59,9 @@ class ZendAfi_View_Helper_Accueil_RechSimple extends ZendAfi_View_Helper_Accueil } - public function shouldCacheContent() { - if (1 == (int)$this->preferences["select_bib"]) - return false; - - return parent::shouldCacheContent(); + public function shouldCacheContent() : bool { + return (1 == (int) $this->preferences["select_bib"]) + ? false + : parent::shouldCacheContent(); } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Accueil/Sito.php b/library/ZendAfi/View/Helper/Accueil/Sito.php index ee3af7942b2..d7de4c1651f 100644 --- a/library/ZendAfi/View/Helper/Accueil/Sito.php +++ b/library/ZendAfi/View/Helper/Accueil/Sito.php @@ -22,8 +22,9 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base { protected $strategy, $page; - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn(Class_ScriptLoader $script_loader) : self { $this->getStrategy()->renderHeadScriptsOn($script_loader); + return $this; } @@ -50,7 +51,7 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return $this->isPaginatedDisplay() ? false : parent::shouldCacheContent(); diff --git a/library/ZendAfi/View/Helper/Telephone/Kiosque.php b/library/ZendAfi/View/Helper/Telephone/Kiosque.php index 7a8a878f203..98387b8aec9 100644 --- a/library/ZendAfi/View/Helper/Telephone/Kiosque.php +++ b/library/ZendAfi/View/Helper/Telephone/Kiosque.php @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_Telephone_Kiosque extends ZendAfi_View_Helper_Accueil_Base { - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn(Class_ScriptLoader $script_loader) : self { $script_loader ->addScript(BASE_URL . '/public/opac/mobile/js/kiosque-slideshow') ->addJQueryReady('$(\'#slideshow\').kiosqueSlideshow()') @@ -49,6 +49,7 @@ class ZendAfi_View_Helper_Telephone_Kiosque extends ZendAfi_View_Helper_Accueil_ } '); + return $this; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index 6c515166913..61f3004c93c 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -26,6 +26,7 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra $_picture_cache, $_selectable_action = false, $_main_title, + $_secondary_title_cache, $_description, $_badges, $_allow_XSL = false, @@ -40,7 +41,9 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra public function getSecondaryTitle() { - return $this->_model->getMainAuthorFromCodif(); + return $this->_secondary_title_cache = $this->_secondary_title_cache + ? $this->_secondary_title_cache + : $this->_model->getMainAuthorFromCodif(); } diff --git a/library/templates/Intonation/Library/Widget/Accessibility/View.php b/library/templates/Intonation/Library/Widget/Accessibility/View.php index 6bcfbfbb83d..a27ec70fb4a 100644 --- a/library/templates/Intonation/Library/Widget/Accessibility/View.php +++ b/library/templates/Intonation/Library/Widget/Accessibility/View.php @@ -29,7 +29,7 @@ class Intonation_Library_Widget_Accessibility_View extends Zendafi_View_Helper_A } - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn(Class_ScriptLoader $script_loader) : self { $id = 'accessibility_widget_tools_' . $this->getId(); $script_loader @@ -41,6 +41,8 @@ class Intonation_Library_Widget_Accessibility_View extends Zendafi_View_Helper_A if ($this->_settings->getDisplayFontSize()) $script_loader->addOPACStyleSheet('font_size_rules'); + + return $this; } diff --git a/library/templates/Intonation/Library/Widget/AdminTools/View.php b/library/templates/Intonation/Library/Widget/AdminTools/View.php index 7c8fe5a373a..d7c686ef8f2 100644 --- a/library/templates/Intonation/Library/Widget/AdminTools/View.php +++ b/library/templates/Intonation/Library/Widget/AdminTools/View.php @@ -32,7 +32,7 @@ class Intonation_Library_Widget_Admintools_View extends Zendafi_View_Helper_Accu } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return false; } diff --git a/library/templates/Intonation/Library/Widget/Breadcrumb/View.php b/library/templates/Intonation/Library/Widget/Breadcrumb/View.php index 89a24c36836..ea6eb3a3f2e 100644 --- a/library/templates/Intonation/Library/Widget/Breadcrumb/View.php +++ b/library/templates/Intonation/Library/Widget/Breadcrumb/View.php @@ -35,7 +35,7 @@ class Intonation_Library_Widget_Breadcrumb_View extends Zendafi_View_Helper_Accu } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return false; } diff --git a/library/templates/Intonation/Library/Widget/Carousel/Agenda/View.php b/library/templates/Intonation/Library/Widget/Carousel/Agenda/View.php index 278f245bf48..53dfc99af15 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Agenda/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Agenda/View.php @@ -27,7 +27,7 @@ class Intonation_Library_Widget_Carousel_Agenda_View extends Intonation_Library_ protected $_calendar; - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn(Class_ScriptLoader $script_loader) : self { $script_loader->addOPACScript('calendrier'); parent::_renderHeadScriptsOn($script_loader); return $this; diff --git a/library/templates/Intonation/Library/Widget/Carousel/Library/View.php b/library/templates/Intonation/Library/Widget/Carousel/Library/View.php index 09a30e77b2e..241aded2b52 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Library/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Library/View.php @@ -30,7 +30,7 @@ class Intonation_Library_Widget_Carousel_Library_View extends Intonation_Library } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return false; } diff --git a/library/templates/Intonation/Library/Widget/Carousel/Menu/View.php b/library/templates/Intonation/Library/Widget/Carousel/Menu/View.php index 78018e2b637..a266d910f4c 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Menu/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Menu/View.php @@ -122,14 +122,14 @@ class Intonation_Library_Widget_Carousel_Menu_View extends Intonation_Library_Wi } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return $this->_useNotCachedWidget() ? false : parent::shouldCacheContent(); } - protected function _useNotCachedWidget() { + protected function _useNotCachedWidget() : bool { if ( ! $menu = $this->_getMenu()) return false; diff --git a/library/templates/Intonation/Library/Widget/Carousel/Newsletter/View.php b/library/templates/Intonation/Library/Widget/Carousel/Newsletter/View.php index aff584ed3a8..c0acc4697b8 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Newsletter/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Newsletter/View.php @@ -23,7 +23,8 @@ class Intonation_Library_Widget_Carousel_Newsletter_View extends Intonation_Library_Widget_Carousel_View { - public function shouldCacheContent() { + + public function shouldCacheContent() : bool { return !Class_Users::hasIdentity(); } diff --git a/library/templates/Intonation/Library/Widget/Carousel/View.php b/library/templates/Intonation/Library/Widget/Carousel/View.php index 144d530f9b4..f2211de1aba 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/View.php @@ -67,13 +67,21 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help } - protected function _renderHeadScriptsOn($script_loader) { + public function shouldCacheContent() : bool { + return $this->_isDelayed() + ? false + : parent::shouldCacheContent(); + } + + + protected function _renderHeadScriptsOn( Class_ScriptLoader $script_loader) : self { $this->_getLayoutHelper((string) $this->_settings->getLayout()) ->renderHeadScriptsOn($script_loader); + return $this; } - public function getFooter() { + public function getFooter() : string { $rss = $this->_settings->getRss() ? $this->_getTagRss() : ''; @@ -82,6 +90,7 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help ? $this->_getTagEmbededCode() : ''; + $link_to_all = $this->_settings->getLinkToAll() ? $this->_getTagLinkToAll() : ''; @@ -100,7 +109,7 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help } - protected function _getTagRss() { + protected function _getTagRss() : string { return $this->view->tagAnchor( $this->_getRSSUrl(), $this->view @@ -108,7 +117,8 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help 'utils'), ['class' => 'flux-rss', 'type' => 'application/rss+xml', - 'title' => $this->_('Flux RSS de la boite "%s"', $this->_settings->getTitre()) ]); + 'title' => $this->_('Flux RSS de la boite "%s"', + $this->_settings->getTitre()) ]); } diff --git a/library/templates/Intonation/Library/Widget/Login/View.php b/library/templates/Intonation/Library/Widget/Login/View.php index 3fe152948fd..c067d94c907 100644 --- a/library/templates/Intonation/Library/Widget/Login/View.php +++ b/library/templates/Intonation/Library/Widget/Login/View.php @@ -33,7 +33,7 @@ class Intonation_Library_Widget_Login_View extends Zendafi_View_Helper_Accueil_B } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return false; } diff --git a/library/templates/Intonation/Library/Widget/Notify/View.php b/library/templates/Intonation/Library/Widget/Notify/View.php index b30f0828e95..07222a90669 100644 --- a/library/templates/Intonation/Library/Widget/Notify/View.php +++ b/library/templates/Intonation/Library/Widget/Notify/View.php @@ -32,7 +32,7 @@ class Intonation_Library_Widget_Notify_View extends Zendafi_View_Helper_Accueil_ } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return false; } diff --git a/library/templates/Intonation/Library/Widget/Scroll/View.php b/library/templates/Intonation/Library/Widget/Scroll/View.php index 062625f2c37..59d388df78f 100644 --- a/library/templates/Intonation/Library/Widget/Scroll/View.php +++ b/library/templates/Intonation/Library/Widget/Scroll/View.php @@ -29,7 +29,7 @@ class Intonation_Library_Widget_Scroll_View extends Zendafi_View_Helper_Accueil_ } - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn(Class_ScriptLoader $script_loader) : self { $id = 'scroll_widget_' . $this->getId(); $direction = $this->_settings->getDirection(); @@ -39,6 +39,7 @@ class Intonation_Library_Widget_Scroll_View extends Zendafi_View_Helper_Accueil_ ->addJQueryReady(sprintf('$("#%s").scroll_button({direction: "%s"})', $id, $direction)); + return $this; } diff --git a/library/templates/Intonation/Library/Widget/Search/View.php b/library/templates/Intonation/Library/Widget/Search/View.php index 76219df02d7..a8169965067 100644 --- a/library/templates/Intonation/Library/Widget/Search/View.php +++ b/library/templates/Intonation/Library/Widget/Search/View.php @@ -31,7 +31,7 @@ class Intonation_Library_Widget_Search_View extends ZendAfi_View_Helper_Accueil_ } - public function shouldCacheContent() { + public function shouldCacheContent() : bool { return false; } @@ -58,7 +58,7 @@ class Intonation_Library_Widget_Search_View extends ZendAfi_View_Helper_Accueil_ } - protected function _renderHeadScriptsOn($script_loader) { + protected function _renderHeadScriptsOn(Class_ScriptLoader $script_loader) : self { $id = '#expressionRecherche_' . $this->_settings->getIdForHtml(); $script_loader ->addJQueryReady('$("' . $id . '").attr("x-webkit-speech","x-webkit-speech")') diff --git a/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php b/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php index 537e1c64490..aeee070a69f 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php @@ -18,10 +18,11 @@ n * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserve * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; + abstract class SitoViewHelperTestCase extends ViewHelperTestCase { - protected $_storm_default_to_volatile = true; protected $html; protected $_preferences = []; @@ -52,9 +53,11 @@ abstract class SitoViewHelperTestCase extends ViewHelperTestCase { protected function createBoxAndHelper() { - $this->_helper = new ZendAfi_View_Helper_Accueil_Sito(2, ['division' => '1', - 'type_module' => 'SITO', - 'preferences' => $this->_preferences]); + $this->_helper = new ZendAfi_View_Helper_Accueil_Sito(2, + ['division' => '1', + 'type_module' => 'SITO', + 'preferences' => + $this->_preferences]); $view = new ZendAfi_Controller_Action_Helper_View(); $view->setScriptPath('application/modules/opac/views/scripts'); diff --git a/tests/scenarios/Templates/TemplatesWidgetCarouselTest.php b/tests/scenarios/Templates/TemplatesWidgetCarouselTest.php index b4085cd9298..350c7026c25 100644 --- a/tests/scenarios/Templates/TemplatesWidgetCarouselTest.php +++ b/tests/scenarios/Templates/TemplatesWidgetCarouselTest.php @@ -414,4 +414,13 @@ class TemplatesWidgetCarouselDelayedRecordWithDomainTest extends TemplatesWidget $this->dispatch('/admin/widget/edit-widget/id/1/id_profil/1'); $this->assertXPath('//form//input[@name="delayed"][@type="checkbox"][@data-level="expert"][@checked]'); } + + + /** @test */ + public function widgetOneShouldNotBeCached() { + $cache = $this->mock(); + Storm_Cache::setDefaultZendCache($cache); + $this->dispatch('/index'); + $this->assertTrue($cache->methodHasNotBeenCalled('memoize')); + } } \ No newline at end of file -- GitLab