Projet

Général

Profil

Paste
Télécharger (22,2 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / rules / ui / ui.data.inc @ 950416da

1
<?php
2

    
3
/**
4
 * @file
5
 * Contains data type related forms.
6
 */
7

    
8
/**
9
 * Interface for data types providing a direct input form.
10
 */
11
interface RulesDataDirectInputFormInterface {
12

    
13
  /**
14
   * Constructs the direct input form.
15
   *
16
   * @return array
17
   *   The direct input form.
18
   */
19
  public static function inputForm($name, $info, $settings, RulesPlugin $element);
20

    
21
  /**
22
   * Render the configured value.
23
   *
24
   * @return array
25
   *   A renderable array.
26
   */
27
  public static function render($value);
28

    
29
}
30

    
31
/**
32
 * Interface for data UI classes providing an options list.
33
 */
34
interface RulesDataInputOptionsListInterface extends RulesDataDirectInputFormInterface {
35

    
36
  /**
37
   * Returns the options list for the data type.
38
   *
39
   * For retrieving information about the used data type and parameter, the
40
   * helper RulesDataUI::getTypeInfo() may be used as following:
41
   * @code
42
   *   list($type, $parameter_info) = RulesDataUI::getTypeInfo($element, $name);
43
   * @endcode
44
   *
45
   * @param RulesPlugin $element
46
   *   The rules element to get the options for.
47
   * @param string $name
48
   *   The name of the parameter for which to get options.
49
   *
50
   * @return array
51
   *   An array of options as used by hook_options_list().
52
   */
53
  public static function optionsList(RulesPlugin $element, $name);
54

    
55
}
56

    
57
/**
58
 * Default UI related class for data types.
59
 */
60
class RulesDataUI {
61

    
62
  /**
63
   * Specifies the default input mode per data type.
64
   */
65
  public static function getDefaultMode() {
66
    return 'selector';
67
  }
68

    
69
  /**
70
   * Provides the selection form for a parameter.
71
   */
72
  public static function selectionForm($name, $info, $settings, RulesPlugin $element) {
73
    if (!isset($settings[$name . ':select'])) {
74
      $settings[$name . ':select'] = '';
75
      $vars = $element->availableVariables();
76
      // Default to variables with the same name as the parameter.
77
      if (isset($vars[$name])) {
78
        $settings[$name . ':select'] = $name;
79
      }
80
      // If there is only one match, use it by default.
81
      elseif (count($matches = RulesData::matchingDataSelector($vars, $info, '', 1, FALSE)) == 1) {
82
        $settings[$name . ':select'] = rules_array_key($matches);
83
      }
84
    }
85
    $form[$name . ':select'] = array(
86
      '#type' => 'rules_data_selection',
87
      '#title' => t('Data selector'),
88
      '#default_value' => $settings[$name . ':select'],
89
      '#required' => empty($info['optional']),
90
      '#autocomplete_path' => RulesPluginUI::path($element->root()->name, 'autocomplete' . '/' . $name),
91
      // Make the autocomplete textfield big enough so that it can display
92
      // descriptions without word wraps.
93
      '#size' => 75,
94
      '#description' => t("The data selector helps you drill down into the data available to Rules. <em>To make entity fields appear in the data selector, you may have to use the condition 'entity has field' (or 'content is of type').</em> More useful tips about data selection is available in <a href='@url'>the online documentation</a>.",
95
        array('@url' => rules_external_help('data-selection'))),
96
    );
97

    
98
    $cache = rules_get_cache();
99
    $form['types_help'] = array(
100
      '#theme' => 'rules_settings_help',
101
      '#heading' => t('Data types'),
102
    );
103
    if ($info['type'] == '*') {
104
      $type_labels[] = t('any');
105
    }
106
    else {
107
      $types = is_array($info['type']) ? $info['type'] : array($info['type']);
108
      $type_labels = array();
109
      foreach ($types as $type) {
110
        $type_labels[] = drupal_ucfirst(isset($cache['data_info'][$type]['label']) ? $cache['data_info'][$type]['label'] : $type);
111
      }
112
    }
113
    $form['types_help']['#text'] = format_plural(count($type_labels), 'Select data of the type %types.', 'Select data of the types %types.', array('%types' => implode(', ', $type_labels)));
114

    
115
    if (!empty($info['translatable'])) {
116
      if (empty($info['custom translation language'])) {
117
        $text = t('If a multilingual data source (i.e. a translatable field) is given, the argument is translated to the current interface language.');
118
      }
119
      else {
120
        $text = t('If a multilingual data source (i.e. a translatable field) is given, the argument is translated to the configured language.');
121
      }
122
      $form['translation'] = array(
123
        '#theme' => 'rules_settings_help',
124
        '#text' => $text,
125
        '#heading' => t('Translation'),
126
      );
127
    }
128
    $form['help'] = array(
129
      '#theme' => 'rules_data_selector_help',
130
      '#variables' => $element->availableVariables(),
131
      '#parameter' => $info,
132
    );
133

    
134
    // Add data processor.
135
    $settings += array($name . ':process' => array());
136
    $form[$name . ':process'] = array();
137
    RulesDataProcessor::attachForm($form[$name . ':process'], $settings[$name . ':process'], $info, $element->availableVariables());
138
    return $form;
139
  }
140

    
141
  /**
142
   * Renders the value with a label if an options list is available.
143
   *
144
   * Used for data UI classes implementing the
145
   * RulesDataDirectInputFormInterface.
146
   *
147
   * In case an options list is available, the the usual render() method won't
148
   * be invoked, instead the selected entry is rendered via this method.
149
   *
150
   * @todo for Drupal 8: Refactor to avoid implementations have to care about
151
   * option lists when generating the form, but not when rendering values.
152
   */
153
  public static function renderOptionsLabel($value, $name, $info, RulesPlugin $element) {
154
    if (!empty($info['options list'])) {
155
      $element->call('loadBasicInclude');
156
      $options = entity_property_options_flatten(call_user_func($info['options list'], $element, $name));
157
      if (!is_array($value) && isset($options[$value])) {
158
        $value = $options[$value];
159
      }
160
      elseif (is_array($value)) {
161
        foreach ($value as $key => $single_value) {
162
          if (isset($options[$single_value])) {
163
            $value[$key] = $options[$single_value];
164
          }
165
        }
166
        $value = implode(', ', $value);
167
      }
168
      return array(
169
        'content' => array('#markup' => check_plain($value)),
170
        '#attributes' => array('class' => array('rules-parameter-options-entry')),
171
      );
172
    }
173
  }
174

    
175
  /**
176
   * Returns the data type and parameter information for the given arguments.
177
   *
178
   * This helper may be used by options list callbacks operation at data-type
179
   * level, see RulesDataInputOptionsListInterface.
180
   */
181
  public static function getTypeInfo(RulesPlugin $element, $name) {
182
    $parameters = $element->pluginParameterInfo();
183
    return array($parameters[$name]['type'], $parameters[$name]);
184
  }
185

    
186
}
187

    
188
/**
189
 * UI for textual data.
190
 */
191
class RulesDataUIText extends RulesDataUI implements RulesDataDirectInputFormInterface {
192

    
193
  /**
194
   * Overrides RulesDataUI::getDefaultMode().
195
   */
196
  public static function getDefaultMode() {
197
    return 'input';
198
  }
199

    
200
  /**
201
   * Implements RulesDataDirectInputFormInterface::inputForm().
202
   */
203
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
204
    if (!empty($info['options list'])) {
205
      // Make sure the .rules.inc of the providing module is included as the
206
      // options list callback may reside there.
207
      $element->call('loadBasicInclude');
208
      $form[$name] = array(
209
        '#type' => 'select',
210
        '#options' => call_user_func($info['options list'], $element, $name),
211
      );
212
    }
213
    else {
214
      $form[$name] = array(
215
        '#type' => 'textarea',
216
        '#rows' => 3,
217
      );
218
      RulesDataInputEvaluator::attachForm($form, $settings, $info, $element->availableVariables());
219
    }
220
    $settings += array($name => isset($info['default value']) ? $info['default value'] : NULL);
221
    $form[$name] += array(
222
      '#title' => t('Value'),
223
      '#default_value' => $settings[$name],
224
      '#required' => empty($info['optional']),
225
      '#after_build' => array('rules_ui_element_fix_empty_after_build'),
226
    );
227
    return $form;
228
  }
229

    
230
  /**
231
   * Implements RulesDataDirectInputFormInterface::render().
232
   */
233
  public static function render($value) {
234
    return array(
235
      'content' => array('#markup' => check_plain($value)),
236
      '#attributes' => array('class' => array('rules-parameter-text')),
237
    );
238
  }
239

    
240
}
241

    
242
/**
243
 * UI for text tokens.
244
 */
