diff options
Diffstat (limited to 'apps/calendar')
-rwxr-xr-x | apps/calendar/ajax/daysofweekend.php | 11 | ||||
-rwxr-xr-x | apps/calendar/ajax/firstdayofweek.php | 12 | ||||
-rw-r--r-- | apps/calendar/ajax/geteventinfo.php | 9 | ||||
-rwxr-xr-x | apps/calendar/ajax/setdaysofweekend.php | 30 | ||||
-rwxr-xr-x | apps/calendar/ajax/setfirstdayofweek.php | 16 | ||||
-rw-r--r-- | apps/calendar/js/calendar.js | 28 | ||||
-rw-r--r-- | apps/calendar/js/settings.js | 34 | ||||
-rw-r--r-- | apps/calendar/templates/calendar.php | 84 | ||||
-rw-r--r-- | apps/calendar/templates/settings.php | 25 |
9 files changed, 224 insertions, 25 deletions
diff --git a/apps/calendar/ajax/daysofweekend.php b/apps/calendar/ajax/daysofweekend.php new file mode 100755 index 00000000000..606d13b1e1c --- /dev/null +++ b/apps/calendar/ajax/daysofweekend.php @@ -0,0 +1,11 @@ +<?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(); +echo OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'weekend', '{"Monday":"false","Tuesday":"false","Wednesday":"false","Thursday":"false","Friday":"false","Saturday":"true","Sunday":"true"}'); +?> diff --git a/apps/calendar/ajax/firstdayofweek.php b/apps/calendar/ajax/firstdayofweek.php new file mode 100755 index 00000000000..eff82cece1d --- /dev/null +++ b/apps/calendar/ajax/firstdayofweek.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(); +$firstdayofweek = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); +OC_JSON::encodedPrint(array("firstdayofweek" => $firstdayofweek)); +?>
\ No newline at end of file diff --git a/apps/calendar/ajax/geteventinfo.php b/apps/calendar/ajax/geteventinfo.php deleted file mode 100644 index 2e5e713c197..00000000000 --- a/apps/calendar/ajax/geteventinfo.php +++ /dev/null @@ -1,9 +0,0 @@ -<?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. - */ - -?> diff --git a/apps/calendar/ajax/setdaysofweekend.php b/apps/calendar/ajax/setdaysofweekend.php new file mode 100755 index 00000000000..b5ef5f8573f --- /dev/null +++ b/apps/calendar/ajax/setdaysofweekend.php @@ -0,0 +1,30 @@ +<?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(); +$weekenddays = array("Monday"=>"false", "Tuesday"=>"false", "Wednesday"=>"false", "Thursday"=>"false", "Friday"=>"false", "Saturday"=>"false", "Sunday"=>"false"); +for($i = 0;$i < count($_POST["weekend"]); $i++){ + switch ($_POST["weekend"][$i]){ + case "Monday": + case "Tuesday": + case "Wednesday": + case "Thursday": + case "Friday": + case "Saturday": + case "Sunday": + break; + default: + OC_JSON::error(); + exit; + } + $weekenddays[$_POST["weekend"][$i]] = "true"; +} +$setValue = json_encode($weekenddays); +OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'weekend', $setValue); +OC_JSON::success(); +?> diff --git a/apps/calendar/ajax/setfirstdayofweek.php b/apps/calendar/ajax/setfirstdayofweek.php new file mode 100755 index 00000000000..571b95af0e3 --- /dev/null +++ b/apps/calendar/ajax/setfirstdayofweek.php @@ -0,0 +1,16 @@ +<?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["firstdayofweek"])){ + OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'firstdayofweek', $_POST["firstdayofweek"]); + OC_JSON::success(); +}else{ + OC_JSON::error(); +} +?> diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index ce45db22fd6..554d1f1b0a4 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -8,6 +8,8 @@ Calendar={ space:' ', + firstdayofweek: '', + weekend: '', Date:{ normal_year_cal: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], leap_year_cal: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], @@ -79,7 +81,7 @@ Calendar={ }, UI:{ - weekdays: ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"], + weekdays: '', formatDayShort:function(day){ if (typeof(day) == 'undefined'){ day = Calendar.Date.current.getDay(); @@ -219,7 +221,7 @@ Calendar={ if (!events) { return; } - var weekday = (date.getDay()+6)%7; + var weekday = (date.getDay()+7-Calendar.firstdayofweek)%7; if( typeof (events["allday"]) != "undefined") { var eventnumber = 1; var eventcontainer = this.current.getEventContainer(week, weekday, "allday"); @@ -496,7 +498,7 @@ Calendar={ cancel:function(button, calendarid){ $(button).closest('tr').prev().show().next().remove(); }, - }, + },/* OneDay:{ forward:function(){ Calendar.Date.forward_day(); @@ -526,7 +528,7 @@ Calendar={ return $(document.createElement('p')) .html(time + event['description']) }, - }, + },*/ OneWeek:{ forward:function(){ Calendar.Date.forward_week(); @@ -545,7 +547,7 @@ Calendar={ var dates = this.generateDates(); var today = new Date(); for(var i = 0; i <= 6; i++){ - $("#oneweekview th." + Calendar.UI.weekdays[i]).html(Calendar.UI.formatDayShort((i+1)%7) + Calendar.space + dates[i].getDate() + Calendar.space + Calendar.UI.formatMonthShort(dates[i].getMonth())); + $("#oneweekview th." + Calendar.UI.weekdays[i]).html(Calendar.UI.formatDayShort((i+Calendar.firstdayofweek)%7) + Calendar.space + dates[i].getDate() + Calendar.space + Calendar.UI.formatMonthShort(dates[i].getMonth())); if(dates[i].getDate() == today.getDate() && dates[i].getMonth() == today.getMonth() && dates[i].getFullYear() == today.getFullYear()){ $("#oneweekview ." + Calendar.UI.weekdays[i]).addClass("thisday"); } @@ -576,14 +578,18 @@ Calendar={ if(dayofweek == 0) { dayofweek = 7; } - date.setDate(date.getDate() - dayofweek + 1); + if(Calendar.firstdayofweek > dayofweek){ + date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek - 7); + }else{ + date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek); + } for(var i = 0; i <= 6; i++) { dates[i] = new Date(date) date.setDate(date.getDate() + 1); } return dates; }, - }, + },/* FourWeeks:{ forward:function(){ Calendar.Date.forward_week(); @@ -680,7 +686,7 @@ Calendar={ } return dates; }, - }, + },*/ OneMonth:{ forward:function(){ Calendar.Date.forward_month(); @@ -782,7 +788,11 @@ Calendar={ dayofweek = 7; this.rows++; } - date.setDate(date.getDate() - dayofweek + 1); + if(Calendar.firstdayofweek > dayofweek){ + date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek - 7); + }else{ + date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek); + } for(var i = 0; i <= 41; i++) { dates[i] = new Date(date) date.setDate(date.getDate() + 1); diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js index 7c24fb0963f..5d048b83c36 100644 --- a/apps/calendar/js/settings.js +++ b/apps/calendar/js/settings.js @@ -8,4 +8,38 @@ $(document).ready(function(){ }); return false; }); + $("#timezone").chosen(); + $("#firstdayofweek").change( function(){ + var data = $("#firstdayofweek").serialize(); + $.post( OC.filePath('calendar', 'ajax', 'setfirstdayofweek.php'), data, function(data){ + if(data == "error"){ + console.log("saving first day of week failed"); + } + }); + }); + $.getJSON(OC.filePath('calendar', 'ajax', 'firstdayofweek.php'), function(jsondata, status) { + $("#select_" + jsondata.firstdayofweek).attr('selected',true); + $("#firstdayofweek").chosen(); + }); + $.getJSON(OC.filePath('calendar', 'ajax', 'daysofweekend.php'), function(jsondata, status) { + for(day in jsondata){ + if(jsondata[day] == "true"){ + $("#selectweekend_" + day).attr('selected',true); + } + } + $("#weekend").multiselect({ + header: false, + noneSelectedText: $('#weekend').attr('title'), + selectedList: 2, + minWidth:'auto', + }); + }); + $("#weekend").change( function(){ + var data = $("#weekend").serialize(); + $.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){ + if(data == "error"){ + console.log("saving days of weekend failed"); + } + }); + }); }); diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index a185d3e7087..25d92b0c7e4 100644 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -26,9 +26,82 @@ $hours = array( 22 => '22', 23 => '23', ); -$weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); +/* +$hours24 = 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', +); +$hoursampm = array( + 'allday' => $l->t('All day'), + 0 => '12 a.m.', + 1 => '1 a.m.', + 2 => '2 a.m.', + 3 => '3 a.m.', + 4 => '4 a.m.', + 5 => '5 a.m.', + 6 => '6 a.m.', + 7 => '7 a.m.', + 8 => '8 a.m.', + 9 => '9 a.m.', + 10 => '10 a.m.', + 11 => '11 a.m.', + 12 => '12 p.m.', + 13 => '1 p.m.', + 14 => '2 p.m.', + 15 => '3 p.m.', + 16 => '4 p.m.', + 17 => '5 p.m.', + 18 => '6 p.m.', + 19 => '7 p.m.', + 20 => '8 p.m.', + 21 => '9 p.m.', + 22 => '10 p.m.', + 23 => '11 p.m.', +); +*/ +$weekdaynames = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); +$dayforgenerator = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); +$weekdays = array(); +for($i = 0;$i <= 6; $i++){ + $weekdays[$i] = $weekdaynames[$dayforgenerator]; + if($dayforgenerator == 6){ + $dayforgenerator = 0; + }else{ + $dayforgenerator++; + } +} +$weekendjson = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'weekend', '{"Monday":"false","Tuesday":"false","Wednesday":"false","Thursday":"false","Friday":"false","Saturday":"true","Sunday":"true"}'); +$weekend = json_decode($weekendjson, true); +$weekenddays = array("sunday"=>$weekend["Sunday"], "monday"=>$weekend["Monday"], "tuesday"=>$weekend["Tuesday"], "wednesday"=>$weekend["Wednesday"], "thursday"=>$weekend["Thursday"], "friday"=>$weekend["Friday"], "saturday"=>$weekend["Saturday"]); ?> <script type="text/javascript"> + <?php + echo "var weekdays = new Array('".$weekdays[0]."','".$weekdays[1]."','".$weekdays[2]."','".$weekdays[3]."','".$weekdays[4]."','".$weekdays[5]."','".$weekdays[6]."');\n"; + ?> + Calendar.UI.weekdays = weekdays; Calendar.UI.daylong = new Array("<?php echo $l -> t("Sunday");?>", "<?php echo $l -> t("Monday");?>", "<?php echo $l -> t("Tuesday");?>", "<?php echo $l -> t("Wednesday");?>", "<?php echo $l -> t("Thursday");?>", "<?php echo $l -> t("Friday");?>", "<?php echo $l -> t("Saturday");?>"); Calendar.UI.dayshort = new Array("<?php echo $l -> t("Sun.");?>", "<?php echo $l -> t("Mon.");?>", "<?php echo $l -> t("Tue.");?>", "<?php echo $l -> t("Wed.");?>", "<?php echo $l -> t("Thu.");?>", "<?php echo $l -> t("Fri.");?>", "<?php echo $l -> t("Sat.");?>"); Calendar.UI.monthlong = new Array("<?php echo $l -> t("January");?>", "<?php echo $l -> t("February");?>", "<?php echo $l -> t("March");?>", "<?php echo $l -> t("April");?>", "<?php echo $l -> t("May");?>", "<?php echo $l -> t("June");?>", "<?php echo $l -> t("July");?>", "<?php echo $l -> t("August");?>", "<?php echo $l -> t("September");?>", "<?php echo $l -> t("October");?>", "<?php echo $l -> t("November");?>", "<?php echo $l -> t("December");?>"); @@ -37,6 +110,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur Calendar.UI.cws_label = "<?php echo $l->t("Weeks");?>"; Calendar.UI.more_before = String('<?php echo $l->t('More before {startdate}') ?>'); Calendar.UI.more_after = String('<?php echo $l->t('More after {enddate}') ?>'); + Calendar.firstdayofweek = parseInt("<?php echo OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); ?>"); //use last view as default on the next Calendar.UI.setCurrentView("<?php echo OC_Preferences::getValue(OC_USER::getUser(), "calendar", "currentview", "onemonthview") ?>"); var totalurl = "<?php echo OC_Helper::linkTo('calendar', 'caldav.php', null, true) . '/calendars'; ?>"; @@ -93,7 +167,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur <tr> <th class="calendar_time"><?php echo $l->t("Time");?></th> <?php foreach($weekdays as $weekdaynr => $weekday): ?> - <th class="calendar_row <?php echo $weekday ?> <?php echo $weekdaynr > 4 ? 'weekend_thead' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>');"></th> + <th class="calendar_row <?php echo $weekday ?> <?php echo $weekenddays[$weekday] == "true" ? 'weekend_thead' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>');"></th> <?php endforeach; ?> </tr> </thead> @@ -102,7 +176,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur <tr> <td class="calendar_time"><?php echo $time_label?></td> <?php foreach($weekdays as $weekdaynr => $weekday): ?> - <td class="<?php echo $weekday ?> <?php echo $time ?> calendar_row <?php echo $weekdaynr > 4 ? 'weekend_row' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>', '<?php echo $time ?>');"></td> + <td class="<?php echo $weekday ?> <?php echo $time ?> calendar_row <?php echo $weekenddays[$weekday] == "true" ? 'weekend_row' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>', '<?php echo $time ?>');"></td> <?php endforeach; ?> </tr> <?php endforeach; ?> @@ -139,7 +213,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur <thead> <tr> <?php foreach($weekdays as $weekdaynr => $weekday): ?> - <th class="calendar_row <?php echo $weekdaynr > 4 ? 'weekend_thead' : '' ?> <?php echo $weekday ?>"><?php echo $l->t(ucfirst($weekday));?></th> + <th class="calendar_row <?php echo $weekenddays[$weekday] == "true" ? 'weekend_thead' : '' ?> <?php echo $weekday ?>"><?php echo $l->t(ucfirst($weekday));?></th> <?php endforeach; ?> </tr> </thead> @@ -147,7 +221,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur <?php foreach(range(1, 6) as $week): ?> <tr class="week_<?php echo $week ?>"> <?php foreach($weekdays as $weekdaynr => $weekday): ?> - <td class="day <?php echo $weekday ?> <?php echo $weekdaynr > 4 ? 'weekend' : '' ?>" onclick="Calendar.UI.newEvent('#onemonthview .week_<?php echo $week ?> .<?php echo $weekday ?>')"> + <td class="day <?php echo $weekday ?> <?php echo $weekenddays[$weekday] == "true" ? 'weekend' : '' ?>" onclick="Calendar.UI.newEvent('#onemonthview .week_<?php echo $week ?> .<?php echo $weekday ?>')"> <div class="dateinfo"></div> <div class="events"></div> </td> diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php index 4b804e48f5b..7df357099e8 100644 --- a/apps/calendar/templates/settings.php +++ b/apps/calendar/templates/settings.php @@ -1,15 +1,18 @@ <?php /** * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> + * 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. */ +OC_UTIL::addScript('', 'jquery.multiselect'); +OC_UTIL::addStyle('', 'jquery.multiselect'); ?> <form id="calendar"> <fieldset class="personalblock"> <label for="timezone"><strong><?php echo $l->t('Timezone');?></strong></label> - <select id="timezone" name="timezone"> + <select style="display: none;" id="timezone" name="timezone"> <?php $continent = ''; foreach($_['timezones'] as $timezone): @@ -24,7 +27,25 @@ echo '<option value="'.$timezone.'"'.($_['timezone'] == $timezone?' selected="selected"':'').'>'.$city.'</option>'; endif; endforeach;?> - </select><span class="msg"></span> + </select><span class="msg"></span> + <label for="firstdayofweek"><strong><?php echo $l->t('First day of the week');?></strong></label> + <select style="display: none;" id="firstdayofweek" name="firstdayofweek"> + <?php + $weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); + for($i = 0;$i <= 6;$i++){ + echo '<option value="'.$i.'" id="select_'.$i.'">' . $l->t($weekdays[$i]) . '</option>'; + } + ?> + </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"; ?>"> + <?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> <br /> Calendar CalDAV syncing address: <?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?><br /> |