From 831b959e05ae5d328927347fa0d630e8d245b67d Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Tue, 29 May 2012 14:05:58 +0000
Subject: [PATCH] =?UTF-8?q?Te=CC=81le=CC=81phone=20/=20Calendrier=20:=20af?=
 =?UTF-8?q?fichage=20de=20la=20liste=20des=20articles=20par=20big=20/=20e?=
 =?UTF-8?q?=CC=81vent?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .gitattributes                                |  1 +
 .../opac/controllers/CmsController.php        |  8 +-
 .../telephone/controllers/CmsController.php   |  9 +-
 .../views/scripts/cms/articleviewbydate.phtml | 39 +++++++++
 library/Class/Calendar.php                    |  2 +-
 .../telephone/skins/original/css/global.css   |  8 +-
 .../controllers/CmsControllerTest.php         | 82 ++++++++++++++++++-
 7 files changed, 139 insertions(+), 10 deletions(-)
 create mode 100644 application/modules/telephone/views/scripts/cms/articleviewbydate.phtml

diff --git a/.gitattributes b/.gitattributes
index 72ae7bd7a1e..96684ab3b42 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -651,6 +651,7 @@ application/modules/telephone/views/scripts/bib-numerique/view-categorie.phtml -
 application/modules/telephone/views/scripts/blog/viewauteur.phtml -text
 application/modules/telephone/views/scripts/blog/viewavis.phtml -text
 application/modules/telephone/views/scripts/cms/articleview.phtml -text
+application/modules/telephone/views/scripts/cms/articleviewbydate.phtml -text
 application/modules/telephone/views/scripts/empty.phtml -text svneol=unset#application/octet-stream
 application/modules/telephone/views/scripts/error/error.phtml -text
 application/modules/telephone/views/scripts/footer.phtml -text