245
class RulesDataUITextToken extends RulesDataUIText {
246

    
247
  /**
248
   * Implements RulesDataDirectInputFormInterface::inputForm().
249
   */
250
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
251
    $form = parent::inputForm($name, $info, $settings, $element);
252
    if ($form[$name]['#type'] == 'textarea') {
253
      $form[$name]['#element_validate'][] = 'rules_ui_element_token_validate';
254
      $form[$name]['#description'] = t('May only contain lowercase letters, numbers, and underscores and has to start with a letter.');
255
      $form[$name]['#rows'] = 1;
256
    }
257
    return $form;
258
  }
259

    
260
}
261

    
262
/**
263
 * UI for formatted text.
264
 */
265
class RulesDataUITextFormatted extends RulesDataUIText {
266

    
267
  /**
268
   * Implements RulesDataDirectInputFormInterface::inputForm().
269
   */
270
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
271
    $form = parent::inputForm($name, $info, $settings, $element);
272
    $settings += array($name => isset($info['default value']) ? $info['default value'] : array('value' => NULL, 'format' => NULL));
273

    
274
    $form[$name]['#type'] = 'text_format';
275
    $form[$name]['#base_type'] = 'textarea';
276
    $form[$name]['#default_value'] = $settings[$name]['value'];
277
    $form[$name]['#format'] = $settings[$name]['format'];
278
    return $form;
279
  }
