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

dev #10430 update even date text

parent 38d38420
Branches
Tags
7 merge requests!1553Master,!1502Master,!1501Stable,!1312Master,!1311Dev#10430 pick day agenda,!1290Dev#10430 pick day agenda,!1262Dev#10430 pick day agenda
......@@ -93,7 +93,8 @@ class ZendAfi_Form_Admin_News extends ZendAfi_Form {
'5' => $this->_('vendredi'),
'6' => $this->_('samedi'),
'0' => $this->_('dimanche')],
'order' => 12 ])
'order' => 12 ,
'separator' => ' '])
->addElement('select', 'id_lieu', ['label' => $this->_('Lieu'),
'multiOptions' => $this->getLocations(),
......
......@@ -70,9 +70,38 @@ class ZendAfi_View_Helper_TagArticleEvent extends Zend_View_Helper_HtmlElement {
if ($year_start == $year_end)
$year_start = '';
return $this->view->_('Du %s au %s',
trim(strftime('%A %d', $date_start) . ' ' . $month_start . ' ' . $year_start),
trim(strftime('%A %d', $date_end) . ' ' . $month_end . ' ' . $year_end));
$picked_days = $article->getPickDayAsArray();
if(empty($article->getPickDayAsArray()) || 7 == count($picked_days))
return $this->view->_('Du %s au %s',
trim(strftime('%A %d', $date_start) . ' ' . $month_start . ' ' . $year_start),
trim(strftime('%A %d', $date_end) . ' ' . $month_end . ' ' . $year_end));
$open_days = $this->getTextualDays($picked_days);
return $this->view->_('Les ' . $open_days . ' du %s au %s',
trim(strftime('%e', $date_start) . ' ' . $month_start . ' ' . $year_start),
trim(strftime('%e', $date_end) . ' ' . $month_end . ' ' . $year_end));
}
protected function getTextualDays($days) {
if(1 == count($days))
return $this->numericDayToTextual($days[0]);
$last = array_pop($days);
$last = $this->numericDayToTextual($last);
$textual_days = '';
foreach($days as $day)
$textual_days.= $this->numericDayToTextual($day) . ', ';
return substr($textual_days, 0, -2) . $this->view->_(' et ') . $last;
}
protected function numericDayToTextual($nb) {
return strftime('%A', strtotime('Sunday +' . $nb . ' days'));
}
}
?>
......@@ -103,6 +103,47 @@ class TagArticleEventTest extends ViewHelperTestCase {
$this->assertTagContains('lundi 05 septembre 2011');
}
/** @test */
public function withMondayPickShouldAnswersTousLesLundi() {
$this->article
->setEventsDebut('2011-09-05 08:00')
->setEventsFin('2011-10-05 10:00')
->setPickDay('1');
$this->assertTagContains('Les lundi du 5 septembre au 5 octobre 2011');
}
/** @test */
public function withSaturdayPickShouldAnswersTousLesSamedi() {
$this->article
->setEventsDebut('2011-09-05 08:00')
->setEventsFin('2011-10-05 10:00')
->setPickDay('6');
$this->assertTagContains('Les samedi du 5 septembre au 5 octobre 2011');
}
/** @test */
public function withMondayAndSaturdayPickShouldAnswersTousLesLundiEtTousLesSamedi() {
$this->article
->setEventsDebut('2011-09-05 08:00')
->setEventsFin('2011-10-05 10:00')
->setPickDay('1,6');
$this->assertTagContains('Les lundi et samedi du 5 septembre au 5 octobre 2011');
}
/** @test */
public function withAllDaysPickShouldAnswersTousLesJours() {
$this->article
->setEventsDebut('2011-09-05 08:00')
->setEventsFin('2011-10-05 10:00')
->setPickDay('0,1,2,3,4,5,6');
$this->assertTagContains('Du lundi 05 septembre au mercredi 05 octobre 2011');
}
protected function assertTagContains($expected) {
$this->assertEquals(sprintf('<span class="calendar_event_date">%s</span>', $expected),
$this->_helper->tagArticleEvent($this->article));
......
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