diff --git a/application/modules/admin/views/scripts/profil/_formProfil.phtml b/application/modules/admin/views/scripts/profil/_formProfil.phtml index 21bb1db1c57f930bc8e6d2cd54d5e06bc0237eac..c3a3be7843ff516a64bb31222abd0229a593355b 100644 --- a/application/modules/admin/views/scripts/profil/_formProfil.phtml +++ b/application/modules/admin/views/scripts/profil/_formProfil.phtml @@ -236,6 +236,17 @@ echo $this->partial('profil/_profil_panel.phtml', </tr> + <tr class="only_browser"> + <td align="right"><?php echo $this->traduire('Activer la mise en page responsive'); ?></td> + <td class="gauche"> + <?php + echo $this->formCheckbox( 'responsive', + null, + ['checked' => $this->profil->isResponsive()]); + ?> + </td> + </tr> + <tr class="only_browser"> <td align="right" style="width:25%"><?php echo $this->traduire('Largeur totale du site'); ?></td> <td> diff --git a/application/modules/opac/views/scripts/head.phtml b/application/modules/opac/views/scripts/head.phtml index f536c1caecb54c3f67b95256db43381d99c959ad..0a22ff20aee0405473d0cf145098ee4be9a13cc0 100644 --- a/application/modules/opac/views/scripts/head.phtml +++ b/application/modules/opac/views/scripts/head.phtml @@ -9,6 +9,7 @@ <meta name="keywords" content="<?php echo $current_profil->getRefTags();?>" /> <meta content="all" name="robots" /> <meta content="10 days" name="revisit-after" /> + <meta content="width=device-width, initial-scale=1, maximun-scale=1" name="viewport" /> <?php Class_ScriptLoader::getInstance()->loadMeta(); @@ -69,6 +70,9 @@ $head_scripts->addStyleSheet($current_profil->getPageCss(), ['id' => 'profil_css', 'media' => 'all']); + if($current_profil->isResponsive()) + $head_scripts->addOpacStyleSheet('responsive'); + if ($this->accessibilite_on) { //Feuilles de styles pour les déficiences visuelles $head_scripts diff --git a/library/Class/Profil.php b/library/Class/Profil.php index 2a2ccb9297fa50ee21484a9c479ee70169de4018..57900dda3ea3e939d15cefa79c0b21938a39f72f 100644 --- a/library/Class/Profil.php +++ b/library/Class/Profil.php @@ -174,40 +174,41 @@ class Class_Profil extends Storm_Model_Abstract { public static function getCfgSiteKeys() { if (!isset(self::$CFG_SITE_KEYS)) self::$CFG_SITE_KEYS = array( 'accessibilite_on', - 'barre_nav_on', - 'display_current_profil_on_breadcrumb', - 'header_css', - 'header_js', - 'header_img', - 'header_img_cycle', - 'largeur_division2', - 'largeur_division3', - 'liens_sortants_off', - 'marge_division1', - 'marge_division2', - 'marge_division3', - 'menu_haut_on', - 'largeur_division1', - 'largeur_site', - 'size_site_scale', + 'barre_nav_on', + 'display_current_profil_on_breadcrumb', + 'header_css', + 'header_js', + 'header_img', + 'header_img_cycle', + 'largeur_division2', + 'largeur_division3', + 'liens_sortants_off', + 'marge_division1', + 'marge_division2', + 'marge_division3', + 'menu_haut_on', + 'largeur_division1', + 'largeur_site', + 'size_site_scale', 'width_division1_scale', 'width_division2_scale', 'width_division3_scale', - 'nb_divisions', - 'ordre_divisions', - 'hauteur_banniere', - 'couleur_lien_bandeau', - 'couleur_texte_bandeau', - 'access_level', - 'favicon', - 'logo_gauche_img', - 'logo_gauche_link', - 'logo_droite_img', - 'logo_droite_link', - 'header_social_network', - 'mail_suggestion_achat', - 'division_three_always_visible' - ); + 'nb_divisions', + 'ordre_divisions', + 'hauteur_banniere', + 'couleur_lien_bandeau', + 'couleur_texte_bandeau', + 'access_level', + 'favicon', + 'logo_gauche_img', + 'logo_gauche_link', + 'logo_droite_img', + 'logo_droite_link', + 'header_social_network', + 'mail_suggestion_achat', + 'division_three_always_visible', + 'responsive' + ); return self::$CFG_SITE_KEYS; } @@ -221,12 +222,12 @@ class Class_Profil extends Storm_Model_Abstract { self::$DEFAULT_VALUES = ['cfg_site' => '', 'cfg_accueil' => ZendAfi_Filters_Serialize::serialize([ 'page_css' => null, - 'use_parent_css' => true, - 'modules' => [], - 'sitemap' => 1]), + 'use_parent_css' => true, + 'modules' => [], + 'sitemap' => 1]), 'cfg_menus' => ZendAfi_Filters_Serialize::serialize(['H' => ['libelle' => 'Menu horizontal', - 'picto' => 'vide.gif', - 'menus' => []], + 'picto' => 'vide.gif', + 'menus' => []], 'V' => ['libelle' => 'Menu vertical', 'picto' => 'vide.gif', 'menus' => []]]), @@ -292,7 +293,8 @@ class Class_Profil extends Storm_Model_Abstract { 'logo_droite_link' => '', 'header_social_network' => false, 'division_three_always_visible' => false, - 'rewrite_url' => '']; + 'rewrite_url' => '', + 'responsive' => false]; return self::$DEFAULT_VALUES; } @@ -465,9 +467,9 @@ class Class_Profil extends Storm_Model_Abstract { return false; return ( - (isset($module['division']) && ($module['division'] == self::DIV_BANNIERE)) - || - (!isset($module['division']) && ($this->isTypeBoiteInBanniere($type_module))) + (isset($module['division']) && ($module['division'] == self::DIV_BANNIERE)) + || + (!isset($module['division']) && ($this->isTypeBoiteInBanniere($type_module))) ); } @@ -520,8 +522,8 @@ class Class_Profil extends Storm_Model_Abstract { && (self::DIV_BANNIERE == $module_config['division']) && $this->hasParentProfil()) { $this->getParentProfil() - ->updateModuleConfigAccueil($id_module, $module_config) - ->save(); + ->updateModuleConfigAccueil($id_module, $module_config) + ->save(); return $this; } @@ -542,10 +544,10 @@ class Class_Profil extends Storm_Model_Abstract { $url = 'http://' . $_SERVER['SERVER_NAME'] . BASE_URL . '/'.$controller.'/'.$action.'?'. http_build_query( - array( - 'id_module' => $id_module, - 'id_profil' => $this->getId(), - 'language' => $this->getLocale())); + array( + 'id_module' => $id_module, + 'id_profil' => $this->getId(), + 'language' => $this->getLocale())); return htmlspecialchars($url); } @@ -657,7 +659,7 @@ class Class_Profil extends Storm_Model_Abstract { public function getModuleAccueilConfigByType($type_module, $division=null) { if ($this->hasParentProfil() && - ($preferences = $this->getParentProfil()->getModuleAccueilConfigByType($type_module, $division))) + ($preferences = $this->getParentProfil()->getModuleAccueilConfigByType($type_module, $division))) return $preferences; $preferences = []; @@ -666,7 +668,7 @@ class Class_Profil extends Storm_Model_Abstract { foreach($cfg_accueil['modules'] as $key_module => $module ) { foreach($module as $key => $value){ if (($module[$key]===$type_module) - && (!$division || ($module['division'] == $division))) { + && (!$division || ($module['division'] == $division))) { return $this->getLocalModuleAccueilConfig($key_module, $type_module); } } @@ -928,9 +930,9 @@ class Class_Profil extends Storm_Model_Abstract { } public function setModulePreference($controller,$action,$pref,$value) { - $cfg_modules = $this->getCfgModulesAsArray(); - $cfg_modules[$controller][$action][$pref]=$value; - $this->setCfgModules($cfg_modules)->save(); + $cfg_modules = $this->getCfgModulesAsArray(); + $cfg_modules[$controller][$action][$pref]=$value; + $this->setCfgModules($cfg_modules)->save(); } /** @@ -1187,10 +1189,10 @@ class Class_Profil extends Storm_Model_Abstract { if ($this->getNbDivisions() < 2) $this->setLargeurDivision2(0); $this->check($this->getLibelle(), 'Le libellé est obligatoire.'); $this->check($this->getSizeSiteScale()!="px" or $this->getLargeurSite() >= 800 and $this->getLargeurSite() <= 2000, - 'La largeur du site doit être comprise entre 800 et 2000 pixels.'); + 'La largeur du site doit être comprise entre 800 et 2000 pixels.'); $this->check($this->getSizeSiteScale()!="px" or ($this->getLargeurDivision1() + - $this->getLargeurDivision2() + + $this->getLargeurDivision2() + $this->getLargeurDivision3() <= $this->getLargeurSite()), 'La somme des largeurs des divisions ne doit pas excéder la largeur du site.'); @@ -1276,6 +1278,11 @@ class Class_Profil extends Storm_Model_Abstract { } + public function isResponsive() { + return $this->_get('responsive'); + } + + public function getAccessLevel() { if($access_level = parent::getAccessLevel()) return $access_level; @@ -1959,19 +1966,19 @@ class Class_Profil extends Storm_Model_Abstract { public function duplicateHorizontalMenu() { $this->topProfilsDoAndSave( - function($profil) { - $profil->setCfgMenuHorizontal($this->getMenu('H')); - } - ); + function($profil) { + $profil->setCfgMenuHorizontal($this->getMenu('H')); + } + ); } public function duplicateConfigModules() { $this->topProfilsDoAndSave( - function($profil) { - $profil->setCfgModules($this->getCfgModules()); - } - ); + function($profil) { + $profil->setCfgModules($this->getCfgModules()); + } + ); } diff --git a/public/opac/css/responsive.css b/public/opac/css/responsive.css new file mode 100644 index 0000000000000000000000000000000000000000..9f20a11c0dcc710883fe8dbcae33300d6924baba --- /dev/null +++ b/public/opac/css/responsive.css @@ -0,0 +1,75 @@ +@media screen and (max-device-width: 1024px) { + + .footer > *:not(.logo), + .colFlottant.layout-division { + display: none !important; + } + + + #menu_horizontal { + + } + + + .siteWeb div#col_wrapper, + #abonne_edit, + #abonne_edit > *, + #abonne_edit fieldset, + #abonne_edit fieldset td, + .filtre_recherche, + .filtre_recherche > *, + #colMilieuInner .contenuInner , + #colMilieuInner .contenuInner > *, + .resultat_recherche, + .resultat_recherche > div , + .resultat_recherche .notice_wrapper, + #colMilieuInner > *, + .siteWeb, + .footer, + #site_web_content, + #site_web_wrapper, + #header > *, + #header, + #col_wrapper .boite, + .layout-division, + .contenu, + .content, + .title, + .titre , + .col_gauche, + .col_droite { + text-align: left !important; + position: relative !important; + display: block !important; + width: 100% !important; + max-width: 100% !important; + min-width: 100% !important; + clear: both !important; + float: left !important; + max-height: auto !important; + min-height: auto !important; + margin: 0 !important; + padding: 0 !important; + top: auto !important; + left: auto !important; + right: auto !important; + bottom: auto !important; + height: auto !important; + overflow: hidden !important; + } + + + + body #site_web_wrapper { + font-size: 22px; + } + + + body #site_web_wrapper * { + font-size: 1em; + max-height: none; + min-height: none; + height: auto; + line-height: 1.3em; + } +} \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/ProfilControllerTest.php b/tests/application/modules/admin/controllers/ProfilControllerTest.php index 83f87c6b3189167453141982bab3b99d8ee15ded..94a3ccd8166e63a208c9439f8b4e97130bed412f 100644 --- a/tests/application/modules/admin/controllers/ProfilControllerTest.php +++ b/tests/application/modules/admin/controllers/ProfilControllerTest.php @@ -101,13 +101,19 @@ class Admin_ProfilControllerEditProfilJeunesseTest extends Admin_ProfilControlle parent::tearDown(); } + + /** @test */ + public function checkboxResponsiveShouldBePresent() { + $this->assertXPath("//input[@type='checkbox'][@name='responsive'][not(@checked)]"); + } + + /** @test */ public function allowInputPercentAndPixels() { $this->assertXPathContentContains("//select[@name='size_site_scale']","pixels"); } - /** @test */ public function allowInputDivision1PercentAndPixels() { $this->assertXPathContentContains("//select[@name='width_division1_scale']","pixels",$this->_response->getBody()); diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index 3fdd5ff748e075361df04dc260e2f811c33b34df..62398a1dd080245004b2832b957ddc55bbd80781 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -224,7 +224,8 @@ abstract class ProfilOptionsControllerWithProfilAdulteTestCase extends AbstractC ->setMenuHautOn(true) ->setCfgMenus($cfg_menus) ->setCommentaire('Super bib') - ->setRefTags('bib,Adulte'); + ->setRefTags('bib,Adulte') + ->setResponsive(true); $this->profil_adulte->assertSave(); $this->profil_adulte->beCurrentProfil(); @@ -314,6 +315,12 @@ class ProfilOptionsControllerProfilAdulteWithCacheTest extends ProfilOptionsCont } + /** @test */ + public function responsiveCssShouldBeLoader() { + $this->assertXPath('//link[contains(@href, "responsive.css")]'); + } + + /** @test */ public function menuHorizontalAccueilShouldNotContainsEmptyUL() { $this->assertNotXPath('//li[@class="menu"]//a[text()="Accueil"][following-sibling::ul]', $this->_response->getBody()); diff --git a/tests/library/Class/ProfilTest.php b/tests/library/Class/ProfilTest.php index 16465d7d7d0a1ba4896ed3348340633b90b3c779..c2839c3b6214c138ec277bbacb6862be7acfed51 100644 --- a/tests/library/Class/ProfilTest.php +++ b/tests/library/Class/ProfilTest.php @@ -436,7 +436,8 @@ abstract class ProfilAdulteChatenayTestCase extends ModelTestCase { 'cfg_accueil' => $cfg_accueil, 'access_level' => '-1', 'parent_id' => null, - 'mail_suggestion_achat' => 'chatenay@chatenay.fr']); + 'mail_suggestion_achat' => 'chatenay@chatenay.fr', + 'responsive' => true]); } } @@ -558,6 +559,12 @@ class ProfilAdulteChatenayTest extends ProfilAdulteChatenayTestCase { } + /** @test */ + public function shouldBeResponsive() { + $this->assertTrue($this->profil->isResponsive()); + } + + /** @test */ public function getHauteurBanniereShouldReturn200() { $this->assertEquals(200, $this->profil->getHauteurBanniere());