diff --git a/VERSIONS_HOTLINE/113717 b/VERSIONS_HOTLINE/113717 new file mode 100644 index 0000000000000000000000000000000000000000..5a150cd1ca98fb50d33af0476dfb5160162e4f3a --- /dev/null +++ b/VERSIONS_HOTLINE/113717 @@ -0,0 +1 @@ + - ticket #113717 : Magasin de thèmes / boite agenda : correction de la prise en compte des paramètres de boîte \ No newline at end of file diff --git a/library/Class/Calendar.php b/library/Class/Calendar.php index a48ebdefa674a7bcd62d7a75c9ea111c93939c3e..89401fd4f37b847711aaf8677d5b6309fa14dcc6 100644 --- a/library/Class/Calendar.php +++ b/library/Class/Calendar.php @@ -216,7 +216,7 @@ class Class_Calendar { } - protected function _getNextEvents(){ + protected function _getNextEvents($fill_with_following_months = true){ $time = $this->getTimeSource()->time(); $prefs = []; if ($this->date == strftime('%Y-%m',$time)) @@ -224,6 +224,9 @@ class Class_Calendar { $articles = $this->_loadArticles($prefs); + if (!$fill_with_following_months) + return $articles; + if (count($articles) < $this->_getSize() && $this->preferences['event_filter'] == 'none') { $next_articles = $this->_loadArticles(['event_start_after' => $this->date, @@ -271,25 +274,17 @@ class Class_Calendar { } - public function getArticles() { + public function getArticles($fill_with_following_months = true) { $articles = isset($this->day) ? $this->_loadArticles(['event_date' => $this->day]) - : $this->_getNextEvents(); - - return array_slice($articles, 0, $this->_getSize()); - } - + : $this->_getNextEvents($fill_with_following_months); - public function getArticlesInMonth() { - $articles = Class_Article::getArticlesByPreferences(['event_date'=> self::getTimeSource()->getMonth($this->month), - 'events_only' => true, - 'status' => 3]); return array_slice($articles, 0, $this->_getSize()); } - public function getNextEvents() { - $articles = $this->_getNextEvents(); + public function getNextEvents($fill_with_following_months = true) { + $articles = $this->_getNextEvents($fill_with_following_months); return array_slice($articles, 0, $this->_getSize()); } diff --git a/library/Class/Catalogue.php b/library/Class/Catalogue.php index c7d95708e6e7323cc146e2f10884d8720d5c4292..c24c70ddb03ee2cb89cbc65119ab72f82a1c44a1 100644 --- a/library/Class/Catalogue.php +++ b/library/Class/Catalogue.php @@ -143,7 +143,7 @@ class CatalogueLoader extends Storm_Model_Loader { if (!Class_NoticeDomain::getClesNoticesForDomain($catalogue->getId())) return ''; - return Class_MoteurRecherche::prepareFacetteDomainForOrConditions($catalogue->getId()); + return (new Class_MoteurRecherche())->prepareFacetteDomainForOrConditions($catalogue->getId()); } diff --git a/library/Class/MoteurRecherche.php b/library/Class/MoteurRecherche.php index a5424d70f7969820b03d5be531ec7ea99ef1651c..3f6eb5c6291c2fc8b450bd5186b104208afb0522 100644 --- a/library/Class/MoteurRecherche.php +++ b/library/Class/MoteurRecherche.php @@ -43,7 +43,7 @@ class Class_MoteurRecherche { public function __construct() { - $this->ix = new Class_Indexation; + $this->ix = Class_Indexation::getInstance(); $this->_type_condition = 'type=' . Class_Notice::TYPE_BIBLIOGRAPHIC; } diff --git a/library/templates/Intonation/Library/Widget/Carousel/Agenda/View.php b/library/templates/Intonation/Library/Widget/Carousel/Agenda/View.php index dc802adcaf9a4a7e7b11ebb9e77219bbbc19acd5..993893776ff11e61df84533f26ffd8915f82b868 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Agenda/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Agenda/View.php @@ -35,7 +35,7 @@ class Intonation_Library_Widget_Carousel_Agenda_View extends Intonation_Library_ protected function _findElements() { $this->_initCalendar(); - return $this->_calendar->getArticlesInMonth(); + return $this->_calendar->getArticles($fill_with_following_months = false); } diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index 41ca0673d88264b5bb8760fc1f42d3e0574cdf31..72300fcd4184866e54cb4876bd4708142b62a52a 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -4036,25 +4036,29 @@ class TemplatesBibControllerProActionsTest extends TemplatesIntonationTestCase { class TemplatesDispatchAgendaWidgetTest extends TemplatesIntonationTestCase { + protected $_vacances; public function setUp() { parent::setUp(); - $vacances = $this - ->fixture('Class_Article', - ['id' => 78, - 'titre' => 'Les vacances', - 'contenu' => 'À la mer']); + Class_Profil::find(72) + ->setCfgAccueil(['modules' => + ['21' => ['division' => 3, + 'type_module' => 'CALENDAR', + 'preferences' => ['id_categorie' => 22]]]]) + ->assertSave(); + + ZendAfi_View_Helper_CalendarContent::setTimeSource(new TimeSourceForTest('2020-04-12 23:34:00')); + + $this->_vacances = $this->fixture('Class_Article', + ['id' => 78, + 'titre' => 'Les vacances', + 'contenu' => 'À la mer']); $this ->onLoaderOfModel('Class_Article') - ->whenCalled('getAllArticles') - ->answers([$vacances]) - - - ->whenCalled('getArticlesByPreferences') - ->answers([$vacances]); + ->answers([$this->_vacances]); } @@ -4067,6 +4071,32 @@ class TemplatesDispatchAgendaWidgetTest extends TemplatesIntonationTestCase { /** @test */ public function boiteAgendaShouldBePresent() { + Class_Article::getLoader() + ->whenCalled('getArticlesByPreferences') + ->with(['display_order' => 'EventDebut', + 'id_categorie' => '22', + 'events_only' => true, + 'event_date' => '2020-04', + 'id_bib' => 0, + 'id_lieu' => '', + 'custom_fields' => [], + 'published' => true]) + ->answers([$this->_vacances]) + + ->whenCalled('getArticlesByPreferences') + ->with(['display_order' => 'EventDebut', + 'id_categorie' => '22', + 'events_only' => true, + 'event_date' => '2020-04', + 'id_bib' => 0, + 'id_lieu' => '', + 'custom_fields' => [], + 'published' => true, + 'event_end_after' => '2020-04-12']) + ->answers([$this->_vacances]) + + ->beStrict(); + $this->dispatch('/opac/index/index/id_profil/72'); $this->assertXPath('//div', 'À la mer'); }