From 50a504e57a9917ed7de461df9ebb580216cf55ad Mon Sep 17 00:00:00 2001 From: efalcy <stl@gresille.org> Date: Fri, 21 Mar 2014 18:18:19 +0100 Subject: [PATCH] Improve domain rendering: - HTML5 compatibility - less divs --- .../opac/controllers/DomainsController.php | 7 +++-- .../opac/views/scripts/domains/browse.phtml | 2 +- .../Systeme/ModulesAccueil/DomainBrowser.php | 2 +- .../ZendAfi/Controller/Action/Helper/View.php | 2 +- .../View/Helper/RenderDomainBrowser.php | 31 +++++++------------ library/ZendAfi/View/Helper/Tag.php | 4 +-- library/storm | 2 +- public/opac/css/global.css | 4 ++- .../controllers/RechercheControllerTest.php | 9 +++++- .../View/Helper/Accueil/DomainBrowserTest.php | 8 ----- 10 files changed, 33 insertions(+), 38 deletions(-) diff --git a/application/modules/opac/controllers/DomainsController.php b/application/modules/opac/controllers/DomainsController.php index 593948728ad..65b152c5c16 100644 --- a/application/modules/opac/controllers/DomainsController.php +++ b/application/modules/opac/controllers/DomainsController.php @@ -26,17 +26,20 @@ class DomainsController extends ZendAfi_Controller_Action { return; } + + $id_module = $this->_getParam('id_module'); if (!$catalog->hasSousDomaines()){ $this->_redirect($this->view->url(array_filter(['controller' => 'recherche', 'action' => 'simple', 'id_catalogue' => $catalog->getId(), - 'id_module' => $this->_getParam('id_module')]), + 'id_module' => $id_module]), null, true)); return; } + $this->view->module_preferences = Class_Profil::getCurrentProfil()->getModuleAccueilPreferences($id_module); $this->view->current_domain = $catalog; - $this->view->id_module = $this->_getParam('id_module'); + $this->view->id_module = $id_module; $this->view->current_breadcrumb = $this->_getParam('parents'); } } diff --git a/application/modules/opac/views/scripts/domains/browse.phtml b/application/modules/opac/views/scripts/domains/browse.phtml index 4d78fa2aa43..2ce8d569424 100644 --- a/application/modules/opac/views/scripts/domains/browse.phtml +++ b/application/modules/opac/views/scripts/domains/browse.phtml @@ -2,6 +2,6 @@ $this->openBoite(''); echo $this->renderDomainBrowser($this->current_domain, $this->id_module, - $this->preferences); + $this->module_preferences); $this->closeBoite(); ?> diff --git a/library/Class/Systeme/ModulesAccueil/DomainBrowser.php b/library/Class/Systeme/ModulesAccueil/DomainBrowser.php index 84285ffb3f3..bc165282540 100644 --- a/library/Class/Systeme/ModulesAccueil/DomainBrowser.php +++ b/library/Class/Systeme/ModulesAccueil/DomainBrowser.php @@ -35,7 +35,7 @@ class Class_Systeme_ModulesAccueil_DomainBrowser extends Class_Systeme_ModulesAc protected $_defaultValues = ['titre' => 'Domaines', 'root_domain_id' => 0, - 'display_mode' => Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR]; + 'display_mode' => Class_Systeme_ModulesAppli::LISTE_FORMAT_ACCORDEON]; diff --git a/library/ZendAfi/Controller/Action/Helper/View.php b/library/ZendAfi/Controller/Action/Helper/View.php index 2516decd335..8f53b86a20b 100644 --- a/library/ZendAfi/Controller/Action/Helper/View.php +++ b/library/ZendAfi/Controller/Action/Helper/View.php @@ -44,7 +44,7 @@ class ZendAfi_Controller_Action_Helper_View extends Zend_View { $this->setEncoding('UTF-8'); $this->setEscape('htmlentities'); - $this->doctype('XHTML1_TRANSITIONAL'); + $this->doctype('HTML5'); } diff --git a/library/ZendAfi/View/Helper/RenderDomainBrowser.php b/library/ZendAfi/View/Helper/RenderDomainBrowser.php index a2560297b37..91e3cff574b 100644 --- a/library/ZendAfi/View/Helper/RenderDomainBrowser.php +++ b/library/ZendAfi/View/Helper/RenderDomainBrowser.php @@ -31,6 +31,7 @@ class ZendAfi_View_Helper_RenderDomainBrowser extends ZendAfi_View_Helper_BaseHe $this->_pref = $preferences; $display_mode = $this->_pref["display_mode"]; + xdebug_break(); $this->renderer = $display_mode == Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR ? new ZendAfi_View_Helper_RenderDomainBrowser_Wall($this->view) : new ZendAfi_View_Helper_RenderDomainBrowser_List($this->view); @@ -75,7 +76,6 @@ class ZendAfi_View_Helper_RenderDomainBrowser extends ZendAfi_View_Helper_BaseHe protected function getBrowsingUrl($domain) { - xdebug_break(); if ($domain->getId()==$this->_pref['root_domain_id']) return $this->view->url([], null, true); $params = $domain->hasSousDomaines() @@ -102,37 +102,28 @@ class ZendAfi_View_Helper_RenderDomainBrowser_Wall{ public function __construct($view) { $this->_view = $view; - Class_ScriptLoader::getInstance() - ->addOPACScript('liste_notices_mur') - ->loadPrettyPhoto(); } - public function children($html) { return $this->_view->tag('div', - $this->_view->tag('div', $html), - ['class' => 'liste_mur children_domains']); + $html, + ['class' => 'liste_mur children_domains']); } public function breadcrumb($html) { - return $this->_view->tag('div', - $this->_view->tag('div', $html), - ['class' => 'liste_mur breadcrumb_domains']); + return $this->_view->tag('div', + $html, + ['class' => 'liste_mur breadcrumb_domains']); } public function display($url, $img, $title){ - $view = $this->_view; - return $view->tag('div', - $view->tag('div', - $view->tag('div',$view->tagAnchor($url, - $img . $view->tag('span', - $title, - ['class' => 'titre_auteur'])), - ['class' => 'notice']), - ['class' => 'notice_wrapper']), - ['style' => 'float:left;list-style-type:none;']); + return $this->_view->tag('div', + $this->_view->tagAnchor($url, + $img . $this->_view->tag('span', + $title, + ['class' => 'titre_auteur']))); } } diff --git a/library/ZendAfi/View/Helper/Tag.php b/library/ZendAfi/View/Helper/Tag.php index cffaa71a1f5..8459b6c41d7 100644 --- a/library/ZendAfi/View/Helper/Tag.php +++ b/library/ZendAfi/View/Helper/Tag.php @@ -20,9 +20,9 @@ */ class ZendAfi_View_Helper_Tag extends Zend_View_Helper_HtmlElement { - public function tag($name, $content='', $attribs=[]) { + public function tag($name, $content=null, $attribs=[]) { $html = '<' . $name . ' ' . $this->_htmlAttribs($attribs); - if (!$content) + if (null === $content) return $html . $this->getClosingBracket(); return $html . '>' . $content . '</' . $name . '>'; } diff --git a/library/storm b/library/storm index ce4ba4ba1ad..730b5eac0be 160000 --- a/library/storm +++ b/library/storm @@ -1 +1 @@ -Subproject commit ce4ba4ba1adcae6c4c8c647a7cc6ff4991f5d86d +Subproject commit 730b5eac0be527ed2df482e21f7ba9b9489653c8 diff --git a/public/opac/css/global.css b/public/opac/css/global.css index 361d20a7f55..5c7873f4db8 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -1399,10 +1399,12 @@ body.abonne_multimedia-hold-view .actions a { .liste_mur { float: left; + width: 100%; } -.liste_mur .notice_wrapper { +.liste_mur .notice_wrapper, +.liste_mur>div { float: left; height: 150px; width: 100px; diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index a6abf1baa63..2e101cf3c0b 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -1467,7 +1467,7 @@ class RechercheControllerSimpleActionWithCatalogueAndDomainBrowserWidgetTest ext 'root_domain_id' =>4 ]]) ->updateModuleConfigAccueil(10, - ['type_module' => 'NEWS', + ['type_module' => 'RSS', 'division' => 1, 'id_module' => 10, ]); @@ -1499,6 +1499,13 @@ class RechercheControllerSimpleActionWithCatalogueAndDomainBrowserWidgetTest ext } + /** @test */ + public function onRechercheSimpleCatalogue3IdModule9BreadcrumbPageShouldBeHtml5Valid() { + $this->dispatch('/recherche/simple/id_catalogue/3/id_module/9', true); + $this->assertHTML5(); + } + + /** @test */ public function onRechercheSimpleCatalogue3IdModule10BreadcrumbShouldNotBeDisplayed() { $this->dispatch('/recherche/simple/id_catalogue/3/id_module/10', true); diff --git a/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php b/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php index 20f206e458e..ff584bfc18d 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php @@ -94,14 +94,6 @@ abstract class ZendAfi_View_Helper_Accueil_DomainBrowserWithDefaultSettingsTestC public function setUp() { parent::setUp(); - Class_Profil::getCurrentProfil()-> - updateModuleConfigAccueil(9, - ['type_module' => 'DOMAIN_BROWSER', - 'division' => 1, - 'id_module' => 9, - 'preferences' => ['display_mode' => Class_Systeme_ModulesAppli::LISTE_FORMAT_ACCORDEON, - 'root_domain_id' =>0 - ]]); $this->helper = new ZendAfi_View_Helper_Accueil_DomainBrowser(9, [ 'division' => 1, -- GitLab