diff --git a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Sitotheque.php b/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Sitotheque.php index 42937a53ed8dcc18037893997fe8e1d4c82ceacd..dbe853b1deeaee9d83426fda570d1783809628a9 100644 --- a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Sitotheque.php +++ b/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Sitotheque.php @@ -142,7 +142,7 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Sitotheque extends public function getCategoriesId() { - return 'sitotheque'; + return 'sitotheque-category'; } diff --git a/library/ZendAfi/View/Helper/PublicListViewMode.php b/library/ZendAfi/View/Helper/PublicListViewMode.php index 4346a4fc92089a45b0709938cf55246529eb85d3..a87157e0c24afd230c19b82a83ce533b6f400a6f 100644 --- a/library/ZendAfi/View/Helper/PublicListViewMode.php +++ b/library/ZendAfi/View/Helper/PublicListViewMode.php @@ -22,16 +22,16 @@ class ZendAfi_View_Helper_PublicListViewMode extends ZendAfi_View_Helper_Admin_ListViewMode { public function publicListViewMode($list) { - if(!$this->_list = $list) + if (!$this->_list = $list) return ''; $html = $this->getSearchFormHTML() - .$this->getBreadcrumbHTML() - .$this->getCategoriesHTML() + . $this->getBreadcrumbHTML() + . $this->getCategoriesHTML() . $this->getItemsHTML() . $this->getItemsPaginatorHTML(); - return $html; + return $html; } @@ -39,40 +39,60 @@ class ZendAfi_View_Helper_PublicListViewMode extends ZendAfi_View_Helper_Admin_ if($this->_list->getSearchValue()) return ''; - $labelWithCount = function($model, $attrib) { - return $this->view->tagAnchor($this->view->url($this->_list->getUrlParams($model),null, true), - $model->$attrib - . ' (' . $this->_list->countRecursiveItemsFor($model) . ')');}; + $html = ''; + foreach($this->_list->getCategories() as $category) + $html .= $this->getCategoryHtml($category); + + return $this->_tag('ul', $html, + ['class' => $this->_list->getCategoriesId()]); + } - return $this->view->tagList($this->_list->getCategories(), - $this->_list->getCategoriesAttribs(), - $this->_list->getCategoriesId(), - [$this->_list->getCategoriesLabelAttrib() => $labelWithCount] + protected function getCategoryHtml($category) { + $label_attrib = $this->_list->getCategoriesLabelAttrib(); + $label = sprintf('%s (%s)', + $category->$label_attrib, + $this->_list->countRecursiveItemsFor($category)); - ); + return $this + ->_tag('li', + $this->_tag('a', $label, + ['href' => $this->view->url($this->_list->getUrlParams($category), + null, true)])); } protected function getItemsHTML() { if(!$this->_list->getModel() && !$this->_list->getSearchValue()) return ''; - $labelWithThumbnail = function($model, $attrib) { - $html=''; - if ($img_url = $this->getThumbnail($model->getUrl())) - $html.= $this->view->tagImg($img_url,['alt' => ""]); - return $html.$this->view->tagAnchor($model->getUrl(),$model->$attrib, - ['title' => 'Aller sur le site']); - }; - return $this->view->tagList($this->_list->getItems(), - $this->_list->getItemsAttribs(), - $this->_list->getItemsId(), - [$this->_list->getItemsLabelAttrib() => $labelWithThumbnail]); + $html = ''; + foreach ($this->_list->getItems() as $item) + $html .= $this->getItemHtml($item); + return $html; + } + protected function getItemHtml($item) { + if (!$item) + return ''; + $html = $this->view->openBoiteContent($item->getTitre()); + + $thumb = ($img_url = $this->getThumbnail($item->getUrl())) ? + $this->view->tagImg($img_url) : ''; + + $link = $this + ->_tag('div', + $this->_tag('a', $this->_('Voir le site'), + ['href' => $item->getUrl()])); + + $html .= $this->_tag('div', + $thumb . $item->getDescription() . $link, + ['class' => $this->_list->getItemsId()]); + + return $html . $this->view->closeBoiteContent(); } @@ -80,8 +100,7 @@ class ZendAfi_View_Helper_PublicListViewMode extends ZendAfi_View_Helper_Admin_ if (!isset($this->thumbnails_helper)) $this->thumbnails_helper = (new ZendAfi_View_Helper_WebThumbnail()) ->setView($this->view); + return $this->thumbnails_helper->webThumbnail($url); } - -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/SitoControllerTest.php b/tests/application/modules/opac/controllers/SitoControllerTest.php index 7fe00391334995509ebb309d749e6144aa606c25..655189bcff56fd9b57bd4c7cc2a3139216dce780 100644 --- a/tests/application/modules/opac/controllers/SitoControllerTest.php +++ b/tests/application/modules/opac/controllers/SitoControllerTest.php @@ -121,14 +121,14 @@ class SitoControllerHierarchicViewTest extends SitoControllerTestCase { /** @test */ public function LinuxFrShouldNotBeShown() { - $this->assertNotXPath('//ul[@class="sitotheque"]//a[@href="http://linuxfr.org"]', + $this->assertNotXPath('//div[@class="sitotheque"]//a[@href="http://linuxfr.org"]', $this->_response->getBody()); } /** @test */ public function FramasoftShouldBeShown() { - $this->assertXPath('//ul[@class="sitotheque"]//a[@href="http://framasoft.org"]', + $this->assertXPath('//div[@class="sitotheque"]//a[@href="http://framasoft.org"]', $this->_response->getBody()); }