diff options
author | Cash Costello <cash.costello@gmail.com> | 2011-07-06 03:56:13 -0700 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2011-07-06 03:56:13 -0700 |
commit | e7d0bf44e4f9958b211f0a010e7c70ea0cae7da7 (patch) | |
tree | e6383f5824a4e40668ca8900f2eb39292f9774c8 /views/default/input/date.php | |
parent | e4ad206bfd288463a37cfd4f86e6f343e3a35f77 (diff) | |
parent | e44192fba9e7b9155061e141278a9c16ed4923f5 (diff) | |
download | elgg-e7d0bf44e4f9958b211f0a010e7c70ea0cae7da7.tar.gz elgg-e7d0bf44e4f9958b211f0a010e7c70ea0cae7da7.tar.bz2 |
Merge pull request #56 from cash/improve-date-handling
Improve date handling
Diffstat (limited to 'views/default/input/date.php')
-rw-r--r-- | views/default/input/date.php | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/views/default/input/date.php b/views/default/input/date.php index e21a5f8f5..ceeb2105c 100644 --- a/views/default/input/date.php +++ b/views/default/input/date.php @@ -3,11 +3,18 @@ * Elgg date input * Displays a text field with a popup date picker. * - * @package Elgg - * @subpackage Core + * 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. * - * @uses $vars['value'] The current value, if any (as a unix timestamp) - * @uses $vars['class'] Additional CSS class + * 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 @@ -20,16 +27,30 @@ if (isset($vars['class'])) { $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'], + )); -if ($vars['value'] > 86400) { - $vars['value'] = date('n/d/Y', $vars['value']); + $vars['class'] = "{$vars['class']} elgg-input-timestamp"; + $vars['id'] = $vars['name']; + unset($vars['name']); + unset($vars['internalname']); } -$attributes = elgg_format_attributes($vars); +// convert timestamps to text for display +if (is_numeric($vars['value'])) { + $vars['value'] = gmdate('Y/m/d', $vars['value']); +} -?> -<input type="text" <?php echo $attributes; ?> />
\ No newline at end of file +$attributes = elgg_format_attributes($vars); +echo "<input type=\"text\" $attributes />"; |