Projet

Général

Profil

Révision 950416da

Ajouté par Assos Assos il y a plus de 5 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/rules/modules/rules_core.eval.inc
5 5
 * Contains rules core integration needed during evaluation.
6 6
 *
7 7
 * @addtogroup rules
8
 *
8 9
 * @{
9 10
 */
10 11

  
......
46 47
    $state->mergeSaveVariables($new_state, $component, $element->settings);
47 48
    $state->unblock($component);
48 49

  
49
    // Cleanup the state, what saves not mergable variables now.
50
    // Cleanup the state, what saves not mergeable variables now.
50 51
    $new_state->cleanup();
51 52
    rules_log('Finished evaluation of @plugin %label.', $replacements, RulesLog::INFO, $component, FALSE);
52 53
    return $return;
......
57 58
}
58 59

  
59 60
/**
60
 * A class implementing a rules input evaluator processing date input. This is
61
 * needed to treat relative date inputs for strtotime right, consider "now".
61
 * A class implementing a rules input evaluator processing date input.
62
 *
63
 * This is needed to treat relative date inputs for strtotime() correctly.
64
 * Consider for example "now".
62 65
 */
63 66
class RulesDateInputEvaluator extends RulesDataInputEvaluator {
64 67

  
65 68
  const DATE_REGEX_LOOSE = '/^(\d{4})-?(\d{2})-?(\d{2})([T\s]?(\d{2}):?(\d{2}):?(\d{2})?)?$/';
66 69

  
70
  /**
71
   * Overrides RulesDataInputEvaluator::prepare().
72
   */
67 73
  public function prepare($text, $var_info) {
68 74
    if (is_numeric($text)) {
69 75
      // Let rules skip this input evaluators in case it's already a timestamp.
......
71 77
    }
72 78
  }
73 79

  
80
  /**
81
   * Overrides RulesDataInputEvaluator::evaluate().
82
   */
74 83
  public function evaluate($text, $options, RulesState $state) {
75 84
    return self::gmstrtotime($text);
76 85
  }
......
89 98
  public static function isFixedDateString($date) {
90 99
    return is_string($date) && preg_match(self::DATE_REGEX_LOOSE, $date);
91 100
  }
101

  
92 102
}
93 103

  
94 104
/**
95
 * A class implementing a rules input evaluator processing URI inputs to make
96
 * sure URIs are absolute and path aliases get applied.
105
 * A class implementing a rules input evaluator processing URI inputs.
106
 *
107
 * Makes sure URIs are absolute and path aliases get applied.
97 108
 */
98 109
class RulesURIInputEvaluator extends RulesDataInputEvaluator {
99 110

  
111
  /**
112
   * Overrides RulesDataInputEvaluator::prepare().
113
   */
100 114
  public function prepare($uri, $var_info) {
101 115
    if (!isset($this->processor) && valid_url($uri, TRUE)) {
102 116
      // Only process if another evaluator is used or the url is not absolute.
......
104 118
    }
105 119
  }
106 120

  
121
  /**
122
   * Overrides RulesDataInputEvaluator::evaluate().
123
   */
107 124
  public function evaluate($uri, $options, RulesState $state) {
108 125
    if (!url_is_external($uri)) {
109 126
      // Extract the path and build the URL using the url() function, so URL
......
119 136
    }
120 137
    throw new RulesEvaluationException('Input evaluation generated an invalid URI.', array(), NULL, RulesLog::WARN);
121 138
  }
139

  
122 140
}
123 141

  
124 142
/**
......
126 144
 */
127 145
class RulesDateOffsetProcessor extends RulesDataProcessor {
128 146

  
147
  /**
148
   * Overrides RulesDataProcessor::form().
149
   */
129 150
  protected static function form($settings, $var_info) {
130 151
    $settings += array('value' => '');
131 152
    $form = array(
......
145 166
    return $form;
146 167
  }
147 168

  
169
  /**
170
   * Overrides RulesDataProcessor::process().
171
   */
148 172
  public function process($value, $info, RulesState $state, RulesPlugin $element) {
149 173
    $value = isset($this->processor) ? $this->processor->process($value, $info, $state, $element) : $value;
150 174
    return RulesDateOffsetProcessor::applyOffset($value, $this->setting['value']);
......
178 202
      return $timestamp + $offset;
179 203
    }
180 204
  }
205

  
181 206
}
182 207

  
183 208
/**
......
185 210
 */
186 211
class RulesNumericOffsetProcessor extends RulesDataProcessor {
187 212

  
213
  /**
214
   * Overrides RulesDataProcessor::form().
215
   */
188 216
  protected static function form($settings, $var_info) {
189 217
    $settings += array('value' => '');
190 218
    $form = array(
......
205 233
    return $form;
206 234
  }
207 235

  
236
  /**
237
   * Overrides RulesDataProcessor::process().
238
   */
208 239
  public function process($value, $info, RulesState $state, RulesPlugin $element) {
209 240
    $value = isset($this->processor) ? $this->processor->process($value, $info, $state, $element) : $value;
210 241
    return $value + $this->setting['value'];
211 242
  }
212
}
213 243

  
244
}
214 245

  
215 246
/**
216
 * A custom wrapper class for vocabularies that is capable of loading vocabularies by machine name.
247
 * A custom wrapper class for vocabularies.
248
 *
249
 * This class is capable of loading vocabularies by machine name.
217 250
 */
218 251
class RulesTaxonomyVocabularyWrapper extends EntityDrupalWrapper {
219 252

  
......
231 264
  }
232 265

  
233 266
  /**
234
   * Overriden to permit machine names as values.
267
   * Overridden to permit machine names as values.
235 268
   */
236 269
  public function validate($value) {
237 270
    if (isset($value) && is_string($value)) {
......
239 272
    }
240 273
    return parent::validate($value);
241 274
  }
275

  
242 276
}
277

  
278
/**
279
 * @}
280
 */

Formats disponibles : Unified diff