diff --git a/FEATURES/156615 b/FEATURES/156615 new file mode 100644 index 0000000000000000000000000000000000000000..a4cce9a30dc3c48d86e2af8973f7a76f403557ee --- /dev/null +++ b/FEATURES/156615 @@ -0,0 +1,10 @@ + '156615' => + ['Label' => $this->_('Image dans le titre des boites et ancre personnalisée'), + 'Desc' => $this->_('Dans les boites du magasin de thèmes, il est maintenant possible de d\'ajouter une image à côté du titre. Il est également possible d\'ajouter une ancre personnalisée dans la boite pour pouvoir faire défiler les pages où vous le souhaitez'), + 'Image' => '', + 'Video' => 'https://youtu.be/Rp1ytN15QeE', + 'Category' => $this->_('Mise en page'), + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => 'https://wiki.bokeh-library-portal.org/index.php?title=Pr%C3%A9sentation_des_boites', + 'Test' => '', + 'Date' => '2022-06-31'], \ No newline at end of file diff --git a/VERSIONS_WIP/156615 b/VERSIONS_WIP/156615 new file mode 100644 index 0000000000000000000000000000000000000000..28df4d458dbe50912db8f85f949a3b57173a15d1 --- /dev/null +++ b/VERSIONS_WIP/156615 @@ -0,0 +1,3 @@ + - fonctionnalité #156615 : Magasin de thèmes : Vous pouvez maintenant ajouter une image + dans le titre des boites. + Vous pouvez maintenant ajouter une ancre dans les boites. \ No newline at end of file diff --git a/library/Class/DigitalResource/ModuleMenu.php b/library/Class/DigitalResource/ModuleMenu.php index 84df000ed3887483ff9b1b1937b2de68b68554a6..82b371b3bf90efc68d1b2e25b1b2c4ad10b90e09 100644 --- a/library/Class/DigitalResource/ModuleMenu.php +++ b/library/Class/DigitalResource/ModuleMenu.php @@ -38,7 +38,7 @@ class Class_DigitalResource_ModuleMenu extends Class_Systeme_ModulesMenu_SSOAbst } - public function getUrl($preferences = []) { + public function getUrl(array $preferences = []) : string { return Class_Url::assemble(['module' => 'opac', 'controller' => 'modules', 'action' => $this->_config->getSsoAction()]); diff --git a/library/Class/FileManager/Model.php b/library/Class/FileManager/Model.php index 30d923fad991a051c8009d233d3ca65ad6dfd6d1..80d4e2c646b631017bba0acd9a225f53008149bd 100644 --- a/library/Class/FileManager/Model.php +++ b/library/Class/FileManager/Model.php @@ -34,6 +34,7 @@ class Class_FileManager_Model { new Class_FileManager_ModelRelationText(Class_Article::class, 'contenu'), new Class_FileManager_ModelRelationText(Class_Article::class, 'description'), new Class_FileManager_ModelRelationProfil($filemanager), + new Class_FileManager_ModelRelationWidget($filemanager), new Class_FileManager_ModelRelation(Class_Bib::class, 'photo') ]; } @@ -123,7 +124,7 @@ class Class_FileManager_ModelRelationProfil { $top_profiles = array_filter(Class_Profil::findTopProfils(), function($profile) use ($path) { if ((new Class_Profil_Preferences_Record($profile))->contains($path)) - return true; + return true; foreach(['header_img', 'favicon', @@ -173,3 +174,79 @@ class Class_FileManager_ModelRelationProfil { $this->_renameOne($model, $path, $by); } } + + + + +class Class_FileManager_ModelRelationWidget { + + protected $_filemanager; + + public function __construct(Class_FileManager $filemanager) { + $this->_filemanager = $filemanager; + } + + + public function findAll(string $path) : array { + $widgets = []; + foreach(Class_Profil::findAllBy([Class_Profil::clauseNotEqual('template', 'null'), + Class_Profil::clauseNotEqual('template', '')]) as $profile) + $widgets = $this->_getWidgetsWithImage($path, $profile, $widgets); + + return $widgets; + } + + + protected function _getWidgetsWithImage(string $path, + Class_Profil $profile, + array $widgets) : array { + foreach ( $profile->getCfgAccueilParam('modules') as $widget_id => $settings_as_array) + if ( $this->_hasImage($settings_as_array, $path) ) + $widgets [] = (new Class_Systeme_Widget_Widget) + ->setId($widget_id) + ->setProfileId($profile->getId()) + ->load(); + + return array_filter($widgets); + } + + + protected function _hasImage(array $settings, string $path) : bool { + return $this->_hasTitlePicto($settings, $path) + || $this->_hasImageWith($settings, $path); + } + + + protected function _hasTitlePicto(array $settings, string $path) : bool { + if ( ! $title_picto = (string) ($settings['preferences']['title_picto'] ?? '')) + return false; + + return $title_picto === '/' . $path; + } + + + protected function _hasImageWith(array $settings, string $path) : bool { + if ( ! $image = (string) ($settings['preferences']['image'] ?? '')) + return false; + + return $image === '/' . $path; + } + + + public function rename(string $path, string $by) : void { + array_map(function($widget) use ($path, $by) + { + $new_params = []; + if ($widget->getTitlePicto() === '/'. $path) + $new_params['title_picto'] = '/' . $by; + + if ($widget->getImage() === '/' . $path) + $new_params['image'] = '/' . $by; + + $widget + ->setNewDatas($new_params) + ->save(); + }, + $this->findAll($path)); + } +} \ No newline at end of file diff --git a/library/Class/Systeme/ModulesAccueil/Null.php b/library/Class/Systeme/ModulesAccueil/Null.php index 8a6f8dc647e01b3e54fc9d71b7895321389478be..415a5cdb624c0ae3aa9499c914417d8ad28b98c6 100644 --- a/library/Class/Systeme/ModulesAccueil/Null.php +++ b/library/Class/Systeme/ModulesAccueil/Null.php @@ -124,7 +124,7 @@ class Class_Systeme_ModulesAccueil_Null { * stub. Subclass responsibility * @return string */ - public function getUrl() { + public function getUrl(array $preferences = []) : string { return '#'; } diff --git a/library/Class/Systeme/ModulesMenu/Avis.php b/library/Class/Systeme/ModulesMenu/Avis.php index 6881394a3f759c456d8384ce0640c5b1b6902444..a73b27e97af74e0f5a0526d6d0039f56ee54d3f8 100644 --- a/library/Class/Systeme/ModulesMenu/Avis.php +++ b/library/Class/Systeme/ModulesMenu/Avis.php @@ -37,7 +37,7 @@ class Class_Systeme_ModulesMenu_Avis extends Class_Systeme_ModulesMenu_Null{ } - public function getUrl($preferences = []) { + public function getUrl(array $preferences = []) : string { $nb = isset($preferences['nb']) ? $preferences['nb'] : $this->_defaultValues['nb']; diff --git a/library/Class/Systeme/ModulesMenu/BibliothequeNumerique.php b/library/Class/Systeme/ModulesMenu/BibliothequeNumerique.php index c4662707e0a2abc739c748cf5f947f8f79e43d8e..1942e3344cd90ad2eed9c9ddb808563c6e010453 100644 --- a/library/Class/Systeme/ModulesMenu/BibliothequeNumerique.php +++ b/library/Class/Systeme/ModulesMenu/BibliothequeNumerique.php @@ -41,7 +41,7 @@ class Class_Systeme_ModulesMenu_BibliothequeNumerique extends Class_Systeme_Modu } - public function getUrl($preferences = []) { + public function getUrl(array $preferences = []) : string { $this->_url = ['controller' => 'bib-numerique', 'action' => 'booklet', 'id' => (isset($preferences['album_id']) ? $preferences['album_id'] : '')]; diff --git a/library/Class/Systeme/ModulesMenu/Catalogue.php b/library/Class/Systeme/ModulesMenu/Catalogue.php index 6261a29821d6c8f7577967b7d9ebe300e946555f..76057d0774a3080c9bb16396f9099a1170d48736 100644 --- a/library/Class/Systeme/ModulesMenu/Catalogue.php +++ b/library/Class/Systeme/ModulesMenu/Catalogue.php @@ -44,7 +44,7 @@ class Class_Systeme_ModulesMenu_Catalogue extends Class_Systeme_ModulesMenu_Null } - public function getUrl($preferences = []) { + public function getUrl(array $preferences = []) : string { $tris = ['0' => 'alpha_titre', '1' => 'date_creation desc', '2' => 'nb_visu desc']; diff --git a/library/Class/Systeme/ModulesMenu/LastNews.php b/library/Class/Systeme/ModulesMenu/LastNews.php index 63e5c586e5d4f3504be0cf850785689780dc1c97..9e3da4cf34b8e08ed5667e3a64e5187383bf5461 100644 --- a/library/Class/Systeme/ModulesMenu/LastNews.php +++ b/library/Class/Systeme/ModulesMenu/LastNews.php @@ -38,7 +38,7 @@ class Class_Systeme_ModulesMenu_LastNews extends Class_Systeme_ModulesMenu_Null } - public function getUrl($preferences = []) { + public function getUrl(array $preferences = []) : string { $this->_url = Class_Url::assemble(['controller' => 'cms', 'action' => 'articleviewrecent', 'nb' => $preferences["nb"]]); diff --git a/library/Class/Systeme/ModulesMenu/Menu.php b/library/Class/Systeme/ModulesMenu/Menu.php index 232c948735298aac55a36bf24868ba76d43753f7..66b812f5bb5fa089d54bab50e329914cf882660e 100644 --- a/library/Class/Systeme/ModulesMenu/Menu.php +++ b/library/Class/Systeme/ModulesMenu/Menu.php @@ -33,7 +33,7 @@ class Class_Systeme_ModulesMenu_Menu extends Class_Systeme_ModulesMenu_Null { } - public function getUrl($preferences=[]) { + public function getUrl(array $preferences=[]) : string { return $preferences['clef_profil'] > 0 ? Class_Url::assemble(['controller' => 'index', 'action' => 'index', diff --git a/library/Class/Systeme/ModulesMenu/MyCow.php b/library/Class/Systeme/ModulesMenu/MyCow.php index 6778ce9db58ba0efe2fd6832a3cbc38e53ce24b5..ba63e0b116329cdb2110daec1f5e75d05d9ec060 100644 --- a/library/Class/Systeme/ModulesMenu/MyCow.php +++ b/library/Class/Systeme/ModulesMenu/MyCow.php @@ -47,7 +47,7 @@ class Class_Systeme_ModulesMenu_MyCow extends Class_Systeme_ModulesMenu_SSOAbstr } - public function getUrl($preferences = []) { + public function getUrl(array $preferences = []) : string { return Class_MyCowLink::staticUrl(); } } diff --git a/library/Class/Systeme/ModulesMenu/News.php b/library/Class/Systeme/ModulesMenu/News.php index 6fe23e8661d05ffd6853d68e871bea20516eeb14..8c76ffd0a72749dbf0ed81cba0c0194def051d4e 100644 --- a/library/Class/Systeme/ModulesMenu/News.php +++ b/library/Class/Systeme/ModulesMenu/News.php @@ -46,7 +46,7 @@ class Class_Systeme_ModulesMenu_News extends Class_Systeme_ModulesMenu_Null { } - public function getUrl($preferences = []) { + public function getUrl(array $preferences = []) : string { $this->_url = array_merge(['controller' => 'cms', 'action' => 'articleviewpreferences'], $this->_clean($preferences)); diff --git a/library/Class/Systeme/ModulesMenu/Null.php b/library/Class/Systeme/ModulesMenu/Null.php index 6a8c72894d6ef6deac3540c971d334a21d359229..a14f3c53ed5c9299c9b692c97d30c621e923d756 100644 --- a/library/Class/Systeme/ModulesMenu/Null.php +++ b/library/Class/Systeme/ModulesMenu/Null.php @@ -34,7 +34,7 @@ class Class_Systeme_ModulesMenu_Null extends Class_Systeme_ModulesAccueil_Null { $_form = 'ZendAfi_Form_Configuration_Menu_Entry'; - public function getUrl($preferences = []) { + public function getUrl(array $preferences = []) : string { if(!isset($preferences['preferences'])) $preferences['preferences'] = $preferences; diff --git a/library/Class/Systeme/ModulesMenu/PlanetNemo.php b/library/Class/Systeme/ModulesMenu/PlanetNemo.php index 84fd710b8c7ae2894544f1f6e588239cb9dd14b8..51dce4e095343fd428de6dd8554898fed545ed63 100644 --- a/library/Class/Systeme/ModulesMenu/PlanetNemo.php +++ b/library/Class/Systeme/ModulesMenu/PlanetNemo.php @@ -45,7 +45,7 @@ class Class_Systeme_ModulesMenu_PlanetNemo extends Class_Systeme_ModulesMenu_SSO } - public function getUrl($preferences = []) { + public function getUrl(array $preferences = []) : string { return Class_PlanetNemoLink::staticUrl(); } } diff --git a/library/Class/Systeme/ModulesMenu/Profil.php b/library/Class/Systeme/ModulesMenu/Profil.php index b99db8488587bbd229f397d10b2959e88a27b455..c17e62ce7a660eabe81daf592759c3a3f49f8f56 100644 --- a/library/Class/Systeme/ModulesMenu/Profil.php +++ b/library/Class/Systeme/ModulesMenu/Profil.php @@ -38,9 +38,14 @@ class Class_Systeme_ModulesMenu_Profil extends Class_Systeme_ModulesMenu_Null { } - public function getUrl($preferences=[]) { - return $this->_url = Class_Url::assemble($this->_getUrlParams($preferences), - null, true); + public function getUrl(array $preferences = []) : string { + $url = Class_Url::assemble($this->_getUrlParams($preferences)); + + $scroll_anchor = $preferences['scroll_anchor_target'] ?? ''; + + return $this->_url = $scroll_anchor + ? $url . '#' . $scroll_anchor + : $url; } @@ -50,5 +55,4 @@ class Class_Systeme_ModulesMenu_Profil extends Class_Systeme_ModulesMenu_Null { return $profil->getUrlParts(); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/Class/Systeme/ModulesMenu/Rss.php b/library/Class/Systeme/ModulesMenu/Rss.php index 0893f3d1e90e7ea4e10853357221632cbe958c95..2d2b37dd073e7ce4180dcb01e0cbe1991317e176 100644 --- a/library/Class/Systeme/ModulesMenu/Rss.php +++ b/library/Class/Systeme/ModulesMenu/Rss.php @@ -38,7 +38,7 @@ class Class_Systeme_ModulesMenu_Rss extends Class_Systeme_ModulesMenu_Null { } - public function getUrl($preferences =[]) { + public function getUrl(array $preferences =[]) : string { $this->_url = ['controller' => 'rss', 'action' => 'main']; diff --git a/library/Class/Systeme/ModulesMenu/Sitotheque.php b/library/Class/Systeme/ModulesMenu/Sitotheque.php index a09e5b6863b41ae5c45e69ecd1fd4d208b9af19a..f60635e15a0057a58e6f42a651ad5a00b97f8f58 100644 --- a/library/Class/Systeme/ModulesMenu/Sitotheque.php +++ b/library/Class/Systeme/ModulesMenu/Sitotheque.php @@ -38,7 +38,7 @@ class Class_Systeme_ModulesMenu_Sitotheque extends Class_Systeme_ModulesMenu_Nul } - public function getUrl($preferences = []) { + public function getUrl(array $preferences = []) : string { $this->_url = array_merge(['controller' => 'sito', 'action' => 'sitoview'], array_filter(array_intersect_key($preferences, $this->_defaultValues))); diff --git a/library/Class/Systeme/ModulesMenu/Url.php b/library/Class/Systeme/ModulesMenu/Url.php index 789f8b79ced3e71dac4311b414edf5e9078fe0b4..170ee01a95b9e7c5562606ec4dee32586f8d23c6 100644 --- a/library/Class/Systeme/ModulesMenu/Url.php +++ b/library/Class/Systeme/ModulesMenu/Url.php @@ -38,7 +38,7 @@ class Class_Systeme_ModulesMenu_Url extends Class_Systeme_ModulesMenu_Null { } - public function getUrl($preferences=[]) { + public function getUrl(array $preferences=[]) : string { return $preferences['url']; } diff --git a/library/Class/Systeme/Widget/Widget.php b/library/Class/Systeme/Widget/Widget.php index ae98352fc3c0256fff165d62434949247682c64f..69398e31d9fbe6aa87ba0763f61f0918ab76dae9 100644 --- a/library/Class/Systeme/Widget/Widget.php +++ b/library/Class/Systeme/Widget/Widget.php @@ -22,7 +22,6 @@ class Class_Systeme_Widget_Widget extends Class_Systeme_Widget_Abstract { - protected function _load() : self { return $this->_transmute($this->_findLeaf($this->getId())); } @@ -242,4 +241,19 @@ class Class_Systeme_Widget_Widget extends Class_Systeme_Widget_Abstract { strtolower($this->getDivisionLabel()), $this->getProfileOrParentProfileId()); } + + + public function getClassName() : string { + return $this->getTypeLabel(); + } + + + public function getTitlePicto() : string { + return (string) $this->get('title_picto'); + } + + + public function getImage() : string { + return (string) $this->get('image'); + } } diff --git a/library/ZendAfi/Form.php b/library/ZendAfi/Form.php index 28b2d3797af10f015ce9e953a6a3ed862292bae5..6cff846147c8cdf09e8d7e1c1e31ef88af8f39da 100644 --- a/library/ZendAfi/Form.php +++ b/library/ZendAfi/Form.php @@ -238,7 +238,7 @@ class ZendAfi_Form extends Zend_Form { return $this->getElement($element); }, $element_names); - $group->addElements($elements); + $group->addElements(array_filter($elements)); $this->_order[$group_name] = $this->_displayGroups[$group_name]->getOrder(); $this->_orderUpdated = true; return $this; diff --git a/library/ZendAfi/Form/Configuration/Menu/LinkToProfile.php b/library/ZendAfi/Form/Configuration/Menu/LinkToProfile.php index 1a597d5f22bf12007abc811ced29cf389f4d00c2..597fdb8340784dc2f82ff3436eae88aef4400a53 100644 --- a/library/ZendAfi/Form/Configuration/Menu/LinkToProfile.php +++ b/library/ZendAfi/Form/Configuration/Menu/LinkToProfile.php @@ -30,13 +30,18 @@ class ZendAfi_Form_Configuration_Menu_LinkToProfile extends ZendAfi_Form_Configu ['label' => $this->_('Lien vers le profil'), 'empty_option' => true, 'value' => 1]) + ->addExpertElement('text', + 'scroll_anchor_target', + ['label' => $this->_('Ancrage à utiliser pour le défilement'), + 'placeholder' => 'scroll_to_agenda']) ->removeElement('use_profil'); } public function populate(array $datas) { parent::populate($datas); - $this->addToHeadGroup(['clef_profil']); + $this->addToHeadGroup(['clef_profil', + 'scroll_anchor_target']); return $this; } } \ No newline at end of file diff --git a/library/ZendAfi/Form/Configuration/Widget/Search.php b/library/ZendAfi/Form/Configuration/Widget/Search.php index 8bed24502217d04a182e2966cb097d4b1b44f456..168526cdf796623cbe587976e744e177351937cd 100644 --- a/library/ZendAfi/Form/Configuration/Widget/Search.php +++ b/library/ZendAfi/Form/Configuration/Widget/Search.php @@ -90,7 +90,8 @@ class ZendAfi_Form_Configuration_Widget_Search ->addElement('comboProfils', 'profil_redirect', ['label' => $this->_('Basculer automatiquement sur le profil'), - 'empty_option' => true]) + 'empty_option' => true, + 'order' => 1000]) ->addElement('select', 'type_doc', diff --git a/library/ZendAfi/View/Helper/Accueil/Base.php b/library/ZendAfi/View/Helper/Accueil/Base.php index 023caf976ff5749607b8892b2fbe7e79bc26a11f..aa5f2a4d22991a043b24ca4f2f371ea6aa9e017d 100644 --- a/library/ZendAfi/View/Helper/Accueil/Base.php +++ b/library/ZendAfi/View/Helper/Accueil/Base.php @@ -511,10 +511,23 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac } - public function getTitle() { - return $this->titre + public function getTitle() : string { + $title = $this->titre ? $this->titre : $this->_settings->getTitle(); + + return $this->getTitlePicto() + ? $this->view->tag('div', + $title, + ['class' => 'title_sibling_picto']) + : $title; + } + + + public function getTitlePictoAsHtml() : string { + return ($title_picto = $this->getTitlePicto()) + ? $this->view->templateIco($title_picto) + : ''; } diff --git a/library/ZendAfi/View/Helper/Admin/TagEdit.php b/library/ZendAfi/View/Helper/Admin/TagEdit.php index 8768e20cef26365a7f6cf67efd3935deabf5e529..039a5c445033fc1f24d8d400f8c7311b97beb9a2 100644 --- a/library/ZendAfi/View/Helper/Admin/TagEdit.php +++ b/library/ZendAfi/View/Helper/Admin/TagEdit.php @@ -42,6 +42,9 @@ class ZendAfi_View_Helper_Admin_TagEdit extends ZendAfi_View_Helper_BaseHelper { if($model instanceof Class_Bib) return $this->view->tagEditLibrary($model); + if($model instanceof Class_Systeme_Widget_Widget) + return $this->view->tagEditWidget($model); + return ''; } } diff --git a/library/ZendAfi/View/Helper/BaseHelper.php b/library/ZendAfi/View/Helper/BaseHelper.php index efcdd4c3ae585b00bdd4b6b31b2ca3517b9ee4a7..7d3a53adffc16336ccc64111828196d5bcb9136c 100644 --- a/library/ZendAfi/View/Helper/BaseHelper.php +++ b/library/ZendAfi/View/Helper/BaseHelper.php @@ -108,7 +108,7 @@ class ZendAfi_View_Helper_BaseHelper extends Zend_View_Helper_HtmlElement { } - protected function _templateIco() { - return call_user_func_array([$this->view, 'templateIco'], func_get_args()); + 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/Template/Base.php b/library/ZendAfi/View/Helper/Template/Base.php index a961e97a717e6b029a403de4436f6eec800670ec..660e0ea7ee805c311e94eda7bd6e441de377ec40 100644 --- a/library/ZendAfi/View/Helper/Template/Base.php +++ b/library/ZendAfi/View/Helper/Template/Base.php @@ -47,7 +47,7 @@ class ZendAfi_View_Helper_Template_Base extends ZendAfi_View_Helper_BaseHelper { public function getHtml() { $closure = function() { $this->_initLegacyHtml(); - $html = []; + $html = $this->_getScrollAnchor(); if ($this->_widget->showHeader() && $header_html = $this->_getTitle()) @@ -96,10 +96,20 @@ class ZendAfi_View_Helper_Template_Base extends ZendAfi_View_Helper_BaseHelper { } - protected function _getTitle() { - return ($html = $this->_view_helper->getTitle()) - ? $html - : ''; + protected function _getScrollAnchor() : array { + if ( ! $id = $this->_view_helper->getScrollAnchorId()) + return []; + + return + [$this->view->div(['id' => $id, + 'class' => 'scroll_anchor sr-only'], + $this->view->screenReaderOnly($this->view->_('Ancrage pour faire défiler la page ici.')))]; + } + + + protected function _getTitle() : string { + return $this->_view_helper->getTitlePictoAsHtml() + . $this->_view_helper->getTitle(); } diff --git a/library/templates/Intonation/Library/FormCustomizer/Widget/Default.php b/library/templates/Intonation/Library/FormCustomizer/Widget/Default.php index d7974439a6406547f40fe9fa6228015fcaec5925..f1cf557de9789962dd0a8071488cb70aba22e325 100644 --- a/library/templates/Intonation/Library/FormCustomizer/Widget/Default.php +++ b/library/templates/Intonation/Library/FormCustomizer/Widget/Default.php @@ -37,7 +37,26 @@ class Intonation_Library_FormCustomizer_Widget_Default extends Intonation_Librar ->addExpertElement('checkbox', $this->_template->withNameSpace('show_footer'), ['label' => $this->_('Afficher le pied'), - 'value' => 1]); + 'value' => 1]) + + ->addExpertElement('text', + 'scroll_anchor_id', + ['label' => $this->_('Ancre de la boite'), + 'placeholder' => 'scroll_boite_agenda', + 'value' => '', + 'order' => 102, + 'allowEmpty' => true, + 'validators' => [(new Zend_Validate_Regex('/^[a-z0-9_\-]+$/i')) + ->setMessage($this->_('L\'ancre peut contenir des chiffres, des lettres, des tirets et des tirets bas'))]]) + + ->addElement('userfile', + 'title_picto', + ['label' => $this->_('Logo du titre'), + 'folder' => 'image', + 'order' => 101]) + + ->addToHeadGroup(['title_picto', + 'scroll_anchor_id']); $this->_addCustomElement(); @@ -49,6 +68,12 @@ class Intonation_Library_FormCustomizer_Widget_Default extends Intonation_Librar ->_addResponsiveGroupTo() ->_addControllerVisibilityGroupTo(); + $this->_form + ; + + $this->_form +; + return $this->_form; } diff --git a/library/templates/Intonation/Library/Menu/Articles/Definition.php b/library/templates/Intonation/Library/Menu/Articles/Definition.php index ad2ec72f6f7d1d8d471f07dddfc8fd46f9a29afc..ca2f1161bb067ab67fef8a3e84df919809163905 100644 --- a/library/templates/Intonation/Library/Menu/Articles/Definition.php +++ b/library/templates/Intonation/Library/Menu/Articles/Definition.php @@ -28,20 +28,28 @@ class Intonation_Library_Menu_Articles_Definition extends Class_Systeme_ModulesM } - public function getUrl($preferences = []) { - $use_profil = isset($preferences['use_profil']) - ? $preferences['use_profil'] - : null; + public function getUrl(array $preferences = []) : string { + $use_profil = $preferences['use_profil'] ?? null; + + if ( $use_profil && !Class_Profil::find($use_profil)) + $use_profil = null; $widget_context = $this->getWidgetContext(); - return Class_Url::relative(['module' => 'opac', - 'controller' => 'widget', - 'action' => 'render-menu-entry', - 'parent' => $widget_context->getParent(), - 'menu_profil' => $widget_context->getProfileId(), - 'menu' => $widget_context->getId(), - 'id_profil' => $use_profil], null, true); + $scroll_anchor = $preferences['scroll_anchor_id'] ?? ''; + + if ( $scroll_anchor) + $scroll_anchor = '#' . $scroll_anchor; + + return + Class_Url::relative(['module' => 'opac', + 'controller' => 'widget', + 'action' => 'render-menu-entry', + 'parent' => $widget_context->getParent(), + 'menu_profil' => $widget_context->getProfileId(), + 'menu' => $widget_context->getId(), + 'id_profil' => $use_profil]) + . $scroll_anchor; } diff --git a/library/templates/Intonation/Library/Selection.php b/library/templates/Intonation/Library/Selection.php index 29a839fd8cf7a5ab61ba535465684839d9a2ab5e..7ff3a022d153b59737f6ad5b20148a59323e5207 100644 --- a/library/templates/Intonation/Library/Selection.php +++ b/library/templates/Intonation/Library/Selection.php @@ -34,12 +34,12 @@ class Intonation_Library_Selection extends Class_Entity { } - public function getTitle() { - return $this->get('Title'); + public function getTitle() : string { + return (string) $this->get('Title'); } - protected function _getImageForContext() { + protected function _getImageForContext() : string { return $this->_isIn() ? $this->getImage() : $this->getRevertImage(); @@ -136,13 +136,13 @@ class Intonation_Library_Selection extends Class_Entity { } - public function getRevertImage() { - return $this->get('RevertImage'); + public function getRevertImage() : string { + return (string) $this->get('RevertImage'); } - public function getImage() { - return $this->get('Image'); + public function getImage() : string { + return (string) $this->get('Image'); } diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 35ddda527e6474dd35420e7614faba0c9a41f493..1481b84268bafa2cf77df690bfb998a4bfd5f882 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -346,6 +346,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'span class warning' => 'badge-warning text-dark', 'a class browse_shelf' => 'badge-secondary', 'div class items_shelf' => 'col-12', + 'div class title_sibling_picto' => 'd-inline-block', ], 'icons_map_doc_types' => [], diff --git a/library/templates/Intonation/View/RenderOverlay.php b/library/templates/Intonation/View/RenderOverlay.php index 7d80486ed11978c659a41356b0dd7f0b37c15aa2..921c79dd727f347e3485f1077cb7988e8836fc6d 100644 --- a/library/templates/Intonation/View/RenderOverlay.php +++ b/library/templates/Intonation/View/RenderOverlay.php @@ -38,7 +38,7 @@ class Intonation_View_RenderOverlay extends ZendAfi_View_Helper_BaseHelper { $element->getSecondaryIco() . $this->view->div(['class' => 'd-inline'], $author_name)); - $doc_type = $this->_templateIco($element->getDocTypeLabel(), + $doc_type = $this->_templateIco((string) $element->getDocTypeLabel(), 'doc_types', ['class' => 'ico_xl doc_type_' . $element->getDocType()]); diff --git a/library/templates/Intonation/View/TemplateIco.php b/library/templates/Intonation/View/TemplateIco.php index d27f0ed28c9d67793cb2f18639acfafebfd132d4..599f63d3b881d04f062114c74eb6cb25bdf3554f 100644 --- a/library/templates/Intonation/View/TemplateIco.php +++ b/library/templates/Intonation/View/TemplateIco.php @@ -21,7 +21,8 @@ class Intonation_View_TemplateIco extends ZendAfi_View_Helper_BaseHelper { - public function templateIco($key, $category, $attribs = []) { + + public function templateIco(string $key, string $category = '', array $attribs = []) : string { return Class_Template::current()->getIco($this->view, $key, $category, $attribs); } } diff --git a/public/opac/css/core.css b/public/opac/css/core.css index ab74c529eb1969c3c9bb3ebc4ed79665089a836a..bbf65e04a5bb7539da11c22a79d080a625ddbf91 100644 --- a/public/opac/css/core.css +++ b/public/opac/css/core.css @@ -220,3 +220,8 @@ body[data-admin_level=""] [data-level="expert"] { .navbar_collapse_always > .navbar-header > .navbar-toggler { display: block; } + +.scroll_anchor.sr-only { + top: 0; + left: 0; +} diff --git a/tests/application/modules/admin/controllers/FileManagerControllerTest.php b/tests/application/modules/admin/controllers/FileManagerControllerTest.php index fd66de6876c1a18cef45fb76144b8bcdeb5d527f..2195badbbb5f3ba917b59403cd59eae3823e693a 100644 --- a/tests/application/modules/admin/controllers/FileManagerControllerTest.php +++ b/tests/application/modules/admin/controllers/FileManagerControllerTest.php @@ -2286,3 +2286,140 @@ class FileManagerControllerWithImageInLibraryTest extends FileManagerControllerT $this->assertXpath('//table//td//a[@href="/admin/bib/edit?id=1"]'); } } + + + + +class FileManagerControllerWithImageInWidgetTest extends FileManagerControllerTestCase { + + public function setUp() { + parent::setUp(); + $profile = $this->_buildTemplateProfil(['id' => 789]); + + $profile_patcher = (new Class_Template_ProfilePatcher(null)) + ->setProfile($profile) + ->addWidget(Intonation_Library_Widget_Carousel_Library_Definition::CODE, + Class_Profil::DIV_MAIN, + ['titre' => 'Réseau', + 'title_picto' => '/userfiles/image/home.png']) + ->addWidget(Intonation_Library_Widget_Carousel_Agenda_Definition::CODE, + Class_Profil::DIV_MAIN, + ['titre' => 'Agenda', + 'title_picto' => 'class fas fa-home']) + ->addWidget(Intonation_Library_Widget_Carousel_Newsletter_Definition::CODE, + Class_Profil::DIV_MAIN, + ['titre' => 'Abonnez-vous']) + ->addWidget(Intonation_Library_Widget_Image_Definition::CODE, + Class_Profil::DIV_MAIN, + ['titre' => 'Bannière', + 'image' => '/userfiles/image/home.png']); + + $disk = Class_FileManager::getFileSystem() + ->whenCalled('rename') + ->with('userfiles/image/home.png', 'userfiles/image/network.png') + ->answers(true) + + ->whenCalled('directoryAt') + ->with('userfiles/image/home.png') + ->answers(null) + + ->whenCalled('fileAt') + ->with('userfiles/image/home.png') + ->answers((new Class_FileManager) + ->setId('userfiles/image/home.png') + ->setPath('userfiles/image/home.png') + ->setParentPath('userfiles/image') + ->setName('home.png') + ->setDir(false) + ->setWritable(true) + ->setExtension('png')); + } + + + /** @test */ + public function dispatchDeleteShouldDisplayDisabledDeleteButton() { + $this->dispatch('/admin/file-manager/delete?item=userfiles%2Fimage%2Fhome.png'); + $this->assertXPathContentContains('//div//button[@disabled]', 'Supprimer'); + } + + + /** @test */ + public function dispatchForceDeleteShouldRedirectWithErrorMessage() { + $this->dispatch('/admin/file-manager/force-delete?item=userfiles%2Fimage%2Fhome.png'); + $this->assertRedirect(''); + $this->assertFlashMessengerContentContains('Impossible de supprimer "userfiles/image/home.png'); + } + + + /** @test */ + public function dispatchDeleteShouldDisplayAnchorToEditWidget() { + $this->dispatch('/admin/file-manager/delete?item=userfiles%2Fimage%2Fhome.png'); + $this->assertXPath('//table//td//a[contains(@href, "/admin/widget/edit-widget?id=1&id_profil=789")]'); + } + + + /** @test */ + public function dispatchDeleteShouldDisplayTdTypeBoiteDesBibliotheques() { + $this->dispatch('/admin/file-manager/delete?item=userfiles%2Fimage%2Fhome.png'); + $this->assertXPathContentContains('//div//table//td', + 'Boite des bibliothèques'); + } + + + /** @test */ + public function dispatchDeleteShouldDisplayTdTitleReseau() { + $this->dispatch('/admin/file-manager/delete?item=userfiles%2Fimage%2Fhome.png'); + $this->assertXPathContentContains('//div//table//td', + 'Réseau'); + } + + + /** @test */ + public function dispatchDeleteShouldNotDisplayTdTitleAgenda() { + $this->dispatch('/admin/file-manager/delete?item=userfiles%2Fimage%2Fhome.png'); + $this->assertNotXPathContentContains('//div[@class="modules"]', 'Agenda'); + } + + + /** @test */ + public function dispatchDeleteShouldNotDisplayTdTitleAbonnezVous() { + $this->dispatch('/admin/file-manager/delete?item=userfiles%2Fimage%2Fhome.png'); + $this->assertNotXPathContentContains('//div[@class="modules"]', 'Abonnez-vous'); + } + + + /** @test */ + public function renameHomeImageShouldUpdateWidgetReseauTitlePicto() { + $this->postDispatch('/admin/file-manager/rename?item=userfiles%2Fimage%2Fhome.png', + ['name' => 'network']); + Class_Profil::clearCache(); + $this->assertEquals('/userfiles/image/network.png', + (new Class_Systeme_Widget_Widget) + ->setId(1) + ->setProfileId(789) + ->load() + ->getTitlePicto()); + } + + + /** @test */ + public function dispatchDeleteShouldDisplayTdTitleBanniere() { + $this->dispatch('/admin/file-manager/delete?item=userfiles%2Fimage%2Fhome.png'); + $this->assertXPathContentContains('//div//table//td', + 'Bannière'); + } + + + /** @test */ + public function renameHomeImageShouldUpdateWidgetBanniereImage() { + $this->postDispatch('/admin/file-manager/rename?item=userfiles%2Fimage%2Fhome.png', + ['name' => 'network']); + Class_Profil::clearCache(); + $this->assertEquals('/userfiles/image/network.png', + (new Class_Systeme_Widget_Widget) + ->setId(4) + ->setProfileId(789) + ->load() + ->getImage()); + } +} \ No newline at end of file diff --git a/tests/scenarios/Templates/ChiliLoginTest.php b/tests/scenarios/Templates/ChiliLoginTest.php index 09543a17ed00ebee282e59a1bcfa0e7af545c6c2..ddd188a52860f71f98dccc31176f944cb4b1ce6e 100644 --- a/tests/scenarios/Templates/ChiliLoginTest.php +++ b/tests/scenarios/Templates/ChiliLoginTest.php @@ -83,6 +83,20 @@ class ChiliLoginWidgetAdminFormsTest extends ChiliLoginWidgetTestCase { } + /** @test */ + public function inputScrollAnchorIdShouldBeText() { + $this->dispatch('/admin/widget/edit-widget/id/1/id_profil/4'); + $this->assertXpath('//input[@name="scroll_anchor_id"][@type="text"]'); + } + + + /** @test */ + public function inputTitleImageShouldBeText() { + $this->dispatch('/admin/widget/edit-widget/id/1/id_profil/4'); + $this->assertXpath('//input[@name="title_picto"][@type="text"]'); + } + + /** @test */ public function pageShouldContainsFormWithNotAuthenticatedMenuSelectorWithHomeSubmenu() { $this->dispatch('/admin/widget/edit-widget/id/1/id_profil/4'); diff --git a/tests/scenarios/Templates/TemplatesMenuTest.php b/tests/scenarios/Templates/TemplatesMenuTest.php index 2019e2d426ec659896e3e3e3bb1ca339cc14c5d9..2b3d7a55dc6b9c68036f13654a9716a93c514394 100644 --- a/tests/scenarios/Templates/TemplatesMenuTest.php +++ b/tests/scenarios/Templates/TemplatesMenuTest.php @@ -26,7 +26,13 @@ class TemplatesMenuDispatchEditMenuHTest extends TemplatesIntonationTestCase { public function setUp() { parent::setUp(); Class_Profil::setCurrentProfil(Class_Profil::find(2)); - $this->dispatch('/admin/widget/edit-menu/id/H/id_profil/72', true); + $this->dispatch('/admin/widget/edit-menu/id/H/id_profil/72'); + } + + + /** @test */ + public function inputTextScrollAnchorTargetShouldNotBePresent() { + $this->assertNotXpath('//input[@name="scroll_anchor_target"]'); } @@ -56,6 +62,7 @@ class TemplatesMenuDispatchEditMenuHTest extends TemplatesIntonationTestCase { + abstract class TemplatesMenuUrlTestCase extends TemplatesIntonationTestCase { public function setUp(){ parent::setUp(); @@ -68,7 +75,18 @@ abstract class TemplatesMenuUrlTestCase extends TemplatesIntonationTestCase { 'libelle' => 'url de lien vers site', 'picto' => 'toto.gif', 'preferences' => ['url'=>'http://www.framasoft.org/'] - ]]]); + ], + ['type_menu' => 'PROFIL', + 'libelle' => 'agenda', + 'picto' => 'toto.gif', + 'preferences' => ['clef_profil' => '2', + 'scroll_anchor_target' => 'scroll_to_agenda']], + ['type_menu' => 'NEWS', + 'libelle' => 'Carnaval', + 'picto' => 'carnaval.svg', + 'preferences' => ['id_items' => '1', + 'use_profil' => '890797987987789', + 'scroll_anchor_id' => 'scroll_to_carnaval']]]]); } } @@ -76,13 +94,19 @@ abstract class TemplatesMenuUrlTestCase extends TemplatesIntonationTestCase { class TemplatesMenuUrlFormTest extends TemplatesMenuUrlTestCase { + public function setUp() { parent::setUp(); - $this->dispatch('/admin/widget/edit-menu/id/0/id_profil/72/parent/H'); } + /** @test */ + public function inputTextScrollAnchorTargetShouldNotBePresent() { + $this->assertNotXpath('//input[@name="scroll_anchor_target"]'); + } + + /** @test */ public function inputUrlShouldContainsFramasoftDotOrg() { $this->assertXPath('//input[@id="url"][@value="http://www.framasoft.org/"]'); @@ -203,9 +227,6 @@ class TemplatesMenuUrlProfilTestCase extends TemplatesIntonationTestCase { class TemplatesMenuDisplayTwoTimesTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - - public function setUp() { parent::setUp(); @@ -224,6 +245,8 @@ class TemplatesMenuDisplayTwoTimesTest extends Admin_AbstractControllerTestCase ZendAfi_Auth::getInstance()->logUser($user); + $this->fixture(Class_Profil::class, ['id' => 55]); + $profile = $this->_buildTemplateProfil(['id' => 1]); (new Class_Profil_Import($profile)) @@ -246,7 +269,6 @@ class TemplatesMenuDisplayTwoTimesTest extends Admin_AbstractControllerTestCase } - /** @test */ public function loginWidgetInMenuShouldNotBeCached() { $this->dispatch('/index'); @@ -595,9 +617,6 @@ class TemplatesMenuWithSubmenuTest extends TemplatesMenuTestCase { class TemplatesMenuDisplayWithArticlesListTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - - public function setUp() { parent::setUp(); @@ -607,6 +626,7 @@ class TemplatesMenuDisplayWithArticlesListTest extends Admin_AbstractControllerT (new Class_Profil_Import($profile)) ->import(__DIR__ . '/140106_profile_with_menu_with_articles_list.json'); + $this->fixture(Class_Profil::class, ['id' => 146]); $this->dispatch('/index'); } @@ -614,7 +634,7 @@ class TemplatesMenuDisplayWithArticlesListTest extends Admin_AbstractControllerT /** @test */ public function linkToRenderMenuEntryMediavueEtHandicapShouldContainsParent3AndMenu5() { - $this->assertXPathContentContains('//a[@href="/widget/render-menu-entry/parent/3/menu_profil/1/menu/5/id_profil/146"]', 'Médiavue et handicap', $this->_response->getBody()); + $this->assertXPathContentContains('//a[@href="/widget/render-menu-entry/parent/3/menu_profil/1/menu/5/id_profil/146"]', 'Médiavue et handicap'); } @@ -704,3 +724,45 @@ class TemplatesMenuRenderMenuEntryTemplateSettingsTest extends Admin_AbstractCon 'facebook'); } } + + + + +class TemplatesMenuProfilEditionTest extends TemplatesMenuUrlTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/widget/edit-menu/id/1/id_profil/72/parent/H'); + } + + + /** @test */ + public function inputTextScrollAnchorTargetIdShouldBePresent() { + $this->assertXpath('//input[@name="scroll_anchor_target"][@type="text"]'); + } +} + + + + +class TemplatesMenuProfilWithScrollToAgendaTest extends TemplatesMenuUrlTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/index/index/id_profil/72'); + } + + + /** @test */ + public function linkAgendaInNavShouldContainsUrlIndexIndexProfilTwoSharpScrollToAgenda() { + $this->assertXpathContentContains('//nav//ul//li//a[@href="/index/index/id_profil/2#scroll_to_agenda"]', + 'agenda'); + } + + + /** @test */ + public function linkToCarnavalInNavShouldContainsUrlProfilTwoSharpScrollToAgenda() { + $this->assertXpathContentContains('//nav//ul//li//a[@href="/widget/render-menu-entry/parent/H/menu_profil/72/menu/2#scroll_to_carnaval"]', + 'carnaval'); + } +} diff --git a/tests/scenarios/Templates/TemplatesSearchTest.php b/tests/scenarios/Templates/TemplatesSearchTest.php index a28f54ea883ef3f2858ed465df31c235eebde632..3b8f2709401107426dd005c2dc2a71ebc077dda5 100644 --- a/tests/scenarios/Templates/TemplatesSearchTest.php +++ b/tests/scenarios/Templates/TemplatesSearchTest.php @@ -1221,8 +1221,6 @@ class TemplatesSearchResultWithSearchTermHighLightedTest extends AbstractControl class TemplatesSearchEditActionTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - public function setUp() { parent::setUp(); @@ -1254,9 +1252,6 @@ class TemplatesSearchEditActionTest extends Admin_AbstractControllerTestCase { class TemplatesSearchHighlightCollectionTest extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - - public function setUp() { parent::setUp(); diff --git a/tests/scenarios/Templates/TemplatesWidgetTest.php b/tests/scenarios/Templates/TemplatesWidgetTest.php index c9a6ec0d93db27a6b1e8da58bc80c1ff0934244d..606e10d1fee99efdc20bbabaabe5de672d69ce1a 100644 --- a/tests/scenarios/Templates/TemplatesWidgetTest.php +++ b/tests/scenarios/Templates/TemplatesWidgetTest.php @@ -56,6 +56,20 @@ class TemplatesWidgetsNewsletterTest extends TemplatesIntonationTestCase { $this->assertXPathContentContains('//a[@class="disable_all_newsletters btn-warning btn btn-sm"][@href="/abonne/disable-newsletter"]', 'Ne plus recevoir de lettre d\'information'); } + + + /** @test */ + public function inputScrollAnchorIdShouldBeText() { + $this->dispatch('/admin/widget/edit-widget/id/25/id_profil/72'); + $this->assertXpath('//input[@name="scroll_anchor_id"][@type="text"]'); + } + + + /** @test */ + public function inputTitleImageShouldBeText() { + $this->dispatch('/admin/widget/edit-widget/id/25/id_profil/72'); + $this->assertXpath('//input[@name="title_picto"][@type="text"]'); + } } @@ -1938,3 +1952,33 @@ class TemplatesWidgetEditUnknownWidgetTest extends TemplatesIntonationTestCase { $this->assertFlashMessengerContentContains('Impossible de configurer l\'élément'); } } + + + + +class TemplatesWidgetWithTopHighlightLayoutLogoTitleAndScrollAnchorIdTest extends AbstractTemplatesWidgetWithHighlightLayoutTest { + + protected function _widgetSettings() { + return ['rendering' => 'card', + 'title_picto' => 'class fas fa-home', + 'scroll_anchor_id' => 'ma_super_boite', + 'cycle' => 2, + 'order' => Class_Systeme_ModulesAccueil_Library::ORDER_ALPHA, + 'libraries' => implode(';', array_keys($this->_libraries)), + 'layout' => 'top_highlight_carousel']; + } + + + /** @test */ + public function boiteLibraryTitleShouldContainsIClassFasFaHome() { + $this->assertXPathContentContains('//div[@class="boite library widget col-12 card"]//div[@class="widget-header card-header"]//i[@class="fas fa-home"]/following-sibling::div[@class="title_sibling_picto d-inline-block"]', + 'Boite des bibliothèques'); + } + + + /** @test */ + public function boiteLibraryShouldContainsAnchorMaSuperBoite() { + $this->assertXPathContentContains('//div[@class="boite library widget col-12 card"]/div[@id="ma_super_boite"][@class="scroll_anchor sr-only"][1]/span[@class="sr-only"]', + 'Ancrage pour faire défiler la page ici.'); + } +} \ No newline at end of file