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:
Yuchen Wang 2011-10-19 12:42:22 -04:00
parent 0989a1c13f
commit d9186a3bf2
6 changed files with 70 additions and 3 deletions

View file

@ -81,7 +81,8 @@ class ApiController extends Zend_Controller_Action
"timestamp" => time(), "timestamp" => time(),
"timezoneOffset" => date("Z"), "timezoneOffset" => date("Z"),
"timeScale" => Application_Model_Preference::GetCalendarTimeScale(), "timeScale" => Application_Model_Preference::GetCalendarTimeScale(),
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval() "timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
); );
} }

View file

@ -36,6 +36,7 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]); Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]);
Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]); Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]);
Application_Model_Preference::SetTimezone($values["preferences_general"]["timezone"]); 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::SetAutoUploadRecordedShowToSoundcloud($values["preferences_soundcloud"]["UseSoundCloud"]);
Application_Model_Preference::SetUploadToSoundcloudOption($values["preferences_soundcloud"]["UploadToSoundcloudOption"]); Application_Model_Preference::SetUploadToSoundcloudOption($values["preferences_soundcloud"]["UploadToSoundcloudOption"]);

View file

@ -65,6 +65,14 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
$timezone->setValue(Application_Model_Preference::GetTimezone()); $timezone->setValue(Application_Model_Preference::GetTimezone());
$timezone->setDecorators(array('ViewHelper')); $timezone->setDecorators(array('ViewHelper'));
$this->addElement($timezone); $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(){ 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;
}
} }

View file

@ -486,6 +486,21 @@ class Application_Model_Preference
return self::GetValue("soundcloud_downloadable"); 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. * Sets the time scale preference (day/week/month) in Calendar.
* *
@ -533,5 +548,7 @@ class Application_Model_Preference
public static function GetCalendarTimeInterval() { public static function GetCalendarTimeInterval() {
return self::GetValue("calendar_time_interval", true /* user specific */); return self::GetValue("calendar_time_interval", true /* user specific */);
} }
/* User specific preferences end */
} }

View file

@ -88,5 +88,32 @@
</ul> </ul>
<?php endif; ?> <?php endif; ?>
</dd> </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> </dl>
</fieldset> </fieldset>

View file

@ -333,6 +333,7 @@ function createFullCalendar(data){
}, },
defaultView: getTimeScalePreference(data), defaultView: getTimeScalePreference(data),
slotMinutes: getTimeIntervalPreference(data), slotMinutes: getTimeIntervalPreference(data),
firstDay: data.calendarInit.weekStartDay,
editable: false, editable: false,
allDaySlot: false, allDaySlot: false,
axisFormat: 'H:mm', axisFormat: 'H:mm',