class RulesDateInputEvaluator in Rules 7.2
A class implementing a rules input evaluator processing date input.
This is needed to treat relative date inputs for strtotime() correctly. Consider for example "now".
Hierarchy
- class \RulesDataProcessor
- class \RulesDataInputEvaluator
- class \RulesDateInputEvaluator
- class \RulesDataInputEvaluator
Expanded class hierarchy of RulesDateInputEvaluator
Related topics
1 string reference to 'RulesDateInputEvaluator'
- rules_rules_core_evaluator_info in modules/
rules_core.rules.inc - Implements hook_rules_evaluator_info() on behalf of the pseudo rules_core module.
File
- modules/
rules_core.eval.inc, line 66 - Contains rules core integration needed during evaluation.
View source
class RulesDateInputEvaluator extends RulesDataInputEvaluator {
const DATE_REGEX_LOOSE = '/^(\\d{4})-?(\\d{2})-?(\\d{2})([T\\s]?(\\d{2}):?(\\d{2}):?(\\d{2})?)?$/';
/**
* Overrides RulesDataInputEvaluator::prepare().
*/
public function prepare($text, $var_info) {
if (is_numeric($text)) {
// Let rules skip this input evaluators in case it's already a timestamp.
$this->setting = NULL;
}
}
/**
* Overrides RulesDataInputEvaluator::evaluate().
*/
public function evaluate($text, $options, RulesState $state) {
return self::gmstrtotime($text);
}
/**
* Convert a time string to a GMT (UTC) unix timestamp.
*/
public static function gmstrtotime($date) {
// Pass the current timestamp in UTC to ensure the retrieved time is UTC.
return strtotime($date, time());
}
/**
* Determine whether the given date string specifies a fixed date.
*/
public static function isFixedDateString($date) {
return is_string($date) && preg_match(self::DATE_REGEX_LOOSE, $date);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RulesDataInputEvaluator:: |
public static | function |
Overrides RulesDataProcessor::attachForm(). Overrides RulesDataProcessor:: |
|
RulesDataInputEvaluator:: |
public static | function | Returns all input evaluators that can be applied to the parameters type. | |
RulesDataInputEvaluator:: |
protected | function | Generates the evaluator $options. | |
RulesDataInputEvaluator:: |
protected | function |
Return $this or skip this processor by returning the next processor. Overrides RulesDataProcessor:: |
|
RulesDataInputEvaluator:: |
public static | function | Provide some usage help for the evaluator. | 3 |
RulesDataInputEvaluator:: |
public static | function |
Overridden to prepare input evaluator processors. Overrides RulesDataProcessor:: |
|
RulesDataInputEvaluator:: |
public | function |
Overridden to generate evaluator $options and invoke evaluate(). Overrides RulesDataProcessor:: |
1 |
RulesDataInputEvaluator:: |
public static | function |
Overrides RulesDataProcessor::processors(). Overrides RulesDataProcessor:: |
|
RulesDataInputEvaluator:: |
protected | function |
Overridden to invoke prepare(). Overrides RulesDataProcessor:: |
|
RulesDataProcessor:: |
protected | property | Allows chaining processors. If set, the next processor to invoke. | |
RulesDataProcessor:: |
protected | property | The processors' setting value. | |
RulesDataProcessor:: |
public static | function | Return whether the current user has permission to use the processor. | 1 |
RulesDataProcessor:: |
public | function | Returns an array of modules which we depend on. | |
RulesDataProcessor:: |
public | function | Determines whether the current user has permission to edit this chain of data processors. | 2 |
RulesDataProcessor:: |
protected static | function | Defines the processor form element. | 3 |
RulesDataProcessor:: |
public | function | Gets the settings array for this and all contained chained processors. | |
RulesDataProcessor:: |
public | function | Gets the settings of this processor. | |
RulesDataProcessor:: |
protected | function | ||
RulesDataProcessor:: |
public static | function | ||
RulesDateInputEvaluator:: |
constant | |||
RulesDateInputEvaluator:: |
public | function |
Overrides RulesDataInputEvaluator::evaluate(). Overrides RulesDataInputEvaluator:: |
|
RulesDateInputEvaluator:: |
public static | function | Convert a time string to a GMT (UTC) unix timestamp. | |
RulesDateInputEvaluator:: |
public static | function | Determine whether the given date string specifies a fixed date. | |
RulesDateInputEvaluator:: |
public | function |
Overrides RulesDataInputEvaluator::prepare(). Overrides RulesDataInputEvaluator:: |