280

    
281
  /**
282
   * Implements RulesDataDirectInputFormInterface::render().
283
   */
284
  public static function render($value) {
285
    return array(
286
      'content' => array('#markup' => check_plain($value['value'])),
287
      '#attributes' => array('class' => array('rules-parameter-text-formatted')),
288
    );
289
  }
290

    
291
}
292

    
293
/**
294
 * UI for decimal data.
295
 */
296
class RulesDataUIDecimal extends RulesDataUIText {
297

    
298
  /**
299
   * Implements RulesDataDirectInputFormInterface::inputForm().
300
   */
301
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
302
    $form = parent::inputForm($name, $info, $settings, $element);
303
    if (empty($info['options list'])) {
304
      $form[$name]['#type'] = 'textfield';
305
    }
306
    $form[$name]['#element_validate'][] = 'rules_ui_element_decimal_validate';
307
    $form[$name]['#rows'] = 1;
308
    return $form;
309
  }
310

    
311
}
312

    
313
/**
314
 * UI for integers.
315
 */
316
class RulesDataUIInteger extends RulesDataUIText {
317

    
318
  /**
319
   * Implements RulesDataDirectInputFormInterface::inputForm().
320
   */
321
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
322
    $form = parent::inputForm($name, $info, $settings, $element);
323
    if (empty($info['options list'])) {
324
      $form[$name]['#type'] = 'textfield';
325
    }
326
    $form[$name]['#element_validate'][] = 'rules_ui_element_integer_validate';
327
    return $form;
328
  }
329

    
330
}
331

    
332
/**
333
 * UI for IP addresses.
334
 */
335
class RulesDataUIIPAddress extends RulesDataUIText {
336

    
337
  /**
338
   * Implements RulesDataDirectInputFormInterface::inputForm().
339
   */
340
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
341
    $form = parent::inputForm($name, $info, $settings, $element);
342
    if (empty($info['options list'])) {
343
      $form[$name]['#type'] = 'textfield';
344
      $form[$name]['#description'] = t('If not provided, the IP address of the current user will be used.');
345
    }
346
    $form[$name]['#element_validate'][] = 'rules_ui_element_ip_address_validate';
347
    $form[$name]['#rows'] = 1;
348
    return $form;
349
  }
350

    
351
}
352

    
353
/**
354
 * UI for boolean data.
355
 */
