diff --git a/VERSIONS_WIP/169813 b/VERSIONS_WIP/169813 new file mode 100644 index 0000000000000000000000000000000000000000..e56cf9594956f2c2bc8066a280753f799e70983d --- /dev/null +++ b/VERSIONS_WIP/169813 @@ -0,0 +1 @@ + - fonctionnalité #169813 : Thème MyBibApp : amélioration du thème pour la nouvelle version de l'application mobile MyBibApp. \ No newline at end of file diff --git a/library/Class/Template.php b/library/Class/Template.php index 05fd69e4bc0f8c1f44bbf08c713a85b4fe92bb91..def11cfc9395011b8de8c1f3710cab538140163c 100644 --- a/library/Class/Template.php +++ b/library/Class/Template.php @@ -696,7 +696,7 @@ class Class_Template { } - protected function _getMapWrapper() { + protected function _getMapWrapper() : array { return []; } @@ -742,4 +742,4 @@ class Class_Template { public function getTemplateCssFileName() : string { return ''; } -} \ No newline at end of file +} diff --git a/library/ZendAfi/Controller/Action/Helper/ViewRenderer.php b/library/ZendAfi/Controller/Action/Helper/ViewRenderer.php index 4a3754e2ef4ba8d143e7f1893e4a9823c489d853..465c6187b7ef519a5e9feebbd132879c16fcbd7f 100644 --- a/library/ZendAfi/Controller/Action/Helper/ViewRenderer.php +++ b/library/ZendAfi/Controller/Action/Helper/ViewRenderer.php @@ -171,4 +171,10 @@ class ZendAfi_Controller_Action_Helper_ViewRenderer extends Zend_Controller_Acti $this->getResponse()->setBody(json_encode($result)); } } + + + public function initializeHelperPaths() : self { + $this->_initializeHelperPaths(); + return $this; + } } diff --git a/library/ZendAfi/View/Helper/BaseHelper.php b/library/ZendAfi/View/Helper/BaseHelper.php index 7d3a53adffc16336ccc64111828196d5bcb9136c..66998522554a5f2e1db07f057af21c0992dc4b72 100644 --- a/library/ZendAfi/View/Helper/BaseHelper.php +++ b/library/ZendAfi/View/Helper/BaseHelper.php @@ -98,7 +98,7 @@ class ZendAfi_View_Helper_BaseHelper extends Zend_View_Helper_HtmlElement { } - protected function _escapeJsAttrib($value) { + protected function _escapeJsAttrib(string $value) : string { return str_replace(['\'', '"'], '\\\'', $value); } @@ -111,4 +111,4 @@ class ZendAfi_View_Helper_BaseHelper extends Zend_View_Helper_HtmlElement { protected function _templateIco(string $key, string $category = '', array $attribs = []) : string { return $this->view->templateIco($key, $category, $attribs); } -} \ No newline at end of file +} diff --git a/library/ZendAfi/View/Helper/Button.php b/library/ZendAfi/View/Helper/Button.php index 0b65f070d5fc317aa0d95f5f9a35aaeff5ec2842..d8589baaba677b3c70086be60d075d5e5a938893 100644 --- a/library/ZendAfi/View/Helper/Button.php +++ b/library/ZendAfi/View/Helper/Button.php @@ -55,10 +55,11 @@ class ZendAfi_View_Helper_Button extends ZendAfi_View_Helper_BaseHelper { if ($this->view->isPopup() && ! $button->getDisablePopup()) return $this; - if ($button->getUrl()) { + + if (($url = $button->getUrl()) && is_string($url)) $button->setAttrib('onclick', sprintf('window.location.href = \'%s\';', $this->_escapeJsAttrib($button->getUrl()))); - } + return $this; } diff --git a/library/ZendAfi/View/Helper/Template/Jumbotron.php b/library/ZendAfi/View/Helper/Template/Jumbotron.php index 15748846d23a8211172c76a7ee149037e158c888..90b0a84ea3bcb620aac001adeefc328c1d9fc3a1 100644 --- a/library/ZendAfi/View/Helper/Template/Jumbotron.php +++ b/library/ZendAfi/View/Helper/Template/Jumbotron.php @@ -29,15 +29,18 @@ class ZendAfi_View_Helper_Template_Jumbotron extends ZendAfi_View_Helper_BaseHel $_current_url; + protected Closure $_nav_rendering; + + public function jumbotron($element) { $this->_element = $element; - if ( ! $this->_rich_content = $element->getRichContent()) + if ( ! $this->_rich_content = $this->getRichContent()) return ''; $this->_current_url = $this->view->url(); - $this->_sections = $this->_rich_content->getSections(); + $this->_sections = $this->getSections(); $content = $this->_renderContent(); @@ -48,6 +51,18 @@ class ZendAfi_View_Helper_Template_Jumbotron extends ZendAfi_View_Helper_BaseHel } + public function getRichContent() : ?Intonation_Library_View_Wrapper_RichContent_Abstract { + return $this->_rich_content ??= $this->_element->getRichContent(); + } + + + public function getSections() : array { + return $this->_sections ??= ($this->getRichContent() + ? $this->getRichContent()->getSections() + : []); + } + + protected function _renderHead() { $html = []; @@ -130,11 +145,11 @@ class ZendAfi_View_Helper_Template_Jumbotron extends ZendAfi_View_Helper_BaseHel } - protected function _nav() { - $html = array_map(function($item) - { - return $this->_renderNavItem($item); - }, + protected function _nav() : string { + if ($callback = $this->_nav_rendering ?? null) + return $callback($this->getSections()); + + $html = array_map(fn($item) => $this->_renderNavItem($item), $this->_sections); return $this->_tag('ul', @@ -143,8 +158,8 @@ class ZendAfi_View_Helper_Template_Jumbotron extends ZendAfi_View_Helper_BaseHel } - protected function _renderNavItem($item) { - $id = $item->getModel()->getId(); + protected function _renderNavItem(Intonation_Library_View_Wrapper_RichContent_Section $item) : string { + $id = $item->getModelId(); $active_class = $item->getActiveClass(); $classes = $item->getClass(); @@ -247,4 +262,10 @@ class ZendAfi_View_Helper_Template_Jumbotron extends ZendAfi_View_Helper_BaseHel ? '_with_one_pagination' : '_no_pagination'; } + + + public function setNavRendering(Closure $callback) : self { + $this->_nav_rendering = $callback; + return $this; + } } diff --git a/library/ZendAfi/View/Helper/Template/Opac.php b/library/ZendAfi/View/Helper/Template/Opac.php index 25b79bdb45c6506fc7907b7e5a341434c5f01128..c98bc3948d06674463270b67303559d816fd795b 100644 --- a/library/ZendAfi/View/Helper/Template/Opac.php +++ b/library/ZendAfi/View/Helper/Template/Opac.php @@ -170,12 +170,12 @@ class ZendAfi_View_Helper_Template_Opac extends ZendAfi_View_Helper_BaseHelper { if ($core_css = $this->_styles->coreCssUrl()) $head_scripts->addStyleSheet($core_css); - if ($css_patchs = $this->_styles->cssPatchsUrls()) - $head_scripts->addStyleSheets($css_patchs); - if ($intonation_css = $this->_styles->intonationCssUrl()) $head_scripts->addStyleSheet($intonation_css); + if ($css_patchs = $this->_styles->cssPatchsUrls()) + $head_scripts->addStyleSheets($css_patchs); + if ($template_css = $this->_styles->templateCssUrl()) $head_scripts->addStyleSheet($template_css); diff --git a/library/ZendAfi/View/Helper/Template/RenderingDescription.php b/library/ZendAfi/View/Helper/Template/RenderingDescription.php index 3b788fbabafe70ec8b75c4ccd75f7d868589e8d3..32821475511c9f057c7bea8848884624b27c07d6 100644 --- a/library/ZendAfi/View/Helper/Template/RenderingDescription.php +++ b/library/ZendAfi/View/Helper/Template/RenderingDescription.php @@ -22,6 +22,9 @@ class ZendAfi_View_Helper_Template_RenderingDescription extends ZendAfi_View_Helper_Template_CardHelper { + protected string $_footer = ''; + + public function renderingDescription($element, $img = '') { $element_class = get_class($element); $content = [$element->getContentForJSSearch()]; @@ -44,9 +47,26 @@ class ZendAfi_View_Helper_Template_RenderingDescription extends ZendAfi_View_Hel if (!empty($content)) $html [] = $this->_tag('div', implode($content), - ['class' => 'card-body card_body card_body_' . $element_class]); + ['class' => 'card_body card_body_' . $element_class]); + + $html = $this->_addFooter($element, $html); + + return $this->_tag('div', + $element->getAnchor() + . $img + . implode($html), + ['class' => 'card card_template card_' . $element_class]); + } + + + protected function _addFooter($element, array $html) : array { + if ( $this->_footer) { + $html [] = $this->_footer; + return $html; + } $links = []; + if ($link = $element->getMainLink()) $links [] = $this->view->tagAction($link); @@ -55,17 +75,23 @@ class ZendAfi_View_Helper_Template_RenderingDescription extends ZendAfi_View_Hel $hide_text_button_class = ( 2 >= count($links)) ? '' - : 'button_text_d_none'; + : 'button_text_d_none '; - if (!empty($links)) - $html [] = $this->_tag('div', - implode($links), - ['class' => 'card-footer d-flex flex-row justify-content-between ' . $hide_text_button_class . ' card_footer card_footer_' . $element_class]); + $html [] = $this->footerHtml($links, $hide_text_button_class, $element); + return $html; + } - return $this->_tag('div', - $element->getAnchor() - . $img - . implode($html), - ['class' => 'card card_template card_' . $element_class]); + + public function footerHtml(array $links, string $dnone_text, $element) : string { + return $links + ? $this->_div(['class' => 'card_footer ' . $dnone_text . 'card_footer_' . get_class($element)], + implode($links)) + : ''; + } + + + public function setFooter(string $footer) : self { + $this->_footer = $footer; + return $this; } } diff --git a/library/templates/Chili/Template.php b/library/templates/Chili/Template.php index 124ea215483893949f0c60a691a71c8bec6b2891..866a89949f929a78523819d462f740ff4c828346 100644 --- a/library/templates/Chili/Template.php +++ b/library/templates/Chili/Template.php @@ -105,7 +105,7 @@ class Chili_Template extends Intonation_Template { } - protected function _getMapWrapper() { + protected function _getMapWrapper() : array { return array_merge(parent::_getMapWrapper(), ['Class_Notice' => 'Chili_Library_Wrapper_Record', diff --git a/library/templates/Chili/View/Jumbotron/Record.php b/library/templates/Chili/View/Jumbotron/Record.php index 2558ddb1c4770e1975ab934a33c0329e3de18d3a..cffaad62b0b10593f9226ae750c1063457a17902 100644 --- a/library/templates/Chili/View/Jumbotron/Record.php +++ b/library/templates/Chili/View/Jumbotron/Record.php @@ -22,7 +22,8 @@ class Chili_View_Jumbotron_Record extends Intonation_View_Jumbotron_Record { public function jumbotron_Record($record) { - $this->setShowCurrentSection((new Intonation_Library_View_Wrapper_Record_RichContent_Items($this->_getRichContent($record)->getWrapperInstance())) + $wrapper = $this->_getWrappedInstance()->setView($this->view)->setModel($record); + $this->setShowCurrentSection((new Intonation_Library_View_Wrapper_Record_RichContent_Items($this->_getRichContent($wrapper)->getWrapperInstance())) ->getClass()); return $this->_core($record); } diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index 93c0461e0484508931cf5a513759460036801650..aae3451250a3aaae457cd78d744880c37fbe6bdd 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -97,10 +97,9 @@ div:hover > .img_as_background { .card-link img:first-child, i:first-child, -i:first-child:last-child, .widget.rech_simple .dropdown-menu i:first-child, .widget.rech_simple .criteres_recherche i:first-child, -.card-link + .card-link, +.card-link:not(:last-child), .card-footer .card-link + label, .badge, p > i { @@ -108,6 +107,7 @@ p > i { vertical-align: middle; } +i:only-child, i:last-child { margin-right: 0; } @@ -334,9 +334,10 @@ pre { } [class*="carousel-control"] { - height: 30%; - margin: auto 0; - width: auto; + position: absolute; + top: 50%; + bottom: 50%; + transform: translate(-50%, -50%); } .carousel-indicators li { @@ -680,9 +681,9 @@ dl.row { margin: 0; } -.card_grid > .card, -.card-deck > .card, -.card-columns > .card { +.card_grid > .card .badge_group, +.card-deck > .card .badge_group, +.card-columns > .card .badge_group { overflow: hidden; } @@ -1170,3 +1171,7 @@ button.view_more_record_actions, .multi_input_table { width: 100%; } + +.card_description p { + margin-bottom: 0; +} diff --git a/library/templates/Intonation/Library/Selection.php b/library/templates/Intonation/Library/Selection.php index 11171d03cc0af423687cad7fb6c984fc0e4bface..df6184058e40c88a0cbb4d5b807bb839f6caba52 100644 --- a/library/templates/Intonation/Library/Selection.php +++ b/library/templates/Intonation/Library/Selection.php @@ -90,7 +90,8 @@ class Intonation_Library_Selection { public function getAction() : Intonation_Library_Link { $url = $this->getView()->url($this->_getUrlForContext(), null, true); - $js = sprintf("event.preventDefault(); event.stopPropagation(); var anchor = $(this); $.ajax({type: 'GET', url: '%s', success: function(data) {anchor.replaceWith(data.anchor);}});", + $js = + sprintf("event.preventDefault(); event.stopPropagation(); var url = $(this).attr('href'); var anchors = $('a[href=\'' + url + '\']'); $.ajax({type: 'GET', url: '%s', success: function(data) {anchors.replaceWith(data.anchor);}});", $url); $popup = Class_Users::getIdentity() ? false : 'true'; diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 6b71546c97818c7533e7ddc0e0efe864788766a6..dd1f4e4b9c6f3f4ed1598801761ba52d8f92ccc7 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -244,7 +244,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'a class record_serie' => 'badge-white no_truncate', 'div class rich_content_actions' => 'col-12 px-0 mt-3 record_summary', - 'div class rich_content_row_actions' => 'col col-lg-12 pt-1 mt-1 mr-1 pr-1 w-s_nowrap', + 'div class rich_content_row_actions' => 'col col-lg-12 pt-1 mt-1 mr-1 pr-1 w-s_nowrap text-center', 'div class cardify_horizontal_img' => 'col-12 col-md-4 col-lg-3 px-0 pl-md-0 pr-md-3', 'div class cardify_horizontal_content' => 'col-12 col-md-8 col-lg-6 px-0 py-3 py-md-0', 'div class cardify_horizontal_actions' => 'col-12 col-md-12 col-lg-3 px-0 pl-lg-3 pr-lg-0', @@ -352,7 +352,10 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'div class ina_interviews' => 'card bg-dark text-white shadow', 'span class record_not_available' => 'badge-danger', 'span class record_available' => 'badge-success', - 'span class availability_no_answers' => 'badge-info' + 'span class availability_no_answers' => 'badge-info', + 'div class card_footer' => 'card-footer row mx-1 px-3 justify-content-between', + 'div class extra_actions' => 'col-12 row justify-content-around mx-0 px-0 mb-2', + 'div class card_body' => 'card-body pb-1', ], 'icons_map_doc_types' => [], @@ -496,6 +499,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { protected function _getDefaultSettings() { + $this->_default_settings['css_patchs'] = $this->_template->getCssPatchsFiles(); $this->_default_settings['icons_map_doc_types'] = [Class_TypeDoc::getLabelFor(Class_TypeDoc::UNKNOWN) => 'class far fa-question-circle', Class_TypeDoc::getLabelFor(Class_TypeDoc::LIVRE) => 'class fas fa-book', diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php index bb8412d754e4e14d5b16e63dba1e1a739663b726..a3c0e407a6fae1cd616ff20d10eef392b8d46edf 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -251,6 +251,11 @@ abstract class Intonation_Library_View_Wrapper_Abstract { } + public function renderExtraActions() : string { + return ''; + } + + /** @return string */ abstract public function getMainTitle(); diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index 2261cc392464faa85f54510c795dc053c2903ea1..6d39c821e310ce996aabc8e1bcad7e8022d2278f 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -524,7 +524,7 @@ class Intonation_Library_View_Wrapper_Record if ($this->getSelectableAction()) $actions [] = $this->_view->tagSelectRecord($this->_model); - $actions [] = $this->_moreActions(); + $actions = $this->_moreActions($actions); return $actions; } @@ -546,10 +546,7 @@ class Intonation_Library_View_Wrapper_Record return $actions; } - if ( ! $items = $this->_model->getExemplaires()) - return $actions; - - if ( ! $first_item = reset($items)) + if ( ! $first_item = Class_Exemplaire::findFirstBy(['id_notice' => $this->_model->getId()])) return $actions; if ($url = $first_item->getUrl()) { @@ -595,14 +592,10 @@ class Intonation_Library_View_Wrapper_Record } - protected function _moreActions() { - $actions = array_merge([$this->_addToSelectionAction()], - $this->_socialNetworksActions(), - [$this->_printAction()], - $this->_thumbnailActions(), - [$this->_addNumericResourceAction()]); + protected function _moreActions(array $actions) : array { + $more_actions = $this->_moreActionsAsArray($actions); - return (new Intonation_Library_Link) + $link = (new Intonation_Library_Link) ->setImage($this->getIco('more', 'utils')) ->setText($this->_('Plus')) ->setScreenReaderText($this->_('Voir plus d\'actions pour le document %s', @@ -610,13 +603,26 @@ class Intonation_Library_View_Wrapper_Record ->setTitle($this->_('Voir plus d\'actions pour le document %s', $this->_model->getTitrePrincipal(' '))) ->setClass('view_more_record_actions') - ->setCallback(function($button) use ($actions) - { - $button->setCallback(null); - return $this->_view->dropdown($this->_view->actionsInGrid($actions), - $button, - 'dropleft dropup'); - }); + ->setCallback(function($button) use ($more_actions) + { + $button->setCallback(null); + return $this->_view->dropdown($this->_view->actionsInGrid($more_actions), + $button, + 'dropleft dropup'); + }); + + $actions [] = $link; + return $actions; + } + + + protected function _moreActionsAsArray(array $actions) : array { + return + array_merge([$this->_addToSelectionAction()], + $this->_socialNetworksActions(), + [$this->_printAction()], + $this->_thumbnailActions(), + [$this->_addNumericResourceAction()]); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent.php b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent.php index 41367bdaf10a9cd554a20511fef245fa7a57a43d..d4218bb8a45bf10249103e896e71b35c7f0f80b3 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent.php @@ -33,12 +33,8 @@ class Intonation_Library_View_Wrapper_Record_RichContent protected $_navigation; public function getNavigation() { - if ($this->_navigation) - return $this->_navigation; - - return $this->_navigation = (new Intonation_Library_View_Wrapper_Record_RichContent_Navigation) - ->setModel($this->_model) - ->setView($this->_view); + return $this->_navigation ??= + (new Intonation_Library_View_Wrapper_Record_RichContent_Navigation($this->_model, $this->_view)); } @@ -51,15 +47,27 @@ class Intonation_Library_View_Wrapper_Record_RichContent } - public function getRowActions() { - $actions = array_merge(['position_in_seach_result' => $this->getNavigation()->getPosition(), - 'back_to_search_result' => $this->getNavigation()->getBackUrl()], - $this->getWrapperInstance()->getActions()); + public function getRowActions() : string { + $actions = $this->_getRowActionsArray(); return $this->_view->actionsInGrid($actions, ['class' => 'rich_content_row_actions']); } + protected function _getRowActionsArray() : array { + return + array_merge($this->_defaultsRowActionsArray(), + $this->getWrapperInstance()->getActions()); + } + + + protected function _defaultsRowActionsArray() : array { + return + ['position_in_seach_result' => $this->getNavigation()->getPosition(), + 'back_to_search_result' => $this->getNavigation()->getBackUrl()]; + } + + protected function _getSectionsMap() { return [static::HOME => Intonation_Library_View_Wrapper_Record_RichContent_Home::class, static::ITEMS => Intonation_Library_View_Wrapper_Record_RichContent_Items::class, diff --git a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Home.php b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Home.php index 015102e91cb0b14cbb3253c047ae508368b299c9..054996b172516dad7ae80b94b635903409652d03 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Home.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Home.php @@ -20,7 +20,8 @@ */ -class Intonation_Library_View_Wrapper_Record_RichContent_Home extends Intonation_Library_View_Wrapper_Record_RichContent_Section { +class Intonation_Library_View_Wrapper_Record_RichContent_Home + extends Intonation_Library_View_Wrapper_Record_RichContent_Section { public function getTitle() { return $this->_('Tout'); diff --git a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Navigation.php b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Navigation.php index 6a2195b7d9361595229f8d0b60eb45b96c220a9b..f23afb76937b3785c742b0f1dab6baca3115e4e0 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Navigation.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Navigation.php @@ -29,6 +29,12 @@ class Intonation_Library_View_Wrapper_Record_RichContent_Navigation { $_navigation; + public function __construct($record, Zend_View $view) { + $this->_view = $view; + $this->_model = $record; + } + + public function setView($view) { $this->_view = $view; return $this; @@ -103,9 +109,9 @@ class Intonation_Library_View_Wrapper_Record_RichContent_Navigation { } - public function getBackUrl() { + public function getBackUrl() : ?Intonation_Library_Link { if (! $this->_isVisible()) - return ''; + return null; $link = (new Intonation_Library_Link) ->setUrl($this->_getNavigation()->getBackToListUrl()) diff --git a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Section.php b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Section.php index bd1cda9a46c2d3b36353301f9e8398f701bdb2c8..e36a5497157b31ad9abf7b4698a997ea6b17eb18 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Section.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Section.php @@ -20,5 +20,6 @@ */ -abstract class Intonation_Library_View_Wrapper_Record_RichContent_Section extends Intonation_Library_View_Wrapper_RichContent_Section { +abstract class Intonation_Library_View_Wrapper_Record_RichContent_Section + extends Intonation_Library_View_Wrapper_RichContent_Section { } diff --git a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php index 26ea74de537b89f43f54da48175f4e9affb08a18..8f92144ee10d0dc8fb3388100a0853b803f40cdd 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php +++ b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php @@ -36,9 +36,7 @@ class Intonation_Library_View_Wrapper_ReviewsByRecord extends Intonation_Library if (!$model) return $this; - $this->_record = (new Intonation_Library_View_Wrapper_Record) - ->setView($this->_view) - ->setModel($model->getRecord()); + $this->_record = Class_Template::current()->newWrapper($model->getRecord(), $this->_view); $this->_reviews = []; foreach ($model->getReviews() as $review) diff --git a/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php index 2d1c294947d3e96dede5201e7d750a4d0ae9b786..81a9735dd52cdcebed195efe2e0f92c993247638 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php @@ -29,6 +29,7 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Abstract { protected $_view, $_model, + $_wrapper, $_sections; @@ -52,6 +53,12 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Abstract { } + public function setWrapper(Intonation_Library_View_Wrapper_Abstract $wrapper) : self { + $this->_wrapper = $wrapper; + return $this; + } + + public function getModel() { return $this->_model; } @@ -86,7 +93,10 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Abstract { } - public function getWrapperInstance() { + public function getWrapperInstance() : Intonation_Library_View_Wrapper_Abstract { + if ( $this->_wrapper) + return $this->_wrapper; + $wrapper_class = $this->_getWrapper() ? $this->_getWrapper() : Intonation_Library_View_Wrapper_Null::class; diff --git a/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php b/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php index 8ac105c32f565a1691b5a1171a61fc17d31a794a..e831bc4c71f9f96e6f04fa22d8b62731a4cce4ac 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php +++ b/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php @@ -227,6 +227,23 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section { } + public function getModelId() : string { + return $this->_model ? (string) $this->_model->getId() : ''; + } + + + public function toLink() : Intonation_Library_Link { + return (new Intonation_Library_Link) + ->setElement('button') + ->setText($this->getDBTitle()) + ->setScreenReaderText($this->getDBNavTitle()) + ->setImage($this->_view->renderIcon($this->getDBNavIco())) + ->setClass($this->getClass()) + ->setUrl($this->_view->url($this->getNavUrl())) + ->setTitle($this->getDBNavTitle()); + } + + abstract public function getTitle(); abstract public function getContent(); abstract public function getClass(); diff --git a/library/templates/Intonation/Library/View/Wrapper/Work/RichContent.php b/library/templates/Intonation/Library/View/Wrapper/Work/RichContent.php index 8d1c25d8634b977b4fc11666145c8d90b351fdfb..5cf83152761a75bd4e2c77fbf14a803bd87426a5 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Work/RichContent.php +++ b/library/templates/Intonation/Library/View/Wrapper/Work/RichContent.php @@ -45,9 +45,9 @@ class Intonation_Library_View_Wrapper_Work_RichContent if ($this->_navigation) return $this->_navigation; - return $this->_navigation = (new Intonation_Library_View_Wrapper_Work_RichContent_Navigation) - ->setModel($this->_model) - ->setView($this->_view); + return $this->_navigation = + new Intonation_Library_View_Wrapper_Work_RichContent_Navigation($this->_model, + $this->_view); } diff --git a/library/templates/Intonation/Template.php b/library/templates/Intonation/Template.php index 047c1e40fa929c9f15c4820574565d2f93a9747b..8db7209c4a76c3a0bb6b644a05e348b88f971286 100644 --- a/library/templates/Intonation/Template.php +++ b/library/templates/Intonation/Template.php @@ -470,8 +470,8 @@ class Intonation_Template extends Class_Template { } - protected function _getMapWrapper() { - return ['Class_Notice' => Intonation_Library_View_Wrapper_Record::class, - 'Class_Bib' => Intonation_Library_View_Wrapper_Library::class]; + protected function _getMapWrapper() : array { + return [Class_Notice::class => Intonation_Library_View_Wrapper_Record::class, + Class_Bib::class => Intonation_Library_View_Wrapper_Library::class]; } } diff --git a/library/templates/Intonation/View/Jumbotron/Abstract.php b/library/templates/Intonation/View/Jumbotron/Abstract.php index 902dfdce7eec4f0572144a8e6420f21f2d98ff10..bb725d3233aca480562fe4eed9e94b763bda6040 100644 --- a/library/templates/Intonation/View/Jumbotron/Abstract.php +++ b/library/templates/Intonation/View/Jumbotron/Abstract.php @@ -34,7 +34,7 @@ abstract class Intonation_View_Jumbotron_Abstract extends ZendAfi_View_Helper_Ba ->setView($this->view) ->setModel($model); - $rich_content = $this->_getRichContent($model); + $rich_content = $this->_getRichContent($wrapped); $this->_hookOn($rich_content); $this->_showSections($rich_content->getSections()); @@ -47,10 +47,11 @@ abstract class Intonation_View_Jumbotron_Abstract extends ZendAfi_View_Helper_Ba } - protected function _getRichContent($model) { + protected function _getRichContent($wrapper) { return $this->_getRichContentInstance() + ->setWrapper($wrapper) ->setView($this->view) - ->setModel($model); + ->setModel($wrapper->getModel()); } diff --git a/library/templates/MyBibApp/Assets/css/mybibapp.css b/library/templates/MyBibApp/Assets/css/mybibapp.css index 6336614956a27b557f52aa3741cc4e2f6baac8cc..417e9dfbbb5c0c2126302fbb51b403f936517004 100644 --- a/library/templates/MyBibApp/Assets/css/mybibapp.css +++ b/library/templates/MyBibApp/Assets/css/mybibapp.css @@ -119,3 +119,20 @@ a.card-link { padding: 0; margin: 0; } + +.masonry-brick { + overflow: visible; +} + +.sticky_top_scroll { + position: fixed; + top: 0; + z-index: 1; + background-color: var(--mba-widget-background); + max-height: 50%; + max-width: 90%; + overflow: scroll; + scroll-behavior: smooth; + border: 5px solid var(--mba-button-background) !important; + padding: 5px 0 0 5px !important; +} diff --git a/library/templates/MyBibApp/Assets/js/sticky_top/sticky_top.js b/library/templates/MyBibApp/Assets/js/sticky_top/sticky_top.js new file mode 100644 index 0000000000000000000000000000000000000000..9ad59b46a31a0304f7d8922974925e045ca7c5b3 --- /dev/null +++ b/library/templates/MyBibApp/Assets/js/sticky_top/sticky_top.js @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2012-2023, 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 + */ + + +(function ( $ ) { + $.fn.sticky_top = function () { + var sticky_div = $('.sticky_top > :first-child'); + if ( 0 == $(sticky_div).length) + return; + + $(window).on('scroll', function() { + var + sticky_rect = sticky_div[0].getBoundingClientRect(), + sticky_parent_rect = sticky_div.parent()[0].getBoundingClientRect(), + sticky_class = 'sticky_top_scroll'; + + if ( 0 < (sticky_parent_rect.top)) + return sticky_div.removeClass(sticky_class); + + if ( 0 >= sticky_rect.top ) + return sticky_div.addClass(sticky_class); + + sticky_div.removeClass(sticky_class); + }); + } +} (jQuery)); diff --git a/library/templates/MyBibApp/Library/ProfilePatcher.php b/library/templates/MyBibApp/Library/ProfilePatcher.php index 29e360f9a15d56b097428f11484397e0e89e794e..e702a716bdbc1f89341e969d9c61b3d3537cdb7e 100644 --- a/library/templates/MyBibApp/Library/ProfilePatcher.php +++ b/library/templates/MyBibApp/Library/ProfilePatcher.php @@ -22,20 +22,43 @@ class MyBibApp_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher { + protected string $_novelty_domain_id = ''; + + protected function _upgradeProfile() { parent::_upgradeProfile(); $this->_profile ->setLibelle($this->_('Accueil MyBibApp')); + return $this->_addAgendaPage(); + } + + + protected function _upgradeActions() { + parent::_upgradeActions(); + (new Class_Profil_Preferences()) ->setModulePref($this->_profile, (new Class_Profil_ModuleDefinition('recherche', 'resultat', 'simple')), - ['boite' => ['px-3']]); + ['liste_format' => Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR, + 'boite' => ['px-3', 'limit_badges_5']]); - return $this->_addAgendaPage(); + foreach ( array_filter(array_keys(Class_TypeDoc::getMultiOptions())) as $doc_type_id) + (new Class_Profil_Preferences()) + ->setModulePref($this->_profile, + (new Class_Profil_ModuleDefinition('recherche', + 'viewnotice', + $doc_type_id)), + ['boite' => ['px-3', 'limit_badges_5']]); + + (new Class_Profil_ItemsSettings($this->_profile)) + ->setSetting('all_items_map', '') + ->save(); + + return $this; } @@ -46,6 +69,9 @@ class MyBibApp_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher ->addWidget(Intonation_Library_Widget_Carousel_Agenda_Definition::CODE, Class_Profil::DIV_MAIN, array_merge(['titre' => $this->_('Agenda'), + 'size' => 200, + 'layout' => Intonation_Library_Widget_Carousel_Definition::GRID, + 'rendering' => Intonation_Library_Widget_Carousel_Definition::CARD, 'boite' => ['mba_widget', 'no_border', 'no_border_radius', 'no_shadow']])); return $this; @@ -75,94 +101,56 @@ class MyBibApp_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher protected function _upgradeWidgets() { $this + ->_createNoveltiesDomain() ->removeWidgets() - ->_addWidget(Intonation_Library_Widget_Breadcrumb_Definition::CODE, + ->_addWidget(Intonation_Library_Widget_Image_Definition::CODE, Class_Profil::DIV_BANNIERE, - ['titre' => ' ', - 'boite' => ['mba_widget', 'px-3', 'pt-3', 'no_border', 'no_border_radius', 'no_shadow'], - 'root' => $this->_profile_id, - 'show_profile' => 4, - $this->_template->withNameSpace('width_xsmall') => 12, - $this->_template->withNameSpace('show_header') => 0, - $this->_template->withNameSpace('show_content') => 0, - $this->_template->withNameSpace('show_footer') => 0]) - - ->_addWidget(Intonation_Library_Widget_Login_Definition::CODE, - Class_Profil::DIV_BANNIERE, - ['titre' => ' ', + ['titre' => '', + 'image' => '/template/MyBibApp/Assets/images/logo.png', + 'image_alt' => $this->_('Logo de la bibliothèque'), + 'link' => '/', + 'link_title' => $this->_('Accueil'), 'boite' => ['mba_widget', 'px-3', 'no_border', 'no_border_radius', 'no_shadow'], - 'titre_connecte' => '', - 'message_connecte' => '', - 'identifiant' => '', - 'mot_de_passe' => '', - 'identifiant_exemple' => $this->_('N° de carte / email'), - 'mot_de_passe_exemple' => $this->_('Mot de passe'), - 'lien_connexion' => $this->_('Se connecter'), - 'lien_mot_de_passe_oublie' => $this->_('Mot de passe oublié'), - 'lien_deconnection' => '', - 'lien_compte' => '', - 'lien_creer_compte' => '', - $this->_template->withNameSpace('form_style') => 'inline', $this->_template->withNameSpace('width_xsmall') => 12, $this->_template->withNameSpace('show_header') => 0, $this->_template->withNameSpace('show_content') => 0, $this->_template->withNameSpace('show_footer') => 0]) - ->_addWidget(Intonation_Library_Widget_Search_Definition::CODE, - Class_Profil::DIV_BANNIERE, - ['titre' => $this->_('Le catalogue'), - 'boite' => ['mba_widget', 'no_border', 'no_border_radius', 'no_shadow'], - 'search_button' => $this->_('Rechercher'), - 'placeholder' => $this->_('Titre, auteur…'), - 'type_doc' => '', - $this->_template->withNameSpace('form_style') => 'inline', - $this->_template->withNameSpace('width_xsmall') => 12, - $this->_template->withNameSpace('show_header') => 1, - $this->_template->withNameSpace('show_content') => 1, - $this->_template->withNameSpace('show_footer') => 0]) - - ->_addWidget(Intonation_Library_Widget_Carousel_Library_Definition::CODE, + ->_addWidget(Intonation_Library_Widget_Carousel_Record_Definition::CODE, Class_Profil::DIV_MAIN, - ['titre' => $this->_('Horaires'), + ['titre' => $this->_('Nouveautés'), 'boite' => ['mba_widget', 'no_border', 'no_border_radius', 'no_shadow'], - 'rendering' => 'card-horizontal', - 'layout' => 'list', - 'osm_map' => 0, + 'rendering' => Intonation_Library_Widget_Carousel_Definition::CARD, + 'layout' => Intonation_Library_Widget_Carousel_Definition::MULTIPLE_CAROUSEL_PLUS, + 'order' => Class_CriteresRecherche_Abstract::SORT_NOVELTY_DESC, + 'id_catalogue' => $this->_novelty_domain_id, + 'size' => 15, + 'link_to_all' => 1, $this->_template->withNameSpace('width_xsmall') => 12, $this->_template->withNameSpace('show_header') => 1, $this->_template->withNameSpace('show_content') => 1, - $this->_template->withNameSpace('show_footer') => 0]) + $this->_template->withNameSpace('show_footer') => 1]) ->_addWidget(Intonation_Library_Widget_Carousel_Review_Definition::CODE, Class_Profil::DIV_MAIN, ['titre' => $this->_('Les dernières critiques'), 'boite' => ['mba_widget', 'no_border', 'no_border_radius', 'no_shadow'], - 'rendering' => 'card', - 'layout' => 'wall', + 'rendering' => Intonation_Library_Widget_Carousel_Definition::CARD, + 'layout' => Intonation_Library_Widget_Carousel_Definition::MULTIPLE_CAROUSEL_PLUS, 'abon_ou_bib' => 'all', 'order' => 'review_date', - 'size' => 3, + 'size' => 15, 'link_to_all' => 1, + 'all_layout' => Intonation_Library_Widget_Carousel_Definition::LISTING_WITH_OPTIONS, $this->_template->withNameSpace('width_xsmall') => 12, $this->_template->withNameSpace('show_header') => 1, $this->_template->withNameSpace('show_content') => 1, $this->_template->withNameSpace('show_footer') => 1]) - ->_addWidget(Intonation_Library_Widget_Credits_Definition::CODE, - Class_Profil::DIV_FOOTER, - ['titre' => '', - 'boite' => ['mba_widget', 'px-3', 'no_border', 'no_border_radius', 'no_shadow', 'align-items-center'], - $this->_template->withNameSpace('width_xsmall') => 12, - $this->_template->withNameSpace('show_header') => 0, - $this->_template->withNameSpace('show_content') => 0, - $this->_template->withNameSpace('show_footer') => 0]) - ->_addScrollTopWidget() - ->_addScrollDownWidget() - ->_addAdminWidget() - ->_addAccessibilityWidget() - ->_addNotificationWidget(); + ->_addAdminWidget() + ->_addNotificationWidget(); return $this; } @@ -181,4 +169,23 @@ class MyBibApp_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher $this->_template->withNameSpace('show_content') => 1, $this->_template->withNameSpace('show_footer') => 0]; } -} \ No newline at end of file + + + protected function _createNoveltiesDomain() : self { + $label = $this->_('Nouveautés %s', $this->_template->getTitle()); + + if ( $domain = Class_Catalogue::findFirstBy(['libelle' => $label])) { + $this->_novelty_domain_id = $domain->getId(); + return $this; + } + + $domain = Class_Catalogue::newInstance() + ->setLibelle($label) + ->setNouveaute(1); + $domain->save(); + + $this->_novelty_domain_id = $domain->getId(); + + return $this; + } +} diff --git a/library/templates/MyBibApp/Library/Settings.php b/library/templates/MyBibApp/Library/Settings.php index 245de248ac312ea2f75cfe3a2be46795ce23edd8..4471678aa3448a109698d1b650c03cef34f189a4 100644 --- a/library/templates/MyBibApp/Library/Settings.php +++ b/library/templates/MyBibApp/Library/Settings.php @@ -31,6 +31,15 @@ class MyBibApp_Library_Settings extends Intonation_Library_Settings { $custom_css_classes [] = 'mba_logo_background'; $settings[$this->_template->withNameSpace('custom_css_class')] = $custom_css_classes; + + $hydrating_mapping = $settings[$this->_template->withNameSpace('hydrating_mapping')]; + $hydrating_mapping['div class card_action'] = 'col-12 p-0 mx-1 my-1'; + $hydrating_mapping['button class tab_to_active_dropdown_button'] = 'btn-primary text-left dropdown-toggle mx-0 w-100 btn btn-lg'; + $hydrating_mapping['button class tab_to_dropdown_button'] = 'btn btn-secondary text-left my-1 w-100'; + $hydrating_mapping['div class search_facets_col'] = 'sticky_top col-12 col-md-3 order-5'; + + $settings[$this->_template->withNameSpace('hydrating_mapping')] = $hydrating_mapping; + return $settings; } } diff --git a/library/templates/MyBibApp/Library/Wrapper/Record.php b/library/templates/MyBibApp/Library/Wrapper/Record.php new file mode 100644 index 0000000000000000000000000000000000000000..d57250181d60946c903ab63b76ec4b89c22a8c5c --- /dev/null +++ b/library/templates/MyBibApp/Library/Wrapper/Record.php @@ -0,0 +1,70 @@ +<?php +/** + * Copyright (c) 2012-2023, 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 MyBibApp_Library_Wrapper_Record extends Intonation_Library_View_Wrapper_Record { + + public function getActions() : array { + $actions = $this->_getNiceAction([]); + $actions = $this->_moreActions($actions); + + foreach($actions as $action) + $action->alwaysDisplayText(); + + return $actions; + } + + + protected function _getSelectionActions(array $actions) : array { + foreach((new Intonation_Library_UserPatcher) + ->getDefaultSelections() as $selection) + $actions [] = $this->_getActionsFor($selection); + + return $actions; + } + + + protected function _getActionsFor(Intonation_Library_Selection $selection) : Intonation_Library_Link { + return $selection + ->setView($this->_view) + ->setRecord($this->_model) + ->getAction(); + } + + + protected function _moreActionsAsArray(array $actions) : array { + $parent_actions = parent::_moreActionsAsArray($actions); + + $actions = $this->_getSelectionActions($actions); + if ($this->getSelectableAction()) + $actions [] = $this->_view->tagSelectRecord($this->_model); + + if ($main_link = $this->getMainLink()) + array_unshift($actions, $this->_view->tagAction($main_link)); + + return array_merge($actions, $parent_actions); + } + + + public function renderExtraActions() : string { + return implode(array_map(fn($action) => $this->_view->tagAction($action), $this->_getSelectionActions([]))); + } +} diff --git a/library/templates/MyBibApp/Library/Wrapper/Record/RichContent.php b/library/templates/MyBibApp/Library/Wrapper/Record/RichContent.php new file mode 100644 index 0000000000000000000000000000000000000000..3fd9df03b899b3be6b7d89be4a58c19226dd5eba --- /dev/null +++ b/library/templates/MyBibApp/Library/Wrapper/Record/RichContent.php @@ -0,0 +1,47 @@ +<?php +/** + * Copyright (c) 2012-2020, 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 MyBibApp_Library_Wrapper_Record_RichContent + extends Intonation_Library_View_Wrapper_Record_RichContent { + + + public function getNavigation() : Intonation_Library_View_Wrapper_Record_RichContent_Navigation { + return $this->_navigation ??= (new MyBibApp_Library_Wrapper_Record_RichContent_Navigation($this->_model, + $this->_view)); + } + + + public function getRowActions() : string { + $html = [$this->_view->grid($this->getWrapperInstance()->renderExtraActions(), [], ['class' => 'extra_actions'])]; + + $html [] = parent::getRowActions(); + return implode(array_filter($html)); + } + + + protected function _getRowActionsArray() : array { + $actions = parent::_defaultsRowActionsArray(); + $wrapper_actions = $this->getWrapperInstance()->getActions(); + array_shift($wrapper_actions); + return array_merge($actions, $wrapper_actions); + } +} diff --git a/library/templates/MyBibApp/Library/Wrapper/Record/RichContent/Navigation.php b/library/templates/MyBibApp/Library/Wrapper/Record/RichContent/Navigation.php new file mode 100644 index 0000000000000000000000000000000000000000..ef697d0b66d799f96279fb565c95d52e7f29b682 --- /dev/null +++ b/library/templates/MyBibApp/Library/Wrapper/Record/RichContent/Navigation.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 MyBibApp_Library_Wrapper_Record_RichContent_Navigation + extends Intonation_Library_View_Wrapper_Record_RichContent_Navigation { + + public function getBackUrl() : ?Intonation_Library_Link { + return ($back_button = parent::getBackUrl()) + ? ($back_button + ->setText($this->_('Retour à la recherche')) + ->alwaysDisplayText()) + : null; + } + + + protected function _isVisible() : bool { + return $this->_getNavigation() && $this->_getNavigation()->hasCriteria(); + } + + + protected function _getNavigation() { + if (!$this->_navigation) + $this->_navigation = $this->_view->notice_navigation; + + return $this->_navigation; + } +} diff --git a/library/templates/MyBibApp/Template.php b/library/templates/MyBibApp/Template.php index 5355e74f5b30d8154e7ba8f130286f7740fe7d47..b0c0a8f53bacbcd8a91e9b06dd38ab1960febc9a 100644 --- a/library/templates/MyBibApp/Template.php +++ b/library/templates/MyBibApp/Template.php @@ -59,4 +59,25 @@ class MyBibApp_Template extends Intonation_Template { ? 'mybibapp' : ''; } + + + protected function _getMapWrapper() : array { + return + array_merge(parent::_getMapWrapper(), + [Class_Notice::class => MyBibApp_Library_Wrapper_Record::class]); + } + + + public function addHelperPath($view) { + parent::addHelperPath($view); + $view->addHelperPath('templates/MyBibApp/View', 'MyBibApp_View'); + return $this; + } + + + public function getCarouselRenderer(string $layout) : string { + return (Intonation_Library_Widget_Carousel_Definition::MULTIPLE_CAROUSEL_PLUS == $layout) + ? Chili_View_MultipleCarousel::class + : ''; + } } diff --git a/library/templates/MyBibApp/View/Jumbotron.php b/library/templates/MyBibApp/View/Jumbotron.php new file mode 100644 index 0000000000000000000000000000000000000000..cd97087b5c0179ebb3356e2ced4906306727e335 --- /dev/null +++ b/library/templates/MyBibApp/View/Jumbotron.php @@ -0,0 +1,72 @@ +<?php +/** + * Copyright (c) 2012-2022, 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 MyBibApp_View_Jumbotron extends ZendAfi_View_Helper_BaseHelper { + protected ZendAfi_View_Helper_Template_Jumbotron $_helper; + + + public function jumbotron(Intonation_Library_View_Wrapper_Abstract $wrapper) : string { + $this->_helper = (new ZendAfi_View_Helper_Template_Jumbotron) + ->setView($this->view) + ->setNavRendering($this->_navToDropdown()); + + return $this->_helper->jumbotron($wrapper); + } + + + protected function _navToDropdown() : Closure { + return fn($sections) => $this->_renderNav($sections); + } + + + protected function _renderNav(array $sections) : string { + $collection = new Storm_Collection($sections); + $active = $collection->detect(fn($section) => $section->isActive()); + $others = + $collection->reject(fn($section) => $section->isActive()) + ->injectInto([], + function($html, $section) { + $html [] = $this->view->tagAction(($section + ->toLink() + ->setClass('tab_to_dropdown_button') + ->alwaysDisplayText())); + return $html; + }); + + return $this->view->dropdown(implode($others), + ($active + ->toLink() + ->setClass('tab_to_active_dropdown_button') + ->setUrl('') + ->alwaysDisplayText())); + } + + + protected function _tabsToHtml(array $tabs) : string { + return ''; + } + + + protected function _tabToHtml() : string { + return ''; + } +} diff --git a/library/templates/MyBibApp/View/Jumbotron/Record.php b/library/templates/MyBibApp/View/Jumbotron/Record.php new file mode 100644 index 0000000000000000000000000000000000000000..a3f82b3a6da2a5dacd40fe0c13acd67e2cd80821 --- /dev/null +++ b/library/templates/MyBibApp/View/Jumbotron/Record.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 MyBibApp_View_Jumbotron_Record extends Intonation_View_Jumbotron_Record { + protected function _getWrappedInstance() { + return new MyBibApp_Library_Wrapper_Record; + } + + + protected function _getRichContentInstance() { + return new MyBibApp_Library_Wrapper_Record_RichContent; + } +} diff --git a/library/templates/MyBibApp/View/RenderingDescription.php b/library/templates/MyBibApp/View/RenderingDescription.php new file mode 100644 index 0000000000000000000000000000000000000000..29c65af830ee303ac99374af3cc9f194e63fde38 --- /dev/null +++ b/library/templates/MyBibApp/View/RenderingDescription.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright (c) 2012-2022, 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 MyBibApp_View_RenderingDescription extends ZendAfi_View_Helper_BaseHelper { + + protected ZendAfi_View_Helper_Template_RenderingDescription $_helper; + + public function renderingDescription($element, string $img = '') : string { + $this->_helper = (new ZendAfi_View_Helper_Template_RenderingDescription)->setView($this->view); + + return $this->_helper + ->setFooter($this->_getFooter($element)) + ->renderingDescription($element, $img); + } + + + protected function _getFooter($element) : string { + $html = []; + + if ( $extra_actions = $element->renderExtraActions()) + $html [] = $this->_div(['class' => 'extra_actions'], + $extra_actions); + + foreach($element->getActions() as $action) + $html [] = $this->view->tagAction($action); + + return $this->_helper->footerHtml($html, '', $element); + } +} diff --git a/library/templates/MyBibApp/View/Search/Facets.php b/library/templates/MyBibApp/View/Search/Facets.php new file mode 100644 index 0000000000000000000000000000000000000000..fa55e7373294796054f18710b277368c8e123540 --- /dev/null +++ b/library/templates/MyBibApp/View/Search/Facets.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright (c) 2012-2022, 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 MyBibApp_View_Search_Facets extends ZendAfi_View_Helper_BaseHelper { + public function search_Facets(array $facets, array $preferences, Class_CriteresRecherche $criteres) { + + Class_ScriptLoader::getInstance() + ->addScript(Class_Url::relative('library/templates/MyBibApp/Assets/js/sticky_top/sticky_top.js')) + ->addJQueryReady('$(\'body\').sticky_top();'); + + + return (new Intonation_View_Search_Facets) + ->setView($this->view) + ->search_Facets($facets, $preferences, $criteres); + } +} diff --git a/library/templates/MyBibApp/View/Search/Result.php b/library/templates/MyBibApp/View/Search/Result.php new file mode 100644 index 0000000000000000000000000000000000000000..b0cb14957b8a38ac6e5bcb03b11baee19146f943 --- /dev/null +++ b/library/templates/MyBibApp/View/Search/Result.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright (c) 2012-2022, 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 MyBibApp_View_Search_Result extends Intonation_View_Search_Result { + + + protected function _getRecordWrapperClass() { + return MyBibApp_Library_Wrapper_Record::class; + } +} diff --git a/tests/TearDown.php b/tests/TearDown.php index 09c0e5283e4a29921f0d1e32258599246e259a7f..3c252f116be80b341c13b24351d71dc942fb8370 100644 --- a/tests/TearDown.php +++ b/tests/TearDown.php @@ -42,6 +42,7 @@ class TearDown { Zend_Registry::set('cfg', $cfg); Bokeh_Engine::reset(); + (new Storm_Cache)->clean(); $_SERVER['HTTP_REFERER'] = '/'; @@ -111,5 +112,8 @@ class TearDown { ZendAfi_Form_Element_Captcha::reset(); ZendAfi_Acl_AdminControllerGroup::setAcl(null); ZendAfi_Acl_AdminControllerRoles::reset(); + + Class_Systeme_Report_Portal::setIp(null); + ZendAfi_Auth::setInstance(null); } } diff --git a/tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php b/tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php index 0d1fdf6b43914de7fe6fd101030e970cc24ae123..c7ad0c5f90783df965b3539c2d663dc1e105c876 100644 --- a/tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php +++ b/tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php @@ -133,17 +133,6 @@ abstract class ViewHelperTestCase extends ModelTestCase { } - protected function tearDown() { - (new Storm_Cache)->clean(); - $this->logout(); - Class_Systeme_Report_Portal::setIp(null); - if($this->_storm_default_to_volatile) - Storm_Model_Loader::defaultToDb(); - - parent::tearDown(); - } - - public function logout() { ZendAfi_Auth::getInstance()->clearIdentity(); } diff --git a/tests/scenarios/Templates/ChiliTest.php b/tests/scenarios/Templates/ChiliTest.php index 6f7ab3e062d88d30945088982b450922d485ffaf..3f4b0f402e2a49b75751c3c38055b8e7e9679c7b 100644 --- a/tests/scenarios/Templates/ChiliTest.php +++ b/tests/scenarios/Templates/ChiliTest.php @@ -137,16 +137,16 @@ class ChiliTemplateProfilePatcherTest extends ChiliTemplateTestCase { $this->assertXPath('//link[4][contains(@href, "bootstrap-rgaa.css")]'); $this->assertXPath('//link[5][contains(@href, "core.css")]'); $this->assertXPath('//link[6][contains(@href, "intonation.css")]'); - $this->assertXPath('//link[7][contains(@href, "chili.css")]'); - $this->assertXPath('//link[8][contains(@href, "custom_template.css")]'); - $this->assertXPath('//link[9][contains(@href, "live_editor.css")]'); + $this->assertXPath('//link[7][contains(@href, "2022_05_improve_thumbnail_rendering.css")]'); + $this->assertXPath('//link[8][contains(@href, "chili.css")]'); + $this->assertXPath('//link[9][contains(@href, "custom_template.css")]'); + $this->assertXPath('//link[10][contains(@href, "live_editor.css")]'); } /** @test */ public function topHighlightCarouselShouldBePresent() { - $this->assertXPath('//div[contains(@class, "top_highlight_carousel")]', - $this->_response->getBody()); + $this->assertXPath('//div[contains(@class, "top_highlight_carousel")]'); } diff --git a/tests/scenarios/Templates/CssPatchsTest.php b/tests/scenarios/Templates/CssPatchsTest.php index ded5e73f5ac63373f9c447731dddd72bb0be356d..d162d551491735b13709a84b27589c1e596179f0 100644 --- a/tests/scenarios/Templates/CssPatchsTest.php +++ b/tests/scenarios/Templates/CssPatchsTest.php @@ -27,6 +27,11 @@ class CssPatchsAdminTemplateEditExistingProfile202205Test extends Admin_Abstract $this->_buildTemplateProfil(['id' => 78, 'template' => 'MUSCLE']); + $this->fixture(Class_Template_Settings::class, + ['id' => 1, + 'template' => 'MUSCLE', + 'settings' => serialize(['MuscleCssPatchs' => []])]); + $this->dispatch('/admin/template/edit/template/MUSCLE'); } @@ -92,6 +97,12 @@ class CssPatchsIndexOldTemplate202205Test extends Admin_AbstractControllerTestCa parent::setUp(); $this->_buildTemplateProfil(['id' => 78, 'template' => 'MUSCLE']); + + $this->fixture(Class_Template_Settings::class, + ['id' => 1, + 'template' => 'MUSCLE', + 'settings' => serialize(['MuscleCssPatchs' => []])]); + $this->dispatch('/index'); } @@ -100,4 +111,25 @@ class CssPatchsIndexOldTemplate202205Test extends Admin_AbstractControllerTestCa public function cssFile202205ImproveThumbnailRenderingCssShouldBeNotBeLinked() { $this->assertNotXPath('//head//link[contains(@href, "2022_05_improve_thumbnail_rendering")]'); } -} \ No newline at end of file +} + + + + +class CssPatchsTryMyBibAppShouldAdd202205CssPatchTest extends Admin_AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + $profile = $this->_buildTemplateProfil(['id' => 78]); + + (new MyBibApp_Template)->tryOn($profile); + + $this->dispatch('/admin/template/edit/template/MYBIBAPP'); + } + + + /** @test */ + public function cssFile202205ImproveThumbnailRenderingCssShouldBeChecked() { + $this->assertXPath('//div//form//input[@type="checkbox"][@name="MybibappCssPatchs[]"][@checked][@value="2022_05_improve_thumbnail_rendering.css"]'); + } +} diff --git a/tests/scenarios/Templates/MuscleTemplateTest.php b/tests/scenarios/Templates/MuscleTemplateTest.php index 5c4ebd7a5bd82b067500598a815637197715adc0..776591d3f046c83d6d1aa42f0bb34d2cf550026a 100644 --- a/tests/scenarios/Templates/MuscleTemplateTest.php +++ b/tests/scenarios/Templates/MuscleTemplateTest.php @@ -212,9 +212,10 @@ class MuscleTemplateProfilePatcherTest extends MuscleTemplateTestCase { $this->assertXPath('//link[4][contains(@href, "bootstrap-rgaa.css")]'); $this->assertXPath('//link[5][contains(@href, "core.css")]'); $this->assertXPath('//link[6][contains(@href, "intonation.css")]'); - $this->assertXPath('//link[7][contains(@href, "muscle.css")]'); - $this->assertXPath('//link[8][contains(@href, "custom_template.css")]'); - $this->assertXPath('//link[9][contains(@href, "live_editor.css")]'); + $this->assertXPath('//link[7][contains(@href, "2022_05_improve_thumbnail_rendering.css")]'); + $this->assertXPath('//link[8][contains(@href, "muscle.css")]'); + $this->assertXPath('//link[9][contains(@href, "custom_template.css")]'); + $this->assertXPath('//link[10][contains(@href, "live_editor.css")]'); } diff --git a/tests/scenarios/Templates/MyBibAppTemplateTest.php b/tests/scenarios/Templates/MyBibAppTemplateTest.php index 0b2d93430e8bbf5166d0ec81407e850b1aadd6c7..f5489723dfc1baf4e06ec7ee53fad6d974ed0b01 100644 --- a/tests/scenarios/Templates/MyBibAppTemplateTest.php +++ b/tests/scenarios/Templates/MyBibAppTemplateTest.php @@ -63,22 +63,19 @@ class MyBibAppTemplateProfilePatcherTest extends MyBibAppTemplateTestCase { ['id' => 23]); (new MyBibApp_Template)->tryOn($profile); + + $my_bib_app_profile = Class_Profil::find(24); + (new Class_Profil_Promoter())->promote($profile); $this->dispatch('/opac/index/index'); } public function widgetsClasses() { - return [ - ['login'], - ['accessibility'], - ['rech_simple'], - ['admin_tools'], - ['scroll'], - ['ariane'], - ['library'], + return [['image'], + ['kiosque'], ['critiques'], - ['credits'] + ['admin_tools'], ]; } @@ -211,6 +208,12 @@ class MyBibAppTemplateEditTemplateTest extends Admin_AbstractControllerTestCase } + /** @test */ + public function checkboxImproveThumbnailRenderingCssPatchShouldBeChecked() { + $this->assertXPath('//form//input[@type="checkbox"][@name="MybibappCssPatchs[]"][@checked]'); + } + + /** @test */ public function customCssShouldContainsClassMbaWidget() { $this->assertContains('"mba_widget"', $this->_response->getBody()); @@ -234,13 +237,13 @@ class MyBibAppTemplateOauthWithUserAgentTest extends MyBibAppTemplateTestCase { Class_Profil::find(2)->beCurrentProfil(); $this->fixture( Class_IdentityClient::class, - [ 'id' => 1, - 'client_id'=>'MyBibApp', - 'type' => 'mybibapp', - 'label' => 'MyBibApp', - 'active' => 1, - 'config' => "{}" - ]); + [ 'id' => 1, + 'client_id'=>'MyBibApp', + 'type' => 'mybibapp', + 'label' => 'MyBibApp', + 'active' => 1, + 'config' => "{}" + ]); $this->dispatch('/opac/auth/oauth/response_type/code/id_profil/1/client_id/MyBibApp?redirect_uri=www.mon-bokeh.org'); } @@ -280,22 +283,22 @@ class MyBibAppTemplatePostDispatchOauthWithUserAgentTest extends MyBibAppTemplat public function setUp() { parent::setUp(); $this->fixture( Class_IdentityClient::class, - [ 'id' => 1, - 'client_id'=>'MyBibApp', - 'type' => 'mybibapp', - 'label' => 'MyBibApp', - 'active' => 1, - 'config' => "{}" - ]); + [ 'id' => 1, + 'client_id'=>'MyBibApp', + 'type' => 'mybibapp', + 'label' => 'MyBibApp', + 'active' => 1, + 'config' => "{}" + ]); $this->fixture( Class_IdentityClient::class, - [ 'id' => 10, - 'client_id'=>'My webapp', - 'type' => 'oauth2', - 'label' => 'Portail citoyen', - 'redirect_uri' => 'http://mon-portail.org/bokeh/oauth', - 'active' => 1, - ]); + [ 'id' => 10, + 'client_id'=>'My webapp', + 'type' => 'oauth2', + 'label' => 'Portail citoyen', + 'redirect_uri' => 'http://mon-portail.org/bokeh/oauth', + 'active' => 1, + ]); $puppy = $this->fixture('Class_Users', ['id' => 345, @@ -494,4 +497,457 @@ class MyBibAppTemplatePageAgendaTest extends AbstractControllerTestCase { $this->dispatch('/agenda_mybibapp'); $this->assertXPathContentContains('//main//div[@class="boite calendar mba_widget no_border no_border_radius no_shadow widget col-12 card"]', 'Agenda'); } + + + /** @test */ + public function widgetAgendaShouldBeCreated() { + $agenda = (new Class_Systeme_Widget_Widget) + ->setId(1) + ->setProfileId(25) + ->load(); + + $this->assertNotNull($agenda); + return $agenda; + } + + + /** + * @test + * @depends widgetAgendaShouldBeCreated + */ + public function agendaShouldHaveASizeOf200Items($agenda) { + $this->assertEquals(200, $agenda->get('size')); + } + + + /** + * @test + * @depends widgetAgendaShouldBeCreated + */ + public function agendalayoutShouldBeGrid($agenda) { + $this->assertEquals('grid', $agenda->get('layout')); + } + + + /** + * @test + * @depends widgetAgendaShouldBeCreated + */ + public function agendaRenderingShouldBeCard($agenda) { + $this->assertEquals('card', $agenda->get('rendering')); + } +} + + + + +class MyBibAppTemplateNoveltyDomainTest extends MyBibAppTemplateTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture(Class_Catalogue::class, + ['id' => 1, + 'libelle' => 'Empty']); + + $profile = $this->fixture(Class_Profil::class, ['id' => 23]); + (new MyBibApp_Template)->tryOn($profile); + } + + + public function tearDown() { + Class_MoteurRecherche::setTimesource(null); + return parent::tearDown(); + } + + + /** @test */ + public function noveltyDomainShouldBeCreated() { + $domain = Class_Catalogue::findFirstBy(['libelle' => 'Nouveautés MyBibApp']); + $this->assertNotNull($domain); + return $domain; + } + + + /** + * @test + * @depends noveltyDomainShouldBeCreated + */ + public function mybibappNoveltiesDomainShouldHaveSqlWithNovelty(Class_Catalogue $domain) { + Class_MoteurRecherche::setTimesource(new TimeSourceForTest('2023-04-24 10:00:01')); + $this->assertEquals('select * from notices Where (date_creation >\'2023-04-24\') and type=1 order by alpha_titre LIMIT 0,5000', + $domain->getRequestsAsArray()['req_liste']); + } + + + /** + * @test + * @depends noveltyDomainShouldBeCreated + */ + public function noveltyDomainShouldBeCreatedOnce(Class_Catalogue $domain) { + $profile = $this->fixture(Class_Profil::class, ['id' => 29]); + (new MyBibApp_Template)->tryOn($profile); + + $this->assertCount(1, Class_Catalogue::findAllBy(['libelle' => 'Nouveautés MyBibApp'])); + } + + + /** + * @test + * @depends noveltyDomainShouldBeCreated + */ + public function recordsWidgetShouldHaveNoveltyDomainSelected(Class_Catalogue $domain) { + $widget = (new Class_Systeme_Widget_Widget) + ->setId(2) + ->setProfileId(24) + ->load(); + + $this->assertEquals(2, $widget->get('id_catalogue')); + } +} + + + + +class MyBibAppTemplateWithExistingNoveltyDomainTest extends MyBibAppTemplateTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture(Class_Catalogue::class, + ['id' => 67, + 'libelle' => 'Nouveautés MyBibApp']); + + $profile = $this->fixture(Class_Profil::class, ['id' => 23]); + (new MyBibApp_Template)->tryOn($profile); + } + + + /** @test */ + public function recordWidgetShouldHaveFirstNoveltyDomainIdSixtySevenSelected() { + $widget = (new Class_Systeme_Widget_Widget) + ->setId(2) + ->setProfileId(24) + ->load(); + + $this->assertEquals(67, $widget->get('id_catalogue')); + } +} + + + + +class MyBibAppTemplateSearchResultTest extends MyBibAppTemplateTestCase { + + protected array $_search = []; + + + public function setUp() { + parent::setUp(); + $profile = $this->fixture(Class_Profil::class, ['id' => 23]); + (new MyBibApp_Template)->tryOn($profile); + + $this->_search = + (new Class_Profil_Preferences)->getModulePref(Class_Profil::find(24), + (new Class_Profil_ModuleDefinition('recherche', + 'resultat', + 'simple'))); + } + + + /** @test */ + public function searchPageLayoutShouldBeWall() { + $this->assertEquals('4', $this->_search['liste_format']); + } + + + /** @test */ + public function searchPageShouldHaveCssClassLimitBadgesFive() { + $this->assertEquals('limit_badges_5', $this->_search['boite'][1]); + } +} + + + + + +class MyBibAppTemplateRecordPageTest extends MyBibAppTemplateTestCase { + + protected array $_record = []; + + + public function setUp() { + parent::setUp(); + $profile = $this->fixture(Class_Profil::class, ['id' => 23]); + (new MyBibApp_Template)->tryOn($profile); + + $this->_record = + (new Class_Profil_Preferences)->getModulePref(Class_Profil::find(24), + (new Class_Profil_ModuleDefinition('recherche', + 'viewnotice', + '1'))); + } + + + /** @test */ + public function recordPageShouldHaveCssClassLimitBadgesFive() { + $this->assertEquals('limit_badges_5', $this->_record['boite'][1]); + } +} + + + + +class MyBibAppTemplateItemsPageTest extends MyBibAppTemplateTestCase { + + protected Class_Profil_ItemsSettings $_items; + + + public function setUp() { + parent::setUp(); + $profile = $this->fixture(Class_Profil::class, ['id' => 23]); + (new MyBibApp_Template)->tryOn($profile); + + $this->_items = (new Class_Profil_ItemsSettings(Class_Profil::find(24))); + } + + + /** @test */ + public function itemsPageShouldHaveCssClassLimitBadgesFive() { + $this->assertEquals('', $this->_items->isAllItemsMap()); + } +} + + + + +class MyBibAppTemplateActionsCardTest extends ViewHelperTestCase { + + public string $html = ''; + + + protected static PHPUNIT_FrameWork_TestCase $_set_up; + + + public static function setUpBeforeClass() { + parent::setUpBeforeClass(); + + static::$_set_up = new static(); + static::$_set_up->setup(); + + Class_AdminVar::set('MENU_BOITE', 1); + + static::fixture(Class_Profil::class, + ['id' => 23, + 'template' => 'MyBibApp', + 'parent_id' => null]) + ->beCurrentProfil(); + + static::fixture(Class_PanierNotice::class, + ['id' => 1, + 'libelle' => 'Mes favoris', + 'clef_alpha' => 'TROLLSDETROY1']); + + static::fixture(Class_Notice::class, + ['id' => 213, + 'clef_alpha' => 'TROLLSDETROY1', + 'exemplaires' => [static::fixture(Class_Exemplaire::class, + ['id' => 2])]]); + + $widget_type = Intonation_Library_Widget_Carousel_Record_Definition::CODE; + + $settings = + array_merge(Class_Systeme_ModulesAccueil::getInstance() + ->getModuleByCode($widget_type) + ->getDefaultValues(), + ['rendering' => Intonation_Library_Widget_Carousel_Definition::CARD, + 'id_panier' => 1]); + + $widget = (new Class_Systeme_Widget_Widget) + ->loadFromSettings(['type_module' => $widget_type, + 'profile_id' => 23, + 'preferences' => $settings]); + + Class_Template::current()->addAdminHelperPath(static::$_set_up->view); + Class_Template::current()->addHelperPath(static::$_set_up->view); + + + $iam = static::fixture(Class_Users::class, + ['id' => 789798, + 'login' => 'IAM', + 'password' => 'mars']); + + ZendAfi_Auth::getInstance()->logUser($iam); + + static::$_set_up->html = Class_Template::current()->renderWidget($widget, static::$_set_up->view); + } + + + public static function tearDownAfterClass() { + static::$_set_up->tearDown(); + parent::tearDownAfterClass(); + } + + + /** @test */ + public function cardFooterShouldContainsReserver() { + $this->assertXPathContentContains(static::$_set_up->html, + '//div[@class="card_footer card_footer_MyBibApp_Library_Wrapper_Record card-footer row mx-1 px-3 justify-content-between"]/a[contains(@class,"hold_record")][1]', + Class_CharSet::fromISOtoUTF8('Réserver')); + } + + + /** @test */ + public function cardFooterShouldOnlyContainsOneLink() { + $this->assertXPathCount(static::$_set_up->html, + '//div[@class="card_footer card_footer_MyBibApp_Library_Wrapper_Record card-footer row mx-1 px-3 justify-content-between"]/a', + 1); + } + + + /** @test */ + public function addToReadedShouldBeDisplayInRow() { + $this->assertXPathContentContains(static::$_set_up->html, + '//div[@class="card_footer card_footer_MyBibApp_Library_Wrapper_Record card-footer row mx-1 px-3 justify-content-between"]/div[@class="extra_actions col-12 row justify-content-around mx-0 px-0 mb-2"]/a[contains(@href, "/abonne/ajouter-le-document-a-la-selection/")]', + Class_CharSet::fromISOtoUTF8('Déjà lu')); + } + + + /** + * @test + * @depends addToReadedShouldBeDisplayInRow + */ + public function addToReadedShouldContainsScript() { + $js = 'event.preventDefault(); event.stopPropagation(); var url = $(this).attr(\'href\'); var anchors = $(\'a[href=\\\'\' + url + \'\\\']\'); $.ajax({type: \'GET\', url: \'/abonne/ajouter-le-document-a-la-selection/selection_label/D%C3%A9j%C3%A0+lu/image/readed/revert-image/unread/record_id/213/ajax/\', success: function(data) {anchors.replaceWith(data.anchor);}});'; + + $this->assertXPath(static::$_set_up->html, + '//a[contains(@onclick, "'. $js .'")]'); + } + + + /** + * @test + * @depends addToReadedShouldBeDisplayInRow + */ + public function addToReadedBeInDropdown() { + $this->assertXPathContentContains(static::$_set_up->html, + '//div[@class="card_footer card_footer_MyBibApp_Library_Wrapper_Record card-footer row mx-1 px-3 justify-content-between"]//div[@class="dropdown dropleft dropup"]//div/a[contains(@href, "/abonne/ajouter-le-document-a-la-selection/")]', + Class_CharSet::fromISOtoUTF8('Déjà lu')); + } + + + /** @test */ + public function cardFooterShouldContainsReserverInDropdown() { + $this->assertXPathContentContains(static::$_set_up->html, + '//div[@class="card_footer card_footer_MyBibApp_Library_Wrapper_Record card-footer row mx-1 px-3 justify-content-between"]//div[@class="dropdown dropleft dropup"]//div//a[contains(@class,"hold_record")]', + Class_CharSet::fromISOtoUTF8('Réserver')); + } +} + + + + +class MyBibAppTemplateViewNoticeTest extends MyBibAppTemplateTestCase { + + + public function setUp() { + parent::setUp(); + + $record = + $this->fixture(Class_Notice::class, + ['id' => 1, + 'clef_oeuvre' => 'PSYKO', + 'facettes' => 'G13 M12']); + $record + ->set_subfield('330', 'a', 'Résumé du document') + ->save(); + + (new MyBibApp_Template)->tryOn(Class_Profil::getCurrentProfil()); + + $iam = $this->fixture(Class_Users::class, + ['id' => 789798, + 'login' => 'IAM', + 'password' => 'mars']); + + ZendAfi_Auth::getInstance()->logUser($iam); + + $this->dispatch('/recherche/viewnotice/id/1/id_panier/1'); + } + + + /** @test */ + public function actionsBackToSearchResultShouldBePresent() { + $this->assertXPathContentContains('//div[@class="rich_content_row_actions back_to_search_result col col-lg-12 pt-1 mt-1 mr-1 pr-1 w-s_nowrap text-center"]//a[@class="card-link back_to_search_result"]//div[@class="d-inline text-left"]', + 'Retour à la recherche'); + } + + + /** @test */ + public function actionsBackToSearchShouldBeTheLonelyLink() { + $this->assertXPathCount('//div[@class="jumbotron_actions jumbotron_actions_no_pagination order-5 order-lg-4 mh-100 no-gutters col-10 col-md-9 col-lg-2"]/div[2]//a', 1); + } + + + /** @test */ + public function addToReadedShouldBeDisplayInRow() { + $this->assertXPathContentContains('//div[@class="jumbotron_actions jumbotron_actions_no_pagination order-5 order-lg-4 mh-100 no-gutters col-10 col-md-9 col-lg-2"]//div[@class="extra_actions row no-gutters col-12 justify-content-around mx-0 px-0 mb-2"]/a[contains(@href, "/abonne/ajouter-le-document-a-la-selection/")]', + 'Déjà lu'); + } + + + /** @test */ + public function allTabShouldBeActivatedHasADropdownButton() { + $this->assertXPathContentContains('//div[contains(@class, "jumbotron_nav")]/div[@class="dropdown"]/button[@data-toggle="dropdown"][@class="all_record_data tab_to_active_dropdown_button btn btn-primary text-left dropdown-toggle mx-0 w-100 btn-lg"]', + 'Tout'); + } + + + /** @test */ + public function itemsTabShouldBeInDropdownMenu() { + $this->assertXPathContentContains('//div[contains(@class, "jumbotron_nav")]/div[@class="dropdown"]/div[@class="dropdown-menu"]/div/button[@class="document_items tab_to_dropdown_button btn btn-secondary text-left my-1 w-100"][contains(@onclick, "/record/items/id/1")]', + 'Exemplaires'); + } +} + + + + +class MyBibAppTemplateFacetsInSearchTest extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 1, + 'template' => 'MYBIBAPP']); + + $this->fixture(Class_PanierNotice::class, + ['id' => 1, + 'titre' => 'Top 10 BD', + 'notices' => 'TROLL;TROY;LANFEUST;SIMBAD' + ]); + + $this->fixture(Class_Notice::class, + ['id' => 1, + 'clef_alpha' => 'TROLL', + ]); + + Zend_Registry::set('sql', $this->mock()->whenCalled('fetchAll')->answers([[1, '']])); + + $this->dispatch('/recherche/simple/id_panier/1'); + } + + + /** @test */ + public function searchFacetsColShouldHaveClassStickyTop() { + $this->assertXPath('//div[@class="search_facets_col sticky_top col-12 col-md-3 order-5"]'); + } + + + /** @test */ + public function searchResultShouldContainsScriptStickyTop() { + $this->assertXPath('//script[contains(@src, "/library/templates/MyBibApp/Assets/js/sticky_top/sticky_top.js")]'); + } + + + /** @test */ + public function searchResultShouldContainsScriptToInitializeStickyTop() { + $this->assertXPathContentContains('//script', '$(\'body\').sticky_top()'); + } } diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index 4000d3d9da84eb1fa8c41f570131caf3f9ae1b53..ebf65b2c9e96d894cd8921412459d1c3f88c6ecd 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -464,7 +464,8 @@ class TemplatesAbonnePaginatedReviewsPage2Test extends TemplatesAbonnePaginatedC /** @test */ public function shouldContainsReviewWithContentAvecSaCouronne() { - $this->assertXPathContentContains('//div[@class="list-group bg-transparent no_border"]//div[@class= "list-group-item bg-transparent px-0 mb-3"]//div[@class= "card-body card_body card_body_Intonation_Library_View_Wrapper_ReviewInRecord"]//p', 'avec sa couronne'); + $this->assertXPathContentContains('//div[@class="list-group bg-transparent no_border"]//div[@class= "list-group-item bg-transparent px-0 mb-3"]//div[@class= "card_body card_body_Intonation_Library_View_Wrapper_ReviewInRecord card-body pb-1"]//p', + 'avec sa couronne'); } diff --git a/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php b/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php index 70d0a445f552ba942a32d2916fc0c1fd4f0854e1..4fb690d5bf6fd63285f0b1b59b1c795d4a211bc5 100644 --- a/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php +++ b/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php @@ -1177,7 +1177,7 @@ class TemplatesAjaxPaginatedWallTest extends AbstractControllerTestCase { /** @test */ public function shouldDisplay10ItemsInWallHasCardDescription() { - $this->assertXPathCount('//div[@class="masonry"]//div[@class="masonry-brick"]//div[contains(@class, "card card_template")]//div[@class ="card-body card_body card_body_Intonation_Library_View_Wrapper_Item"]', + $this->assertXPathCount('//div[@class="masonry"]//div[@class="masonry-brick"]//div[contains(@class, "card card_template")]//div[@class ="card_body card_body_Intonation_Library_View_Wrapper_Item card-body pb-1"]', 10); } } diff --git a/tests/scenarios/Templates/TemplatesNewslettersTest.php b/tests/scenarios/Templates/TemplatesNewslettersTest.php index 9f4a6f5b7d565a3ae946d114097d43e436f077df..fc3af61a1c7dd6bf05fabe480f36686551d8bd51 100644 --- a/tests/scenarios/Templates/TemplatesNewslettersTest.php +++ b/tests/scenarios/Templates/TemplatesNewslettersTest.php @@ -262,7 +262,7 @@ class TemplatesNewslettersIndexWithWidgetAndUserConnectedTest extends TemplatesN /** @test */ public function linkUnsubscribeShouldBePresent() { - $this->assertXPathContentContains('//div[@class="card-footer d-flex flex-row justify-content-between card_footer card_footer_Intonation_Library_View_Wrapper_Newsletter"]//a[@href="/abonne/unsubscribe-newsletter/id/3"]', + $this->assertXPathContentContains('//div[@class="card_footer card_footer_Intonation_Library_View_Wrapper_Newsletter card-footer row mx-1 px-3 justify-content-between"]//a[@href="/abonne/unsubscribe-newsletter/id/3"]', 'Me désinscrire'); } } @@ -282,4 +282,4 @@ class TemplatesNewslettersIndexWithWidgetAndNoUserTest extends TemplatesNewslett $this->assertXPathContentContains('//body//div[@class="section_content_wrapper"]', 'Cache de la boite newsletter.'); } -} \ No newline at end of file +} diff --git a/tests/scenarios/Templates/TemplatesRecordsTest.php b/tests/scenarios/Templates/TemplatesRecordsTest.php index d683b7eff6a4be6554198b43ed12ea4b0ba86701..7e59ce540eff6ab2e98254d5682322033c0e0aeb 100644 --- a/tests/scenarios/Templates/TemplatesRecordsTest.php +++ b/tests/scenarios/Templates/TemplatesRecordsTest.php @@ -1625,7 +1625,7 @@ class TemplatesRecordsPaginationTest extends AbstractControllerTestCase { /** @test */ public function positionInSearchResultShouldHaveClassPositionInSearchResult() { $this->dispatch('/recherche/viewnotice/id/456/id_catalogue/22'); - $this->assertXPathContentContains('//div[@class="bokeh_jumbotron bokeh_jumbotron_with_both_pagination jumbotron jumbotron-fluid w-100 py-3 mb-3"]//div[@class= "rich_content_row_actions position_in_seach_result col col-lg-12 pt-1 mt-1 mr-1 pr-1 w-s_nowrap"]', + $this->assertXPathContentContains('//div[@class="bokeh_jumbotron bokeh_jumbotron_with_both_pagination jumbotron jumbotron-fluid w-100 py-3 mb-3"]//div[@class= "rich_content_row_actions position_in_seach_result col col-lg-12 pt-1 mt-1 mr-1 pr-1 w-s_nowrap text-center"]', '2 / 5'); } @@ -1633,7 +1633,7 @@ class TemplatesRecordsPaginationTest extends AbstractControllerTestCase { /** @test */ public function backToSearchResultShouldHaveClassBackToSearchResult() { $this->dispatch('/recherche/viewnotice/id/456/id_catalogue/22'); - $this->assertXPathContentContains('//div[@class="bokeh_jumbotron bokeh_jumbotron_with_both_pagination jumbotron jumbotron-fluid w-100 py-3 mb-3"]//div[@class= "rich_content_row_actions back_to_search_result col col-lg-12 pt-1 mt-1 mr-1 pr-1 w-s_nowrap"]//a[contains(@href, "/recherche/simple/id_catalogue/22#456")]', + $this->assertXPathContentContains('//div[@class="bokeh_jumbotron bokeh_jumbotron_with_both_pagination jumbotron jumbotron-fluid w-100 py-3 mb-3"]//div[@class= "rich_content_row_actions back_to_search_result col col-lg-12 pt-1 mt-1 mr-1 pr-1 w-s_nowrap text-center"]//a[contains(@href, "/recherche/simple/id_catalogue/22#456")]', 'Recherche'); } } diff --git a/tests/scenarios/Templates/TemplatesWidgetCarouselTest.php b/tests/scenarios/Templates/TemplatesWidgetCarouselTest.php index f532a2ac6170680c891beafffefc8991011c02c4..04d48cb7aa142cd17379c3f580f32ec0d4af6fed 100644 --- a/tests/scenarios/Templates/TemplatesWidgetCarouselTest.php +++ b/tests/scenarios/Templates/TemplatesWidgetCarouselTest.php @@ -421,6 +421,7 @@ class TemplatesWidgetCarouselDelayedRecordWithDomainTest extends TemplatesWidget $cache = $this->mock(); Storm_Cache::setDefaultZendCache($cache); $this->dispatch('/index'); + Storm_Cache::setDefaultZendCache(null); $this->assertTrue($cache->methodHasNotBeenCalled('memoize')); } -} \ No newline at end of file +}