diff --git a/VERSIONS b/VERSIONS index 41841135c24eeb17bf6e24dc5b08665a0c5b5add..2048d7ec9ecbe7df4c1def5e8f61154b29d32501 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,19 @@ +10/06/2021 - v8.0.126 + + - ticket #136213 : Affichage : correction de la mauvaise fermeture de certaines balises iframe. + + - ticket #135586 : Agendas externes : Maintenance du connecteur OpenAgenda. + + - ticket #135970 : Magasin de thèmes : Ajout de l'activation/désactivation de l'affichage des onglets dans les vues notices, mon compte, bibliothèque et auteur. + + - ticket #132300 : Magasin de thèmes : Amélioration de la boite sitothèque et correction de l'affichage des sitothèques en provenance des liens de menus. + + - ticket #133828 : Magasin de thèmes : Ajout d'une nouvelle option dans les boites : autoriser les balises HTML dans la description. + + - ticket #133847 : Magasin de thèmes : La représentation des listes en accordéon est maintenant disponible pour tous les thèmes. + + + 08/06/2021 - v8.0.125 - ticket #136289 : Système : Correction du non chargement des skins diff --git a/VERSIONS_HOTLINE/136213 b/VERSIONS_HOTLINE/136213 deleted file mode 100644 index a44eb7b04082cee46ca6b3f45269371a6d316350..0000000000000000000000000000000000000000 --- a/VERSIONS_HOTLINE/136213 +++ /dev/null @@ -1 +0,0 @@ - - ticket #136213 : Affichage : correction de la fermeture de balise iframe \ No newline at end of file diff --git a/application/modules/admin/controllers/WidgetController.php b/application/modules/admin/controllers/WidgetController.php index c75c109396e6ebbcbd5fa9d8ff1830849b1a9c13..c7decc5cb9717ee0ac8ba96e1524a878d9c21aa6 100644 --- a/application/modules/admin/controllers/WidgetController.php +++ b/application/modules/admin/controllers/WidgetController.php @@ -27,9 +27,11 @@ class Admin_WidgetController extends ZendAfi_Controller_Action { public function preDispatch() { parent::preDispatch(); + if(!Class_Users::isCurrentUserAllowedToEditProfile(Class_Profil::find($this->_getParam('id_profil', 1)))) { - if(!Class_Users::isCurrentUserAllowedToEditProfile(Class_Profil::find($this->_getParam('id_profil', 1)))) + $this->_helper->notify($this->_('Vous n\'avez pas le droit de configurer ce profil.')); $this->_redirectClose($this->_getReferer()); + } $this->_plugins ->eachDo(function($plugin) diff --git a/application/modules/opac/views/scripts/sito/viewsitos.phtml b/application/modules/opac/views/scripts/sito/viewsitos.phtml index b6dfdf7c713bd7447b2dea0a7b35fdceec90663e..bcd08cd4aed05f7f8e640d8561db75b60170f40f 100644 --- a/application/modules/opac/views/scripts/sito/viewsitos.phtml +++ b/application/modules/opac/views/scripts/sito/viewsitos.phtml @@ -1,18 +1,2 @@ -<?php -foreach($this->sitos as $sito) { - $thumb_url = $this->webThumbnail($sito->getUrl()); - - $this->openBoite($sito->getTitre()); - echo "<div class='sitotheque'>"; - - if ($thumb_url) - printf('<img src="%s">', $thumb_url); - - echo $sito->getDescription(); - - printf('<div><a href="%s" target="_blank">%s</a></div>', $sito->getUrl(), $this->_('Voir le site')); - $this->closeBoite(); - - echo "</div>"; -} -?> +<?php +echo $this->renderWebsites($this->sitos); diff --git a/library/Class/ExternalAgenda/ICalendar.php b/library/Class/ExternalAgenda/ICalendar.php index a68eb95f3b654b2a44cabccbddb8f70464c67c1f..b853c063acdf65fe0d72aa123bbaa9cfff39002b 100644 --- a/library/Class/ExternalAgenda/ICalendar.php +++ b/library/Class/ExternalAgenda/ICalendar.php @@ -29,11 +29,12 @@ class Class_ExternalAgenda_ICalendar extends Class_ExternalAgenda_Provider { protected function _import() { $this->_current_event = null; - $ics_content = $this->httpGet($this->_external_agenda->getUrl()); - $ics_content = preg_replace('|\n\s|', '', $ics_content); //see RFC2445 - $lines = preg_split('|\r?\n|', $ics_content); + $content = $this->httpGet($this->_url()); + $content = preg_replace('|\n\s|', '', $content); //see RFC2445 + $lines = preg_split('|\r?\n|', $content); - array_map([$this, '_importLine'], $lines); + foreach($lines as $line) + $this->_importLine($line); return $this; } @@ -72,7 +73,7 @@ class Class_ExternalAgenda_ICalendar extends Class_ExternalAgenda_Provider { protected function onBeginVEvent() { - $this->_current_event = $this->_external_agenda->newEvent(); + $this->_current_event = $this->_newEvent(); return $this; } diff --git a/library/Class/ExternalAgenda/OpenAgenda.php b/library/Class/ExternalAgenda/OpenAgenda.php index 0f9425be425d3125ba9face3b66875c12eeba5c8..dcdef4757ee42164629fd4b71b319d59c36c28ec 100644 --- a/library/Class/ExternalAgenda/OpenAgenda.php +++ b/library/Class/ExternalAgenda/OpenAgenda.php @@ -22,25 +22,24 @@ class Class_ExternalAgenda_OpenAgenda extends Class_ExternalAgenda_Provider { - public function _import() { - $this->_loadPage(); - return $this; - } + $page = 1; + while ($content = json_decode($this->httpGet($this->_pageUrl($page)), true)) { + if (!isset($content['events']) || !is_array($content['events']) || !$content['events']) + break; + foreach($content['events'] as $event) + $this->_processEvent($event); - protected function _loadPage($offset = 0, $event_count = 0){ - $content = json_decode($this->httpGet($this->_external_agenda->getUrl().'&offset='. (int) $offset),true); + $page++; + } - if (!$content) - return $this; + return $this; + } - array_map([$this, '_processEvent'], $content['events']); - $event_count += count($content['events']); - return ($event_count < $content['total']) - ? $this->_loadPage( $offset + 1, $event_count) - : $this; + protected function _pageUrl($page) { + return $this->_url() . '&page=' . $page; } @@ -57,8 +56,8 @@ class Class_ExternalAgenda_OpenAgenda extends Class_ExternalAgenda_Provider { protected function _buildArticleForTiming($event, $timing) { - return $this->_external_agenda - ->newEvent() + return $this + ->_newEvent() ->setTitre($event->getString('title')) ->setContenu($event->getImageTagWithCredits() .$event->getHtml() diff --git a/library/Class/ExternalAgenda/Provider.php b/library/Class/ExternalAgenda/Provider.php index 31bc1e91460c7f25e73ed3be205fa959b5be61a8..8b6b93adc2830a7a1ce9b397237776293844c055 100644 --- a/library/Class/ExternalAgenda/Provider.php +++ b/library/Class/ExternalAgenda/Provider.php @@ -41,4 +41,14 @@ class Class_ExternalAgenda_Provider extends Class_WebService_Abstract { protected function _import() { return $this; } + + + protected function _url() { + return $this->_external_agenda->getUrl(); + } + + + protected function _newEvent() { + return $this->_external_agenda->newEvent(); + } } diff --git a/library/Class/Sitotheque.php b/library/Class/Sitotheque.php index 328ce32615d971d90ee3867a45376c543bef15de..0827336611081cd27de7364844e1356153fcca1c 100644 --- a/library/Class/Sitotheque.php +++ b/library/Class/Sitotheque.php @@ -188,9 +188,6 @@ class Class_Sitotheque extends Storm_Model_Abstract { } - //------------------------------------------------------------------------------------------------------ - // Get site - //------------------------------------------------------------------------------------------------------ public function getSite($id_site) { if(!$id_site) return false; @@ -210,14 +207,15 @@ class Class_Sitotheque extends Storm_Model_Abstract { return ''; } - //------------------------------------------------------------------------------------------------------ - // Renvoie tous les articles pour une categorie et ses sous-categories - //------------------------------------------------------------------------------------------------------ + public function getSitesCategorie($id_categorie) { - if(!$id_categorie) return array(); + if ( ! $id_categorie) + return []; + if ( ! $category = Class_SitothequeCategorie::find($id_categorie)) + return []; - $categories = Class_SitothequeCategorie::find($id_categorie)->getRecursiveSousCategories(); + $categories = $category->getRecursiveSousCategories(); $ids = array_map(function($categorie) {return $categorie->getId();}, $categories); diff --git a/library/ZendAfi/Form/Configuration/Widget/Action/Author.php b/library/ZendAfi/Form/Configuration/Widget/Action/Author.php index 2ab9042f2a213dc0c35070ee9b34dfbddb003914..9965919ee79632be5ebbbdf80fa4cb9f4981e076 100644 --- a/library/ZendAfi/Form/Configuration/Widget/Action/Author.php +++ b/library/ZendAfi/Form/Configuration/Widget/Action/Author.php @@ -22,8 +22,6 @@ class ZendAfi_Form_Configuration_Widget_Action_Author extends ZendAfi_Form_Configuration_Widget_Action_Tabs { protected function _getRichContentInstance() { - return (new Intonation_Library_View_Wrapper_Author_RichContent) - ->setView(new Class_Entity) - ->setModel(new Class_CodifAuteur); + return new Intonation_Library_View_Wrapper_Author_RichContent(new Class_CodifAuteur); } } \ No newline at end of file diff --git a/library/ZendAfi/Form/Configuration/Widget/Action/Library.php b/library/ZendAfi/Form/Configuration/Widget/Action/Library.php index e22f8ee94dbfff26e3fec0e6f168eccdb68b0ea3..3664c3a31df731c9f4bf42bd9e4872498cf9839a 100644 --- a/library/ZendAfi/Form/Configuration/Widget/Action/Library.php +++ b/library/ZendAfi/Form/Configuration/Widget/Action/Library.php @@ -22,8 +22,6 @@ class ZendAfi_Form_Configuration_Widget_Action_Library extends ZendAfi_Form_Configuration_Widget_Action_Tabs { protected function _getRichContentInstance() { - return (new Intonation_Library_View_Wrapper_Library_RichContent) - ->setView(new Class_Entity) - ->setModel(new Class_Bib); + return new Intonation_Library_View_Wrapper_Library_RichContent(new Class_Bib); } } \ No newline at end of file diff --git a/library/ZendAfi/Form/Configuration/Widget/Action/Record.php b/library/ZendAfi/Form/Configuration/Widget/Action/Record.php index 31a22e337f040a2bcf39fdf4a9894eaec61c5585..9fad52d86d7c86f5b7855c5d976732c80b21129c 100644 --- a/library/ZendAfi/Form/Configuration/Widget/Action/Record.php +++ b/library/ZendAfi/Form/Configuration/Widget/Action/Record.php @@ -44,10 +44,9 @@ class ZendAfi_Form_Configuration_Widget_Action_Record extends ZendAfi_Form_Confi parent::initDisplayGroups(); } + protected function _getRichContentInstance() { - return (new Intonation_Library_View_Wrapper_Record_RichContent) - ->setView(new Class_Entity) - ->setModel(new Class_Notice); + return new Intonation_Library_View_Wrapper_Record_RichContent(new Class_Notice); } diff --git a/library/ZendAfi/Form/Configuration/Widget/Action/Tabs.php b/library/ZendAfi/Form/Configuration/Widget/Action/Tabs.php index 3125e1ef64e22f13bfce5fa47d2bdac37730e424..df691ce8a1d2c643a934b5969011c8c4fdd554ae 100644 --- a/library/ZendAfi/Form/Configuration/Widget/Action/Tabs.php +++ b/library/ZendAfi/Form/Configuration/Widget/Action/Tabs.php @@ -48,8 +48,14 @@ abstract class ZendAfi_Form_Configuration_Widget_Action_Tabs extends ZendAfi_For ->addElement('text', $title_id, ['label' => $this->_('Attribut "title" de l\'onglet %s', $title), - 'placeholder' => $tab->getNavTitle()]); + 'placeholder' => $tab->getNavTitle()]) + ->addElement('checkbox', + get_class($tab), + ['label' => $this->_('Activer l\'affichage de l\'onglet %s', $title), + 'value' => 1]); + + $group [] = get_class($tab); $group [] = $ico_id; $group [] = $label_id; $group [] = $title_id; diff --git a/library/ZendAfi/Form/Configuration/Widget/Action/User.php b/library/ZendAfi/Form/Configuration/Widget/Action/User.php index 546da0e63a1f551bdd3c35d69e33cf513506e835..a0ab60d3a75668c447450c1cc83d9a0e541860cf 100644 --- a/library/ZendAfi/Form/Configuration/Widget/Action/User.php +++ b/library/ZendAfi/Form/Configuration/Widget/Action/User.php @@ -22,8 +22,6 @@ class ZendAfi_Form_Configuration_Widget_Action_User extends ZendAfi_Form_Configuration_Widget_Action_Tabs { protected function _getRichContentInstance() { - return (new Intonation_Library_View_Wrapper_User_RichContent) - ->setView(new Class_Entity) - ->setModel(new Class_Users); + return new Intonation_Library_View_Wrapper_User_RichContent(new Class_Users); } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/RenderWebsites.php b/library/ZendAfi/View/Helper/RenderWebsites.php new file mode 100644 index 0000000000000000000000000000000000000000..89d3970e01e54925d439a04323c04ff08de4464a --- /dev/null +++ b/library/ZendAfi/View/Helper/RenderWebsites.php @@ -0,0 +1,49 @@ +<?php +/** + * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_View_Helper_RenderWebsites extends ZendAfi_View_Helper_BaseHelper { + public function renderWebsites($websites) { + $html = []; + foreach($websites as $website) { + $html [] = $this->view->openBoiteContent($website->getTitre()); + + $html [] = $this->_div(['class' => 'sitotheque'], $this->_websiteHtml($website)); + + $html [] = $this->view->closeBoiteContent(); + } + + return implode($html); + } + + + protected function _websiteHtml($website) { + $img = ''; + if ($thumb_url = $this->view->webThumbnail($website->getUrl())) + $img = $this->view->tagImg($thumb_url); + + return $img + . $website->getDescription() + . $this->_div([], + $this->view->tagAnchor($website->getUrl(), + $this->_('Voir le site'))); + } +} diff --git a/library/startup.php b/library/startup.php index b95c9953d423449559b302cad5239429d4b69d6c..d51e88ed0130370d0a4936a36ecfb005685d8504 100644 --- a/library/startup.php +++ b/library/startup.php @@ -84,7 +84,7 @@ class Bokeh_Engine { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','8.0'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.125'); + defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.126'); defineConstant('BOKEH_REMOTE_FILES', 'https://git.afi-sa.net/afi/opacce/'); diff --git a/library/templates/Chili/Library/Settings.php b/library/templates/Chili/Library/Settings.php index c82ec4b595d5fa393e59c3cfccd8f1490f361aa3..305c80b655ce9fa82d60174fac72aaf2d5316985 100644 --- a/library/templates/Chili/Library/Settings.php +++ b/library/templates/Chili/Library/Settings.php @@ -106,7 +106,6 @@ class Chili_Library_Settings extends Intonation_Library_Settings { $hydrating_mapping['div class items_hold_link'] = 'col-12 p-3 my-3 text-center'; $hydrating_mapping['div class description_library_openings'] = 'col-12'; $hydrating_mapping['div class description_library_opened'] = 'col-12'; - $hydrating_mapping['button class accordion_button'] = 'btn btn-link'; $hydrating_mapping['div class wall_grid_lg'] = 'd-none d-lg-block'; $hydrating_mapping['div class wall_grid_md'] = 'd-lg-none'; $hydrating_mapping['div class highlight_carousel_xl'] = 'd-none d-xl-block'; diff --git a/library/templates/Chili/Library/Widget/Carousel/Definition.php b/library/templates/Chili/Library/Widget/Carousel/Definition.php index 0eb063a0889a90e7fa7ddc4d7a700608cd999818..c9e1dd4298d506e706f86cbf027ed95757a39de9 100644 --- a/library/templates/Chili/Library/Widget/Carousel/Definition.php +++ b/library/templates/Chili/Library/Widget/Carousel/Definition.php @@ -23,6 +23,5 @@ class Chili_Library_Widget_Carousel_Definition { const TOP_HIGHLIGHT_CAROUSEL = 'top_highlight_carousel', - LEFT_HIGHLIGHT_CAROUSEL = 'left_highlight_carousel', - ACCORDION_CAROUSEL = 'accordion'; + LEFT_HIGHLIGHT_CAROUSEL = 'left_highlight_carousel'; } diff --git a/library/templates/Chili/Template.php b/library/templates/Chili/Template.php index e884be9dbd4ef3bebd22316730c35941dabfe324..d81fb4c3335054f53c7e139dfb405126394aeb79 100644 --- a/library/templates/Chili/Template.php +++ b/library/templates/Chili/Template.php @@ -79,9 +79,6 @@ class Chili_Template extends Intonation_Template { if (Chili_Library_Widget_Carousel_Definition::TOP_HIGHLIGHT_CAROUSEL == $layout) return Chili_View_RenderTopHighlightCarousel::class; - if (Chili_Library_Widget_Carousel_Definition::ACCORDION_CAROUSEL == $layout) - return Intonation_View_RenderAccordionCarousel::class; - if (Chili_Library_Widget_Carousel_Definition::LEFT_HIGHLIGHT_CAROUSEL == $layout) return Chili_View_RenderLeftHighlightCarousel::class; @@ -98,10 +95,7 @@ class Chili_Template extends Intonation_Template { public function getCarouselLayouts() { return [Chili_Library_Widget_Carousel_Definition::TOP_HIGHLIGHT_CAROUSEL => $this->_('Carousel avec mise en avant au dessus'), - - Chili_Library_Widget_Carousel_Definition::LEFT_HIGHLIGHT_CAROUSEL => $this->_('Carousel avec mise en avant à gauche'), - - Chili_Library_Widget_Carousel_Definition::ACCORDION_CAROUSEL => $this->_('Accordéon')]; + Chili_Library_Widget_Carousel_Definition::LEFT_HIGHLIGHT_CAROUSEL => $this->_('Carousel avec mise en avant à gauche')]; } diff --git a/library/templates/Intonation/Library/AjaxPaginatedListHelper.php b/library/templates/Intonation/Library/AjaxPaginatedListHelper.php index 1863fde497c522356daffbb1c60eedf31432ecfe..413af52f9c1417d3e45732820b4efe80c3febad5 100644 --- a/library/templates/Intonation/Library/AjaxPaginatedListHelper.php +++ b/library/templates/Intonation/Library/AjaxPaginatedListHelper.php @@ -135,7 +135,7 @@ class Intonation_Library_AjaxPaginatedListHelper { $slice = function($collection) use ($page) { $sub = array_slice($collection->getArrayCopy(), (($page - 1) * $this->_page_size), - ($page * $this->_page_size)); + $this->_page_size); return $this->_page = new Storm_Collection($sub); }; diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 3a61973ae2c4a2c82cff989e5f6be806065cb102..1f72f536c48b2280d320311ad8fbf5f1524f061d 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -297,6 +297,11 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'form class user_configuration_form' => 'form row no-gutters', 'a class manage_activities_button' => 'btn btn-sm btn-success menu_admin_front_anchor', 'input class zendafi_form_review_review_submit' => 'ml-auto mr-auto mt-3', + 'button class accordion_button' => 'btn btn-link', + 'div class collection_actions' => 'col-12', + 'div class collection_truncate_list' => 'col-12', + 'div class websites_list_title' => 'col-12', + 'div class websites_list_content' => 'col-12', ], 'icons_map_doc_types' => [], diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php index a7e783740c2903d4622b86dba70a8d77d7690943..3feb73f8fbe3a4b482a9ee38ee9c65ebd12ddd6d 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -139,9 +139,14 @@ abstract class Intonation_Library_View_Wrapper_Abstract { ? $this->_widget_context->getDescriptionLength() : null; + $with_html = $this->_widget_context + ? $this->_widget_context->getDescriptionHtml() + : null; + return $this->_view->truncate($text, ['class' => 'model_description_' . get_class($this->_model)], - $number_of_word); + $number_of_word, + $with_html); } diff --git a/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php index a38c2d62515f274b6d8f0bbdea3f007da3de5b17..208d74fb7bce3ce8c41186347d5427af68bc5483 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php @@ -31,6 +31,7 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Abstract { public function __construct($model = null , $view = null) { + $view = $view ? $view : new ZendAfi_Controller_Action_Helper_View; $this ->setModel($model) ->setView($view); @@ -65,6 +66,7 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Abstract { return $this->_sections; $map = $this->_getSectionsMap(); + $map = $this->_removeDisabledSections($map); return $this->_sections = array_map(function($class) @@ -75,6 +77,23 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Abstract { } + protected function _removeDisabledSections($map) { + if ( ! $settings = $this->_view->_module_settings) + return $map; + + if ( ! $settings = $settings->getLocalSettings()) + return $map; + + return array_filter($map, function($section) use ($settings) + { + if ( ! isset($settings[$section])) + return true; + + return (bool) $settings[$section]; + }); + } + + public function getWrapperInstance() { $wrapper_class = $this->_getWrapper() ? $this->_getWrapper() diff --git a/library/templates/Intonation/Library/View/Wrapper/Website.php b/library/templates/Intonation/Library/View/Wrapper/Website.php index 9a87c501ddaa648870dfe2b13cec5f673e215df6..775f8d59b48394f3df37e7e30fef7bc5697afe81 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Website.php +++ b/library/templates/Intonation/Library/View/Wrapper/Website.php @@ -22,6 +22,23 @@ class Intonation_Library_View_Wrapper_Website extends Intonation_Library_View_Wrapper_Abstract { + protected $_title, + $_picture, + $_description; + + + public function __sleep() { + $this->_title = $this->getMainTitle(); + $this->_picture = $this->getPicture(); + $this->_description = $this->getDescription(); + + return array_merge(parent::__sleep(), + ['_title', + '_picture', + '_description']); + } + + public function getMainTitle() { return $this->_model->getTitle(); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery.php b/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery.php index 63746010e52013ad74a12d6d85439d485fab6d91..c48485789a75dc42c7a114c902cb6184551fa218 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery.php +++ b/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery.php @@ -22,123 +22,11 @@ class Intonation_Library_View_Wrapper_Website_Smeltery { public function meltWebsite($website) { - return new Intonation_Library_View_Wrapper_Website_WebsiteMelted($website); + return new Intonation_Library_View_Wrapper_Website_Smeltery_Melted($website); } public function meltAlbum($album) { - return new Intonation_Library_View_Wrapper_Website_AlbumMelted($album); + return new Intonation_Library_View_Wrapper_Website_Smeltery_AlbumMelted($album); } -} - - - -abstract class Intonation_Library_View_Wrapper_Website_MeltedItem { - protected $_model, - $_resource_cache; - - - public function __construct($model) { - $this->_model = $model; - } - - - public function getTitle() { - return $this->_model->getTitre(); - } - - - public function getTags() { - return explode(';', $this->_model->getTags()); - } - - - public function getDescription() { - return $this->_model->getDescription(); - } - - - abstract public function getUrl(); - abstract public function getPreviewImageUrl(); - abstract public function getCategory(); - abstract public function getDomains(); -} - - - - -class Intonation_Library_View_Wrapper_Website_WebsiteMelted extends Intonation_Library_View_Wrapper_Website_MeltedItem{ - - public function getUrl() { - return $this->_model->getUrl(); - } - - - public function getPreviewImageUrl() { - return Class_Url::assemble(['module' => 'opac', - 'controller' => 'sitotheque', - 'action' => 'webthumbnail'], - null, - true) . '?url=' . urlencode($this->_model->getUrl()); - } - - - public function getDomains() { - if ( ! $ids = $this->_model->getDomaineIds()) - return []; - - $domains = []; - - return (new Storm_Model_Collection(Class_Catalogue::findAllBy(['id_catalogue' => $ids]))) - ->collect('libelle') - ->getArrayCopy(); - } - - - public function getCategory() { - return $this->_model->getCategorieLibelle(); - } -} - - - - -class Intonation_Library_View_Wrapper_Website_AlbumMelted extends Intonation_Library_View_Wrapper_Website_MeltedItem { - - public function getUrl() { - return $this->_withResourceDo(function ($resource) { return $resource->getUrl();}); - } - - - - protected function _getResource() { - if ( $this->_resource_cache) - return $this->_resource_cache; - - $resources = $this->_model->getRessources(); - return $this->_resource_cache = reset($resources); - } - - - protected function _withResourceDo($callback) { - if ( ! $this->_getResource()) - return ''; - - return $callback($this->_getResource()); - } - - - public function getPreviewImageUrl() { - return $this->_withResourceDo(function ($resource) { return $resource->getThumbnailsUrl();}); - } - - - public function getDomains() { - return []; - } - - - public function getCategory() { - return $this->_model->getCategoryLabel(); - } -} +} \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery/AlbumMelted.php b/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery/AlbumMelted.php new file mode 100644 index 0000000000000000000000000000000000000000..9d8c6efbeac9d36a322708dbc276c6f9d21b9217 --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery/AlbumMelted.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + + + + + +class Intonation_Library_View_Wrapper_Website_Smeltery_AlbumMelted extends Intonation_Library_View_Wrapper_Website_Smeltery_MeltedItem { + + protected $_resource_cache; + + + public function getUrl() { + return $this->_withResourceDo(function ($resource) { return $resource->getUrl();}); + } + + + protected function _getResource() { + if ( $this->_resource_cache) + return $this->_resource_cache; + + $resources = $this->_model->getRessources(); + return $this->_resource_cache = reset($resources); + } + + + protected function _withResourceDo($callback) { + if ( ! $this->_getResource()) + return ''; + + return $callback($this->_getResource()); + } + + + public function getPreviewImageUrl() { + return $this->_withResourceDo(function ($resource) { return $resource->getThumbnailsUrl();}); + } + + + public function getDomains() { + return []; + } + + + public function getCategory() { + return $this->_model->getCategoryLabel(); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery/Melted.php b/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery/Melted.php new file mode 100644 index 0000000000000000000000000000000000000000..845e6c996e259d5c14f7966b337df684edaf6235 --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery/Melted.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_Library_View_Wrapper_Website_Smeltery_Melted extends Intonation_Library_View_Wrapper_Website_Smeltery_MeltedItem { + + public function getUrl() { + return $this->_model->getUrl(); + } + + + public function getPreviewImageUrl() { + return (new Class_WebService_WebSiteThumbnail)->getWebThumbnailURL($this->_model->getUrl()); + } + + + public function getDomains() { + if ( ! $ids = $this->_model->getDomaineIds()) + return []; + + $domains = []; + + return (new Storm_Model_Collection(Class_Catalogue::findAllBy(['id_catalogue' => $ids]))) + ->collect('libelle') + ->getArrayCopy(); + } + + + public function getCategory() { + return $this->_model->getCategorieLibelle(); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery/MeltedItem.php b/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery/MeltedItem.php new file mode 100644 index 0000000000000000000000000000000000000000..060018f6a9d6255b7d9cfef9725efcc534389fa8 --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/Website/Smeltery/MeltedItem.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +abstract class Intonation_Library_View_Wrapper_Website_Smeltery_MeltedItem { + + protected $_model; + + + public function __sleep() { + return ['_model']; + } + + + public function __construct($model) { + $this->_model = $model; + } + + + public function getId() { + return $this->_model->getId(); + } + + + public function getLastEdited() { + return $this->_model->getDateMaj(); + } + + + public function getTitle() { + return $this->_model->getTitre(); + } + + + public function getTags() { + return explode(';', $this->_model->getTags()); + } + + + public function getDescription() { + return $this->_model->getDescription(); + } + + + abstract public function getUrl(); + abstract public function getPreviewImageUrl(); + abstract public function getCategory(); + abstract public function getDomains(); +} diff --git a/library/templates/Intonation/Library/Widget/Carousel/Definition.php b/library/templates/Intonation/Library/Widget/Carousel/Definition.php index e785ec94d2b9ebb13e5c1d2e8e5db3ed5fb5961c..ebc478273ee36999d7a6a6053803a989328baf7e 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Definition.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Definition.php @@ -23,6 +23,7 @@ class Intonation_Library_Widget_Carousel_Definition extends Class_Systeme_ModulesAccueil_Null { const + ACCORDION_CAROUSEL = 'accordion', WALL = 'wall', CAROUSEL = 'carousel', GRID = 'grid', diff --git a/library/templates/Intonation/Library/Widget/Carousel/Form.php b/library/templates/Intonation/Library/Widget/Carousel/Form.php index adc614e4190d46dde414e94cc2a1f820c430b702..828412a86e65054b6ca065018a678f4c2732c154 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Form.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Form.php @@ -27,7 +27,8 @@ abstract class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Conf Class_ScriptLoader::getInstance() ->addJQueryReady('toggleVisibilityForElement("#link_to_all_url", $("#all_layout, #all_rendering").closest("tr"), function(element) {return ! element.val();});') - ->addJQueryReady('checkBoxToggleVisibilityForElement("#link_to_all", $("#all_layout, #all_rendering, #link_to_all_text, #link_to_all_title, #link_to_all_url, #link_to_all_to_main_title").closest("tr"), true);'); + ->addJQueryReady('checkBoxToggleVisibilityForElement("#link_to_all", $("#all_layout, #all_rendering, #link_to_all_text, #link_to_all_title, #link_to_all_url, #link_to_all_to_main_title").closest("tr"), true);') + ->addJQueryReady('checkBoxToggleVisibilityForElement("#description_html", $("#description_length").closest("tr"), false);'); $this @@ -55,6 +56,11 @@ abstract class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Conf 'value' => 20, 'min' => 0]) + ->addElement('checkbox', + 'description_html', + ['label' => $this->_('Autoriser les balises HTML dans la description (description non coupée)'), + 'value' => 0]) + ->addElement('checkbox', 'link_to_all', ['label' => $this->_('Proposer le lien vers tous les documents')]) @@ -126,7 +132,8 @@ abstract class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Conf 'link_to_all_to_main_title', 'all_rendering', 'all_layout']) - ->addToDisplayGroup(['description_length'], + ->addToDisplayGroup(['description_length', + 'description_html'], Class_Template::current()->withNameSpace('group')) ; @@ -135,7 +142,8 @@ abstract class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Conf public function getLayouts() { - $layouts = array_merge([Intonation_Library_Widget_Carousel_Definition::CAROUSEL => $this->_('Carousel'), + $layouts = array_merge([Intonation_Library_Widget_Carousel_Definition::ACCORDION_CAROUSEL => $this->_('Accordéon'), + Intonation_Library_Widget_Carousel_Definition::CAROUSEL => $this->_('Carousel'), Intonation_Library_Widget_Carousel_Definition::MULTIPLE_CAROUSEL => $this->_('Carousel à 3 colonnes'), Intonation_Library_Widget_Carousel_Definition::MULTIPLE_CAROUSEL_PLUS => $this->_('Carousel à 5 colonnes'), Intonation_Library_Widget_Carousel_Definition::GRID => $this->_('Grille'), diff --git a/library/templates/Intonation/Library/Widget/Carousel/View.php b/library/templates/Intonation/Library/Widget/Carousel/View.php index e067fa21d5648fd546144843c798af298b95d83b..88240cf439f17514c20f8318d1a9db8993805ba3 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/View.php @@ -27,15 +27,16 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help protected static $_helper_by_layout = [ - Intonation_Library_Widget_Carousel_Definition::WALL => 'Intonation_View_RenderWall', - Intonation_Library_Widget_Carousel_Definition::CAROUSEL => 'Intonation_View_RenderCarousel', - Intonation_Library_Widget_Carousel_Definition::LISTING => 'Intonation_View_RenderList', - Intonation_Library_Widget_Carousel_Definition::LISTING_WITH_OPTIONS => 'Intonation_View_RenderTruncateList', - Intonation_Library_Widget_Carousel_Definition::HORIZONTAL_LISTING => 'Intonation_View_RenderHorizontalList', - Intonation_Library_Widget_Carousel_Definition::MULTIPLE_CAROUSEL => 'Intonation_View_RenderMultipleCarousel', - Intonation_Library_Widget_Carousel_Definition::MULTIPLE_CAROUSEL_PLUS => 'Intonation_View_RenderMultipleCarousel', - Intonation_Library_Widget_Carousel_Definition::GRID => 'Intonation_View_RenderWallGrid', - Intonation_Library_Widget_Carousel_Definition::MAP => 'Intonation_View_RenderMap', + Intonation_Library_Widget_Carousel_Definition::WALL => Intonation_View_RenderWall::class, + Intonation_Library_Widget_Carousel_Definition::CAROUSEL => Intonation_View_RenderCarousel::class, + Intonation_Library_Widget_Carousel_Definition::LISTING => Intonation_View_RenderList::class, + Intonation_Library_Widget_Carousel_Definition::LISTING_WITH_OPTIONS => Intonation_View_RenderTruncateList::class, + Intonation_Library_Widget_Carousel_Definition::HORIZONTAL_LISTING => Intonation_View_RenderHorizontalList::class, + Intonation_Library_Widget_Carousel_Definition::MULTIPLE_CAROUSEL => Intonation_View_RenderMultipleCarousel::class, + Intonation_Library_Widget_Carousel_Definition::MULTIPLE_CAROUSEL_PLUS => Intonation_View_RenderMultipleCarousel::class, + Intonation_Library_Widget_Carousel_Definition::GRID => Intonation_View_RenderWallGrid::class, + Intonation_Library_Widget_Carousel_Definition::MAP => Intonation_View_RenderMap::class, + Intonation_Library_Widget_Carousel_Definition::ACCORDION_CAROUSEL => Intonation_View_RenderAccordionCarousel::class, ]; protected $_layout_helper; @@ -188,9 +189,7 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help protected function _renderElements($elements) { $content_callback = $this->_getContentCallback($this->_settings->getRendering()); - $elements = array_slice($elements, 0, $this->_settings->getSize()); - - $elements = $this->_wrapElements($elements); + $elements = $this->_sliceElements($elements); return $this->_renderLayout($this->_settings->getLayout(), $elements, $content_callback); } @@ -357,7 +356,13 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help public function newCollectionWith($order) { $this->_settings->setOrder($order); - return new Storm_Collection($this->_wrapElements($this->_findElements())); + return new Storm_Collection($this->_sliceElements($this->_findElements())); + } + + + protected function _sliceElements($elements) { + $elements = array_slice($elements, 0, $this->_settings->getSize()); + return $this->_wrapElements($elements); } diff --git a/library/templates/Intonation/Library/Widget/Carousel/Websites/Definition.php b/library/templates/Intonation/Library/Widget/Carousel/Websites/Definition.php index 87cb368947ae9e454e7f3df75137c9d6137f2255..3e9ddc48df09e4edd5936085a3cdeee8f34993c8 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Websites/Definition.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Websites/Definition.php @@ -24,7 +24,19 @@ class Intonation_Library_Widget_Carousel_Websites_Definition extends Intonation_ const CODE = 'SITO', - SEARCH = 'search'; + + SORT_SELECTION = 'Selection', + + SORT_RANDOM = 'Random', + + SORT_TITLE_ASC = 'TitleAsc', + SORT_TITLE_DESC = 'TitleDesc', + + SORT_CREATION_ASC = 'CreatedAsc', + SORT_CREATION_DESC = 'CreatedDesc', + + SORT_EDITION_ASC = 'EditedAsc', + SORT_EDITION_DESC = 'EditedDesc'; protected $_group = Class_Systeme_ModulesAccueil::GROUP_INFO; @@ -48,4 +60,85 @@ class Intonation_Library_Widget_Carousel_Websites_Definition extends Intonation_ static::HORIZONTAL_LISTING, static::WALL]; } + + + public function getOrders() { + return [static::SORT_RANDOM => $this->_('Aléatoire'), + + static::SORT_CREATION_ASC => $this->_('Date de création croissant'), + static::SORT_CREATION_DESC => $this->_('Date de création décroissant'), + + static::SORT_EDITION_ASC => $this->_('Date de modification croissant'), + static::SORT_EDITION_DESC => $this->_('Date de modification décroissant'), + + static::SORT_SELECTION => $this->_('Sélection'), + + static::SORT_TITLE_ASC => $this->_('Titre A-z'), + static::SORT_TITLE_DESC => $this->_('Titre Z-a')]; + } + + + public function getOrderCallback($order) { + if ( static::SORT_SELECTION == $order) + return function ($websites) { return $websites; }; + + if ( static::SORT_RANDOM == $order) + return function ($websites) + { + shuffle($websites); + return $websites; + }; + + return $this->_isASC($order) + ? $this->_doASCCallback($order) + : $this->_doDESCCallback($order); + } + + + protected function _isASC($order) { + return in_array($order, + [static::SORT_CREATION_ASC, + static::SORT_EDITION_ASC, + static::SORT_TITLE_ASC]); + } + + + protected function _doASCCallback($order) { + $method_name = $this->_getMethodNameFor($order); + return function ($websites) use ($method_name) + { + usort($websites, function($a, $b) use ($method_name) + { + return strnatcasecmp($a->$method_name(), $b->$method_name()); + }); + return $websites; + }; + } + + + protected function _doDESCCallback($order) { + $method_name = $this->_getMethodNameFor($order); + return function ($websites) use ($method_name) + { + usort($websites, function($a, $b) use ($method_name) + { + $cmp = strnatcasecmp($a->$method_name(), $b->$method_name()); + return ($cmp == 0) + ? $cmp + : !$cmp; + }); + return $websites; + }; + } + + + protected function _getMethodNameFor($order) { + if ( static::SORT_EDITION_ASC == $order || static::SORT_EDITION_DESC == $order ) + return 'getLastEdited'; + + if ( static::SORT_TITLE_ASC == $order || static::SORT_TITLE_DESC == $order) + return 'getTitle'; + + return 'getId'; + } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/Widget/Carousel/Websites/Form.php b/library/templates/Intonation/Library/Widget/Carousel/Websites/Form.php index 62238316817715ce6f36a1a23432cc17b755c644..184c7cdd89a5051bb5fadfa18805a0c07c813da6 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Websites/Form.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Websites/Form.php @@ -55,7 +55,7 @@ class Intonation_Library_Widget_Carousel_Websites_Form extends Intonation_Librar public function getOrders() { - return []; + return (new Intonation_Library_Widget_Carousel_Websites_Definition)->getOrders(); } diff --git a/library/templates/Intonation/Library/Widget/Carousel/Websites/View.php b/library/templates/Intonation/Library/Widget/Carousel/Websites/View.php index 646942ad9837d8eeedec239948f04088fc483c01..5819feea1de2d57a9b9d912f9f4bd517c5e8468e 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Websites/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Websites/View.php @@ -52,7 +52,7 @@ class Intonation_Library_Widget_Carousel_Websites_View extends Intonation_Librar foreach ($albums as $album) $melted_websites [] = $smeltery->meltAlbum($album); - return $melted_websites; + return $this->_order($melted_websites); } @@ -77,4 +77,13 @@ class Intonation_Library_Widget_Carousel_Websites_View extends Intonation_Librar protected function _getWrapper() { return Intonation_Library_View_Wrapper_Website::class; } + + + protected function _order($websites) { + $order = $this->_settings->getOrder(); + $order_callback = (new Intonation_Library_Widget_Carousel_Websites_Definition) + ->getOrderCallback($order); + + return $order_callback($websites); + } } diff --git a/library/templates/Intonation/System/Abstract.php b/library/templates/Intonation/System/Abstract.php index b21cb2cee6f90fb1a6ff452431f988c4861e29a5..524d1486954d81d0be6eebde2b88354ce0bdb548 100644 --- a/library/templates/Intonation/System/Abstract.php +++ b/library/templates/Intonation/System/Abstract.php @@ -174,6 +174,7 @@ abstract class Intonation_System_Abstract { $controllers [] = 'formulaire'; $controllers [] = 'bib'; $controllers [] = 'widget'; + $controllers [] = 'sito'; } if($this->isVisibleForBlogController()) { diff --git a/library/templates/Intonation/Template.php b/library/templates/Intonation/Template.php index 0e3814f9fc8c841be4dc6de64e54441ecee54a09..8333e0530f0f0e6e652054a4b4f6f8729fed6426 100644 --- a/library/templates/Intonation/Template.php +++ b/library/templates/Intonation/Template.php @@ -439,7 +439,7 @@ class Intonation_Template extends Class_Template { protected function _getMapWrapper() { - return ['Class_Notice' => 'Intonation_Library_View_Wrapper_Record', - 'Class_Bib' => 'Intonation_Library_View_Wrapper_Library']; + return ['Class_Notice' => Intonation_Library_View_Wrapper_Record::class, + 'Class_Bib' => Intonation_Library_View_Wrapper_Library::class]; } } diff --git a/library/templates/Intonation/View/RenderAjaxPaginatedList.php b/library/templates/Intonation/View/RenderAjaxPaginatedList.php index 8287817c6ea89502f7ff7950db7395f77e5477a7..a4aaef347396bf9084b2277b8f8d9c46bd407e92 100644 --- a/library/templates/Intonation/View/RenderAjaxPaginatedList.php +++ b/library/templates/Intonation/View/RenderAjaxPaginatedList.php @@ -76,33 +76,43 @@ class Intonation_View_RenderAjaxPaginatedList extends ZendAfi_View_Helper_BaseHe ? true : null; + $anchor_previous_url = $this->view->url(['controller' => 'index', + 'action' => 'ajax-paginated-list', + 'id' => $this->_id, + 'size' => $helper->getPageSize(), + 'page' => $current_page -1], null, true); + + $anchor_previous = $this->view->tagAnchor($anchor_previous_url, + $this->_tag('i','',['class' => 'fas fa-chevron-left m-0']), + array_filter(['title' => $this->_('page précedente'), + 'class' => 'btn btn-sm btn-secondary ajax_anchor previous_ajax_anchor', + 'id' => 'previous_' . $this->_id, + 'data-disabled' => $previous_button_disabled])); + + $anchor_next_url = $this->view->url(['controller' => 'index', + 'action' => 'ajax-paginated-list', + 'id_profil' => Class_Profil::getCurrentProfil()->getId(), + 'id' => $this->_id, + 'size' => $helper->getPageSize(), + 'page' => $current_page +1], + null, + true); + + $anchor_next = $this->view->tagAnchor($anchor_next_url, + $this->_tag('i','',['class' => 'fas fa-chevron-right m-0']), + array_filter(['title' => $this->_('page suivante'), + 'class' => 'btn btn-sm btn-secondary ajax_anchor next_ajax_anchor', + 'id' => 'next_' . $this->_id, + 'data-disabled' => $next_button_disabled])); + return $this->view->div([], - implode([$this->view->tagAnchor(['controller' => 'index', - 'action' => 'ajax-paginated-list', - 'id' => $this->_id, - 'size' => $helper->getPageSize(), - 'page' => $current_page -1], - $this->_tag('i','',['class' => 'fas fa-chevron-left m-0']), - array_filter(['title' => $this->_('page précedente'), - 'class' => 'btn btn-sm btn-secondary ajax_anchor previous_ajax_anchor', - 'id' => 'previous_' . $this->_id, - 'data-disabled' => $previous_button_disabled])), + implode([$anchor_previous, $this->_tag( 'span' , $this->_('Page %d / %d' , $current_page, $count_pages), ['class' => 'btn btn-sm']), - $this->view->tagAnchor(['controller' => 'index', - 'action' => 'ajax-paginated-list', - 'id_profil' => Class_Profil::getCurrentProfil()->getId(), - 'id' => $this->_id, - 'size' => $helper->getPageSize(), - 'page' => $current_page +1], - $this->_tag('i','',['class' => 'fas fa-chevron-right m-0']), - array_filter(['title' => $this->_('page suivante'), - 'class' => 'btn btn-sm btn-secondary ajax_anchor next_ajax_anchor', - 'id' => 'next_' . $this->_id, - 'data-disabled' => $next_button_disabled]))])); + $anchor_next])); } diff --git a/library/templates/Intonation/View/RenderCollection.php b/library/templates/Intonation/View/RenderCollection.php index a4b41d98680928942df59696c8a72915cfd0a6a7..7fbf0a028d02917ca3c6684ee29960e6f4ab3773 100644 --- a/library/templates/Intonation/View/RenderCollection.php +++ b/library/templates/Intonation/View/RenderCollection.php @@ -33,9 +33,9 @@ class Intonation_View_RenderCollection extends ZendAfi_View_Helper_BaseHelper { if ( ! $action->getClass()) $action->setClass('btn btn-sm btn-success'); - $html = [$this->view->div(['class' => 'col-12'], + $html = [$this->view->div(['class' => 'collection_actions'], $this->view->renderCollectionActions($actions)), - $this->view->div(['class' => 'col-12'], + $this->view->div(['class' => 'collection_truncate_list'], $this->view->renderTruncateList($collection, $callback, $page_size))]; diff --git a/library/templates/Intonation/View/RenderWebsites.php b/library/templates/Intonation/View/RenderWebsites.php new file mode 100644 index 0000000000000000000000000000000000000000..b0c5536da312e4b248b77f35de76eac384569156 --- /dev/null +++ b/library/templates/Intonation/View/RenderWebsites.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_View_RenderWebsites extends ZendAfi_View_Helper_BaseHelper { + public function renderWebsites($websites) { + if ( ! $this->view->titre) + $this->view->titre = $this->_('Sélection de sites'); + + $smeltery = new Intonation_Library_View_Wrapper_Website_Smeltery; + + $melted_websites = []; + foreach ($websites as $website) + $melted_websites [] = new Intonation_Library_View_Wrapper_Website($smeltery->meltWebsite($website), + $this->view); + + $content = [$this->_div(['class' => 'websites_list_title'], + $this->_tag('h1', $this->view->titre)), + + $this->_div(['class' => 'websites_list_content'], + $this->view->renderCollection(new Storm_Collection($melted_websites)))]; + + return $this->view->grid($content); + } +} diff --git a/library/templates/Intonation/View/Truncate.php b/library/templates/Intonation/View/Truncate.php index 869cc9ea535181478eef0cfece32b1cabdb8d6eb..b4093d3a2f9ae6c10190eeb68b10205c87ee7646 100644 --- a/library/templates/Intonation/View/Truncate.php +++ b/library/templates/Intonation/View/Truncate.php @@ -21,14 +21,21 @@ class Intonation_View_Truncate extends ZendAfi_View_Helper_BaseHelper { - public function truncate($text, $attribs = [], $size = 20, $tag = 'p') { + public function truncate($text, $attribs = [], $size = 20, $html = false, $tag = 'p') { if (! $text) return ''; + return $html + ? $this->_tag($tag, $this->_removeHTML($text), $attribs) + : $this->_onlyText($text, $attribs, $size, $tag); + } + + + protected function _onlyText($text, $attribs, $size, $tag) { if (null === $size) $size = 20; - $text = preg_replace('/(<(script|style|link)\b[^>]*>).*?(<\/\2>)/is', "", $text); + $text = $this->_removeHTML($text); $text = strip_tags(html_entity_decode($text)); @@ -49,4 +56,10 @@ class Intonation_View_Truncate extends ZendAfi_View_Helper_BaseHelper { implode(' ', $ellipsis), $attribs); } + + + protected function _removeHTML($text) { + $text = preg_replace('/(<(script|style|link|canvas|iframe)\b[^>]*>).*?(<\/\2>)/is', "", $text); + return preg_replace('/(<(img)\b).*?(\/>)/is', '', $text); + } } \ No newline at end of file diff --git a/tests/scenarios/ExternalAgendas/ExternalAgendasOpenAgendaTest.php b/tests/scenarios/ExternalAgendas/ExternalAgendasOpenAgendaTest.php index fe1e4a6d60f6bd00e668f04376a564e2edc37e92..2dd27dba0ca5d1cdbdec4e0f2f61d10fccc16894 100644 --- a/tests/scenarios/ExternalAgendas/ExternalAgendasOpenAgendaTest.php +++ b/tests/scenarios/ExternalAgendas/ExternalAgendasOpenAgendaTest.php @@ -20,14 +20,10 @@ */ -class ExternalAgendasOpenAgendaAdminTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile=true; - +class ExternalAgendasOpenAgendaImportTest extends ModelTestCase { public function setup() { parent::setup(); - - $events_category = $this->fixture('Class_ArticleCategorie', ['id'=>123, 'libelle' => 'Coding Gouter', @@ -35,37 +31,41 @@ class ExternalAgendasOpenAgendaAdminTest extends Admin_AbstractControllerTestCas ['id'=>7, 'libelle'=>'Joliville'])]); - Class_AdminVar::set('AGENDA_KEEP_LOCAL_CONTENT',0); - - $time_source = new TimeSourceForTest('2019-11-01 08:00:00'); - - Class_ExternalAgenda::setTimeSource($time_source); - Class_Article::setTimeSource($time_source); - + $agenda_url = 'https://openagenda.com/agendas/36758196/events.json?lang=fr&key=e0f9e6b4302a439f99b78549b9d63fd6'; $this->fixture('Class_ExternalAgenda', - [ 'id' => 12, + ['id' => 12, 'label' => 'agenda PNB', - 'url' => 'https://openagenda.com/agendas/36758196/events.json?lang=fr&key=e0f9e6b4302a439f99b78549b9d63fd6', + 'url' => $agenda_url, 'provider' => Class_ExternalAgenda::OPEN_AGENDA, 'status' => Class_Article::STATUS_DRAFT, 'delete_orphan_events' => 1, 'category' => $events_category]); - Class_ExternalAgenda_OpenAgenda::setDefaultHttpClient($this->mock() - ->whenCalled('open_url') - ->with('https://openagenda.com/agendas/36758196/events.json?lang=fr&key=e0f9e6b4302a439f99b78549b9d63fd6&offset=0') - ->answers(file_get_contents(__DIR__.'/open-agenda-1.json')) - ->whenCalled('open_url') - ->with('https://openagenda.com/agendas/36758196/events.json?lang=fr&key=e0f9e6b4302a439f99b78549b9d63fd6&offset=1') - ->answers(file_get_contents(__DIR__.'/open-agenda-2.json')) - ->whenCalled('open_url') - ->with('https://openagenda.com/agendas/36758196/events.json?lang=fr&key=e0f9e6b4302a439f99b78549b9d63fd6&offset=2') - ->answers(file_get_contents(__DIR__.'/open-agenda-3.json')) - ->beStrict() - ); + + $http_client = $this->mock() + ->whenCalled('open_url') + ->with($agenda_url . '&page=1') + ->answers(file_get_contents(__DIR__.'/open-agenda-1.json')) + + ->whenCalled('open_url') + ->with($agenda_url . '&page=2') + ->answers(file_get_contents(__DIR__.'/open-agenda-2.json')) + + ->whenCalled('open_url') + ->with($agenda_url . '&page=3') + ->answers(file_get_contents(__DIR__.'/open-agenda-3.json')) + + ->beStrict(); + + Class_ExternalAgenda_OpenAgenda::setDefaultHttpClient($http_client); + + $time_source = new TimeSourceForTest('2019-11-01 08:00:00'); + Class_ExternalAgenda::setTimeSource($time_source); + Class_Article::setTimeSource($time_source); Class_ExternalAgenda::find(12)->import(); } + public function teardown() { Class_ExternalAgenda::setTimeSource(null); Class_Article::setTimeSource(null); diff --git a/tests/scenarios/Templates/ChiliAccordionTest.php b/tests/scenarios/Templates/ChiliAccordionTest.php index 7f913cf5e055c39bed26124e5b31305a98372322..c5fc459463b295e3cb8040c945de2641816e2674 100644 --- a/tests/scenarios/Templates/ChiliAccordionTest.php +++ b/tests/scenarios/Templates/ChiliAccordionTest.php @@ -38,7 +38,7 @@ class ChiliAccordionWidgetTest extends AbstractControllerTestCase { ->addWidget(Intonation_Library_Widget_Carousel_Article_Definition::CODE, Class_Profil::DIV_MAIN, ['rendering' => 'card-horizontal', - 'id_items' => '56;57', + 'id_items' => '56;57;58', 'layout' => 'accordion', 'size' => 5, 'description_length' => 4]); @@ -55,6 +55,11 @@ class ChiliAccordionWidgetTest extends AbstractControllerTestCase { 'contenu' => 'Milkyway' ]); + $this->fixture(Class_Article::class, + ['id' => 58, + 'titre' => 'Bibliographies', + 'contenu' => '<iframe allowfullscreen="" allowtransparency="" frameborder="0" height="300" scrolling="no" src="//v.calameo.com/?bkcode=00261361896ea4b0d3648&mode=mini&authid=b9EvnNDuyW4J" style="margin:0 auto;" width="500"></iframe>']); + $this->dispatch('/opac/index/index'); } @@ -91,7 +96,7 @@ class ChiliAccordionWidgetTest extends AbstractControllerTestCase { /** @test */ - public function accordionShouldContainsTwoCollapsableArticlesWithMatchingAriaTagsIdHeadingAndCollapse() { + public function accordionShouldContainsThreeCollapsableArticlesWithMatchingAriaTagsIdHeadingAndCollapse() { /** Matches this structure: div class=card-header id=heading_XX @@ -100,7 +105,7 @@ class ChiliAccordionWidgetTest extends AbstractControllerTestCase { div id=collapse_XX aria-labelledby=heading_XX */ $this->assertXPathCount('//div[@id=following-sibling::div[contains(@id, "collapse_")]/@aria-labelledby]/h2/button[@aria-controls=ancestor::div[contains(@class, "card-header")]/following-sibling::div/@id]', - 2); + 3); } @@ -120,10 +125,4 @@ class ChiliAccordionWidgetTest extends AbstractControllerTestCase { public function cardifyHorizontalActionsShouldBeHydratedWithCol12ColSm3Px3() { $this->assertXPath('//div[@class = "cardify_horizontal_actions col-12 col-sm-3 px-3 px-sm-0"]'); } - - - /** @test */ - public function pageShouldBeHTML5Valid() { - $this->assertHTML5(); - } } diff --git a/tests/scenarios/Templates/TemplateDigitalResourcesTest.php b/tests/scenarios/Templates/TemplateDigitalResourcesTest.php deleted file mode 100644 index bca06ef661015b06826a27e5c14308fcf2cd00d5..0000000000000000000000000000000000000000 --- a/tests/scenarios/Templates/TemplateDigitalResourcesTest.php +++ /dev/null @@ -1,247 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -require_once 'tests/fixtures/DilicomFixtures.php'; - -class TemplateDigitalResourcesDispatchTest extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - - - public function setUp() { - parent::setUp(); - - $this->_buildTemplateProfil(['id' => 9, - 'template' => 'MUSCLE']); - - $this->fixture('Class_Notice', - ['id' => 123, - 'type_doc' => Class_TypeDoc::LIVRE_NUM]); - - $this->fixture('Class_Exemplaire', - ['id' => 34, - 'id_origine' => 8, - 'id_notice' => 123]); - - $this->fixture('Class_Album', - ['id' => 8, - 'titre' => 'old book', - 'type_doc_id' => Class_TypeDoc::LIVRE_NUM]); - - $this->dispatch('noticeajax/digital-resources/id_notice/123'); - } - - - /** @test */ - public function bookletShouldBeLoadedWithAlbumTypeLivreNumerique() { - $this->assertXPathContentContains('//script', '_load_in_scriptsRoot'); - } - - - /** @test */ - public function setupAnchorsTargetShouldBeInScript() { - $this->assertXPathContentContains('//script', 'setupAnchorsTarget();'); - } - - - /** @test */ - public function initializePopupsShouldBeInScript() { - $this->assertXPathContentContains('//script', 'setTimeout(function(){initializePopups();setupAnchorsTarget();}, 5);'); - } -} - - - - -class TemplateDigitalResourcesMediaAndTrailerDispatchTest extends AbstractControllerTestCase { - - protected $_storm_default_to_volatile = true; - - - public function setUp() { - parent::setUp(); - - - $this->_buildTemplateProfil(['id' => 5, - 'template' => 'CHILI']); - - $this->fixture('Class_Notice', - ['id' => 34, - 'titre_principal' => 'Psycho', - ]); - - Class_CosmoVar::set('url_services', 'https://cache-server.org'); - - $mock = $this - ->mock() - ->whenCalled('open_url') - ->answers(json_encode(['source' => 'testing', - 'player' => '<iframe src="https://www.super-trailers.org/?media=18397590" style="width:500px; height:400px" frameborder="0"></iframe>'])); - - Class_WebService_AllServices::setHttpClient($mock); - } - - - /** @test */ - public function noticeajaxTrailershouldDisplayTrailer() { - $this->dispatch('/noticeajax/trailer/id/34'); - $this->assertXPath('//div[contains(@class, "embed-responsive")]//iframe[@src= "https://www.super-trailers.org/?media=18397590"][@class="embed-responsive-item"]'); - } - - - /** @test */ - public function noticeajaxTrailershouldDisplayTrailerTarteAuCitron() { - Class_AdminVar_Cookies::setManager(new Class_Cookies_TarteAuCitron()); - $this->dispatch('/noticeajax/trailer/id/34'); - $this->assertXPath('//div[contains(@class, "embed-responsive")]//div[@class="tac_iframe"][@data-url= "https://www.super-trailers.org/?media=18397590"]'); - } - - - /** @test */ - public function noticeajaxTrailershouldContainsInitializePopup() { - $this->dispatch('/noticeajax/trailer/id/34'); - $this->assertXPathContentContains('//script', 'initializePopups();'); - } - - - /** @test */ - public function noticeajaxMediaDisplayTrailer() { - $this->dispatch('/noticeajax/media/id/34'); - $this->assertXPath('//div[contains(@class, "embed-responsive")]//iframe[@src= "https://www.super-trailers.org/?media=18397590"][@class="embed-responsive-item"]'); - } - - - /** @test */ - public function shouldRenderEditTrailer() { - $this->dispatch('/noticeajax/media/id/34'); - $this->assertXPath('//button[contains(@onclick, "/admin/records/trailer/id/34")]'); - } - - - /** @test */ - public function noticeajaxMediaShouldContainsInitializePopup() { - $this->dispatch('/noticeajax/media/id/34'); - $this->assertXPathContentContains('//script', 'initializePopups();'); - } -} - - - - -abstract class TemplateDigitalResourcesDilicomTestCase extends AbstractControllerTestCase { - - protected $_storm_default_to_volatile = true; - - - public function setUp() { - parent::setUp(); - - $this->_buildTemplateProfil(['id' => 9, - 'template' => 'MUSCLE']); - - $this->fixture('Class_Bib', - ['id' => 1, - 'libelle' => 'annecy', - 'gln' => '2222' - ]); - - $group = $this->fixture('Class_UserGroup', - ['id' => '20', - 'libelle' => 'Multimedia', - 'rights' => [Class_UserGroup::RIGHT_ACCES_PNB_DILICOM]]); - - $logged_user = $this->fixture('Class_Users', - ['id' => 6, - 'nom'=>'Pito', - 'login'=>'Chat', - 'password'=>'123456', - 'id_site' => 1, - 'idabon' => '12345', - 'user_groups' => [$group]]); - - $logged_user->beAbonneSIGB()->assertSave(); - ZendAfi_Auth::getInstance()->logUser($logged_user); - - $this->fixture('Class_Album', - ['id' => 34, - 'titre' => 'La Planète des chats', - 'type_doc_id' => Class_TypeDoc::LIVRE_NUM]); - } -} - - - - -class TemplateDigitalResourcesLoanBookAjaxTest extends TemplateDigitalResourcesDilicomTestCase { - - public function setUp() { - parent::setUp(); - $this->dispatch('bib-numerique/loan-book-ajax/id/34'); - } - - - /** @test */ - public function subModalJSShouldBeLoaded() { - $this->assertXPath('//script[contains(@src, "public/opac/js/subModal.js")]'); - } - - - /** @test */ - public function initializeAjaxFormSubmitShouldBePresent() { - $this->assertXPathContentContains('//script', 'initializeAjaxFormSubmit($("#pnb_devices"));'); - } -} - - - - -class TemplateDigitalResourcesDilicomItemTest extends TemplateDigitalResourcesDilicomTestCase { - - public function setUp() { - parent::setUp(); - - $this->fixture('Class_Notice', - ['id' => 123, - 'type_doc' => Class_TypeDoc::LIVRE_NUM]); - - $this->fixture('Class_Exemplaire', - ['id' => 8, - 'id_origine' => 3, - 'id_notice' => 123]); - - (new DilicomFixtures())->albumTotemThora(); - RessourcesNumeriquesFixtures::activateDilicom(); - - $this->dispatch('noticeajax/digital-resources/id_notice/123'); - } - - - /** @test */ - public function loanLinkShouldBeDisabled() { - $this->assertXPathContentContains('//a[@data-disabled]', 'Emprunter le livre au format EPUB'); - } - - - /** @test */ - public function consultLinkShouldBeDisabled() { - $this->assertXPathContentContains('//a[@data-disabled]', 'Consulter le livre en ligne'); - } -} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index 23ee4dd968dcd789c56c8344ca8c50497232669f..f38dc17ae8cd67d3581b5b27d710b3eac4770ed0 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -1676,3 +1676,77 @@ class TemplatesAbonneSearchHistoryTest extends AbstractControllerTestCase { $this->assertXPathContentContains('//div[@class="collection_action alone_in_the_list clear_history_button col mr-3 col-3"]/a[@class="card-link clear_history_button btn btn-sm btn-warning"]', 'Vider'); } } + + + + +class TemplatesAbonneEditActionFicheTest extends Admin_AbstractControllerTestCase { + + + public function setUp() { + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 19]); + + (new Class_Profil_Preferences) + ->setModulePref(Class_Profil::getCurrentProfil(), + (new Class_Profil_ModuleDefinition('abonne', + 'fiche')), + [Intonation_Library_View_Wrapper_User_RichContent_Agenda::class => '0']); + + + $this->dispatch('/admin/widget/edit-action/id/abonne_fiche/id_profil/19'); + } + + + /** @test */ + public function pageShouldContainsCheckboxAgendaTabDeactivated() { + $this->assertXPath('//input[@type="checkbox"][@name="Intonation_Library_View_Wrapper_User_RichContent_Agenda"][not(@checked)]'); + } + + + /** @test */ + public function pageShouldContainsCheckboxHomeTabActivated() { + $this->assertXPath('//input[@type="checkbox"][@name="Intonation_Library_View_Wrapper_User_RichContent_Home"][@checked]'); + } +} + + + + + +class TemplatesAbonneAgendaDisabledTest extends AbstractControllerTestCase { + + + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 9]); + + (new Class_Profil_Preferences) + ->setModulePref(Class_Profil::getCurrentProfil(), + (new Class_Profil_ModuleDefinition('abonne', + 'fiche')), + [Intonation_Library_View_Wrapper_User_RichContent_Agenda::class => '0']); + + $searcher = + $this->fixture(Class_Users::class, + ['id' => 1, + 'login' => 'Searcher', + 'password' => 'secret', + ]); + + ZendAfi_Auth::getInstance()->logUser($searcher); + + $this->dispatch('/opac/abonne'); + } + + + /** @test */ + public function agendaTabShouldNotBePresent() { + $this->assertNotXPath('//div//a[contains(@class, "user_agenda")]'); + } +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesArticlesTest.php b/tests/scenarios/Templates/TemplatesArticlesTest.php index acd7f3a0cd96425da09715f0ba7b4d9eaecc30e5..d3033f5740dba458ee0ccb3fc9173bfc4b9ef513 100644 --- a/tests/scenarios/Templates/TemplatesArticlesTest.php +++ b/tests/scenarios/Templates/TemplatesArticlesTest.php @@ -140,6 +140,12 @@ class TemplatesArticlesEditWidgetTest extends TemplatesArticlesWidgetTestCase { public function formShouldContainsInputNumberForDescriptionLength() { $this->assertXPath('//input[@type="number"][@name="description_length"][@value="20"]'); } + + + /** @test */ + public function formShouldContainsCheckboxDescriptionHtml() { + $this->assertXPath('//input[@type="checkbox"][@name="description_html"][not(@checked)]'); + } } @@ -704,7 +710,7 @@ class TemplatesArticlesWidgetWithDescriptionLengthTest extends AbstractControlle ->answers([$this->fixture('Class_Article', ['id' => 7, 'titre' => 'Parlez-vous français ?', - 'description' => 'La description s\'arrête ici et pas plus loin.', + 'description' => '<canvas></canvas>La description s\'arrête ici et pas plus loin.', 'contenu' => '<p>Une b...</p>'])]); $profile_patcher @@ -1042,3 +1048,48 @@ class TemplatesArticlesWithLibraryUrlRewriteTest extends AbstractControllerTestC } } + + + + +class TemplatesArticlesWidgetWithDescriptionHTMLTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + ZendAfi_Auth::getInstance()->clearIdentity(); + + $this->_buildTemplateProfil(['id' => 34]); + + $profile_patcher = (new Class_Template_ProfilePatcher(null)) + ->setProfile(Class_Profil::getCurrentProfil()); + + $this + ->onLoaderOfModel('Class_Article') + ->whenCalled('getArticlesByPreferences') + ->answers([$this->fixture('Class_Article', + ['id' => 7, + 'titre' => 'Parlez-vous français ?', + 'description' => '<a href="#">là </a><img src=""/><iframe></iframe><canvas></canvas><a href="#">ici</a>La description s\'arrête ici et pas plus loin.', + 'contenu' => '<p>Une b...</p>'])]); + + $profile_patcher + ->addWidget(Intonation_Library_Widget_Carousel_Article_Definition::CODE, + Class_Profil::DIV_MAIN, + ['rendering' => 'card-description', + 'layout' => 'list', + 'size' => 1, + 'description_html' => 1]); + + $this->dispatch('/opac/widget/render/widget_id/1/profile_id/34'); + } + + + /** @test */ + public function descriptionShouldBeHTML() { + $this->assertXPathContentContains('//div[contains(@class, "news widget")]//p[contains(@class, "model_description")]', + '<a href="#">là </a><a href="#">ici</a>La description s\'arrête ici et pas plus loin.'); + } +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesDigitalResourcesTest.php b/tests/scenarios/Templates/TemplatesDigitalResourcesTest.php index 0fca69ed676e4d99d36e14fb65fbbc18cada4b7e..b9750fb4527d896459ca998a23b4a811b14fd3c7 100644 --- a/tests/scenarios/Templates/TemplatesDigitalResourcesTest.php +++ b/tests/scenarios/Templates/TemplatesDigitalResourcesTest.php @@ -518,4 +518,4 @@ class TemplatesDigitalResourcesTrailerEmptyPlayerAdministrationTest extends Abst public function trailerShouldNotBeRender() { $this->assertNotXPath('//iframe'); } -} +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesRecordsTest.php b/tests/scenarios/Templates/TemplatesRecordsTest.php index 71095ee8a7e714534c3cba960e9e4d114f5de141..35de31fb24348b4ed17e40c0a18da86ea019a1f2 100644 --- a/tests/scenarios/Templates/TemplatesRecordsTest.php +++ b/tests/scenarios/Templates/TemplatesRecordsTest.php @@ -599,3 +599,72 @@ class TemplatesRecordsCollectionDateApproximateTest extends AbstractControllerTe '[après 1950]'); } } + + + + +class TemplatesRecordsTabsDisabledTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 19]); + + (new Class_Profil_Preferences) + ->setModulePref(Class_Profil::getCurrentProfil(), + (new Class_Profil_ModuleDefinition('recherche', + 'viewnotice', + '1')), + [Intonation_Library_View_Wrapper_Record_RichContent_Author::class => 0]); + + + $this->fixture(Class_Notice::class, + ['id' => 1, + 'type_doc' => 1]); + + $this->dispatch('/recherche/viewnotice/id/1'); + } + + + /** @test */ + public function authorBiografyTabShouldNotBePresent() { + $this->assertNotXPath('//div//a[contains(@class, "document_author")]'); + } +} + + + + +class TemplatesRecordsEditActionTest extends Admin_AbstractControllerTestCase { + + + public function setUp() { + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 19]); + + (new Class_Profil_Preferences) + ->setModulePref(Class_Profil::getCurrentProfil(), + (new Class_Profil_ModuleDefinition('recherche', + 'viewnotice', + '1')), + [Intonation_Library_View_Wrapper_Record_RichContent_Author::class => '0']); + + + $this->dispatch('/admin/widget/edit-action/id/recherche_viewnotice_1/id_profil/19'); + } + + + /** @test */ + public function pageShouldContainsCheckboxAuthorTabDeactivated() { + $this->assertXPath('//input[@type="checkbox"][@name="Intonation_Library_View_Wrapper_Record_RichContent_Author"][not(@checked)]'); + } + + + /** @test */ + public function pageShouldContainsCheckboxHomeTabActivated() { + $this->assertXPath('//input[@type="checkbox"][@name="Intonation_Library_View_Wrapper_Record_RichContent_Home"][@checked]'); + } +} diff --git a/tests/scenarios/Templates/TemplatesWebsitesTest.php b/tests/scenarios/Templates/TemplatesWebsitesTest.php index 911179741062be8414a5fa0380458a4d3b355fb5..6864592a9811e85d32ad10a61cc302bd7f9a4c4c 100644 --- a/tests/scenarios/Templates/TemplatesWebsitesTest.php +++ b/tests/scenarios/Templates/TemplatesWebsitesTest.php @@ -40,7 +40,13 @@ abstract class TemplatesWebsitesWidgetTestCase extends Admin_AbstractControllerT 'websites_ids' => '1-2', 'websites_categories' => '8-5', 'id_items' => '4-19', - 'id_categorie' => '3-53']); + 'id_categorie' => '3-53', + 'order' => $this->_order()]); + } + + + protected function _order() { + return 'Selection'; } } @@ -96,15 +102,17 @@ class TemplatesWebsitesWidgetAsAdminTest extends TemplatesWebsitesWidgetTestCase $this->dispatch('/admin/widget/add-from-template/id_profil/19'); $this->assertXPathContentContains('//div', 'Sitothèque'); } -} + /** @test */ + public function orderCreatedAscShouldBePresent() { + $this->dispatch('admin/widget/edit-widget/id/1/id_profil/19'); + $this->assertXPath('//div//select/option', 'Date de création croissant'); + } +} -class TemplatesWebsitesWidgetDispatchTest extends TemplatesWebsitesWidgetTestCase { - protected $_storm_default_to_volatile = true; - - +abstract class TemplatesWebsitesFixturesTestCase extends TemplatesWebsitesWidgetTestCase { public function setUp() { parent::setUp(); @@ -215,6 +223,17 @@ class TemplatesWebsitesWidgetDispatchTest extends TemplatesWebsitesWidgetTestCas 'titre' => 'Site de l\'eau' ]); + } +} + + + + +class TemplatesWebsitesWidgetDispatchTest extends TemplatesWebsitesFixturesTestCase { + + + public function setUp() { + parent::setUp(); $this->dispatch('opac/index'); } @@ -265,4 +284,153 @@ class TemplatesWebsitesWidgetDispatchTest extends TemplatesWebsitesWidgetTestCas public function leSiteDuLacShouldBePresent() { $this->assertXPathContentContains('//div', 'Le site du lac'); } +} + + + + +class TemplatesWebsitesControllerTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + $profile = + $this->_buildTemplateProfil(['id' => '19', + 'template' => 'MUSCLE']); + + $this->fixture('Class_Sitotheque', + ['id' => '32', + 'titre' => 'La médiathèque de la montée', + 'url' => 'https://la-mediatheque-de-la-montee.org', + 'id_cat' => '127' + ]); + + $this->fixture('Class_SitothequeCategorie', + ['id' => '127', + 'libelle' => 'Montée' + ]); + + $this->dispatch('/sito/sitoview/id_categorie/127'); + } + + + /** @test */ + public function pageShouldContainsMain() { + $this->assertXPath('//body//main'); + } +} + + + +class TemplatesWebsitesWidgetDispatchWithRandomOrderTest extends TemplatesWebsitesWidgetDispatchTest { + protected function _order() { + return 'Random'; + } +} + + + + +class TemplatesWebsitesWidgetDispatchWithTitleAscOrderTest extends TemplatesWebsitesWidgetDispatchTest { + protected function _order() { + return 'TitleAsc'; + } + + + /** @test */ + public function firstWebsiteShoulBeLaMediathequeDeLaDescente() { + $this->assertXPathContentContains('(//div[contains(@class, "card")])[1]', 'La médiathèque de la descente'); + } +} + + + +class TemplatesWebsitesWidgetDispatchWithTitleDescOrderTest extends TemplatesWebsitesWidgetDispatchTest { + protected function _order() { + return 'TitleDesc'; + } + + + /** @test */ + public function firstWebsiteShoulBeLaMediathequeDuCoin() { + $this->assertXPathContentContains('(//div[contains(@class, "card")])[1]', 'La médiathèque du coin'); + } +} + + + + +class TemplatesWebsitesWidgetDispatchWithCreationAscOrderTest extends TemplatesWebsitesWidgetDispatchTest { + protected function _order() { + return 'CreatedAsc'; + } + + + /** @test */ + public function firstWebsiteShoulBeLaMediathequeDeLaRue() { + $this->assertXPathContentContains('(//div[contains(@class, "card")])[1]', 'La médiathèque de la rue'); + } +} + + + + +class TemplatesWebsitesWidgetDispatchWithCreationDescOrderTest extends TemplatesWebsitesWidgetDispatchTest { + protected function _order() { + return 'CreatedDesc'; + } + + + /** @test */ + public function firstWebsiteShoulBeLaMediathequeDeLaDescente() { + $this->assertXPathContentContains('(//div[contains(@class, "card")])[1]', 'La médiathèque de la descente'); + } +} + + + + +class TemplatesWebsitesWidgetDispatchWithEditionAscOrderTest extends TemplatesWebsitesWidgetDispatchTest { + protected function _order() { + return 'EditedAsc'; + } +} + + + + +class TemplatesWebsitesWidgetDispatchWithEditionDescOrderTest extends TemplatesWebsitesWidgetDispatchTest { + protected function _order() { + return 'EditedDesc'; + } +} + + + + +class TemplatesWebsitesDispatchPaginatedTest extends TemplatesWebsitesFixturesTestCase { + /** @test */ + public function page2ShouldContainsSearchInputWithMd5Key() { + Storm_Cache::beVolatile(); + + $smeltery = new Intonation_Library_View_Wrapper_Website_Smeltery; + + $melted_websites = []; + + $view_renderer = new ZendAfi_Controller_Action_Helper_ViewRenderer; + $view_renderer->preDispatch(); + + foreach (Class_Sitotheque::getSitesCategorie(8) as $website) + $melted_websites [] = new Intonation_Library_View_Wrapper_Website($smeltery->meltWebsite($website), $view_renderer->view); + + $helper = (new Intonation_Library_AjaxPaginatedListHelper) + ->setCollection(new Storm_Collection($melted_websites)) + ->setRendering('cardifyHorizontal'); + + $id = $helper->getId(); + + $this->dispatch('/opac/index/ajax-paginated-list/id/' . $id . '/page/1/render/ajax/id_profil/19'); + $this->assertContains('input_38bcd646a69f4da7fce8921d4cf762ad', $this->_response->getBody()); + } } \ No newline at end of file