diff --git a/application/modules/opac/controllers/CmsController.php b/application/modules/opac/controllers/CmsController.php
index 42aaaccabe8..318408c6e0f 100644
--- a/application/modules/opac/controllers/CmsController.php
+++ b/application/modules/opac/controllers/CmsController.php
@@ -239,8 +239,10 @@ class CmsController extends Zend_Controller_Action {
 
 		$date = $this->_getParam("date");
 		$id_module = $this->_getParam("id_module");
-		$preferences = $this->_modulesPreferences($id_module);
 
+		$module_calendrier = new Class_Systeme_ModulesAccueil_Calendrier();
+		$preferences = array_merge($module_calendrier->getDefaultValues(),
+															 $this->_modulesPreferences($id_module));
 		if (!preg_match('/[0-9]{4}-[0-9]{2}/', $date)) {
 			$date = date('Y-m-d');
 		}
@@ -254,12 +256,12 @@ class CmsController extends Zend_Controller_Action {
 		$param["NB_NEWS"]= (int)$preferences["nb_events"];
 		$param["ALEATOIRE"]=1;
 		$param["ID_MODULE"] = $id_module;
-		$param["ID_CAT"] = $preferences["id_categorie"];
+		$param["ID_CAT"] = $preferences['id_categorie'];
 		$param["SELECT_ID_CAT"] = $preferences["display_cat_select"]
 																? $this->_getParam("select_id_categorie")
 																: "all";
 		$param["DISPLAY_CAT_SELECT"] = $preferences["display_cat_select"];
-		$param["DISPLAY_NEXT_EVENT"] = array_key_exists('display_next_event', $preferences) ? $preferences["display_next_event"] : '1';
+		$param["DISPLAY_NEXT_EVENT"] = $preferences["display_next_event"];
 		$param["EVENT_INFO"] = $preferences["display_event_info"];
 		$class_calendar = new Class_Calendar($param);
 		$this->getResponse()->setBody($class_calendar->rendHTML());
diff --git a/application/modules/telephone/controllers/CmsController.php b/application/modules/telephone/controllers/CmsController.php
index ac484c3263e..7c04737905e 100644
--- a/application/modules/telephone/controllers/CmsController.php
+++ b/application/modules/telephone/controllers/CmsController.php
@@ -18,9 +18,10 @@
  * along with AFI-OPAC 2.0; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
  */
-class Telephone_CmsController extends Zend_Controller_Action {
-	function articleviewAction() {
-		$this->view->article = Class_Article::getLoader()->find((int)$this->_getParam('id'));
-	}
+
+require_once ROOT_PATH.'application/modules/opac/controllers/CmsController.php';
+
+class Telephone_CmsController extends CmsController {
 }
+
 ?>
\ No newline at end of file
diff --git a/application/modules/telephone/views/scripts/cms/articleviewbydate.phtml b/application/modules/telephone/views/scripts/cms/articleviewbydate.phtml
new file mode 100644
index 00000000000..e6d73267ced
--- /dev/null
+++ b/application/modules/telephone/views/scripts/cms/articleviewbydate.phtml
@@ -0,0 +1,39 @@
+<?php 
+echo $this->toolbar($this->_('Articles'), 
+										$this->url(array(), null, true),
+										false); 
+?>
+
+
+<?php if (0 < count($this->articles)) { ?>
+		<div class="liste">
+			<?php foreach ($this->articles as $bibliotheque => $articles) { ?>
+				<h2><?php echo ('' == $bibliotheque) ? $this->_('Portail') : $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 } ?>
+		</div>
+<?php
+
+} else {
+	echo '<div class="pave">'.$this->_('Aucun contenu').'</div>';
+
+} ?>
\ No newline at end of file
diff --git a/library/Class/Calendar.php b/library/Class/Calendar.php
index 3629c8a069c..c8cb63ceecc 100644
--- a/library/Class/Calendar.php
+++ b/library/Class/Calendar.php
@@ -47,7 +47,7 @@ class Class_Calendar {
 				month_link.click(function(event) {
 					event.preventDefault();
 					var url = $(this).attr('href');
-					$(this).parents(".calendar").load(url, 
+					$(this).parents(".calendar").load(url+' .calendar>div', 
 																						ajaxify_calendars);
 				});
 
diff --git a/public/telephone/skins/original/css/global.css b/public/telephone/skins/original/css/global.css
index 8f54bcf6670..59ed26042ab 100644
--- a/public/telephone/skins/original/css/global.css
+++ b/public/telephone/skins/original/css/global.css
@@ -144,7 +144,7 @@ h1 {color:#666666;margin:0px; font-size:16px;padding:5px 3px 3px 3px}
 }
 
 /* Bloc pavé interne */
-.pave, .resumes>div>div, .calendar
+.pave, .resumes>div>div, .calendar>div
 {
 	background-color:#FFFFFF;
 	margin: 6px 6px 17px 6px;
@@ -325,4 +325,10 @@ tr.calendar_title {
 
 table.calendar_table {
 		text-align: right;
+}
+
+
+.day_clickable {
+		font-weight: bold;
+		text-decoration: underline;
 }
\ No newline at end of file
diff --git a/tests/application/modules/telephone/controllers/CmsControllerTest.php b/tests/application/modules/telephone/controllers/CmsControllerTest.php
index 59c3165f8e4..67632f9089a 100644
--- a/tests/application/modules/telephone/controllers/CmsControllerTest.php
+++ b/tests/application/modules/telephone/controllers/CmsControllerTest.php
@@ -32,6 +32,8 @@ abstract class AbstractCmsControllerTelephoneTestCase extends TelephoneAbstractC
 }
 
 
+
+
 class CmsControllerTelephoneTest extends AbstractCmsControllerTelephoneTestCase {
 	public function setUp() {
 		parent::setUp();
@@ -50,10 +52,11 @@ class CmsControllerTelephoneTest extends AbstractCmsControllerTelephoneTestCase
 	function contentShouldBeAAnnecy() {
 		$this->assertXPathContentContains('//div[@class="article pave"]', 'A Annecy !');
 	}
-
 }
 
 
+
+
 class CmsControllerTelephoneEmbeddedTest extends AbstractCmsControllerTelephoneTestCase {
 	public function setUp() {
 		parent::setUp();
@@ -68,4 +71,81 @@ class CmsControllerTelephoneEmbeddedTest extends AbstractCmsControllerTelephoneT
 	}
 }
 
+
+
+
+
+class CmsControllerCalendarActionTest extends AbstractCmsControllerTelephoneTestCase {
+	public function setUp() {
+		parent::setUp();
+
+		$this->dispatch('/telephone/cms/calendar?date=2011-10', true);
+	}
+
+
+	/** @test */
+	public function pageShouldRenderOctober() {
+		$this->assertXPathContentContains('//td[@class="calendar_title_month"]/a', 
+																			"octobre"); 
+	}
+}
+
+
+
+
+class CmsControllerArticleViewByDateActionTest extends AbstractCmsControllerTelephoneTestCase {
+	public function setUp() {
+		parent::setUp();
+
+		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')
+																		 ),
+											));
+
+		$this->dispatch('/telephone/cms/articleviewbydate?d=2011-10-01', true);
+	}
+
+
+	/** @test */
+	public function feteDeLaBananeShouldBePresent() {
+		$this->assertXpathContentContains('//ul//li//a', 'La fête de la banane');
+	}
+
+
+	/** @test */
+	public function feteDeLaBananeAnchorShouldLinkToActionViewArticleOne() {
+		$this->assertXpathContentContains('//ul//li//a[contains(@href, "cms/articleview/id/1")]', 
+																			'La fête de la banane');
+	}
+
+
+	/** @test */
+	public function toolbarUrlRetourShouldBeRoot() {
+		$this->assertXPath('//div[@class="toolbar"]//a[@href="/"]');
+	}
+}
+
 ?>
\ No newline at end of file
-- 
GitLab