]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
now uses a date_local view to consistently display events in local server time
authorKevin Jardine <kevinjardine@yahoo.com>
Mon, 24 Oct 2011 10:08:24 +0000 (12:08 +0200)
committerKevin Jardine <kevinjardine@yahoo.com>
Mon, 24 Oct 2011 10:08:24 +0000 (12:08 +0200)
views/default/event_calendar/input/date_local.php [new file with mode: 0644]
views/default/forms/event_calendar/edit.php

diff --git a/views/default/event_calendar/input/date_local.php b/views/default/event_calendar/input/date_local.php
new file mode 100644 (file)
index 0000000..f9979cb
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Elgg date input
+ * Displays a text field with a popup date picker.
+ *
+ * The elgg.ui JavaScript library initializes the jQueryUI datepicker based
+ * on the CSS class .elgg-input-date. It uses the ISO 8601 standard for date
+ * representation: yyyy-mm-dd.
+ *
+ * Unix timestamps are supported by setting the 'timestamp' parameter to true.
+ * The date is still displayed to the user in a text format but is submitted as
+ * a unix timestamp in seconds.
+ *
+ * @uses $vars['value']     The current value, if any (as a unix timestamp)
+ * @uses $vars['class']     Additional CSS class
+ * @uses $vars['timestamp'] Store as a Unix timestamp in seconds. Default = false
+ *                          Note: you cannot use an id with the timestamp option.
+ */
+
+//@todo popup_calendar deprecated in 1.8.  Remove in 2.0
+if (isset($vars['class'])) {
+       $vars['class'] = "elgg-input-date popup_calendar {$vars['class']}";
+} else {
+       $vars['class'] = "elgg-input-date popup_calendar";
+}
+
+$defaults = array(
+       'value' => '',
+       'disabled' => false,
+       'timestamp' => false,
+);
+
+$vars = array_merge($defaults, $vars);
+
+$timestamp = $vars['timestamp'];
+unset($vars['timestamp']);
+
+if ($timestamp) {
+       echo elgg_view('input/hidden', array(
+               'name' => $vars['name'],
+               'value' => $vars['value'],
+       ));
+
+       $vars['class'] = "{$vars['class']} elgg-input-timestamp";
+       $vars['id'] = $vars['name'];
+       unset($vars['name']);
+       unset($vars['internalname']);
+}
+
+// convert timestamps to text for display
+if (is_numeric($vars['value'])) {
+       $vars['value'] = date('Y/m/d', $vars['value']);
+}
+
+$attributes = elgg_format_attributes($vars);
+echo "<input type=\"text\" $attributes />";
index 25062e2df2f2e4283a8a79ede267a9a08e2278a0..214a51f4e2ee3b06584defd09a39cc88f8c4ab69 100644 (file)
@@ -118,7 +118,7 @@ if ($event_calendar_times == 'yes') {
 }
 
 $body .= '<p><label>'.elgg_echo("event_calendar:start_date_label").'<br />';
-$body .= elgg_view("input/date",array('timestamp'=>TRUE, 'autocomplete'=>'off','name' => 'start_date','value'=>$start_date));
+$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>';
 
@@ -131,7 +131,7 @@ if ($event_calendar_hide_end != 'yes') {
        }
        
        $body .= '<p><label>'.elgg_echo("event_calendar:end_date_label").'<br />';
-       $body .= elgg_view("input/date",array('timestamp'=>TRUE,'autocomplete'=>'off','name' => 'end_date','value'=>$end_date));
+       $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>';
 }