356
class RulesDataUIBoolean extends RulesDataUI implements RulesDataDirectInputFormInterface {
357

    
358
  /**
359
   * Overrides RulesDataUI::getDefaultMode().
360
   */
361
  public static function getDefaultMode() {
362
    return 'input';
363
  }
364

    
365
  /**
366
   * Implements RulesDataDirectInputFormInterface::inputForm().
367
   */
368
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
369
    $settings += array($name => isset($info['default value']) ? $info['default value'] : NULL);
370
    // Note: Due to the checkbox even optional parameter always receive a value.
371
    $form[$name] = array(
372
      '#type' => 'radios',
373
      '#default_value' => $settings[$name],
374
      '#options' => array(
375
        TRUE => t('@label: True.', array('@label' => $info['label'])),
376
        FALSE => t('@label: False.', array('@label' => $info['label'])),
377
      ),
378
    );
379
    return $form;
380
  }
381

    
382
  /**
383
   * Implements RulesDataDirectInputFormInterface::render().
384
   */
385
  public static function render($value) {
386
    return array(
387
      'content' => array('#markup' => !empty($value) ? t('true') : t('false')),
388
      '#attributes' => array('class' => array('rules-parameter-boolean')),
389
    );
390
  }
391

    
392
}
393

    
394
/**
395
 * UI for dates.
396
 */
397
class RulesDataUIDate extends RulesDataUIText {
398

    
399
  /**
400
   * Implements RulesDataDirectInputFormInterface::inputForm().
401
   */
402
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
403
    $settings += array($name => isset($info['default value']) ? $info['default value'] : (empty($info['optional']) ? gmdate('Y-m-d H:i:s', time()) : NULL));
404

    
405
    // Convert any configured timestamp into a readable format.
406
    if (is_numeric($settings[$name])) {
407
      $settings[$name] = gmdate('Y-m-d H:i:s', $settings[$name]);
408
    }
409
    $form = parent::inputForm($name, $info, $settings, $element);
410
    $form[$name]['#type'] = 'textfield';
411
    $form[$name]['#element_validate'][] = 'rules_ui_element_date_validate';
412
    // Note that the date input evaluator takes care for parsing dates using
413
    // strtotime() into a timestamp, which is the internal date format.
414
    $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.',
415
      array('%format' => gmdate('Y-m-d H:i:s', time() + 86400),
416
            '!strtotime' => l('strtotime()', 'http://php.net/strtotime')));
417

    
418
    // @todo Leverage the jquery datepicker+timepicker once a module providing
419
    // The timepicker is available.
420
    return $form;
421
  }
422

    
423
  /**
424
   * Implements RulesDataDirectInputFormInterface::render().
425
   */
426
  public static function render($value) {
427
    $value = is_numeric($value) ? format_date($value, 'short') : check_plain($value);
428
    return array(
429
      'content' => array('#markup' => $value),
430
      '#attributes' => array('class' => array('rules-parameter-date')),
431
    );
432
  }
433

    
434
}
435

    
436
/**
437
 * UI for duration type parameter.
438
 */
439
class RulesDataUIDuration extends RulesDataUIText {
440

    
441
  /**
442
   * Implements RulesDataDirectInputFormInterface::inputForm().
443
   */
444
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
445
    $form = parent::inputForm($name, $info, $settings, $element);
446
    $form[$name]['#type'] = 'rules_duration';
447
    $form[$name]['#after_build'][] = 'rules_ui_element_duration_after_build';
448
    return $form;
449
  }
450

    
451
  /**
452
   * Implements RulesDataDirectInputFormInterface::render().
453
   */
454
  public static function render($value) {
455
    $value = is_numeric($value) ? format_interval($value) : check_plain($value);
456
    return array(
457
      'content' => array('#markup' => $value),
458
      '#attributes' => array('class' => array('rules-parameter-duration')),
459
    );
460
  }
461

    
462
}
463

    
464
/**
465
 * UI for the URI type parameter.
466
 */
467
class RulesDataUIURI extends RulesDataUIText {
468

    
469
  /**
470
   * Implements RulesDataDirectInputFormInterface::inputForm().
471
   */
472
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
473
    $form = parent::inputForm($name, $info, $settings, $element);
474
    $form[$name]['#rows'] = 1;
475
    $form[$name]['#description'] = t('You may enter relative URLs like %url as well as absolute URLs like %absolute-url.', array('%url' => 'user/login?destination=node', '%absolute-url' => 'https://www.drupal.org'));
476
    return $form;
477
  }
