Projet

Général

Profil

Révision 32700c57

Ajouté par Assos Assos il y a environ 5 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_field.inc
2 2

  
3 3
/**
4 4
 * @file
5
 * LDAP field handler
5
 * LDAP field handler.
6 6
 *
7
 * Defines a new class field handler for a default ldap field
7
 * Defines a new class field handler for a default ldap field.
8 8
 */
9 9

  
10
/**
11
 *
12
 */
10 13
class ldap_views_handler_field extends views_handler_field {
11 14

  
12
  function render($values) {
15
  /**
16
   *
17
   */
18
  public function render($values) {
13 19
    return array_key_exists($this->field_alias, $values) ? check_plain($values[$this->field_alias]) : '';
14 20
  }
15 21

  
16
  function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
22
  /**
23
   *
24
   */
25
  public function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
17 26
    if (isset($this->definition['element type'])) {
18 27
      return $this->definition['element type'];
19 28
    }
......
21 30
    return 'div';
22 31
  }
23 32

  
24
  function option_definition() {
25
    $options = parent::option_definition();
26
    $options['multivalue']      = array('default' => 'v-all');
27
    $options['value_separator'] = array('default' => '');
28
    $options['index_value']     = array('default' => 0);
33
  /**
34
   *
35
   */
36
  public function option_definition() {
37
    $options                    = parent::option_definition();
38
    $options['multivalue']      = ['default' => 'v-all'];
39
    $options['value_separator'] = ['default' => ''];
40
    $options['index_value']     = ['default' => 0];
29 41
    return $options;
30 42
  }
31 43

  
32
  /*
33
   * Add the field for the LDAP Attribute
44
  /**
45
   * Add the field for the LDAP Attribute.
34 46
   */
35
  function options_form(&$form, &$form_state) {
47
  public function options_form(&$form, &$form_state) {
36 48
    parent::options_form($form, $form_state);
37
    $form['multivalue'] = array(
38
      '#type' => 'select', // it should be 'radios', but it makes #dependency not to work
49
    $form['multivalue'] = [
50
    // It should be 'radios', but it makes #dependency not to work.
51
      '#type' => 'select',
39 52
      '#title' => t('Values to show'),
40 53
      '#description' => t('What to do whith  multivalue attributes'),
41
      '#options' => array(
54
      '#options' => [
42 55
        'v-all' => t('All values'),
43 56
        'v-index' => t('Show Nth value'),
44 57
        'v-count' => t('Count values'),
45
      ),
58
      ],
46 59
      '#default_value' => $this->options['multivalue'],
47 60
      '#required' => TRUE,
48
    );
49
    $form['value_separator'] = array(
61
    ];
62
    $form['value_separator'] = [
50 63
      '#type' => 'textfield',
51 64
      '#title' => t('Value separator'),
52 65
      '#description' => t('Separator to use between values in multivalued attributes'),
53 66
      '#default_value' => $this->options['value_separator'],
54
      '#dependency' => array(
55
        'edit-options-multivalue' => array('v-all'),
56
      ),
57
    );
58
    $form['index_value'] = array(
67
      '#dependency' => [
68
        'edit-options-multivalue' => ['v-all'],
69
      ],
70
    ];
71
    $form['index_value'] = [
59 72
      '#type' => 'textfield',
60 73
      '#title' => t('Index'),
61 74
      '#description' => t('Index of the value to show. Use negative numbers to index from last item (0=First, -1=Last)'),
62 75
      '#default_value' => $this->options['index_value'],
63
      '#dependency' => array(
64
        'edit-options-multivalue' => array('v-index'),
65
      ),
66
    );
76
      '#dependency' => [
77
        'edit-options-multivalue' => ['v-index'],
78
      ],
79
    ];
67 80
  }
81

  
68 82
}

Formats disponibles : Unified diff