Elgg  Version 1.11
date.php
Go to the documentation of this file.
1 <?php
20 $vars['class'] = (array) elgg_extract('class', $vars, []);
21 $vars['class'][] = 'elgg-input-date';
22 
23 //@todo popup_calendar deprecated in 1.8. Remove in 2.0
24 $vars['class'][] = 'popup_calendar';
25 
26 $defaults = array(
27  'value' => '',
28  'disabled' => false,
29  'timestamp' => false,
30  'type' => 'text'
31 );
32 
33 $vars = array_merge($defaults, $vars);
34 
35 $timestamp = $vars['timestamp'];
36 unset($vars['timestamp']);
37 
38 if ($timestamp) {
39  echo elgg_view('input/hidden', ['name' => $vars['name'], 'value' => $vars['value']]);
40 
41  $vars['class'][] = 'elgg-input-timestamp';
42  $vars['id'] = $vars['name'];
43  unset($vars['name']);
44 }
45 
46 // convert timestamps to text for display
47 if (is_numeric($vars['value'])) {
48  $vars['value'] = gmdate('Y-m-d', $vars['value']);
49 }
50 
52 
53 if (elgg_is_xhr()) {
54  echo elgg_format_element('script', null, 'elgg.ui.initDatePicker();');
55 }
elgg_is_xhr()
Checks whether the request was requested via ajax.
Definition: actions.php:227
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1246
$timestamp
Definition: date.php:35
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:215
$vars['class']
Elgg date input Displays a text field with a popup date picker.
Definition: date.php:20
elgg echo
Translates a string.
Definition: languages.js:43
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
$defaults
Definition: date.php:26