Commit 72908f55 authored by Laurent's avatar Laurent

hotline #113717 templates / agenda : now use parameters

parent 55ef241e
Pipeline #10510 passed with stage
in 51 minutes and 30 seconds
- 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
......@@ -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());
}
......
......@@ -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());
}
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment