diff --git a/VERSIONS_WIP/156612 b/VERSIONS_WIP/156612 new file mode 100644 index 0000000000000000000000000000000000000000..fe771efbf553ea1e37aac5d8f90938ea2ab589a1 --- /dev/null +++ b/VERSIONS_WIP/156612 @@ -0,0 +1 @@ + - fonctionnalité #156612 : Magasin de thèmes : Cocher ou décocher le fichier CSS d'un thème est maintenant correctement pris en compte. \ No newline at end of file diff --git a/library/Class/Template.php b/library/Class/Template.php index f23046172bc98db64047094f748f0a0f10b96ef3..4c0deba2e59caa9d7850be8115f684f5e58bbff0 100644 --- a/library/Class/Template.php +++ b/library/Class/Template.php @@ -659,11 +659,6 @@ class Class_Template { } - public function getTemplateCssUrls() { - return []; - } - - public function addTemplateJsTo($script_loader) { return $this; } @@ -734,4 +729,14 @@ class Class_Template { $files_names = $this->getFileSystem()->fileNamesAt(TEMPLATES_CSS_PATCHS); return array_combine($files_names, $files_names); } + + + public function getFolder() : string { + return dirname((new ReflectionClass($this))->getFileName()); + } + + + public function getTemplateCssFileName() : string { + return ''; + } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Template/Opac.php b/library/ZendAfi/View/Helper/Template/Opac.php index c98e22340f0e8ce471f2707706f3707f63c67054..25b79bdb45c6506fc7907b7e5a341434c5f01128 100644 --- a/library/ZendAfi/View/Helper/Template/Opac.php +++ b/library/ZendAfi/View/Helper/Template/Opac.php @@ -173,8 +173,11 @@ class ZendAfi_View_Helper_Template_Opac extends ZendAfi_View_Helper_BaseHelper { if ($css_patchs = $this->_styles->cssPatchsUrls()) $head_scripts->addStyleSheets($css_patchs); - if ($template_css = $this->_styles->templateCssUrls()) - $head_scripts->addStyleSheets($template_css); + if ($intonation_css = $this->_styles->intonationCssUrl()) + $head_scripts->addStyleSheet($intonation_css); + + if ($template_css = $this->_styles->templateCssUrl()) + $head_scripts->addStyleSheet($template_css); $this->_template->addTemplateJsTo($script_loader); diff --git a/library/templates/Chili/Template.php b/library/templates/Chili/Template.php index c17d82b189d3aeef4f4ab3c6f162c56f6a494d75..a4bd18f8816cdedace979cb44662ae5d238827e3 100644 --- a/library/templates/Chili/Template.php +++ b/library/templates/Chili/Template.php @@ -116,4 +116,11 @@ class Chili_Template extends Intonation_Template { public function renderOpac($view) { return (new Chili_View_Opac($this, $view))->render(); } + + + public function getTemplateCssFileName() : string { + return $this->getChiliCss() + ? 'chili' + : ''; + } } diff --git a/library/templates/Herisson/Template.php b/library/templates/Herisson/Template.php index f1dafe4143b0181f535694372277a7db0ec63ba1..0f753349929d9869a21438933de7eef11d4b9636 100644 --- a/library/templates/Herisson/Template.php +++ b/library/templates/Herisson/Template.php @@ -77,4 +77,11 @@ class Herisson_Template extends Intonation_Template { ? Chili_View_RenderMultipleCarousel::class : ''; } + + + public function getTemplateCssFileName() : string { + return $this->getHerissonCss() + ? 'herisson' + : ''; + } } diff --git a/library/templates/Intonation/Library/Styles.php b/library/templates/Intonation/Library/Styles.php index 93113d933dd93f034d68b915613883e56b544b5b..a7dc0bb71e9290ce19bd4153117b7dc7a80821e7 100644 --- a/library/templates/Intonation/Library/Styles.php +++ b/library/templates/Intonation/Library/Styles.php @@ -32,9 +32,10 @@ class Intonation_Library_Styles { $css = new Storm_Collection([$this->fontAwesomeCssUrl(), $this->bootstrapCssUrl(), $this->bootstrapRgaaCssUrl(), - $this->coreCssUrl()]); + $this->coreCssUrl(), + $this->intonationCssUrl()]); $css->addAll($this->cssPatchsUrls()); - $css->addAll($this->templateCssUrls()); + $css->add($this->templateCssUrl()); $css->addAll($this->customCssUrls()); $css->add($this->profileHeaderCssUrl()); @@ -72,7 +73,16 @@ class Intonation_Library_Styles { protected function _cssUrlFor($path) { - return Class_Url::absolute('/library/templates/Intonation/Assets/' . $path); + return Class_Url::relative('/library/templates/Intonation/Assets/' . $path); + } + + + protected function _cssUrlForCssFileName(string $file_name) : string { + return Class_Url::relative('/library/templates/' + . $this->_template->getFolder() + . '/Assets/css/' + . $file_name + . '.css'); } @@ -112,7 +122,9 @@ class Intonation_Library_Styles { } - public function templateCssUrls() { - return $this->_template->getTemplateCssUrls(); + public function templateCssUrl() : string { + return ($css_file_name_enable = $this->_template->getTemplateCssFileName()) + ? $this->_cssUrlForCssFileName($css_file_name_enable) + : ''; } } diff --git a/library/templates/Intonation/Template.php b/library/templates/Intonation/Template.php index 5c715782dfbaf7fc4c1b038d0d7ea79c79e4dfb6..971300af743131ef9186547a36d03a5aacd8cea8 100644 --- a/library/templates/Intonation/Template.php +++ b/library/templates/Intonation/Template.php @@ -411,19 +411,6 @@ class Intonation_Template extends Class_Template { } - public function getTemplateCssUrls() { - $css = $this->getIntonationCss() - ? [ $this->_assetsTemplateCssPath(Intonation_Template::class) ] - : []; - - if (Intonation_Template::ID === $this->getId()) - return $css; - - $css[] = $this->_assetsTemplateCssPath(static::class); - return $css; - } - - protected function _assetsTemplateCssPath($classname) { $directory = explode('_', $classname)[0]; $file = strtolower($directory); diff --git a/library/templates/Muscle/Template.php b/library/templates/Muscle/Template.php index ea040b3228ad19091b2ed6cbe576688f477013ef..8f576b8e5433ba8e743cf3d352e48684ca91e6be 100644 --- a/library/templates/Muscle/Template.php +++ b/library/templates/Muscle/Template.php @@ -54,4 +54,11 @@ class Muscle_Template extends Intonation_Template { $helper = new Muscle_Library_FormCustomizer($this); return $helper->getTemplateForm($form); } + + + public function getTemplateCssFileName() : string { + return $this->getMuscleCss() + ? 'muscle' + : ''; + } } diff --git a/library/templates/MyBibApp/Template.php b/library/templates/MyBibApp/Template.php index 63b4b47ceab1e84dd187365af402af018a0a3758..5355e74f5b30d8154e7ba8f130286f7740fe7d47 100644 --- a/library/templates/MyBibApp/Template.php +++ b/library/templates/MyBibApp/Template.php @@ -52,4 +52,11 @@ class MyBibApp_Template extends Intonation_Template { $helper = new MyBibApp_Library_FormCustomizer($this); return $helper->getTemplateForm($form); } + + + public function getTemplateCssFileName() : string { + return $this->getMybibappCss() + ? 'mybibapp' + : ''; + } } diff --git a/library/templates/Polygone/Template.php b/library/templates/Polygone/Template.php index 13980e82a372310939c8b94db2557104ec7ff99c..10d10b0b800bb58dd55d626112e7dd9fb6f5b848 100644 --- a/library/templates/Polygone/Template.php +++ b/library/templates/Polygone/Template.php @@ -63,4 +63,11 @@ class Polygone_Template extends Intonation_Template { return $this; } + + + public function getTemplateCssFileName() : string { + return $this->getPolygoneCss() + ? 'polygone' + : ''; + } } diff --git a/library/templates/TerreDuMilieu/Template.php b/library/templates/TerreDuMilieu/Template.php index 910975067bb967126fbd96faf70442c52334c87b..dd33a7ed3a38b36056b5b49046dddcbaee2b8c40 100644 --- a/library/templates/TerreDuMilieu/Template.php +++ b/library/templates/TerreDuMilieu/Template.php @@ -54,4 +54,11 @@ class TerreDuMilieu_Template extends Intonation_Template { $helper = new TerreDuMilieu_Library_FormCustomizer($this); return $helper->getTemplateForm($form); } + + + public function getTemplateCssFileName() : string { + return $this->getTerredumilieuCss() + ? 'terredumilieu' + : ''; + } } diff --git a/tests/scenarios/Templates/ChiliTest.php b/tests/scenarios/Templates/ChiliTest.php index 929d0dff09cab78aac9a0511b8c171ecd08503e7..0f1457586d1c1ee5a5d7ab1375cfebe56b3eb63a 100644 --- a/tests/scenarios/Templates/ChiliTest.php +++ b/tests/scenarios/Templates/ChiliTest.php @@ -264,31 +264,35 @@ class ChiliTemplateOpacAdvancedSearchTest extends ChiliTemplateTestCase { + class ChiliTemplateSearchResultMoreOptionsTest extends ChiliTemplateTestCase { + public function setUp() { parent::setUp(); - $this->fixture('Class_CodifAuteur', + $this->fixture(Class_CodifAuteur::class, ['id' => 43, 'libelle' => 'Pomme d\'API']); - $records = [$this->fixture('Class_Notice', + $records = [$this->fixture(Class_Notice::class, ['id' => 89, 'titre_principal' => 'Tintin e i picaros']), - $this->fixture('Class_Notice', + + $this->fixture(Class_Notice::class, ['id' => 99, 'titre_principal' => 'Tintin au Tibet'])]; - $sql = $this->mock() - ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(JARDIN JARDINS JARDIN)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_JARDIN') desc, MATCH(titres) AGAINST('P_JARDIN') desc, MATCH(titres) AGAINST('JARDIN') desc, MATCH(auteurs) AGAINST('JARDIN') desc, date_creation desc", - true, - false) - ->answers([[89, ''], [99, '']]) + $sql = $this + ->mock() + ->whenCalled('fetchAll') + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(JARDIN JARDINS JARDIN)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_JARDIN') desc, MATCH(titres) AGAINST('P_JARDIN') desc, MATCH(titres) AGAINST('JARDIN') desc, MATCH(auteurs) AGAINST('JARDIN') desc, date_creation desc", + true, + false) + ->answers([[89, ''], [99, '']]) - ->whenCalled('fetchAll') - ->with('select distinct(type_doc) from notices') - ->answers([]); + ->whenCalled('fetchAll') + ->with('select distinct(type_doc) from notices') + ->answers([]); Zend_Registry::set('sql', $sql); } @@ -315,6 +319,7 @@ class ChiliTemplateSearchResultMoreOptionsTest extends ChiliTemplateTestCase { $user ->setPassword('uie,uie,uie,') ->setMail('email@doesnotexist.org'); + $user->assertSave(); $this->dispatch('/recherche/send-mail/expressionRecherche/jardin'); $this->assertXPathContentContains('//div', 'Tintin au Tibet'); @@ -323,6 +328,7 @@ class ChiliTemplateSearchResultMoreOptionsTest extends ChiliTemplateTestCase { + class ChiliTemplateIndexFormulaireContactTest extends ChiliTemplateTestCase { /** @test */ diff --git a/tests/scenarios/Templates/HerissonTemplateTest.php b/tests/scenarios/Templates/HerissonTemplateTest.php index 984ffe7f7bda43065ef2c0f08d2d5a751504e606..8247a16b1733be7135e59b69712b2f5e3eec6f52 100644 --- a/tests/scenarios/Templates/HerissonTemplateTest.php +++ b/tests/scenarios/Templates/HerissonTemplateTest.php @@ -180,6 +180,12 @@ class HerissonTemplateIndexTest extends HerissonTemplateTestCase { . Class_Url::relative('/library/templates/Herisson/Assets/images/herisson_logo.png') . '"]'); } + + + /** @test */ + public function herissonCssFileShouldBeLoaded() { + $this->assertXPath('//link[contains(@href, "/library/templates/Herisson/Assets/css/herisson.css")]'); + } } diff --git a/tests/scenarios/Templates/MuscleTemplateTest.php b/tests/scenarios/Templates/MuscleTemplateTest.php index 56ea385d347a3ef55a7042bbb048b1549836d68e..cb3a6e08dc7f3d7b5e5fa9f911569612163b6f0f 100644 --- a/tests/scenarios/Templates/MuscleTemplateTest.php +++ b/tests/scenarios/Templates/MuscleTemplateTest.php @@ -21,7 +21,6 @@ abstract class MuscleTemplateTestCase extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); @@ -597,3 +596,28 @@ class MuscleTemplateNotLoggedTest extends MuscleTemplateTestCase { $this->assertXPath('//form/input[@id="login"][@class= "zendafi_form_login_login btn btn-sm btn-primary order-3 my-3"]'); } } + + + + +class MuscleTemplateRemoveCssTest extends MuscleTemplateTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture(Class_Template_Settings::class, + ['id' => 1, + 'template' => 'MUSCLE']); + + Class_Template_Settings::find(1) + ->updateAttributes(['MuscleMuscleCss' => ""]) + ->save(); + + $this->dispatch('/index'); + } + + + /** @test */ + public function muscleCssFileShouldNotBePresent() { + $this->assertNotXPath('//link[contains(@href, "muscle.css")]'); + } +} diff --git a/tests/scenarios/Templates/MyBibAppTemplateTest.php b/tests/scenarios/Templates/MyBibAppTemplateTest.php index f75ee8226e81e9f1e4f3ad6b35ad970045609579..eb5b870e48c8aa065ab2d2b18f63d69dc32e2838 100644 --- a/tests/scenarios/Templates/MyBibAppTemplateTest.php +++ b/tests/scenarios/Templates/MyBibAppTemplateTest.php @@ -168,7 +168,7 @@ class MyBibAppTemplateOpacIndexWithUserAgentTest extends MyBibAppTemplateTestCas /** @test */ public function pageShouldLoadMyBibAppCss() { - $this->assertXPath('//head/link[contains(@href, "/templates/MyBibApp/Assets/css/mybibapp.css")]'); + $this->assertXPath('//head/link[contains(@href, "/library/templates/MyBibApp/Assets/css/mybibapp.css")]'); }