diff options
author | Kevin Jardine <kevinjardine@yahoo.com> | 2012-03-19 17:09:30 +0100 |
---|---|---|
committer | Kevin Jardine <kevinjardine@yahoo.com> | 2012-03-19 17:09:30 +0100 |
commit | 2d19bfa232be5eff43bb6c1d1eef12e681552956 (patch) | |
tree | d956a896521dfa64f70bc79686d28892ccc0e90e | |
parent | 978d6aa6283933c805622d4d24fa6068833f7817 (diff) | |
download | elgg-2d19bfa232be5eff43bb6c1d1eef12e681552956.tar.gz elgg-2d19bfa232be5eff43bb6c1d1eef12e681552956.tar.bz2 |
full calendar click to view, time system revamp
-rw-r--r-- | languages/en.php | 5 | ||||
-rw-r--r-- | models/model.php | 45 | ||||
-rw-r--r-- | views/default/event_calendar/css.php | 11 | ||||
-rw-r--r-- | views/default/event_calendar/full_calendar_view.php | 22 | ||||
-rw-r--r-- | views/default/forms/event_calendar/edit.php | 41 | ||||
-rw-r--r-- | views/default/input/timepicker.php | 61 | ||||
-rw-r--r-- | views/default/input/timepicker_old.php | 38 | ||||
-rw-r--r-- | views/default/plugins/event_calendar/settings.php | 13 |
8 files changed, 167 insertions, 69 deletions
diff --git a/languages/en.php b/languages/en.php index 1a356524b..2e4c3373a 100644 --- a/languages/en.php +++ b/languages/en.php @@ -256,6 +256,11 @@ You can manage calendar requests for this event here: 'event_calendar:settings:full_calendar:title' => "Support full calendar", 'event_calendar:modify_full_calendar:error' => "Error: could not modify full calendar", + 'event_calendar:from_label' => "From:", + 'event_calendar:to_label' => "To:", + 'event_calendar:settings:timeformat:title' => "Time format", + 'event_calendar:time_format:12hour' => "12 hour (am/pm)", + 'event_calendar:time_format:24hour' => "24 hour", /** * Event calendar river diff --git a/models/model.php b/models/model.php index f1ed39369..aa97bfddb 100644 --- a/models/model.php +++ b/models/model.php @@ -92,23 +92,15 @@ function event_calendar_set_event_from_form($event_guid,$group_guid) { } if ($event_calendar_times != 'no') { - $sh = get_input('start_time_h',''); - $sm = get_input('start_time_m',''); - if (is_numeric($sh) && is_numeric($sm)) { - // workaround for pulldown zero value bug - $sh--; - $sm--; - $event->start_time = $sh*60+$sm; + $st = get_input('start_time',''); + if (is_numeric($st)) { + $event->start_time = $st; } else { $event->start_time = ''; } - $eh = get_input('end_time_h',''); - $em = get_input('end_time_m',''); - if (is_numeric($eh) && is_numeric($em)) { - // workaround for pulldown zero value bug - $eh--; - $em--; - $event->end_time = $eh*60+$em; + $et = get_input('end_time',''); + if (is_numeric($et)) { + $event->end_time = $et; } else { $event->end_time = ''; } @@ -874,9 +866,21 @@ function event_calendar_handle_leave($event, $object_type, $object) { } function event_calendar_convert_time($time) { - $hour = floor($time/60); - $minute = sprintf("%02d",$time-60*$hour); - return "$hour:$minute"; + $event_calendar_time_format = elgg_get_plugin_setting('timeformat','event_calendar'); + if ($event_calendar_time_format == '12') { + $hour = floor($time/60); + $minute = sprintf("%02d",$time-60*$hour); + if ($hour < 12) { + return "$hour:$minute am"; + } else { + $hour -= 12; + return "$hour:$minute pm"; + } + } else { + $hour = floor($time/60); + $minute = sprintf("%02d",$time-60*$hour); + return "$hour:$minute"; + } } function event_calendar_format_time($date,$time1,$time2='') { @@ -970,13 +974,15 @@ function event_calendar_get_formatted_time($event) { $event_calendar_times = elgg_get_plugin_setting('times', 'event_calendar') != 'no'; $start_date = date($date_format,$event->start_date); - if ((!$event->end_date) || ($event->end_date == $event->start_date)) { + if ($event->end_date) { + $end_date = date($date_format,$event->end_date); + } + if ((!$event->end_date) || ($end_date == $start_date)) { if ($event_calendar_times) { $start_date = event_calendar_format_time($start_date,$event->start_time,$event->end_time); } $time_bit = $start_date; } else { - $end_date = date($date_format,$event->end_date); if ($event_calendar_times) { $start_date = event_calendar_format_time($start_date,$event->start_time); $end_date = event_calendar_format_time($end_date,$event->end_time); @@ -1243,6 +1249,7 @@ function event_calendar_get_page_content_edit($page_type,$guid) { } else { elgg_push_breadcrumb(elgg_echo('event_calendar:show_events_title'),'event_calendar/list'); } + elgg_push_breadcrumb($event->title,$event->getURL()); elgg_push_breadcrumb(elgg_echo('event_calendar:manage_event_title')); $content = elgg_view_form('event_calendar/edit', $vars,$body_vars); diff --git a/views/default/event_calendar/css.php b/views/default/event_calendar/css.php index 469f72de8..a2437e065 100644 --- a/views/default/event_calendar/css.php +++ b/views/default/event_calendar/css.php @@ -164,4 +164,15 @@ li.event-calendar-filter-menu-show-only { padding-top:.4em; background:#fff; margin:0 -.3em 0 1.5em; +} + +.event-calendar-compressed-date { + width: 150px !important; + margin-right: 10px; +} + +.event-calendar-date-time-setter label { + float: left; + width: 50px; + margin-top: 5px; }
\ No newline at end of file diff --git a/views/default/event_calendar/full_calendar_view.php b/views/default/event_calendar/full_calendar_view.php index d4e85724e..58aefe741 100644 --- a/views/default/event_calendar/full_calendar_view.php +++ b/views/default/event_calendar/full_calendar_view.php @@ -9,7 +9,9 @@ $times_supported = elgg_get_plugin_setting('times','event_calendar') != 'no'; foreach($events as $e) { $event_item = array( 'guid' => $e->guid, + //'title' => '<a href="'.$e->url.'">'.$e->title.'</a>', 'title' => $e->title, + 'url' => $e->getURL(), 'start_date' => $e->start_date, 'end_date' => $e->real_end_time, ); @@ -28,13 +30,14 @@ $json_events_string = json_encode($event_array); ?> <script> -handleEventDrop = function(event,dayDelta,minuteDelta,allDay,revertFunc) { +handleEventClick = function(event) { + if (event.url) { + window.location.href = event.url; + return false; + } +}; - alert( - event.title + "(" + event.guid + ") was moved " + - dayDelta + " days and " + - minuteDelta + " minutes." - ); +handleEventDrop = function(event,dayDelta,minuteDelta,allDay,revertFunc) { if (!confirm("Are you sure about this change?")) { revertFunc(); @@ -53,7 +56,8 @@ handleEventDrop = function(event,dayDelta,minuteDelta,allDay,revertFunc) { } ); } -} +}; + $(document).ready(function() { var events = <?php echo $json_events_string; ?>; var cal_events = []; @@ -61,6 +65,7 @@ $(document).ready(function() { cal_events.push({ guid: events[i].guid, title : events[i].title, + url: events[i].url, start : new Date(1000*events[i].start_date), end : new Date(1000*events[i].end_date), allDay: events[i].allDay @@ -74,8 +79,9 @@ $(document).ready(function() { right: 'month,agendaWeek,agendaDay' }, editable: true, - slotMinutes: 5, + slotMinutes: 15, eventDrop: handleEventDrop, + eventClick: handleEventClick, events: cal_events }); }); diff --git a/views/default/forms/event_calendar/edit.php b/views/default/forms/event_calendar/edit.php index 7613a79f1..3526627a7 100644 --- a/views/default/forms/event_calendar/edit.php +++ b/views/default/forms/event_calendar/edit.php @@ -128,29 +128,32 @@ $body .= '</label></p>'; $body .= '<p class="description">'.$prefix['venue'].elgg_echo('event_calendar:venue_description').'</p>'; if ($event_calendar_times != 'no') { - $body .= '<p><label>'.elgg_echo("event_calendar:start_time_label").'</label><br />'; + $body .= '<div class="event-calendar-date-time-setter">'; + if ($event_calendar_hide_end != 'yes') { + $body .= '<p><label>'.elgg_echo('event_calendar:from_label').'</label>'; + } + $body .= elgg_view("event_calendar/input/date_local",array('timestamp'=>TRUE, 'autocomplete'=>'off','class'=>'event-calendar-compressed-date','name' => 'start_date','value'=>$start_date)); $body .= elgg_view("input/timepicker",array('name' => 'start_time','value'=>$start_time)); - $body .= '</p>'; - $body .= '<p class="description">'.$prefix['start_time'].elgg_echo('event_calendar:start_time_description').'</p>'; -} - -$body .= '<p><label>'.elgg_echo("event_calendar:start_date_label").'<br />'; -$body .= elgg_view("event_calendar/input/date_local",array('timestamp'=>TRUE, 'autocomplete'=>'off','name' => 'start_date','value'=>$start_date)); -$body .= '</label></p>'; -$body .= '<p class="description">'.$prefix['start_date'].elgg_echo('event_calendar:start_date_description').'</p>'; - -if ($event_calendar_hide_end != 'yes') { - if ($event_calendar_times != 'no') { - $body .= '<p><label>'.elgg_echo("event_calendar:end_time_label").'</label><br />'; + if ($event_calendar_hide_end != 'yes') { + $body .= '</p><p><label>'.elgg_echo('event_calendar:to_label').'</label>'; + $body .= elgg_view("event_calendar/input/date_local",array('timestamp'=>TRUE,'autocomplete'=>'off','class'=>'event-calendar-compressed-date','name' => 'end_date','value'=>$end_date)); $body .= elgg_view("input/timepicker",array('name' => 'end_time','value'=>$end_time)); - $body .= '</p>'; - $body .= '<p class="description">'.$prefix['end_time'].elgg_echo('event_calendar:end_time_description').'</p>'; } - - $body .= '<p><label>'.elgg_echo("event_calendar:end_date_label").'<br />'; - $body .= elgg_view("event_calendar/input/date_local",array('timestamp'=>TRUE,'autocomplete'=>'off','name' => 'end_date','value'=>$end_date)); + $body .= '</p>'; + $body .= '</div>'; +} else { + + $body .= '<p><label>'.elgg_echo("event_calendar:start_date_label").'<br />'; + $body .= elgg_view("event_calendar/input/date_local",array('timestamp'=>TRUE, 'autocomplete'=>'off','name' => 'start_date','value'=>$start_date)); $body .= '</label></p>'; - $body .= '<p class="description">'.$prefix['end_date'].elgg_echo('event_calendar:end_date_description').'</p>'; + $body .= '<p class="description">'.$prefix['start_date'].elgg_echo('event_calendar:start_date_description').'</p>'; + + if ($event_calendar_hide_end != 'yes') { + $body .= '<p><label>'.elgg_echo("event_calendar:end_date_label").'<br />'; + $body .= elgg_view("event_calendar/input/date_local",array('timestamp'=>TRUE,'autocomplete'=>'off','name' => 'end_date','value'=>$end_date)); + $body .= '</label></p>'; + $body .= '<p class="description">'.$prefix['end_date'].elgg_echo('event_calendar:end_date_description').'</p>'; + } } if ($event_calendar_spots_display == 'yes') { diff --git a/views/default/input/timepicker.php b/views/default/input/timepicker.php index faadd6450..d7df04699 100644 --- a/views/default/input/timepicker.php +++ b/views/default/input/timepicker.php @@ -2,37 +2,52 @@ $time_format = elgg_get_plugin_setting('timeformat', 'event_calendar'); if (!$time_format) { - $time_format = 24; + $time_format = '24'; } $value = $vars['value']; if (is_numeric($value)) { $hour = floor($value/60); - $minute = ($value -60*$hour); - - // add 1 to avoid pulldown 0 bug - $hour++; - $minute++; + $minute = ($value -60*$hour); + $time = $hour*60+$minute; } else { - $hour = '-'; - $minute = '-'; + $time = '-'; } -$hours = array(); -$hours['-'] = '-'; - -for($i=0;$i<$time_format;$i++) { - $hours[$i+1] = $i; -} - -$minutes = array(); -$minutes['-'] = '-'; - -for($i=0;$i<60;$i=$i+5) { - $minutes[$i+1] = sprintf("%02d",$i); +$dates = array(); +$dates['-'] = '-'; + +if ($time_format == '12') { + for($h=0;$h<=12;$h++) { + $ht = sprintf("%02d",$h); + for($m=0;$m<60;$m=$m+15) { + $mt = sprintf("%02d",$m); + $t = $h*60+$m; + if ($h < 12) { + $dates[$t] = "$ht:$mt am"; + } else { + $dates[$t] = "$ht:$mt pm"; + } + } + } + for($h=1;$h<12;$h++) { + $ht = sprintf("%02d",$h); + for($m=0;$m<60;$m=$m+15) { + $mt = sprintf("%02d",$m); + $t = 12*60+$h*60+$m; + $dates[$t] = "$ht:$mt pm"; + } + } +} else { + for($h=0;$h<24;$h++) { + $ht = sprintf("%02d",$h); + for($m=0;$m<60;$m=$m+15) { + $mt = sprintf("%02d",$m); + $t = $h*60+$m; + $dates[$t] = "$ht:$mt"; + } + } } -echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_h','value'=>$hour,'options_values'=>$hours)); -echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_m','value'=>$minute,'options_values'=>$minutes)); +echo elgg_view('input/dropdown',array('name'=>$vars['name'],'value'=>$time,'options_values'=>$dates)); -?>
\ No newline at end of file diff --git a/views/default/input/timepicker_old.php b/views/default/input/timepicker_old.php new file mode 100644 index 000000000..1d2156cda --- /dev/null +++ b/views/default/input/timepicker_old.php @@ -0,0 +1,38 @@ +<?php + +$time_format = elgg_get_plugin_setting('timeformat', 'event_calendar'); +if (!$time_format) { + $time_format = 24; +} + +$value = $vars['value']; +if (is_numeric($value)) { + $hour = floor($value/60); + $minute = ($value -60*$hour); + + // add 1 to avoid pulldown 0 bug + $hour++; + $minute++; +} else { + $hour = '-'; + $minute = '-'; +} + +$hours = array(); +$hours['-'] = '-'; + +for($i=0;$i<$time_format;$i++) { + $hours[$i+1] = $i; +} + +$minutes = array(); +$minutes['-'] = '-'; + +for($i=0;$i<60;$i=$i+15) { + $minutes[$i+1] = sprintf("%02d",$i); +} + +echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_h','value'=>$hour,'options_values'=>$hours)); +echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_m','value'=>$minute,'options_values'=>$minutes)); + +?>
\ No newline at end of file diff --git a/views/default/plugins/event_calendar/settings.php b/views/default/plugins/event_calendar/settings.php index 42ac601e5..93724484c 100644 --- a/views/default/plugins/event_calendar/settings.php +++ b/views/default/plugins/event_calendar/settings.php @@ -3,6 +3,8 @@ $yn_options = array(elgg_echo('event_calendar:settings:yes')=>'yes', elgg_echo('event_calendar:settings:no')=>'no', ); +$time_format_options = array(elgg_echo('event_calendar:time_format:12hour')=>'12',elgg_echo('event_calendar:time_format:24hour')=>'24'); + $membership_options = array( elgg_echo('event_calendar:personal_manage:open') => 'open' , elgg_echo('event_calendar:personal_manage:closed') => 'closed', @@ -88,6 +90,17 @@ $body .= elgg_view('input/radio',array('name'=>'params[times]','value'=>$event_c $body .= '<br />'; +$event_calendar_time_format = elgg_get_plugin_setting('timeformat', 'event_calendar'); +if (!$event_calendar_time_format) { + $event_calendar_time_format = '24'; +} + +$body .= elgg_echo('event_calendar:settings:timeformat:title'); +$body .= '<br />'; +$body .= elgg_view('input/radio',array('name'=>'params[timeformat]','value'=>$event_calendar_time_format,'options'=>$time_format_options)); + +$body .= '<br />'; + $event_calendar_autopersonal = elgg_get_plugin_setting('autopersonal', 'event_calendar'); if (!$event_calendar_autopersonal) { $event_calendar_autopersonal = 'yes'; |