FOF30\Form\Field\Calendar::getCalendar PHP Метод

getCalendar() защищенный Метод

Method to get the calendar input markup.
С версии: 2.1.rc4
protected getCalendar ( string $display ) : string
$display string The display to render ('static' or 'repeatable')
Результат string The field input markup.
    protected function getCalendar($display)
    {
        // Initialize some field attributes.
        $format = $this->format ? $this->format : '%Y-%m-%d';
        $class = $this->class ? $this->class : '';
        $default = $this->element['default'] ? (string) $this->element['default'] : '';
        // Get some system objects.
        $config = $this->form->getContainer()->platform->getConfig();
        $user = $this->form->getContainer()->platform->getUser();
        // Check for empty date values
        if (empty($this->value) || $this->value == $this->form->getContainer()->platform->getDbo()->getNullDate() || $this->value == '0000-00-00') {
            $this->value = $default;
        }
        // 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($this->filter)) {
            case 'SERVER_UTC':
                // Convert a date to UTC based on the server timezone.
                if ((int) $this->value) {
                    // Get a date object based on the correct timezone.
                    $date = \JFactory::getDate($this->value, 'UTC');
                    $date->setTimezone(new \DateTimeZone($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 ((int) $this->value) {
                    // Get a date object based on the correct timezone.
                    $date = \JFactory::getDate($this->value, 'UTC');
                    $date->setTimezone(new \DateTimeZone($user->getParam('timezone', $config->get('offset'))));
                    // Transform the date string.
                    $this->value = $date->format('Y-m-d H:i:s', true, false);
                }
                break;
        }
        if ($display == 'static') {
            // Build the attributes array.
            $attributes = array();
            if ($this->size) {
                $attributes['size'] = $this->size;
            }
            if ($this->maxlength) {
                $attributes['maxlength'] = $this->maxlength;
            }
            if ($this->class) {
                $attributes['class'] = $this->class;
            }
            if ($this->readonly) {
                $attributes['readonly'] = 'readonly';
            }
            if ($this->disabled) {
                $attributes['disabled'] = 'disabled';
            }
            if ($this->onchange) {
                $attributes['onchange'] = $this->onchange;
            }
            if ($this->required) {
                $attributes['required'] = 'required';
                $attributes['aria-required'] = 'true';
            }
            // Including fallback code for HTML5 non supported browsers.
            JHtml::_('jquery.framework');
            JHtml::_('script', 'system/html5fallback.js', false, true);
            return JHtml::_('calendar', $this->value, $this->name, $this->id, $format, $attributes);
        } else {
            if (!$this->value && (string) $this->element['empty_replacement']) {
                $value = $this->element['empty_replacement'];
            } else {
                $jDate = new \JDate($this->value);
                $value = strftime($format, $jDate->getTimestamp());
            }
            return '<span class="' . $this->id . ' ' . $class . '">' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '</span>';
        }
    }