diff options
author | Brett Profitt <brett.profitt@gmail.com> | 2011-08-25 10:00:38 -0700 |
---|---|---|
committer | Brett Profitt <brett.profitt@gmail.com> | 2011-08-25 10:00:38 -0700 |
commit | dccc333c765bb28da55b4a55d9c916acdb88413a (patch) | |
tree | bdd26a0b4cd85241a19b7fcb2c0770f0ac3eb9f0 /views/default/input/date.php | |
parent | ec7b94a64aef23b85866ecdac8e8acc712d29bb6 (diff) | |
parent | 003cb81c7888f4d2fd763e5814027c6f8d71186f (diff) | |
download | elgg-dccc333c765bb28da55b4a55d9c916acdb88413a.tar.gz elgg-dccc333c765bb28da55b4a55d9c916acdb88413a.tar.bz2 |
Merge branch 'master' of github.com:brettp/Elgg
Diffstat (limited to 'views/default/input/date.php')
-rw-r--r-- | views/default/input/date.php | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/views/default/input/date.php b/views/default/input/date.php index afc40e899..ceeb2105c 100644 --- a/views/default/input/date.php +++ b/views/default/input/date.php @@ -3,28 +3,54 @@ * 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) + * 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' => '', - 'class' => '', + 'disabled' => false, + 'timestamp' => false, ); $vars = array_merge($defaults, $vars); -//@todo popup_calendar deprecated in 1.8. Remove in 2.0 -$vars['class'] = trim("elgg-input-date popup_calendar {$vars['class']}"); +$timestamp = $vars['timestamp']; +unset($vars['timestamp']); -if ($vars['value'] > 86400) { - $vars['value'] = date('n/d/Y', $vars['value']); +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']); } -$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 />"; |