diff --git a/application/modules/telephone/views/scripts/cms/articlesview.phtml b/application/modules/telephone/views/scripts/cms/articlesview.phtml index 165b1e0bdd9ef1706a73bd9fa937a93f5799ff66..727d0bfd41dd46771ec74c0c608a7d5a70d8a0aa 100644 --- a/application/modules/telephone/views/scripts/cms/articlesview.phtml +++ b/application/modules/telephone/views/scripts/cms/articlesview.phtml @@ -5,27 +5,8 @@ echo $this->toolbar($this->_('Articles'), <?php if (0 < count($this->articles)) { ?> - <div class="liste"><ul> - <?php - foreach ($this->articles as $article) { - ?> - <li class="lien"> - <?php echo $this->tagArticleEvent($article);?> - <span><?php - echo $this->tagAnchor( - $this->url(array('cat' => $article->getIdCat())), - $article->getCategorie()->getLibelle(), - array('class' => 'calendar_event_info') - );?> - <?php - echo $this->tagAnchor( - $article->getUrl(), - $article->getTitre(), - array('class' => 'calendar_event_title') - ); ?> - </span> - </li> - <?php } ?> - </ul> + <div class="liste"> + <?php echo $this->articleEventList($this->articles); ?> </div> <?php diff --git a/application/modules/telephone/views/scripts/cms/articleviewbydate.phtml b/application/modules/telephone/views/scripts/cms/articleviewbydate.phtml index d2c75c4a1e169e02c5c16306a12e75977b57057b..2e3213be575e5b41f9e6569dae88755f8b45e55f 100644 --- a/application/modules/telephone/views/scripts/cms/articleviewbydate.phtml +++ b/application/modules/telephone/views/scripts/cms/articleviewbydate.phtml @@ -8,27 +8,8 @@ echo $this->toolbar($this->_('Articles'), <div class="liste"> <?php foreach ($this->articles as $bibliotheque => $articles) { ?> <h2><?php echo ('' == $bibliotheque) ? $this->_('Portail') : $this->libelle_bibs[$bibliotheque];?></h2> - <ul> - <?php - foreach ($articles as $article) { ?> - <li class="lien"> - <?php echo $this->tagArticleEvent($article);?> - <span><?php - echo $this->tagAnchor( - $this->url(array('cat' => $article->getIdCat())), - $article->getCategorie()->getLibelle(), - array('class' => 'calendar_event_info') - );?> - <?php - echo $this->tagAnchor( - $article->getUrl(), - $article->getTitre(), - array('class' => 'calendar_event_title') - ); ?> - </span> - </li> - <?php } ?> - </ul> - <?php } ?> + <?php echo $this->articleEventList($articles); ?> + <?php } ?> </div> <?php diff --git a/library/ZendAfi/View/Helper/Telephone/ArticleEventList.php b/library/ZendAfi/View/Helper/Telephone/ArticleEventList.php new file mode 100644 index 0000000000000000000000000000000000000000..928433acc504cfa68ab461e173e9836d56b1bb4b --- /dev/null +++ b/library/ZendAfi/View/Helper/Telephone/ArticleEventList.php @@ -0,0 +1,61 @@ +<?php +/** + * Copyright (c) 2012, 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_Telephone_ArticleEventList extends ZendAfi_View_Helper_BaseHelper { + public function articleEventList($articles) { + if (!$articles) + return ''; + + return $this->_tag('ul', + $this->_renderArticles($articles)); + } + + + protected function _renderArticles($articles) { + return implode('', + array_map([$this, '_renderArticle'], + $articles)); + } + + + protected function _renderArticle($article) { + return $this->_tag( + 'li', + $this->view->tagArticleEvent($article) + . $this->_tag('span', + $this->_renderArticleLinks($article) + ), + ['class' => 'lien']); + } + + + protected function _renderArticleLinks($article) { + return + $this->view->tagAnchor( + $this->view->url(['cat' => $article->getIdCat()]), + $article->getCategorie()->getLibelle(), + ['class' => 'calendar_event_info']) + . ' - ' + . $this->view->tagAnchor( + $article->getUrl(), + $article->getTitre(), + ['class' => 'calendar_event_title']); + } +}