Projet

Général

Profil

Paste
Télécharger (1,29 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / tests / test_plugins / views_test_plugin_style_test_mapping.inc @ 5d12d676

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_test_plugin_style_test_mapping.
6
 */
7

    
8
/**
9
 * Provides a test mapping style plugin.
10
 */
11
class views_test_plugin_style_test_mapping extends views_plugin_style_mapping {
12

    
13
  /**
14
   * {@inheritdoc}
15
   */
16
  protected function define_mapping() {
17
    return array(
18
      'title_field' => array(
19
        '#title' => t('Title field'),
20
        '#description' => t('Choose the field with the custom title.'),
21
        '#toggle' => TRUE,
22
        '#required' => TRUE,
23
      ),
24
      'name_field' => array(
25
        '#title' => t('Name field'),
26
        '#description' => t('Choose the field with the custom name.'),
27
      ),
28
      'numeric_field' => array(
29
        '#title' => t('Numeric field'),
30
        '#description' => t('Select one or more numeric fields.'),
31
        '#multiple' => TRUE,
32
        '#toggle' => TRUE,
33
        '#filter' => 'filter_numeric_fields',
34
        '#required' => TRUE,
35
      ),
36
    );
37
  }
38

    
39
  /**
40
   * Restricts the allowed fields to only numeric fields.
41
   *
42
   * @param array $fields
43
   *   An array of field labels, keyed by the field ID.
44
   */
45
  protected function filter_numeric_fields(&$fields) {
46
    foreach ($this->view->field as $id => $field) {
47
      if (!($field instanceof views_handler_field_numeric)) {
48
        unset($fields[$id]);
49
      }
50
    }
51
  }
52

    
53
}