478

    
479
}
480

    
481
/**
482
 * UI for lists of textual data.
483
 */
484
class RulesDataUIListText extends RulesDataUIText {
485

    
486
  /**
487
   * Overrides RulesDataUI::getDefaultMode().
488
   */
489
  public static function getDefaultMode() {
490
    return 'input';
491
  }
492

    
493
  /**
494
   * Implements RulesDataDirectInputFormInterface::inputForm().
495
   *
496
   * @todo This does not work for inputting textual values including "\n".
497
   */
498
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
499
    $settings += array($name => isset($info['default value']) ? $info['default value'] : NULL);
500
    $form = parent::inputForm($name, $info, $settings, $element);
501

    
502
    if ($form[$name]['#type'] == 'textarea') {
503
      // Fix up the value to be an array during after build.
504
      $form[$name]['#delimiter'] = "\n";
505
      $form[$name]['#after_build'][] = 'rules_ui_list_textarea_after_build';
506
      $form[$name]['#pre_render'][] = 'rules_ui_list_textarea_pre_render';
507
      $form[$name]['#default_value'] = !empty($settings[$name]) ? implode("\n", $settings[$name]) : NULL;
508
      $form[$name]['#description'] = t('A list of values, one on each line.');
509
    }
510
    else {
511
      $form[$name]['#multiple'] = TRUE;
512
    }
513
    return $form;
514
  }
515

    
516
  /**
517
   * Implements RulesDataDirectInputFormInterface::render().
518
   */
519
  public static function render($value) {
520
    return array(
521
      'content' => array('#markup' => check_plain(implode(', ', $value))),
522
      '#attributes' => array('class' => array('rules-parameter-list')),
523
    );
524
  }
525

    
526
}
527

    
528
/**
529
 * UI for lists of integers.
530
 */
531
class RulesDataUIListInteger extends RulesDataUIListText {
532

    
533
  /**
534
   * Implements RulesDataDirectInputFormInterface::inputForm().
535
   */
536
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
537
    $settings += array($name => isset($info['default value']) ? $info['default value'] : NULL);
538
    $form = parent::inputForm($name, $info, $settings, $element);
539

    
540
    if ($form[$name]['#type'] == 'textarea') {
541
      $form[$name]['#description'] = t('A list of integers, separated by commas. E.g. enter "1, 2, 3".');
542
      $form[$name]['#delimiter'] = ',';
543
      $form[$name]['#default_value'] = !empty($settings[$name]) ? implode(", ", $settings[$name]) : NULL;
544
      $form[$name]['#element_validate'][] = 'rules_ui_element_integer_list_validate';
545
      $form[$name]['#rows'] = 1;
546
    }
547
    return $form;
548
  }
549

    
550
}
551

    
552
/**
553
 * UI for lists of tokens.
554
 */
555
class RulesDataUIListToken extends RulesDataUIListInteger {
556

    
557
  /**
558
   * Implements RulesDataDirectInputFormInterface::inputForm().
559
   */
560
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
561
    $form = parent::inputForm($name, $info, $settings, $element);
562

    
563
    if ($form[$name]['#type'] == 'textarea') {
564
      $form[$name]['#description'] = t('A list of text tokens, separated by commas. E.g. enter "one, two, three".');
565
      $form[$name]['#element_validate'] = array('rules_ui_element_token_list_validate');
566
    }
567
    return $form;
568
  }
569

    
570
}
571

    
572
/**
573
 * UI for entity-based data types.
574
 */
