Skip to content
Snippets Groups Projects
Commit 1bba874f authored by Ghislain Loas's avatar Ghislain Loas
Browse files

calendar: split articles loaded for the calendar part and the articles list

parent 18d96bb9
Branches
Tags
4 merge requests!529Hotline 6.56,!467Master,!439Dev#16320 loire forez skin,!425Dev#16320 loire forez skin
......@@ -110,7 +110,7 @@
</tr>
<tr>
<td class="droite"><?php echo $this->_('Activer l\'affichage en pleine page'); ?></td>
<td class="droite"><?php echo $this->_('Activer la redirection vers la liste d\'articles'); ?></td>
<td class="gauche">
<?php echo $this->formCheckbox('display_full_page',
$this->preferences['display_full_page'],
......
......@@ -59,8 +59,8 @@ class Class_Calendar {
$this->year = date("Y", $this->getTimeSource()->time());
}
$this->param["DATE"] = sprintf('%4d-%02d', $this->year, $this->month);
// if($day)
// $this->param['DAY'].= sprintf('-%02d', $day);
if($day)
$this->param['DAY'] = $this->param['DATE'] . sprintf('-%02d', $day);
$this->id_module = $this->param["ID_MODULE"];
}
......@@ -189,7 +189,10 @@ class Class_Calendar {
public function getArticles() {
$articles = $this->_getNextEvents();
$articles = isset($this->param['DAY'])
? $this->_loadArticles(['event_date' => $this->param['DAY']])
: $this->_getNextEvents();
$nb_news = $this->param["NB_NEWS"];
return array_slice($articles, 0, $nb_news);
}
......
......@@ -191,6 +191,8 @@ class ZendAfi_View_Helper_Calendar_Table extends Zend_View_Helper_HtmlElement {
protected function getTableCalendarHeader() {
$anchor_class= ['class' => 'calendar_title_month_clickable'];
$anchor_class['class'].= $this->param['DISPLAY_FULL_PAGE'] ? '' : ' calendar_ajax_ready';
$previews_month =
$this->view->tagAnchor($this->getURL('LAST_MONTH'),
'&laquo;&nbsp;',
......@@ -312,6 +314,7 @@ class ZendAfi_View_Helper_Calendar_Table extends Zend_View_Helper_HtmlElement {
$cell_classes = implode(' ', array_unique($day_classes));
if (in_array('day_clickable', $day_classes)) {
$options = ['class' => $cell_classes, 'target' => '_parent'];
$options['class'].= $this->param['DISPLAY_FULL_PAGE'] ? '' : ' calendar_ajax_ready';
$table_cell.= $this->view->tagAnchor($this->getURL('EVENTS',$day), $today_click, $options);
} else {
$table_cell .= $this->view->tag('span', $day,['class' => $cell_classes]);
......
var ajaxify_calendars = function () {
var month_link = $("a.calendar_title_month_clickable:first-child, a.calendar_title_month_clickable:last-child, .calendar .month_list a:not(.no_event), .filters a");
var month_link = $(".calendar_ajax_ready, .calendar_title_left_arrow a, .calendar_title_right_arrow a, .calendar .month_list a:not(.no_event), .filters a");
month_link.click(function(event) {
var url = $(this).attr('href');
......
......@@ -334,21 +334,27 @@ class CmsControllerCalendarActionWithDayTest extends CmsControllerCalendarAction
}
/** @test */
public function currentMonthLinkShouldHaveReadyAjaxClass() {
$this->assertXPath('//table[@class="calendar_main"]//td[@class="calendar_title_month"]//a[contains(@class, "calendar_ajax_ready")]');
}
/** @test */
public function newsOfThe30thShouldBePresent() {
$this->assertXPathContentContains('div[@class="calendar"]//article//header//h2//a', 'News of the 30th september');
$this->assertXPathContentContains('//div[@class="calendar"]//article//header//h2//a', 'News of the 30th September');
}
/** @test **/
public function newsOfThe15ThSeptemberEventShouldNotBPresent() {
$this->assertNotXPathContentContains('div[@class="calendar"]//article//header', 'News of the 15th september');
$this->assertNotXPathContentContains('//div[@class="calendar"]//article//header', 'News of the 15th September');
}
/** @test */
public function newsOfThe15thSeptemberShouldBeClickableAtThe15Th() {
$this->assertXPath('div[@class="calendar"]//table//a[contains(@class, "day_clickable")][contains(@href, "date/2014-09-15")]');
$this->assertXPath('//div[@class="calendar"]//table//a[contains(@class, "day_clickable")][contains(@href, "date/2014-09-15")]');
}
}
?>
\ No newline at end of file
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