class rules_data_type_date in Rules 6
Rules date data type
Hierarchy
- class \rules_data_type
- class \rules_data_type_string
- class \rules_data_type_date
- class \rules_data_type_string
Expanded class hierarchy of rules_data_type_date
Related topics
1 string reference to 'rules_data_type_date'
- rules_rules_data_type_info in rules/
modules/ rules.rules.inc - Implementation of hook_rules_data_type_info().
File
- rules/
modules/ rules.rules.inc, line 86 - rules integration for the rules module
View source
class rules_data_type_date extends rules_data_type_string {
function get_default_input_form($info, $value, &$form_state) {
$info += array(
'long' => FALSE,
'required' => TRUE,
'description' => '',
);
$value = isset($value) ? $value : gmdate('Y-m-d H:i:s', time());
$info['description'] = $info['description'] . ' ' . t('Format: %format or other values in GMT known by the PHP !strtotime function like "+1 day". ', array(
'%format' => gmdate('Y-m-d H:i:s', time() + 86400),
'!strtotime' => l('strtotime()', 'http://php.net/strtotime'),
));
$info['description'] .= '<br />' . t('You may also enter a timestamp in GMT. E.g. use !code together with the PHP input evalutor to specify a date one day after the evaluation time. ', array(
'!code' => '<pre>' . check_plain('<?php echo time() + 86400 * 1; ?>') . '</pre>',
));
return array(
'#type' => $info['long'] ? 'textarea' : 'textfield',
'#title' => $info['label'],
'#description' => $info['description'],
'#required' => $info['required'],
'#default_value' => $value,
);
}
function check_value($info, $value) {
if (is_numeric($value)) {
$value = gmdate('Y-m-d H:i:s', $value);
}
else {
if (is_string($value)) {
$value = gmdate('Y-m-d H:i:s', rules_gmstrtotime($value));
}
}
if (is_string($value) && preg_match(RULES_DATE_REGEX_LOOSE, $value)) {
return $value;
}
rules_log(t('The argument %label is no valid date.', array(
'%label' => $info['label'],
)));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
rules_data_type:: |
property | |||
rules_data_type:: |
property | |||
rules_data_type:: |
property | |||
rules_data_type:: |
function | Constructor | ||
rules_data_type:: |
function | Returns whether the input evaluator should be used for this data | ||
rules_data_type:: |
function | Gets the data | ||
rules_data_type:: |
function | Gets the identifier of this data, which can be of every php data type - even an array. Implement it, if your data type is identifiable. | 5 | |
rules_data_type:: |
function | Gets the information about this data type. | ||
rules_data_type:: |
function | Inititate the data | ||
rules_data_type:: |
function | Returns whether this data is identifiable | ||
rules_data_type:: |
function | Returns whether this data is savable | ||
rules_data_type:: |
function | Loads the data identified with an identifier as returned by get_identifier(). Just return the data or FALSE if loading the data failed. | 5 | |
rules_data_type:: |
function | Makes changes to the data permanent. Implement it, if your data type is savable. | 1 | |
rules_data_type:: |
function | Replaces the data with the new one | ||
rules_data_type:: |
function | Returns whether this data makes use of an input form for creating an instance on the fly. | ||
rules_data_type_date:: |
function |
Checks the value of your data type. E.g. the number data type
uses this to make sure the value is a number. Overrides rules_data_type:: |
||
rules_data_type_date:: |
function |
Gets the input form for the data
Implement it, if your data is not identifiable. Overrides rules_data_type_string:: |