class RulesDataUIDate

UI for dates.

Hierarchy

Expanded class hierarchy of RulesDataUIDate

1 string reference to 'RulesDataUIDate'
rules_rules_core_data_info in modules/rules_core.rules.inc
Implements hook_rules_data_info() on behalf of the pseudo rules_core module.

File

ui/ui.data.inc, line 397

View source
class RulesDataUIDate extends RulesDataUIText {
    
    /**
     * Implements RulesDataDirectInputFormInterface::inputForm().
     */
    public static function inputForm($name, $info, $settings, RulesPlugin $element) {
        $settings += array(
            $name => isset($info['default value']) ? $info['default value'] : (empty($info['optional']) ? gmdate('Y-m-d H:i:s', time()) : NULL),
        );
        // Convert any configured timestamp into a readable format.
        if (is_numeric($settings[$name])) {
            $settings[$name] = gmdate('Y-m-d H:i:s', $settings[$name]);
        }
        $form = parent::inputForm($name, $info, $settings, $element);
        $form[$name]['#type'] = 'textfield';
        $form[$name]['#element_validate'][] = 'rules_ui_element_date_validate';
        // Note that the date input evaluator takes care for parsing dates using
        // strtotime() into a timestamp, which is the internal date format.
        $form[$name]['#description'] = t('The date in GMT. You may enter a fixed time (like %format) or any other values in GMT known by the PHP !strtotime function (like "+1 day"). Relative dates like "+1 day" or "now" relate to the evaluation time.', array(
            '%format' => gmdate('Y-m-d H:i:s', time() + 86400),
            '!strtotime' => l('strtotime()', 'http://php.net/strtotime'),
        ));
        // @todo Leverage the jquery datepicker+timepicker once a module providing
        // The timepicker is available.
        return $form;
    }
    
    /**
     * Implements RulesDataDirectInputFormInterface::render().
     */
    public static function render($value) {
        $value = is_numeric($value) ? format_date($value, 'short') : check_plain($value);
        return array(
            'content' => array(
                '#markup' => $value,
            ),
            '#attributes' => array(
                'class' => array(
                    'rules-parameter-date',
                ),
            ),
        );
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
RulesDataUI::getTypeInfo public static function Returns the data type and parameter information for the given arguments.
RulesDataUI::renderOptionsLabel public static function Renders the value with a label if an options list is available.
RulesDataUI::selectionForm public static function Provides the selection form for a parameter.
RulesDataUIDate::inputForm public static function Implements RulesDataDirectInputFormInterface::inputForm(). Overrides RulesDataUIText::inputForm
RulesDataUIDate::render public static function Implements RulesDataDirectInputFormInterface::render(). Overrides RulesDataUIText::render
RulesDataUIText::getDefaultMode public static function Overrides RulesDataUI::getDefaultMode(). Overrides RulesDataUI::getDefaultMode 2