diff --git a/application/modules/admin/views/scripts/accueil/calendrier.phtml b/application/modules/admin/views/scripts/accueil/calendrier.phtml index 4b28083a03804a6449245c77b32d94bd63aa70ff..a19d4d0c4c16b4175542e093616dc0aab6798d9c 100644 --- a/application/modules/admin/views/scripts/accueil/calendrier.phtml +++ b/application/modules/admin/views/scripts/accueil/calendrier.phtml @@ -77,13 +77,25 @@ 'diaporama_navigation' => $this->_('Diaporama avec navigation'), 'none' => $this->_('Ne pas afficher')]); echo (new ZendAfi_View_Helper_Admin_PropertiesReader()) - ->setView($this) - ->propertiesReader($this->preferences['mode-affichage'], - $this->preferences); + ->setView($this) + ->propertiesReader($this->preferences['mode-affichage'], + $this->preferences); ?> </td> - </tr> - <tr> + </tr> + + <tr> + <td class="droite"><?php echo $this->_('Filtre sur les évènements'); ?></td> + <td class="gauche"> + <?php echo $this->formSelect('event_filter', + $this->preferences['event_filter'], + '', + ['none' => $this->_('aucun'), + 'month' => $this->_('par mois')]); ?> + </td> + </tr> + + <tr> <td class="droite">Mode d'affichage des titres</td> <td class="gauche"> <?php @@ -148,16 +160,16 @@ <div id='table_selection'> <?php - echo $this->treeSelect( - '', - $this->preferences["id_categorie"], - true, - $this->url(array('module' => 'admin', - 'controller' => 'bib', - 'action' => 'articles', - 'id_bib' => $this->id_bib, - 'categories_only' => 1)), - "form"); + echo $this->treeSelect( + '', + $this->preferences["id_categorie"], + true, + $this->url(array('module' => 'admin', + 'controller' => 'bib', + 'action' => 'articles', + 'id_bib' => $this->id_bib, + 'categories_only' => 1)), + "form"); ?> </div> diff --git a/application/modules/opac/controllers/CmsController.php b/application/modules/opac/controllers/CmsController.php index bf5a2c66de3bf77bcea67500ae022d842efdef07..28d38b4ff61d74007359ddd42ae3f06d1d98e088 100644 --- a/application/modules/opac/controllers/CmsController.php +++ b/application/modules/opac/controllers/CmsController.php @@ -292,8 +292,8 @@ class CmsController extends Zend_Controller_Action { $param['DISPLAY_CAT_SELECT'] = $preferences['display_cat_select']; $param['MODE_AFFICHAGE'] = $preferences['mode-affichage']; $param['DISPLAY_CALENDAR'] = $preferences['display_calendar']; - $param['EVENT_INFO'] = $preferences['display_event_info']; + $param['EVENT_FILTER'] = $preferences['event_filter']; $this->view->param = $param; } diff --git a/library/Class/Calendar.php b/library/Class/Calendar.php index a29ff5d628bf5e612dc9b3346f16f4a88877d34b..10d99a7f05e78c1f0966c97956b94e1baeccd7e0 100644 --- a/library/Class/Calendar.php +++ b/library/Class/Calendar.php @@ -109,7 +109,7 @@ class Class_Calendar { /*if ($this->param["ALEATOIRE"] == 1) shuffle($articles);*/ - if (count($articles) < $this->param['NB_NEWS']) { + if (count($articles) < $this->param['NB_NEWS'] && $this->param['EVENT_FILTER']=='none') { $next_articles = $this->_loadArticles(['event_start_after' => $this->param["DATE"], 'event_date' => '', 'event_end_after' => '', diff --git a/library/Class/Systeme/ModulesAccueil/Calendrier.php b/library/Class/Systeme/ModulesAccueil/Calendrier.php index fd157fd9f3a60841366b327b6d8e383c1044091f..663f03505b6ec186e01bfff4c72c429ec9955c88 100644 --- a/library/Class/Systeme/ModulesAccueil/Calendrier.php +++ b/library/Class/Systeme/ModulesAccueil/Calendrier.php @@ -38,7 +38,7 @@ class Class_Systeme_ModulesAccueil_Calendrier extends Class_Systeme_ModulesAccue protected $_isPhone = true; /** @var array */ - protected $_defaultValues = array( + protected $_defaultValues = [ 'titre' => 'Calendrier des animations', // Titre de la boite 'id_categorie' => '', // Catégories d'articles à afficher. ex: 2-3-4 'display_cat_select' => false, // Afficher le sélecteur de catégories @@ -51,8 +51,9 @@ class Class_Systeme_ModulesAccueil_Calendrier extends Class_Systeme_ModulesAccue 'display_mode' => 'Title', // Mode d'affichage Title, Summary, FullArticle, 'nb_events' => '3', // Nombre de rendez-vous à afficher 'display_calendar' => '1', // Mode d'affichage du calendrier: 0 (caché) / 1 (calendrier) / 2 (frise chrono) - 'mode-affichage' => 'simple' // mode d'affichage des prochains événements dans la boite: none (aucun) / simple (titre + catégorie ou bib) / article (résumé article) - ); + 'mode-affichage' => 'simple', // mode d'affichage des prochains événements dans la boite: none (aucun) / simple (titre + catégorie ou bib) / article (résumé article) + 'event_filter' => 'none' // filtre les articles par mois à l'affichage + ]; /** @return array */ diff --git a/library/ZendAfi/View/Helper/Accueil/Calendar.php b/library/ZendAfi/View/Helper/Accueil/Calendar.php index a77d1228a5d81a732be13af65f5ba8d3904f09aa..0433fa8f48774ebf4649175952b2f45edbbbd107 100644 --- a/library/ZendAfi/View/Helper/Accueil/Calendar.php +++ b/library/ZendAfi/View/Helper/Accueil/Calendar.php @@ -56,9 +56,10 @@ class ZendAfi_View_Helper_Accueil_Calendar extends ZendAfi_View_Helper_Accueil_B $this->rss_interne = $this->_getRSSurl('cms', 'calendarrss'); - $param = array(); - if (array_isset('display_date', $this->preferences)) - $param['DATE'] = $this->preferences['display_date']; + $param = []; + + + $param['DATE'] = array_isset('display_date', $this->preferences) ? $this->preferences['display_date'] : ''; $param['URL']=''; $param['ID_BIB']=Class_Profil::getCurrentProfil()->getIdSite(); $param['NB_NEWS']=(int)$this->preferences['nb_events']; @@ -70,6 +71,8 @@ class ZendAfi_View_Helper_Accueil_Calendar extends ZendAfi_View_Helper_Accueil_B $param['ALEATOIRE'] = 1; $param['MODE_AFFICHAGE'] = array_key_exists('mode-affichage', $this->preferences) ? $this->preferences['mode-affichage'] : 'simple'; $param['DISPLAY_CALENDAR'] = $this->preferences['display_calendar']; + $param['EVENT_FILTER'] = array_isset('event_filter', $this->preferences) ? $this->preferences['event_filter'] : ''; + ; $this->contenu = $this->view->calendarContent($param); diff --git a/tests/application/modules/admin/controllers/AccueilControllerCalendarTest.php b/tests/application/modules/admin/controllers/AccueilControllerCalendarTest.php index 2c17e682c1019f48bf511e61a740ae554fde9caa..a96104c6dbc040602b002a7346c951c8c6fec974 100644 --- a/tests/application/modules/admin/controllers/AccueilControllerCalendarTest.php +++ b/tests/application/modules/admin/controllers/AccueilControllerCalendarTest.php @@ -40,13 +40,20 @@ class Admin_AccueilControllerCalendarTestWithDefaultDiaporamaNavigation extends 'display_mode' => 'Summary', 'display_order' => 'EventDebut', 'display_cat_select' => '', - 'id_categorie' => '' + 'id_categorie' => '', + 'event_filter' => 'none' ]]) ->beCurrentProfil(); $this->dispatch('admin/accueil/calendrier?config=accueil&id_profil=1&id_module=1&type_module=CALENDRIER', true); } + + /** @test */ + public function settingsEventFilterToDisplayShouldBePresent() { + $this->assertXPath('//td[contains(text(),"Filtre")]/following-sibling::td/select[@name="event_filter"]/option[@value="none"][@selected="selected"]', $this->_response->getBody()); + } + /** @test */ public function selectDisplayModeShouldBeDisplay() { diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index 5e35af66f7097f3bfa1c916294420b8688f013d9..97f94ce878791bc5ef965faef2f26b29342970e6 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -1832,4 +1832,132 @@ class ProfilOptionsControllerWithFormationExpiredTest extends AbstractController $this->assertNotXpathContentContains('//div[@class="boite formations_widget"]//ul/li/ul/li/dl/dd', 'dogfighting tricks'); } } + + + +abstract class ProfilOptionsControllerProfilBoiteCalendarWithFilterTestCase extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + Class_Article::beVolatile(); + + $article_mars = $this->fixture('Class_Article', + ['id' => 1, + 'titre' => 'News from Mars', + 'contenu' => 'Hey! Hello from Mars.', + 'event_date' => '01/03/2050']); + + $article_october = $this->fixture('Class_Article', + ['id' => 2, + 'titre' => 'News from October', + 'contenu' => 'In october ... ', + 'event_date' => '01/10/2050']); + + + ZendAfi_View_Helper_CalendarContent::setTimeSource(new TimeSourceForTest('2050-03-01 14:14:14')); + + Class_AdminVar::beVolatile(); + + Storm_Test_ObjectWrapper::onloaderOfModel('Class_Article') + ->whenCalled('getArticlesByPreferences') + ->with(['display_order' => 'EventDebut', + 'id_categorie' => '', + 'events_only' => true, + 'event_date' => '2050-03', + 'id_bib' => 0, + 'published' => true, + 'event_end_after' => '2050-03-01']) + ->answers([$article_mars]) +->whenCalled('getArticlesByPreferences') + ->with(['display_order' => 'EventDebut', + 'id_categorie' => '', + 'events_only' => true, + 'event_date' => '2050-03', + 'id_bib' => 0, + 'published' => true]) + ->answers([$article_mars]) + +->whenCalled('getArticlesByPreferences') + ->with(['display_order' => 'EventDebut', + 'id_categorie' => '', + 'events_only' => true, + 'event_date' => '', + 'id_bib' => 0, + 'published' => true, + 'event_start_after' => '2050-03', + 'event_end_after' => '', + 'limit' => 3]) + ->answers([$article_october]) + ->beStrict(); + } +} + + + +class ProfilOptionsControllerProfilBoiteCalendarWithFilterOnMonthsTest extends ProfilOptionsControllerProfilBoiteCalendarWithFilterTestCase { + + public function setup() { + parent::setup(); + + $cfg_accueil = ['modules' => ['45' => ['division' => '1', + 'type_module' => 'CALENDAR', + 'preferences' => ['display_calendar' => '0', + 'mode-affichage' => 'wall', + 'event_filter' => 'month']]]]; + + $this->profil_with_calendar = Class_Profil::getCurrentProfil() + ->setBrowser('opac') + ->setTitreSite('Test Calendar') + ->setLibelle('Profil Portail') + ->setCfgAccueil($cfg_accueil); + + $this->dispatch('/opac'); + } + + + /** @test */ + public function boiteCalendarShouldBeDisplay() { + $this->assertXPath('//div[contains(@class,"calendar")]'); + } + + + /** @test **/ + public function articleFromOctoberShouldNotBePresent() { + $this->assertNotXPath('//article//header//a[contains(text(), "News from October")]'); + } +} + + + +class ProfilOptionsControllerProfilBoiteCalendarWithNoFilterTest extends ProfilOptionsControllerProfilBoiteCalendarWithFilterTestCase { + + public function setup() { + parent::setup(); + + $cfg_accueil = ['modules' => ['45' => ['division' => '1', + 'type_module' => 'CALENDAR', + 'preferences' => ['display_calendar' => '0', + 'mode-affichage' => 'wall', + 'event_filter' => 'none']]]]; + + $this->profil_with_calendar = Class_Profil::getCurrentProfil() + ->setBrowser('opac') + ->setTitreSite('Test Calendar') + ->setLibelle('Profil Portail') + ->setCfgAccueil($cfg_accueil); + + $this->dispatch('/opac'); + } + + + /** @test */ + public function boiteCalendarShouldBeDisplay() { + $this->assertXPath('//div[contains(@class,"calendar")]'); + } + + + /** @test **/ + public function articleFromOctoberShouldBePresent() { + $this->assertXPath('//article//header//a[contains(text(), "News from October")]'); + } +} ?> \ No newline at end of file