diff options
author | Georg Ehrke <georg.stefan.germany@googlemail.com> | 2011-10-01 12:39:07 +0400 |
---|---|---|
committer | Georg Ehrke <georg.stefan.germany@googlemail.com> | 2011-10-01 12:39:07 +0400 |
commit | bf6414d3ad2a19bc9bf5174abd82d8ffaee02ef4 (patch) | |
tree | 304a94619ddcf61b57257c05a6b5f7e4636240a2 /apps | |
parent | 0514a1925bb726cc23ae4b99ed85c4b5451357cc (diff) |
choosable time format
Diffstat (limited to 'apps')
-rw-r--r-- | apps/calendar/ajax/settimeformat.php | 17 | ||||
-rw-r--r-- | apps/calendar/ajax/timeformat.php | 12 | ||||
-rw-r--r-- | apps/calendar/js/settings.js | 12 | ||||
-rw-r--r-- | apps/calendar/templates/calendar.php | 34 | ||||
-rw-r--r-- | apps/calendar/templates/settings.php | 7 |
5 files changed, 52 insertions, 30 deletions
diff --git a/apps/calendar/ajax/settimeformat.php b/apps/calendar/ajax/settimeformat.php new file mode 100644 index 00000000000..7805120ba5e --- /dev/null +++ b/apps/calendar/ajax/settimeformat.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +if(isset($_POST["timeformat"])){ + OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]); + OC_JSON::success(); +}else{ + OC_JSON::error(); +} +?> + diff --git a/apps/calendar/ajax/timeformat.php b/apps/calendar/ajax/timeformat.php new file mode 100644 index 00000000000..3533adcf8e0 --- /dev/null +++ b/apps/calendar/ajax/timeformat.php @@ -0,0 +1,12 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +$timeformat = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24"); +OC_JSON::encodedPrint(array("timeformat" => $timeformat)); +?> diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js index 5d048b83c36..fc5fc7377a6 100644 --- a/apps/calendar/js/settings.js +++ b/apps/calendar/js/settings.js @@ -34,6 +34,18 @@ $(document).ready(function(){ minWidth:'auto', }); }); + $("#timeformat").change( function(){ + var data = $("#timeformat").serialize(); + $.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){ + if(data == "error"){ + console.log("saving timeformat failed"); + } + }); + }); + $.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) { + $("#" + jsondata.timeformat).attr('selected',true); + $("#timeformat").chosen(); + }); $("#weekend").change( function(){ var data = $("#weekend").serialize(); $.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){ diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index 25d92b0c7e4..317bb17ddbc 100644 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -1,32 +1,4 @@ <?php -$hours = array( - 'allday' => $l->t('All day'), - 0 => '0', - 1 => '1', - 2 => '2', - 3 => '3', - 4 => '4', - 5 => '5', - 6 => '6', - 7 => '7', - 8 => '8', - 9 => '9', - 10 => '10', - 11 => '11', - 12 => '12', - 13 => '13', - 14 => '14', - 15 => '15', - 16 => '16', - 17 => '17', - 18 => '18', - 19 => '19', - 20 => '20', - 21 => '21', - 22 => '22', - 23 => '23', -); -/* $hours24 = array( 'allday' => $l->t('All day'), 0 => '0', @@ -81,7 +53,11 @@ $hoursampm = array( 22 => '10 p.m.', 23 => '11 p.m.', ); -*/ +if(OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24") == "24"){ + $hours = $hours24; +}else{ + $hours = $hoursampm; +} $weekdaynames = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); $dayforgenerator = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); $weekdays = array(); diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php index 7df357099e8..d3e3e3c525e 100644 --- a/apps/calendar/templates/settings.php +++ b/apps/calendar/templates/settings.php @@ -38,13 +38,18 @@ OC_UTIL::addStyle('', 'jquery.multiselect'); ?> </select> <label for="weekend"><strong><?php echo $l->t('Days of weekend');?></strong></label> - <select id="weekend" name="weekend[]" multiple="multiple" title="<?php echo "Wochenende"; ?>"> + <select id="weekend" name="weekend[]" multiple="multiple" title="<?php echo $l->t("Weekend"); ?>"> <?php $weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); for($i = 0;$i <= 6;$i++){ echo '<option value="'.$weekdays[$i].'" id="selectweekend_' . $weekdays[$i] . '">' . $l->t($weekdays[$i]) . '</option>'; } ?> + </select> + <label for="timeformat"><strong><?php echo $l->t('Timeformat');?></strong></label> + <select style="display: none;" id="timeformat" title="<?php echo "timeformat"; ?>" name="timeformat"> + <option value="24" id="24h"><?php echo $l->t("24 h"); ?></option> + <option value="ampm" id="ampm"><?php echo $l->t("am/pm"); ?></option> </select> <br /> Calendar CalDAV syncing address: |