From 540fcc8906b2944ad2492b86ca5abd8686952f17 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@afi-sa.fr>
Date: Sat, 5 Mar 2016 10:51:35 +0100
Subject: [PATCH] hotline #38468: adapt article views to phone

---
 .../opac/controllers/CmsController.php        |  7 +--
 .../telephone/controllers/CmsController.php   |  3 --
 .../views/scripts/cms/articlesview.phtml      | 35 ++++++++++++++
 .../views/scripts/cms/articleviewbydate.phtml |  2 +-
 .../controllers/CmsControllerTest.php         | 48 +++++++++----------
 5 files changed, 60 insertions(+), 35 deletions(-)
 create mode 100644 application/modules/telephone/views/scripts/cms/articlesview.phtml

diff --git a/application/modules/opac/controllers/CmsController.php b/application/modules/opac/controllers/CmsController.php
index 0af95b7aa52..6caeba2e836 100644
--- a/application/modules/opac/controllers/CmsController.php
+++ b/application/modules/opac/controllers/CmsController.php
@@ -311,11 +311,6 @@ class CmsController extends ZendAfi_Controller_Action {
       $this->view->show_content = 'FullContent';
     }
 
-    $this->_renderArticlesViewScript();
-  }
-
-
-   protected function _renderArticlesViewScript() {
-     $this->renderScript('cms/articlesview.phtml');
+    $this->renderScript('cms/articlesview.phtml');
    }
 }
\ No newline at end of file
diff --git a/application/modules/telephone/controllers/CmsController.php b/application/modules/telephone/controllers/CmsController.php
index 97ce2a5c8d2..bece20c172e 100644
--- a/application/modules/telephone/controllers/CmsController.php
+++ b/application/modules/telephone/controllers/CmsController.php
@@ -22,9 +22,6 @@
 require_once ROOT_PATH.'application/modules/opac/controllers/CmsController.php';
 
 class Telephone_CmsController extends CmsController {
-   protected function _renderArticlesViewScript() {
-     $this->renderScript('cms/articleviewbydate.phtml');
-   }
 }
 
 ?>
\ No newline at end of file
diff --git a/application/modules/telephone/views/scripts/cms/articlesview.phtml b/application/modules/telephone/views/scripts/cms/articlesview.phtml
new file mode 100644
index 00000000000..165b1e0bdd9
--- /dev/null
+++ b/application/modules/telephone/views/scripts/cms/articlesview.phtml
@@ -0,0 +1,35 @@
+<?php
+echo $this->toolbar($this->_('Articles'),
+                    $this->url(array(), null, true));
+?>
+
+
+<?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>
+  <?php
+
+  } else {
+    echo '<div class="pave">'.$this->_('Aucun contenu').'</div>';
+
+  } ?>
diff --git a/application/modules/telephone/views/scripts/cms/articleviewbydate.phtml b/application/modules/telephone/views/scripts/cms/articleviewbydate.phtml
index 00784869494..d2c75c4a1e1 100644
--- a/application/modules/telephone/views/scripts/cms/articleviewbydate.phtml
+++ b/application/modules/telephone/views/scripts/cms/articleviewbydate.phtml
@@ -10,7 +10,7 @@ echo $this->toolbar($this->_('Articles'),
         <h2><?php echo ('' == $bibliotheque) ? $this->_('Portail') : $this->libelle_bibs[$bibliotheque];?></h2>
         <ul>
         <?php
-        foreach ($this->articles as $article) { ?>
+        foreach ($articles as $article) { ?>
           <li class="lien">
             <?php echo $this->tagArticleEvent($article);?>
             <span><?php
diff --git a/tests/application/modules/telephone/controllers/CmsControllerTest.php b/tests/application/modules/telephone/controllers/CmsControllerTest.php
index 645d451efa1..5680ec543df 100644
--- a/tests/application/modules/telephone/controllers/CmsControllerTest.php
+++ b/tests/application/modules/telephone/controllers/CmsControllerTest.php
@@ -32,31 +32,29 @@ abstract class AbstractCmsControllerTelephoneTestCase extends TelephoneAbstractC
 
     Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article')
       ->whenCalled('getArticlesByPreferences')
-      ->answers(array(
-                      Class_Article::getLoader()
-                      ->newInstanceWithId(1)
-                      ->setTitre('La fête de la banane')
-                      ->setContenu('Une fête qui glisse !')
-                      ->setEventsDebut('2011-09-03')
-                      ->setEventsFin('2011-10-03')
-                      ->setCategorie(
-                                     Class_ArticleCategorie::getLoader()->newInstanceWithId(1)
-                                     ->setLibelle('Alimentaire')
-                                     ->setBib(Class_Bib::getLoader()
-                                              ->newInstanceWithId(1)
-                                              ->setLibelle('Bonlieu'))
-                      ),
-                      Class_Article::getLoader()
-                      ->newInstanceWithId(1)
-                      ->setTitre('La fête de la frite')
-                      ->setContenu('')
-                      ->setEventsDebut('2011-09-03')
-                      ->setEventsFin('2011-09-03')
-                      ->setCategorie(
-                                     Class_ArticleCategorie::getLoader()->newInstanceWithId(1)
-                                     ->setLibelle('Alimentaire')
-                      ),
-                      ));
+      ->answers([
+                 Class_Article::newInstanceWithId(1)
+                 ->setTitre('La fête de la banane')
+                 ->setContenu('Une fête qui glisse !')
+                 ->setEventsDebut('2011-09-03')
+                 ->setEventsFin('2011-10-03')
+                 ->setCategorie(
+                                Class_ArticleCategorie::newInstanceWithId(1)
+                                ->setLibelle('Alimentaire')
+                                ->setBib(Class_Bib::getLoader()
+                                         ->newInstanceWithId(1)
+                                         ->setLibelle('Bonlieu'))
+                 ),
+                 Class_Article::newInstanceWithId(1)
+                 ->setTitre('La fête de la frite')
+                 ->setContenu('')
+                 ->setEventsDebut('2011-09-03')
+                 ->setEventsFin('2011-09-03')
+                 ->setCategorie(
+                                Class_ArticleCategorie::newInstanceWithId(1)
+                                ->setLibelle('Alimentaire')
+                 ),
+                 ]);
 
 
   }
-- 
GitLab