575
class RulesDataUIEntity extends RulesDataUIText {
576

    
577
  /**
578
   * Overrides RulesDataUI::getDefaultMode().
579
   */
580
  public static function getDefaultMode() {
581
    return 'selector';
582
  }
583

    
584
  /**
585
   * Implements RulesDataDirectInputFormInterface::inputForm().
586
   */
587
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
588
    $form = parent::inputForm($name, $info, $settings, $element);
589
    if (empty($info['options list'])) {
590
      $form[$name]['#type'] = 'textfield';
591

    
592
      $entity_info = entity_get_info($info['type']);
593
      if (empty($entity_info['entity keys']['name'])) {
594
        $form[$name]['#element_validate'][] = 'rules_ui_element_integer_validate';
595
      }
596
      $form[$name]['#title'] = t('@entity identifier', array('@entity' => $entity_info['label']));
597
      $entity_label = strtolower($entity_info['label'][0]) . substr($entity_info['label'], 1);
598
      $form[$name]['#description'] = t('Specify an identifier of a @entity.', array('@entity' => $entity_label));
599
    }
600
    return $form;
601
  }
602

    
603
}
604

    
605
/**
606
 * UI for exportable entity-based data types.
607
 */
608
class RulesDataUIEntityExportable extends RulesDataUIEntity {
609

    
610
  /**
611
   * Overrides RulesDataUI::getDefaultMode().
612
   */
613
  public static function getDefaultMode() {
614
    return 'input';
615
  }
616

    
617
}
618

    
619
/**
620
 * Data UI variant displaying a select list of available bundle entities.
621
 *
622
 * This is used for "bundle entities" implemented via the 'bundle of' feature
623
 * of entity.module.
624
 */
625
class RulesDataUIBundleEntity extends RulesDataUIEntity implements RulesDataInputOptionsListInterface {
626

    
627
  /**
628
   * Overrides RulesDataUI::getDefaultMode().
629
   */
630
  public static function getDefaultMode() {
631
    return 'input';
632
  }
633

    
634
  /**
635
   * Implements RulesDataInputOptionsListInterface::optionsList().
636
   */
637
  public static function optionsList(RulesPlugin $element, $name) {
638
    list($data_type, $parameter_info) = RulesDataUI::getTypeInfo($element, $name);
639
    $bundles = array();
640
    $entity_info = entity_get_info();
641
    $bundle_of_type = $entity_info[$data_type]['bundle of'];
642
    if (isset($entity_info[$bundle_of_type]['bundles'])) {
643
      foreach ($entity_info[$bundle_of_type]['bundles'] as $bundle_name => $bundle_info) {
644
        $bundles[$bundle_name] = $bundle_info['label'];
645
      }
646
    }
647
    return $bundles;
648
  }
649

    
650
}
651

    
652
/**
653
 * UI for taxonomy vocabularies.
654
 *
655
 * @see RulesTaxonomyVocabularyWrapper
656
 */
657
class RulesDataUITaxonomyVocabulary extends RulesDataUIEntity implements RulesDataInputOptionsListInterface {
658

    
659
  /**
660
   * Overrides RulesDataUI::getDefaultMode().
661
   */
662
  public static function getDefaultMode() {
663
    return 'input';
664
  }
665

    
666
  /**
667
   * Implements RulesDataInputOptionsListInterface::optionsList().
668
   */
669
  public static function optionsList(RulesPlugin $element, $name) {
670
    $options = array();
671
    foreach (taxonomy_vocabulary_get_names() as $machine_name => $vocab) {
672
      $options[$machine_name] = $vocab->name;
673
    }
674
    return $options;
675
  }
676

    
677
}
678

    
679
/**
680
 * UI for lists of entity-based data types.
681
 */
682
class RulesDataUIListEntity extends RulesDataUIListInteger {
683

    
684
  /**
685
   * Implements RulesDataDirectInputFormInterface::inputForm().
686
   */
687
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
688
    $form = parent::inputForm($name, $info, $settings, $element);
689
    if (empty($info['options list'])) {
690

    
691
      $entity_info = entity_get_info(entity_property_list_extract_type($info['type']));
692
      if (!empty($entity_info['entity keys']['name'])) {
693
        $form[$name]['#element_validate'] = array('rules_ui_element_token_list_validate');
694
      }
695
      $form[$name]['#title'] = t('@entity identifiers', array('@entity' => $entity_info['label']));
696
      $entity_label = strtolower($entity_info['label'][0]) . substr($entity_info['label'], 1);
697
      $form[$name]['#description'] = t('Specify a comma-separated list of identifiers of @entity entities.', array('@entity' => $entity_label));
698
    }
699
    return $form;
700
  }
701

    
702
}