CC-2951: Allow users to select the starting day of the week
Added system preference in Preference page for user to select the start day of a week (defaults to Sunday). Calendar will utilize this information and update the calendar UI accordingly.
This commit is contained in:
parent
0989a1c13f
commit
d9186a3bf2
6 changed files with 70 additions and 3 deletions
|
@ -81,7 +81,8 @@ class ApiController extends Zend_Controller_Action
|
|||
"timestamp" => time(),
|
||||
"timezoneOffset" => date("Z"),
|
||||
"timeScale" => Application_Model_Preference::GetCalendarTimeScale(),
|
||||
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval()
|
||||
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
|
||||
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class PreferenceController extends Zend_Controller_Action
|
|||
Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]);
|
||||
Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]);
|
||||
Application_Model_Preference::SetTimezone($values["preferences_general"]["timezone"]);
|
||||
Application_Model_Preference::SetWeekStartDay($values["preferences_general"]["weekStartDay"]);
|
||||
|
||||
Application_Model_Preference::SetAutoUploadRecordedShowToSoundcloud($values["preferences_soundcloud"]["UseSoundCloud"]);
|
||||
Application_Model_Preference::SetUploadToSoundcloudOption($values["preferences_soundcloud"]["UploadToSoundcloudOption"]);
|
||||
|
|
|
@ -65,6 +65,14 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
$timezone->setValue(Application_Model_Preference::GetTimezone());
|
||||
$timezone->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($timezone);
|
||||
|
||||
/* Form Element for setting which day is the start of the week */
|
||||
$week_start_day = new Zend_Form_Element_Select("weekStartDay");
|
||||
$week_start_day->setLabel("Week Starts On");
|
||||
$week_start_day->setMultiOptions($this->getWeekStartDays());
|
||||
$week_start_day->setValue(Application_Model_Preference::GetWeekStartDay());
|
||||
$week_start_day->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($week_start_day);
|
||||
}
|
||||
|
||||
private function getTimezones(){
|
||||
|
@ -92,5 +100,17 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
}
|
||||
|
||||
|
||||
private function getWeekStartDays() {
|
||||
$days = array(
|
||||
'Sunday',
|
||||
'Monday',
|
||||
'Tuesday',
|
||||
'Wednesday',
|
||||
'Thursday',
|
||||
'Friday',
|
||||
'Saturday'
|
||||
);
|
||||
return $days;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -486,6 +486,21 @@ class Application_Model_Preference
|
|||
return self::GetValue("soundcloud_downloadable");
|
||||
}
|
||||
|
||||
public static function SetWeekStartDay($day) {
|
||||
self::SetValue("week_start_day", $day);
|
||||
}
|
||||
|
||||
public static function GetWeekStartDay() {
|
||||
$val = self::GetValue("week_start_day");
|
||||
if (strlen($val) == 0){
|
||||
return "0";
|
||||
} else {
|
||||
return $val;
|
||||
}
|
||||
}
|
||||
|
||||
/* User specific preferences start */
|
||||
|
||||
/**
|
||||
* Sets the time scale preference (day/week/month) in Calendar.
|
||||
*
|
||||
|
@ -533,5 +548,7 @@ class Application_Model_Preference
|
|||
public static function GetCalendarTimeInterval() {
|
||||
return self::GetValue("calendar_time_interval", true /* user specific */);
|
||||
}
|
||||
|
||||
/* User specific preferences end */
|
||||
}
|
||||
|
||||
|
|
|
@ -88,5 +88,32 @@
|
|||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
|
||||
<!-- Week Start Day option -->
|
||||
<dt id="weekStartDay-label" class="block-display">
|
||||
<label class="required" for="timezone"><?php echo $this->element->getElement('weekStartDay')->getLabel() ?>:
|
||||
</label>
|
||||
</dt>
|
||||
<dd id="weekStartDay-element" class="block-display">
|
||||
<?php $i=0;
|
||||
$value = $this->element->getElement('weekStartDay')->getValue();
|
||||
?>
|
||||
<select id="weekStartDay" name="weekStartDay">
|
||||
<?php foreach ($this->element->getElement('weekStartDay')->getMultiOptions() as $option) : ?>
|
||||
<option value="<?php echo $i ?>" <?php if($i == $value){echo 'selected="selected"';}?> >
|
||||
<?php echo $option ?>
|
||||
</option>
|
||||
<?php $i = $i + 1; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
<?php if($this->element->getElement('weekStartDay')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('weekStartDay')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
|
|
@ -333,6 +333,7 @@ function createFullCalendar(data){
|
|||
},
|
||||
defaultView: getTimeScalePreference(data),
|
||||
slotMinutes: getTimeIntervalPreference(data),
|
||||
firstDay: data.calendarInit.weekStartDay,
|
||||
editable: false,
|
||||
allDaySlot: false,
|
||||
axisFormat: 'H:mm',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue