/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { // Load the calendar behavior Behavior::calendar(); $format = $node->attributes('format') ? $node->attributes('format') : '%Y-%m-%d'; $class = $node->attributes('class') ? $node->attributes('class') : 'inputbox'; return Input::calendar($name, $value, array('format' => $format, 'class' => $class)); }
/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { $class = (string) $node['class']; $class = $class ?: 'text_area'; return Input::hidden($name, $value, array('class' => $class)); }
/** * Displays a hidden token field to reduce the risk of CSRF exploits * * @param string $name * @param integer $delay * @return string */ public static function generate($name = null) { $name = $name ?: self::getName(); return '<label id="hypt_' . $name . '_wrap" style="display:none;">' . "\n" . 'Leave this field empty:' . "\n" . Input::input('text', $name . '[p]') . "\n" . Input::input('text', $name . '[t]', self::getEncrypter()->encrypt(time())) . "\n" . '</label>' . "\n"; }
/** * Method to get the field input markup. * * @return string The field input markup. */ protected function getInput() { // Initialize some field attributes. $format = $this->element['format'] ? (string) $this->element['format'] : '%Y-%m-%d'; // Build the attributes array. $attributes = array(); if ($this->element['size']) { $attributes['size'] = (int) $this->element['size']; } if ($this->element['maxlength']) { $attributes['maxlength'] = (int) $this->element['maxlength']; } if ($this->element['class']) { $attributes['class'] = (string) $this->element['class']; } if ((string) $this->element['readonly'] == 'true') { $attributes['readonly'] = 'readonly'; } if ((string) $this->element['disabled'] == 'true') { $attributes['disabled'] = 'disabled'; } if ($this->element['onchange']) { $attributes['onchange'] = (string) $this->element['onchange']; } // Handle the special case for "now". if (strtoupper($this->value) == 'NOW') { $this->value = strftime($format); } // If a known filter is given use it. switch (strtoupper((string) $this->element['filter'])) { case 'SERVER_UTC': // Convert a date to UTC based on the server timezone. if (intval($this->value)) { // Get a date object based on the correct timezone. $date = new Date($this->value, 'UTC'); $date->setTimezone(new DateTimeZone(App::get('config')->get('offset'))); // Transform the date string. $this->value = $date->format('Y-m-d H:i:s', true, false); } break; case 'USER_UTC': // Convert a date to UTC based on the user timezone. if (intval($this->value)) { // Get a date object based on the correct timezone. $date = new Date($this->value, 'UTC'); $date->setTimezone(new DateTimeZone(App::get('user')->getParam('timezone', App::get('config')->get('offset')))); // Transform the date string. $this->value = $date->format('Y-m-d H:i:s', true, false); } break; } return Input::calendar($this->value, $this->name, $this->id, $format, $attributes); }