diff --git a/VERSIONS_WIP/156519 b/VERSIONS_WIP/156519 new file mode 100644 index 0000000000000000000000000000000000000000..2a3aafe838a9bbad623671edd068938b4c444293 --- /dev/null +++ b/VERSIONS_WIP/156519 @@ -0,0 +1,6 @@ + - fonctionnalité #156519 : Magasin de thèmes : ajout d'un nouveau paramètre + Bokeh 2022_05_improve_thumbnail_rendering.css dans + la configuration des thèmes. + Activer ce paramètre dans la configation de votre thème, + vous permet d'importer les améliorations de rendu sur + les vignettes. \ No newline at end of file diff --git a/library/Class/Template.php b/library/Class/Template.php index b650038d37ba240090a68aa014ec389c52ef2f8e..f23046172bc98db64047094f748f0a0f10b96ef3 100644 --- a/library/Class/Template.php +++ b/library/Class/Template.php @@ -21,9 +21,11 @@ class Class_Template { + use Trait_Translator, - Trait_StaticFileWriter; + Trait_StormFileSystem; + protected static $_instance; @@ -726,4 +728,10 @@ class Class_Template { public function shouldHighlightRecords() : bool { return (bool) Class_AdminVar::isSearchTermHighlightedEnabled(); } -} + + + public function getCssPatchsFiles() : array { + $files_names = $this->getFileSystem()->fileNamesAt(TEMPLATES_CSS_PATCHS); + return array_combine($files_names, $files_names); + } +} \ No newline at end of file diff --git a/library/Class/Template/NullPatcher.php b/library/Class/Template/NullPatcher.php index 9a0cc15304cc184d094659253c7fd16505616404..8e69681f63ea856a48e7802c3f83aecd520a81a6 100644 --- a/library/Class/Template/NullPatcher.php +++ b/library/Class/Template/NullPatcher.php @@ -26,7 +26,7 @@ class Class_Template_NullPatcher { } - public function upgrade($profile) { + public function upgrade(Class_Profil $profile) { return $profile; } } diff --git a/library/Trait/StormFileSystem.php b/library/Trait/StormFileSystem.php index 83a9bf76db7cc8ca8501fe25decc7529262abb70..aecf475ccde1891d6c8e762525833c844ac110f6 100644 --- a/library/Trait/StormFileSystem.php +++ b/library/Trait/StormFileSystem.php @@ -31,6 +31,6 @@ trait Trait_StormFileSystem { public static function getFileSystem() { if (null !== self::$_file_system) return self::$_file_system; - return new Storm_FileSystem_Disk(); + return new Storm_FileSystem_Disk; } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Template/NavbarToggler.php b/library/ZendAfi/View/Helper/Template/NavbarToggler.php new file mode 100644 index 0000000000000000000000000000000000000000..f2b99582ffeb9877b2661d99873938016e694a00 --- /dev/null +++ b/library/ZendAfi/View/Helper/Template/NavbarToggler.php @@ -0,0 +1,33 @@ +<?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 ZendAfi_View_Helper_Template_NavbarToggler extends ZendAfi_View_Helper_BaseHelper { + public function navbarToggler(string $text) : string { + return + $this->_tag('span', + $this->view->screenReaderOnly($this->_('Afficher ou masquer le menu')), + ['class' => 'navbar-toggler-icon']) + . $this->_tag('span', + $text, + ['class' => 'navbar_toggler_text']); + } +} diff --git a/library/startup.php b/library/startup.php index 79f809c1abb8513d13a804c65c066c0a0393cfbc..93122f6d7c15a33b6634dddd24522de43f662bb2 100644 --- a/library/startup.php +++ b/library/startup.php @@ -186,6 +186,7 @@ class Bokeh_Engine { defineConstant('MEMCACHED_PORT', '11211'); defineConstant('IMAGE_MAGICK_PATH', 'convert'); defineConstant('THUMBNAIL_FIT_WIDTH_HEIGHT', '500'); + defineConstant('TEMPLATES_CSS_PATCHS', ROOT_PATH . "public/opac/css/templates_patchs/"); defineConstant('PATCH_PATH', ROOT_PATH . 'cosmogramme/sql/patch/'); defineConstant('GIT_REALTIME',false); diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index 1a4942b6aa4ea7088dc28cd8bfb0140de9b04839..57cce60cfc64c1cd390112c3dbdea8f4159fc77d 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -1140,3 +1140,7 @@ button.view_more_record_actions, margin: 2em 4em 3em 2em; line-height: 1.8em; } + +.navbar_toggler_text { + display: none; +} diff --git a/library/templates/Intonation/Library/FormCustomizer/Template.php b/library/templates/Intonation/Library/FormCustomizer/Template.php index 45b401ca9f928d161d441887240a57d1ff8133a6..b81b2b5e2d62a47b472317233fdad76e8949bb88 100644 --- a/library/templates/Intonation/Library/FormCustomizer/Template.php +++ b/library/templates/Intonation/Library/FormCustomizer/Template.php @@ -36,6 +36,11 @@ class Intonation_Library_FormCustomizer_Template extends Intonation_Library_Form $this->_template->withNameSpace('intonation_css'), ['label' => $this->_('Intonation.css')]) + ->addElement('multiCheckbox', + $this->_template->withNameSpace('css_patchs'), + ['label' => $this->_('Améliorations CSS'), + 'multiOptions' => $this->_template->getCssPatchsFiles()]) + ->addElement('checkbox', $this->_template->withNameSpace('font_awesome_css'), ['label' => $this->_('FontAwesome 5.15.2 Free')]) @@ -103,6 +108,7 @@ class Intonation_Library_FormCustomizer_Template extends Intonation_Library_Form $this ->_addToTemplateGroup(['core_css', + 'css_patchs', 'core_js', 'intonation_css', 'font_awesome_css', diff --git a/library/templates/Intonation/Library/ProfilePatcher.php b/library/templates/Intonation/Library/ProfilePatcher.php index a055e626089f654d9273d34e4a366886a24433d9..f9f49b450ed18f17003bad2c5ee7b2783228b7ec 100644 --- a/library/templates/Intonation/Library/ProfilePatcher.php +++ b/library/templates/Intonation/Library/ProfilePatcher.php @@ -20,8 +20,8 @@ */ -class Intonation_Library_ProfilePatcher extends Class_Template_ProfilePatcher { - +class Intonation_Library_ProfilePatcher extends Class_Template_ProfilePatcher +{ protected $_menu_id, @@ -45,11 +45,12 @@ class Intonation_Library_ProfilePatcher extends Class_Template_ProfilePatcher { $_full_and_tier_responsive_pack; - public function upgrade($profile) { + public function upgrade(Class_Profil $profile) { $this->_profile = $profile; $this->_profile_id = $profile->getId(); $this + ->_upgradeTemplateSettings() ->_generateDefaultsPacks() ->_clearCache() ->_upgradeProfile() @@ -67,6 +68,25 @@ class Intonation_Library_ProfilePatcher extends Class_Template_ProfilePatcher { } + protected function _upgradeTemplateSettings() : self { + $settings = $this->_template->getSettingsInstance(); + $settings_to_array = $settings + ->getSettingsInstance() + ->toArray(); + + $attributes = + array_merge($settings_to_array, + [$this->_template->withNameSpace('css_patchs') => + $this->_template->getCssPatchsFiles()]); + + $this->_template + ->updateAttributes($attributes) + ->save(); + + return $this; + } + + protected function _getOrCreateStylePack($label, $data) { return Class_StylesPack::getOrCreate($label, $data, diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 7167a795b3a601a9144387551266ce419058c5a5..fb9e24849feabddd51724aa553aa60eb360c601e 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -25,6 +25,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { protected $_template, $_default_settings = ['core_css' => 1, + 'css_patchs' => [], 'core_js' => 1, 'font_awesome_css' => 1, 'jquery' => 1, diff --git a/library/templates/Intonation/Library/Styles.php b/library/templates/Intonation/Library/Styles.php index 467a0328aaa47b0529057a0854f7c2924809822e..6890391465aacd78f03ec8b740ef12133d45273f 100644 --- a/library/templates/Intonation/Library/Styles.php +++ b/library/templates/Intonation/Library/Styles.php @@ -33,6 +33,7 @@ class Intonation_Library_Styles { $this->bootstrapCssUrl(), $this->bootstrapRgaaCssUrl(), $this->coreCssUrl()]); + $css->addAll($this->cssPatchsUrls()); $css->addAll($this->templateCssUrls()); $css->addAll($this->customCssUrls()); $css->add($this->profileHeaderCssUrl()); @@ -82,6 +83,16 @@ class Intonation_Library_Styles { } + public function cssPatchsUrls() : array { + $css = []; + foreach($this->_template->getCssPatchs() as $css_file_name) + $css [] = (Class_ScriptLoader::getInstance() + ->opacStyleSheetUrlFor(BASE_URL . TEMPLATES_CSS_PATCHS . $css_file_name)); + + return $css; + } + + public function profileHeaderCssUrl() { return ($profile_css = $this->getProfileHeaderCss()) ? $profile_css diff --git a/library/templates/Intonation/View/Menu/Abstract.php b/library/templates/Intonation/View/Menu/Abstract.php index ea68ae2fb4f83a7d31c4a68d4a2dc849f2295577..80c97c0621be488a040be9e7bda4b4bcb1b8e557 100644 --- a/library/templates/Intonation/View/Menu/Abstract.php +++ b/library/templates/Intonation/View/Menu/Abstract.php @@ -87,9 +87,8 @@ abstract class Intonation_View_Menu_Abstract extends Intonation_View_Abstract_La protected function _renderSandwich() { return $this->_tag('button', - $this->_tag('span', $this->view->screenReaderOnly($this->_('Afficher ou masquer le menu')) - , ['class' => 'navbar-toggler-icon']), - ['class' => 'navbar-light navbar-toggler collapsed', + $this->view->navbarToggler($this->_('Menu')), + ['class' => 'navbar-light text-dark navbar-toggler collapsed', 'type' => 'button', 'data-toggle' => 'collapse', 'data-target' => '#navbar_' . $this->_settings->getIdModule() . '_' . $this->_menu_id]); diff --git a/library/templates/Intonation/View/Opac.php b/library/templates/Intonation/View/Opac.php index 8dd277bc4a7046239020c67058439bb5e3f20c5f..8fb6382755d3ad31b8a02464eeba0f1fbecb7d9a 100644 --- a/library/templates/Intonation/View/Opac.php +++ b/library/templates/Intonation/View/Opac.php @@ -172,6 +172,9 @@ class Intonation_View_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 ($template_css = $this->_styles->templateCssUrls()) $head_scripts->addStyleSheets($template_css); diff --git a/library/templates/Intonation/View/RenderExpandable.php b/library/templates/Intonation/View/RenderExpandable.php index 7bb36a47db2a7a6eca396c6d80f4377c83c251ca..4235a032ec357756b78ef63cfb4ed3a375565630 100644 --- a/library/templates/Intonation/View/RenderExpandable.php +++ b/library/templates/Intonation/View/RenderExpandable.php @@ -44,13 +44,11 @@ class Intonation_View_RenderExpandable extends ZendAfi_View_Helper_BaseHelper { $button = $button ? $button - : $this->_tag('span', '', ['class' => 'navbar-toggler-icon', - 'aria-hidden' => 'true' - ]); + : $this->view->navbarToggler(); return $this->_tag('button', $button, - ['class' => 'navbar-toggler navbar-light mb-2', + ['class' => 'navbar-toggler navbar-light text-dark mb-2', 'type' => 'button', 'data-toggle' => 'collapse', 'data-target' => '#' . $id]); diff --git a/library/templates/Intonation/View/Search/Result.php b/library/templates/Intonation/View/Search/Result.php index e5108d64be17997dab4f3f2ce8c0c9c905e17501..93b619d12d45facc2f5bf292aef53e8ead2f4e58 100644 --- a/library/templates/Intonation/View/Search/Result.php +++ b/library/templates/Intonation/View/Search/Result.php @@ -169,7 +169,9 @@ class Intonation_View_Search_Result extends ZendAfi_View_Helper_BaseHelper { protected function _renderFacets($facets_column_content) { - return $this->view->renderExpandable($facets_column_content); + return + $this->view->renderExpandable($facets_column_content, + $this->view->navbarToggler($this->_('Les filtres'))); } diff --git a/public/opac/css/templates_patchs/2022_05_improve_thumbnail_rendering.css b/public/opac/css/templates_patchs/2022_05_improve_thumbnail_rendering.css new file mode 100644 index 0000000000000000000000000000000000000000..42a7db597521f5e53cc9c3334c043906caf7a053 --- /dev/null +++ b/public/opac/css/templates_patchs/2022_05_improve_thumbnail_rendering.css @@ -0,0 +1,29 @@ +.carousel-inner { + width: 90%; + margin: auto; +} + +.jumbotron .nav-link .jumbotron_nav_tab_text { + font-size: 12px; +} + +body .navbar_toggler_text { + display: inline-block; + vertical-align: middle; +} + +img.card-img, +img.img-thumbnail, +div.record_no_thumbnail { + height: 180px; + object-fit: cover; + width: auto; +} + +@media (min-width: 1200px) { + img.card-img, + img.img-thumbnail, + div.record_no_thumbnail { + height: 300px; + } +} diff --git a/tests/scenarios/Templates/ChiliSearchTest.php b/tests/scenarios/Templates/ChiliSearchTest.php index 8863e5d297bead157f0bdeaf6c764859edb61301..1690a112eac1d4057559febe2bb111ee3dedbb18 100644 --- a/tests/scenarios/Templates/ChiliSearchTest.php +++ b/tests/scenarios/Templates/ChiliSearchTest.php @@ -153,6 +153,12 @@ class ChiliSearchHoldLinkNoSIGBTest extends AbstractControllerTestCase { } + /** @test */ + public function facetsShouldContainsNavbarTogglerTextLesFiltres() { + $this->assertXPathContentContains('//div[@class="search_facets_col col-12 col-md-3 order-5"]//button[@class="navbar-toggler navbar-light text-dark mb-2 btn btn-secondary"]/span[@class="navbar_toggler_text"]', 'Les filtres'); + } + + /** @test */ public function pageShouldBeHTML5Valid() { $this->assertHTML5(); diff --git a/tests/scenarios/Templates/CssPatchsTest.php b/tests/scenarios/Templates/CssPatchsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f2ce3b1aaf25e4ead486557d3cc0a2c44473a21f --- /dev/null +++ b/tests/scenarios/Templates/CssPatchsTest.php @@ -0,0 +1,103 @@ +<?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 CssPatchsAdminTemplateEditExistingProfile202205Test extends Admin_AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 78, + 'template' => 'MUSCLE']); + + $this->dispatch('/admin/template/edit/template/MUSCLE'); + } + + + /** @test */ + public function cssFile202205ImproveThumbnailRenderingCssShouldNotBeChecked() { + $this->assertXPath('//div//form//input[@type="checkbox"][@name="MuscleCssPatchs[]"][not(@checked)][@value="2022_05_improve_thumbnail_rendering.css"]'); + } +} + + + + +class CssPatchsAdminTemplateEditNewTemplate202205Test extends Admin_AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + $profile = $this->_buildTemplateProfil(['id' => 78]); + + (new Muscle_Template)->tryOn($profile); + + $this->dispatch('/admin/template/edit/template/MUSCLE'); + } + + + /** @test */ + public function cssFile202205ImproveThumbnailRenderingCssShouldBeChecked() { + $this->assertXPath('//div//form//input[@type="checkbox"][@name="MuscleCssPatchs[]"][@checked][@value="2022_05_improve_thumbnail_rendering.css"]'); + } +} + + + + +class CssPatchsIndexNewTemplate202205Test extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + $profile = $this->_buildTemplateProfil(['id' => 78]); + $id = (new Muscle_Template)->tryOn($profile); + $this->dispatch('/index/index/id_profil/' . $id); + } + + + /** @test */ + public function cssFile202205ImproveThumbnailRenderingCssShouldBeLinked() { + $this->assertXPath('//head//link[contains(@href, "/public/opac/css/templates_patchs/2022_05_improve_thumbnail_rendering.css?v")]'); + } + + + /** @test */ + public function menuShouldContainsNavbarTogglerTextMenu() { + $this->assertXPathContentContains('//div[@class="boite menu no_border no_border_radius no_shadow justify-content-start menu_buttons widget col-6 card"]//button[@class="navbar-light text-dark navbar-toggler collapsed btn btn-secondary"]/span[@class="navbar_toggler_text"]', + 'Menu'); + } +} + + + + +class CssPatchsIndexOldTemplate202205Test extends Admin_AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + $this->_buildTemplateProfil(['id' => 78, + 'template' => 'MUSCLE']); + $this->dispatch('/index'); + } + + + /** @test */ + public function cssFile202205ImproveThumbnailRenderingCssShouldBeNotBeLinked() { + $this->assertNotXPath('//head//link[contains(@href, "2022_05_improve_thumbnail_rendering")]'); + } +} \ No newline at end of file diff --git a/tests/scenarios/Templates/MuscleTemplateTest.php b/tests/scenarios/Templates/MuscleTemplateTest.php index 57ed718f826e83052de67eca21fa2e37d698dcf9..9c45d17b93a338bc22fde8f16b40e3012d30f131 100644 --- a/tests/scenarios/Templates/MuscleTemplateTest.php +++ b/tests/scenarios/Templates/MuscleTemplateTest.php @@ -596,4 +596,4 @@ class MuscleTemplateNotLoggedTest extends MuscleTemplateTestCase { public function inputLoginShouldBeHydratedWithOrder3() { $this->assertXPath('//form/input[@id="login"][@class= "zendafi_form_login_login btn btn-sm btn-primary order-3 my-3"]'); } -} +} \ No newline at end of file