From 85bde67b81f4286b43a6ba4697ee309411598714 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Mon, 23 Apr 2012 10:52:23 +0000 Subject: [PATCH] =?UTF-8?q?Calendrier:=C2=A0lorsqu'on=20clique=20sur=20le?= =?UTF-8?q?=20titre,=20n'affiche=20que=20les=20articles=20pour=20dont=20la?= =?UTF-8?q?=20cate=CC=81gorie=20a=20e=CC=81te=CC=81=20se=CC=81lectionne?= =?UTF-8?q?=CC=81e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../opac/controllers/CmsController.php | 23 ++++++++++++------- library/Class/Calendar.php | 5 +++- .../ZendAfi/View/Helper/Accueil/Calendar.php | 10 +++++--- .../modules/AbstractControllerTestCase.php | 2 +- .../opac/controllers/CmsControllerTest.php | 13 +++++++---- .../View/Helper/Accueil/CalendarTest.php | 18 +++++++++++---- 6 files changed, 49 insertions(+), 22 deletions(-) diff --git a/application/modules/opac/controllers/CmsController.php b/application/modules/opac/controllers/CmsController.php index 1f0b35e82ba..b75aa3460de 100644 --- a/application/modules/opac/controllers/CmsController.php +++ b/application/modules/opac/controllers/CmsController.php @@ -39,16 +39,22 @@ class CmsController extends ZendAfi_Controller_IFrameAction { * 'cat': identifiant de la catégorie */ public function articleviewbydateAction() { - $prefs = array( - 'event_date' => $this->_getParam('d'), - 'id_bib' => $this->_getParam('b'), - 'display_order' => 'EventDebut', - 'events_only' => true, - 'published' => false); + $id_profil = (int)$this->_getParam('id_profil'); + $id_module = (int)$this->_getParam('id_module'); + if (!$profil = Class_Profil::getLoader()->find($id_profil)) + $profil = Class_Profil::getCurrentProfil(); + $preferences = $profil->getModuleAccueilPreferences($id_module); + + $preferences['event_date'] = $this->_getParam('d'); + $preferences['id_bib'] = $this->_getParam('b'); + $preferences['display_order'] = 'EventDebut'; + $preferences['events_only'] = true; + $preferences['published'] = false; + if ($id_cat = (int)$this->_getParam('select_id_categorie')) - $prefs['id_categorie'] = $id_cat; + $preferences['id_categorie'] = $id_cat; - $articles = Class_Article::getLoader()->getArticlesByPreferences($prefs); + $articles = Class_Article::getLoader()->getArticlesByPreferences($preferences); $articles = Class_Article::getLoader()->filterByLocaleAndWorkflow($articles); @@ -56,6 +62,7 @@ class CmsController extends ZendAfi_Controller_IFrameAction { } + public function calendarrssAction() { $id_profil = (int)$this->_getParam('id_profil'); $id_module = (int)$this->_getParam('id_module'); diff --git a/library/Class/Calendar.php b/library/Class/Calendar.php index cefa4c71edc..82a315f58bc 100644 --- a/library/Class/Calendar.php +++ b/library/Class/Calendar.php @@ -450,7 +450,10 @@ class Class_Calendar { $url = BASE_URL."/cms/articleviewbydate?d=".$this->year.'-'.$mois.'-'.$day; break; } - return $url."&id_module=".$this->id_module.'&select_id_categorie='.$this->param["SELECT_ID_CAT"]; + return $url."&".http_build_query(array( + 'id_module' => $this->id_module, + 'id_profil' => Class_Profil::getCurrentProfil()->getId(), + 'select_id_categorie' => $this->param["SELECT_ID_CAT"])); } function getLastMonth($month, $year) { diff --git a/library/ZendAfi/View/Helper/Accueil/Calendar.php b/library/ZendAfi/View/Helper/Accueil/Calendar.php index c6a3557b717..e4c61a65037 100644 --- a/library/ZendAfi/View/Helper/Accueil/Calendar.php +++ b/library/ZendAfi/View/Helper/Accueil/Calendar.php @@ -26,9 +26,13 @@ class ZendAfi_View_Helper_Accueil_Calendar extends ZendAfi_View_Helper_Accueil_B //--------------------------------------------------------------------- // Fabrique le html //--------------------------------------------------------------------- - public function getHtml() - { - $this->titre = '<a href="'.BASE_URL.'/cms/articleviewbydate">'.$this->preferences["titre"].'</a>'; + public function getHtml() { + $this->titre = $this->view->tagAnchor(array('controller' => 'cms', + 'action' => 'articleviewbydate', + 'id_module' => $this->id_module, + 'id_profil' => Class_Profil::getCurrentProfil()->getId()), + $this->preferences["titre"]); + if ($this->preferences['rss_avis']) $this->rss_interne = $this->_getRSSurl('cms', 'calendarrss'); diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index 9648bb33493..89cb3868a4f 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -92,7 +92,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe public function setUp() { $this->_registry_sql = Zend_Registry::get('sql'); - + Storm_Model_Abstract::unsetLoaders(); Class_ScriptLoader::resetInstance(); $this->_initMockProfil(); diff --git a/tests/application/modules/opac/controllers/CmsControllerTest.php b/tests/application/modules/opac/controllers/CmsControllerTest.php index 32901cbce87..e675a94e260 100644 --- a/tests/application/modules/opac/controllers/CmsControllerTest.php +++ b/tests/application/modules/opac/controllers/CmsControllerTest.php @@ -202,6 +202,11 @@ class CmsControllerArticleViewByDateTest extends AbstractControllerTestCase { $this->_article_loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') ->whenCalled('getArticlesByPreferences') + ->with(array('event_date' => '2011-09-03', + 'id_bib' => null, + 'display_order' => 'EventDebut', + 'events_only' => true, + 'published' => false)) ->answers( array( Class_Article::getLoader() @@ -227,10 +232,10 @@ class CmsControllerArticleViewByDateTest extends AbstractControllerTestCase { Class_ArticleCategorie::getLoader()->newInstanceWithId(1) ->setLibelle('Alimentaire') ), - )) - ->getWrapper(); + )); + - $this->dispatch('/cms/articleviewbydate?d=2011-09-03&id_module=8&select_id_categorie=all'); + $this->dispatch('/cms/articleviewbydate?d=2011-09-03&id_module=8&id_profil=2&select_id_categorie=all'); } /** @test */ @@ -277,7 +282,7 @@ class CmsControllerArticleViewByDateTest extends AbstractControllerTestCase { } -class CmsControllerArticleViewByDateCategorie23Test extends AbstractControllerTestCase { +class CmsControllerArticleViewByDateCategorie23AndNoProfilParamTest extends AbstractControllerTestCase { protected $_article_loader; public function setUp() { diff --git a/tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php b/tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php index 6677ff803ad..1392ac7bacc 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php @@ -126,6 +126,14 @@ class CalendarWithEmptyPreferencesTest extends CalendarWithEmptyPreferencesTestC } + /** @test */ + public function titreShouldBeAgendaAndLinkToArticleViewByDate() { + $this->assertXPathContentContains($this->html, + '//a[contains(@href, "/cms/articleviewbydate/id_module/2/id_profil/2")]', + 'Agenda'); + } + + /** @test */ function shouldDisplayCurrentMonth() { $this->assertXPathContentContains($this->html, @@ -277,7 +285,7 @@ class CalendarWithCategoryLimitAndBibPreferencesTest extends CalendarViewHelperT /** @test */ function titleMonthFirstLinkShouldGoToFebruary() { $this->assertXPath($this->html, - '//td[@class="calendar_title_month"]//a[1][contains(@href, "cms/calendar?date=2011-02&id_module=2&select_id_categorie=all")]', + '//td[@class="calendar_title_month"]//a[1][contains(@href, "cms/calendar?date=2011-02&id_module=2&id_profil=2&select_id_categorie=all")]', $this->html); } @@ -285,7 +293,7 @@ class CalendarWithCategoryLimitAndBibPreferencesTest extends CalendarViewHelperT /** @test */ function titleMonthSecondLinkShouldLinkToArticleViewByDate() { $this->assertXPath($this->html, - '//td[@class="calendar_title_month"]//a[2][contains(@href, "cms/articleviewbydate?d=2011-03&id_module=2&select_id_categorie=all")]', + '//td[@class="calendar_title_month"]//a[2][contains(@href, "cms/articleviewbydate?d=2011-03&id_module=2&id_profil=2&select_id_categorie=all")]', $this->html); } @@ -293,7 +301,7 @@ class CalendarWithCategoryLimitAndBibPreferencesTest extends CalendarViewHelperT /** @test */ function titleMonthLastLinkShouldGoToApril() { $this->assertXPath($this->html, - '//td[@class="calendar_title_month"]//a[3][contains(@href, "cms/calendar?date=2011-04&id_module=2&select_id_categorie=all")]', + '//td[@class="calendar_title_month"]//a[3][contains(@href, "cms/calendar?date=2011-04&id_module=2&id_profil=2&select_id_categorie=all")]', $this->html); } @@ -378,7 +386,7 @@ class CalendarWithCategorySelectorAndRssPreferencesTest extends CalendarViewHelp /** @test */ function titleMonthLastLinkShouldGoToJanuary2012Categorie12() { $this->assertXPath($this->html, - '//td[@class="calendar_title_month"]//a[3][contains(@href, "cms/calendar?date=2012-01&id_module=2&select_id_categorie=12")]', + '//td[@class="calendar_title_month"]//a[3][contains(@href, "cms/calendar?date=2012-01&id_module=2&id_profil=2&select_id_categorie=12")]', $this->html); } @@ -536,7 +544,7 @@ class CalendarOnJanuaryTest extends CalendarViewHelperTestCase { /** @test */ function titleMonthPreviousLinkShouldGoToDecember2011() { $this->assertXPath($this->html, - '//td[@class="calendar_title_month"]//a[1][contains(@href, "cms/calendar?date=2011-12&id_module=2&select_id_categorie=all")]', + '//td[@class="calendar_title_month"]//a[1][contains(@href, "cms/calendar?date=2011-12&id_module=2&id_profil=2&select_id_categorie=all")]', $this->html); } -- GitLab