diff --git a/application/modules/admin/controllers/CmsController.php b/application/modules/admin/controllers/CmsController.php index 5a536570a8bbd2a4e1295ca63a2b9d6b9302e5f6..576bd406d6d2c6b039dd622d47de4357ea2a3626 100644 --- a/application/modules/admin/controllers/CmsController.php +++ b/application/modules/admin/controllers/CmsController.php @@ -518,18 +518,11 @@ class Admin_CmsController extends ZendAfi_Controller_Action { foreach(['description', 'contenu'] as $content_field) $attributes[$content_field] = Class_CmsUrlTransformer::forEditing($attributes[$content_field]); - $attributes['pick_day'] = $this->_getParamsAsArray(',', $attributes['pick_day']); + $attributes['pick_day'] = $model->getPickDayAsArray(); return $attributes; } - protected function _getParamsAsArray($sec, $param) { - if(empty($result = explode($sec, $param))) - return [$param]; - return $result; - } - - protected function _findModel() { if (!$article = Class_Article::find((int)$this->_getParam('id'))) return null; diff --git a/library/Class/Article.php b/library/Class/Article.php index 20722224c31b98ce7e81fb2843a4f0c222666d5f..041e6bd629b538f63dc03c0630008daaa812f195 100644 --- a/library/Class/Article.php +++ b/library/Class/Article.php @@ -514,28 +514,29 @@ class Class_Article extends Storm_Model_Abstract { 'refus_message']; protected $_default_attribute_values = [ - 'id_notice' => null, - 'titre' => '', - 'description' => '', - 'contenu' => '', - 'debut' => null, - 'fin' => null, - 'avis' => false, - 'tags' => '', - 'events_debut' => null, - 'events_fin' => null, - 'indexation' => 1, - 'cacher_titre' => 0, - 'date_maj' => '', - 'date_creation' => '', - 'status' => self::STATUS_DRAFT, - 'id_lieu' => 0, - 'id_cat' => 0, - 'domaine_ids' => '', - 'id_origine' => 0, - 'refus_message' => '', - 'destination_email' => '', - 'all_day' => FALSE]; + 'id_notice' => null, + 'titre' => '', + 'description' => '', + 'contenu' => '', + 'debut' => null, + 'fin' => null, + 'avis' => false, + 'tags' => '', + 'events_debut' => null, + 'events_fin' => null, + 'indexation' => 1, + 'cacher_titre' => 0, + 'date_maj' => '', + 'date_creation' => '', + 'status' => self::STATUS_DRAFT, + 'id_lieu' => 0, + 'id_cat' => 0, + 'domaine_ids' => '', + 'id_origine' => 0, + 'refus_message' => '', + 'destination_email' => '', + 'all_day' => FALSE, + 'pick_day' => null]; public function describeAssociationsOn($associations) { @@ -1324,5 +1325,17 @@ class Class_Article extends Storm_Model_Abstract { return ''; return $author->getLoginOrFullName(); } + + + public function getPickDayAsArray() { + $param = parent::_get('pick_day'); + if($param == '') + return []; + + if(empty($result = explode(',', $param))) + return [$param]; + + return $result; + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/Form/Admin/News.php b/library/ZendAfi/Form/Admin/News.php index 3388b18987ba8b4e6aabfa10ef38b761003a5def..e1199dcae3ce92a6a6d7b63d8863c0061716264a 100644 --- a/library/ZendAfi/Form/Admin/News.php +++ b/library/ZendAfi/Form/Admin/News.php @@ -86,13 +86,13 @@ class ZendAfi_Form_Admin_News extends ZendAfi_Form { ->addElement('multiCheckbox', 'pick_day', ['label' => $this->_('Tous les'), - 'multiOptions' => ['monday' => $this->_('lundi'), - 'tuesday' => $this->_('mardi'), - 'wensday' => $this->_('mercredi'), - 'tursday' => $this->_('jeudi'), - 'friday' => $this->_('vendredi'), - 'saturday' => $this->_('samedi'), - 'sunday' => $this->_('dimanche')], + 'multiOptions' => ['1' => $this->_('lundi'), + '2' => $this->_('mardi'), + '3' => $this->_('mercredi'), + '4' => $this->_('jeudi'), + '5' => $this->_('vendredi'), + '6' => $this->_('samedi'), + '0' => $this->_('dimanche')], 'order' => 12 ]) ->addElement('select', 'id_lieu', ['label' => $this->_('Lieu'), diff --git a/library/ZendAfi/View/Helper/Calendar/Table.php b/library/ZendAfi/View/Helper/Calendar/Table.php index f4dc2d86a4007ae550227e5f3df2e2e1f1d5e13e..2e6e0fa6f6e179292191c816fec9a1d6a73576bf 100644 --- a/library/ZendAfi/View/Helper/Calendar/Table.php +++ b/library/ZendAfi/View/Helper/Calendar/Table.php @@ -129,6 +129,7 @@ class ZendAfi_View_Helper_Calendar_Table extends Zend_View_Helper_HtmlElement { // le dictionnaire et virer tout ce code bizarre. $day = (int)gmdate("j", $date); $month = (int)gmdate("m", $date); + $day_num = gmdate("w", $date); foreach($events as $event) { $event_debut = strtotime($event->getEventsDebut()); @@ -139,7 +140,10 @@ class ZendAfi_View_Helper_Calendar_Table extends Zend_View_Helper_HtmlElement { $jour_fin = (int)date('j', $event_fin); $mois_fin = (int)date('m', $event_fin); - // Jour clickable + if(!empty($event->getPickDayAsArray()) && !in_array($day_num, $event->getPickDayAsArray())) + return false; + + // Jour clickable5# if($mois_debut == $month && $mois_fin == $month) { if($day >= $jour_debut && $day <= $jour_fin) return true; diff --git a/tests/application/modules/admin/controllers/CmsControllerTest.php b/tests/application/modules/admin/controllers/CmsControllerTest.php index e35450031402d820da650a89f878b4bb150aa357..8c1edd3434f3fd0c15f22c202d48c6e6b07f05f6 100644 --- a/tests/application/modules/admin/controllers/CmsControllerTest.php +++ b/tests/application/modules/admin/controllers/CmsControllerTest.php @@ -2785,6 +2785,6 @@ class CmsControllerEditArticleWithDate30December2014Test extends CmsControllerte /** @test */ public function mondayShouldBePicked() { - $this->assertXPath('//input[@checked="checked"][@value="monday"]'); + $this->assertXPath('//input[@checked="checked"][@value="1"]'); } } \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index 1663c1f936ec04d60c37bfae3b280fc3823e3d34..f221c2282613b09dffa7cbb2ca6ef0245a90bde0 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -1628,16 +1628,34 @@ abstract class ProfilOptionsControllerProfilBoiteCalendarTestCase extends Abstra public function setup() { parent::setup(); + $fiesta_annecy = $this->fixture('Class_ArticleCategorie', + ['id' => 1, + 'libelle' => 'Fiesta à Annecy']); + + $fete_caion = $this->fixture('Class_Article', + ['id' => 34, + 'titre' => 'Fête du caion', + 'contenu' => 'Fiesta fiesta', + 'description' => 'à Annecy', + 'events_debut' => '2011-09-01', + 'events_fin' => '2011-09-01', + 'categorie' => $fiesta_annecy]); + + $fete_moulins = $this->fixture('Class_Article', + ['id' => 35, + 'titre' => 'Fête du livre', + 'contenu' => 'Fiesta fiesta', + 'description' => 'à Moulins', + 'events_debut' => '2011-09-05', + 'events_fin' => '2011-10-05', + 'pick_day' => '12345', + 'categorie' => $fiesta_annecy]); + Class_AdminVar::beVolatile(); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') ->whenCalled('getArticlesByPreferences') - ->answers([Class_Article::newInstanceWithId(34, [ - 'titre' => 'Fête du caion', - 'description' => 'à Annecy', - 'events_debut' => '2011-09-03', - 'events_fin' => '2011-09-03', - 'categorie' => Class_ArticleCategorie::newInstanceWithId(1, - ['libelle' => 'Fiesta à Annecy'])])]); + ->answers([$fete_caion, + $fete_moulins]); } } @@ -1659,6 +1677,11 @@ class ProfilOptionsControllerProfilBoiteCalendarWithCalendarDisplayedAndModeSimp ->setLibelle('Profil Portail') ->setCfgAccueil($cfg_accueil); + $time_source = new TimeSourceForTest('2011-09-03 12:30:00'); + + Class_Calendar::setTimeSource($time_source); + ZendAfi_View_Helper_CalendarContent::setTimeSource($time_source); + $this->dispatch('/opac'); } @@ -1728,6 +1751,12 @@ class ProfilOptionsControllerProfilBoiteCalendarWithCalendarDisplayedAndModeSimp public function boiteCalendarLiShouldContainsCalendarEventTitle() { $this->assertXPathContentContains('//li/a[@class="calendar_event_title"]', 'Fête du caion'); } + + + /** @test */ + public function sundayShouldNotContainsLink() { + $this->assertNotXPath('//td[@class="calendar_weekend"]//a[contains(@class, "day_clickable")]', $this->_response->getBody()); + } } diff --git a/tests/library/Class/ArticleTest.php b/tests/library/Class/ArticleTest.php index dfa55991f66f689a0f126058a8c0482612683a20..dabfc3b3daab0d4b097ccc3d82672107f133f196 100644 --- a/tests/library/Class/ArticleTest.php +++ b/tests/library/Class/ArticleTest.php @@ -1321,4 +1321,10 @@ class ArticleFirstImagePathTest extends Storm_Test_ModelTestCase { public function firstImagePathShoulReturnUserfileImagesCatMyImage() { $this->assertEquals('./userfiles/images/cat/my_image.jpg', Class_Article::find(1)->getFirstImagePath()); } + + + /** @test */ + public function pickDayShouldBeAnEmptyArray() { + $this->assertEquals([], $this->_article->getPickDayAsArray()); + } }