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/includes/rules.processor.inc
1 1
<?php
2 2

  
3 3
/**
4
 * @file Contains classes for data processing.
4
 * @file
5
 * Contains classes for data processing.
5 6
 *
6 7
 * Data processors can be used to process element arguments on evaluation time,
7 8
 * e.g. to apply input evaluators or to apply simple calculations to number
......
39 40
  }
40 41

  
41 42
  /**
42
   * Returns whether the current user has permission to edit this chain of data
43
   * processors.
43
   * Determines whether the current user has permission to edit this chain of
44
   * data processors.
45
   *
46
   * @return bool
47
   *   Whether the current user has permission to edit this chain of data
48
   *   processors.
44 49
   */
45 50
  public function editAccess() {
46 51
    return $this->access() && (!isset($this->processor) || $this->processor->editAccess());
47 52
  }
48 53

  
49

  
50 54
  /**
51 55
   * Prepares the processor for parameters.
52 56
   *
53
   * It turns the settings into a suiting processor object, which gets invoked
57
   * It turns the settings into a suitable processor object, which gets invoked
54 58
   * on evaluation time.
55 59
   *
56 60
   * @param $setting
57 61
   *   The processor settings which are to be prepared.
58 62
   * @param $param_info
59 63
   *   The info about the parameter to prepare the processor for.
60
   * @param $var_info
64
   * @param array $var_info
61 65
   *   An array of info about the available variables.
62 66
   */
