Projet

Général

Profil

Révision 5d12d676

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/handlers/views_handler_field_prerender_list.inc
16 16
 * @ingroup views_field_handlers
17 17
 */
18 18
class views_handler_field_prerender_list extends views_handler_field {
19

  
19 20
  /**
20 21
   * Stores all items which are used to render the items.
22
   *
21 23
   * It should be keyed first by the id of the base table, for example nid.
22 24
   * The second key is the id of the thing which is displayed multiple times
23 25
   * per row, for example the tid.
24 26
   *
25 27
   * @var array
26 28
   */
27
  var $items = array();
29
  public $items = array();
28 30

  
29
  function option_definition() {
31
  /**
32
   * {@inheritdoc}
33
   */
34
  public function option_definition() {
30 35
    $options = parent::option_definition();
31 36

  
32 37
    $options['type'] = array('default' => 'separator');
......
35 40
    return $options;
36 41
  }
37 42

  
38
  function options_form(&$form, &$form_state) {
43
  /**
44
   * {@inheritdoc}
45
   */
46
  public function options_form(&$form, &$form_state) {
39 47
    $form['type'] = array(
40 48
      '#type' => 'radios',
41 49
      '#title' => t('Display type'),
......
63 71
   * yet or won't update their prerender list fields. If a render_item method
64 72
   * exists, this will not get used by advanced_render.
65 73
   */
66
  function render($values) {
74
  public function render($values) {
67 75
    $field = $this->get_value($values);
68 76
    if (!empty($this->items[$field])) {
69 77
      if ($this->options['type'] == 'separator') {
......
74 82
          array(
75 83
            'items' => $this->items[$field],
76 84
            'title' => NULL,
77
            'type' => $this->options['type']
85
            'type' => $this->options['type'],
78 86
          ));
79 87
      }
80 88
    }
......
86 94
   * When using advanced render, each possible item in the list is rendered
87 95
   * individually. Then the items are all pasted together.
88 96
   */
89
  function render_items($items) {
97
  public function render_items($items) {
90 98
    if (!empty($items)) {
91 99
      if ($this->options['type'] == 'separator') {
92 100
        return implode($this->sanitize_value($this->options['separator'], 'xss_admin'), $items);
......
96 104
          array(
97 105
            'items' => $items,
98 106
            'title' => NULL,
99
            'type' => $this->options['type']
107
            'type' => $this->options['type'],
100 108
          ));
101 109
      }
102 110
    }
......
105 113
  /**
106 114
   * Return an array of items for the field.
107 115
   *
108
   * Items should be stored in the result array, if possible, as an array
109
   * with 'value' as the actual displayable value of the item, plus
110
   * any items that might be found in the 'alter' options array for
111
   * creating links, such as 'path', 'fragment', 'query' etc, such a thing
112
   * is to be made. Additionally, items that might be turned into tokens
113
   * should also be in this array.
116
   * Items should be stored in the result array, if possible, as an array with
117
   * 'value' as the actual displayable value of the item, plus any items that
118
   * might be found in the 'alter' options array for creating links, such as
119
   * 'path', 'fragment', 'query' etc, such a thing is to be made. Additionally,
120
   * items that might be turned into tokens should also be in this array.
121
   *
122
   * @param mixed $values
123
   *
124
   * @return array
125
   *   The items.
114 126
   */
115
  function get_items($values) {
127
  public function get_items($values) {
116 128
    // Only the parent get_value returns a single field.
117 129
    $field = parent::get_value($values);
118 130
    if (!empty($this->items[$field])) {
......
125 137
  /**
126 138
   * Get the value that's supposed to be rendered.
127 139
   *
128
   * @param $values
140
   * @param object $values
129 141
   *   An object containing all retrieved values.
130
   * @param $field
142
   * @param string $field
131 143
   *   Optional name of the field where the value is stored.
132
   * @param $raw
144
   * @param bool $raw
133 145
   *   Use the raw data and not the data defined in pre_render
134 146
   */
135
  function get_value($values, $field = NULL, $raw = FALSE) {
147
  public function get_value($values, $field = NULL, $raw = FALSE) {
136 148
    if ($raw) {
137 149
      return parent::get_value($values, $field);
138 150
    }
......
149 161
   *
150 162
   * By default, advanced rendering will NOT be allowed if the class
151 163
   * inheriting from this does not implement a 'render_items' method.
164
   *
165
   * @return bool
166
   *   Whether or not the the render method exists.
152 167
   */
153
  function allow_advanced_render() {
168
  public function allow_advanced_render() {
154 169
    // Note that the advanced render bits also use the presence of
155 170
    // this method to determine if it needs to render items as a list.
156 171
    return method_exists($this, 'render_item');
157 172
  }
173

  
158 174
}

Formats disponibles : Unified diff