63 67
  public static function prepareSetting(&$setting, $param_info, $var_info = array()) {
......
88 92

  
89 93
  /**
90 94
   * Returns defined data processors applicable for the given parameter.
91
   * Optionally also access to the processors is checked.
95
   *
96
   * Optionally also checks access to the processors.
92 97
   *
93 98
   * @param $param_info
94 99
   *   If given, only processors valid for this parameter are returned.
100
   * @param bool $access_check
101
   * @param string $hook
95 102
   */
96 103
  public static function processors($param_info = NULL, $access_check = TRUE, $hook = 'data_processor_info') {
97 104
    static $items = array();
98 105

  
99 106
    if (!isset($items[$hook]['all'])) {
100 107
      $items[$hook]['all'] = rules_fetch_data($hook);
101
      uasort($items[$hook]['all'], array(__CLASS__, '_item_sort'));
108
      if (isset($items[$hook]['all'])) {
109
        uasort($items[$hook]['all'], array(__CLASS__, '_item_sort'));
110
      }
102 111
    }
103 112
    // Data processing isn't supported for multiple types.
104 113
    if (isset($param_info) && is_array($param_info['type'])) {
......
182 191
  }
183 192

  
184 193
  /**
185
   * Processes the value. If $this->processor is set, invoke this processor
186
   * first so chaining multiple processors is working.
194
   * Processes the value.
195
   *
196
   * If $this->processor is set, invoke this processor first so chaining
197
   * multiple processors is working.
187 198
   *
188 199
   * @param $value
189 200
   *   The value to process.
190 201
   * @param $info
191 202
   *   Info about the parameter for which we process the value.
192
   * @param $state RulesState
203
   * @param RulesState $state
193 204
   *   The rules evaluation state.
194
   * @param $element RulesPlugin
205
   * @param RulesPlugin $element
195 206
   *   The element for which we process the value.
207
   *
196 208
   * @return
197 209
   *   The processed value.
198 210
   */
......
200 212

  
201 213
  /**
202 214
   * Return whether the current user has permission to use the processor.
215
   *
216
   * @return bool
217
   *   Whether the current user has permission to use the processor.
203 218
   */
204 219
  public static function access() {
205 220
    return TRUE;
......
210 225
   *
211 226
   * @param $settings
212 227
   *   The settings of the processor.
213
   * @param $var_info
228
   * @param array $var_info
214 229
   *   An array of info about the available variables.
215 230
   *
216 231
   * @return
......
219 234
  protected static function form($settings, $var_info) {
220 235
    return array();
221 236
  }
237

  
222 238
}
223 239

  
224 240

  
225 241
/**
226
 * A base processor for use as input evaluators. Input evaluators are not listed
227
 * in hook_rules_data_processor_info(). Instead they use
228
 * hook_rules_evaluator_info() and get attached to input forms.
242
 * A base processor for use by input evaluators.
243
 *
244
 * Input evaluators are not listed in hook_rules_data_processor_info(). Instead
245
 * they use hook_rules_evaluator_info() and get attached to input forms.
229 246
 */
230 247
abstract class RulesDataInputEvaluator extends RulesDataProcessor {
231 248

  
......
266 283
  }
267 284

  
268 285
  /**
269
   * Overriden to prepare input evaluator processors. The setting is expected
270
   * to be the input value to be evaluated later on and is replaced by the
271
   * suiting processor.
286
   * Overridden to prepare input evaluator processors.
287
   *
288
   * The setting is expected to be the input value to be evaluated later on
289
   * and is replaced by the suitable processor.
272 290
   */
273 291
  public static function prepareSetting(&$setting, $param_info, $var_info = array()) {
274 292
    $processor = NULL;
......
284 302
  }
285 303

  
286 304
  /**
287
   * Overriden to just attach the help() of evaluators.
305
   * Overrides RulesDataProcessor::attachForm().
306
   *
307
   * Overridden to just attach the help() of evaluators.
288 308
   */
289 309
  public static function attachForm(&$form, $settings, $param_info, $var_info, $access_check = TRUE) {
290 310
    foreach (self::evaluators($param_info, $access_check) as $name => $info) {
......
294 314
  }
295 315

  
296 316
  /**
297
   * Returns all input evaluators that can be applied to the parameters needed
298
   * type.
317
   * Returns all input evaluators that can be applied to the parameters type.
299 318
   */
300 319
  public static function evaluators($param_info = NULL, $access_check = TRUE) {
301 320
    return parent::processors($param_info, $access_check, 'evaluator_info');
302 321
  }
303 322

  
304 323
  /**
324
   * Overrides RulesDataProcessor::processors().
325
   *
305 326
   * Overridden to default to our hook, thus being equivalent to
306 327
   * self::evaluators().
307 328
   */
......
310 331
  }
311 332

  
312 333
  /**
313
   * Prepares the evalution, e.g. to determine whether the input evaluator has
314
   * been used. If this evaluator should be skipped just unset $this->setting.
334
   * Prepares the evaluation.
315 335
   *
316
   * @param $text
336
   * For example, to determine whether the input evaluator has been used.
337
   * If this evaluator should be skipped just unset $this->setting.
338
   *
339
   * @param string $text
317 340
   *   The text to evaluate later on.
318
   * @param $variables
341
   * @param array $variables
319 342
   *   An array of info about available variables.
320
   * @param $param_info
343
   * @param array $param_info
321 344
   *   (optional) An array of information about the handled parameter value.
322 345
   *   For backward compatibility, this parameter is not required.
323 346
   */
......
326 349
  /**
327 350
   * Apply the input evaluator.
328 351
   *
329
   * @param $text
352
   * @param string $text
330 353
   *   The text to evaluate.
331
   * @param $options
354
   * @param array $options
332 355
   *   A keyed array of settings and flags to control the processing.
333 356
   *   Supported options are:
334 357
   *   - language: A language object to be used when processing.
......
337 360
   *     certain way.
338 361
   *   - sanitize: A boolean flag indicating whether incorporated replacements
339 362
   *     should be sanitized.
340
   * @param RulesState
363
   * @param RulesState $state
341 364
   *   The rules evaluation state.
342 365
   *
343 366
   * @return
......
348 371
  /**
349 372
   * Provide some usage help for the evaluator.
350 373
   *
351
   * @param $variables
374
   * @param array $variables
352 375
   *   An array of info about available variables.
353
   * @param $param_info
376
   * @param array $param_info
354 377
   *   (optional) An array of information about the handled parameter value.
355 378
   *   For backward compatibility, this parameter is not required.
356 379
   *
357
   * @return
380
   * @return array
358 381
   *   A renderable array.
359 382
   */
360 383
  public static function help($variables) {

Formats disponibles : Unified diff