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_argument_many_to_one.inc
6 6
 */
7 7

  
8 8
/**
9
 * An argument handler for use in fields that have a many to one relationship
10
 * with the table(s) to the left. This adds a bunch of options that are
11
 * reasonably common with this type of relationship.
9
 * Argument handler for fields that have many-to-one table relationships.
10
 *
11
 * (i.e. with the table(s) to the left.)
12
 * This adds a bunch of options that are reasonably common with this type of
13
 * relationship.
14
 *
12 15
 * Definition terms:
13 16
 * - numeric: If true, the field will be considered numeric. Probably should
14 17
 *   always be set TRUE as views_handler_argument_string has many to one
15 18
 *   capabilities.
16
 * - zero is null: If true, a 0 will be handled as empty, so for example
17
 *   a default argument can be provided or a summary can be shown.
19
 * - zero is null: If true, a 0 will be handled as empty, so for example a
20
 *   default argument can be provided or a summary can be shown.
18 21
 *
19 22
 * @ingroup views_argument_handlers
20 23
 */
21 24
class views_handler_argument_many_to_one extends views_handler_argument {
22
  function init(&$view, &$options) {
25

  
26
  /**
27
   * {@inheritdoc}
28
   */
29
  public function init(&$view, &$options) {
23 30
    parent::init($view, $options);
24 31
    $this->helper = new views_many_to_one_helper($this);
25 32

  
26
    // Ensure defaults for these, during summaries and stuff:
33
    // Ensure defaults for these, during summaries and stuff.
27 34
    $this->operator = 'or';
28 35
    $this->value = array();
29 36
  }
30 37

  
31
  function option_definition() {
38
  /**
39
   * {@inheritdoc}
40
   */
41
  public function option_definition() {
32 42
    $options = parent::option_definition();
33 43

  
34 44
    if (!empty($this->definition['numeric'])) {
......
49 59
    return $options;
50 60
  }
51 61

  
52
  function options_form(&$form, &$form_state) {
62
  /**
63
   * {@inheritdoc}
64
   */
65
  public function options_form(&$form, &$form_state) {
53 66
    parent::options_form($form, $form_state);
54 67

  
55 68
    // allow + for or, , for and
......
85 98
   * Override ensure_my_table so we can control how this joins in.
86 99
   * The operator actually has influence over joining.
87 100
   */
88
  function ensure_my_table() {
101
  public function ensure_my_table() {
89 102
    $this->helper->ensure_my_table();
90 103
  }
91 104

  
92
  function query($group_by = FALSE) {
105
  /**
106
   * {@inheritdoc}
107
   */
108
  public function query($group_by = FALSE) {
93 109
    $empty = FALSE;
94 110
    if (isset($this->definition['zero is null']) && $this->definition['zero is null']) {
95 111
      if (empty($this->argument)) {
......
118 134
    $this->helper->add_filter();
119 135
  }
120 136

  
121
  function title() {
137
  /**
138
   * {@inheritdoc}
139
   */
140
  public function title() {
122 141
    if (!$this->argument) {
123 142
      return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized');
124 143
    }
......
144 163
    return implode($this->operator == 'or' ? ' + ' : ', ', $this->title_query());
145 164
  }
146 165

  
147
  function summary_query() {
166
  /**
167
   * {@inheritdoc}
168
   */
169
  public function summary_query() {
148 170
    $field = $this->table . '.' . $this->field;
149 171
    $join = $this->get_join();
150 172

  
......
167 189
    return $this->summary_basics();
168 190
  }
169 191

  
170
  function summary_argument($data) {
192
  /**
193
   * {@inheritdoc}
194
   */
195
  public function summary_argument($data) {
171 196
    $value = $data->{$this->base_alias};
172 197
    if (empty($value)) {
173 198
      $value = 0;
......
179 204
  /**
180 205
   * Override for specific title lookups.
181 206
   */
182
  function title_query() {
207
  public function title_query() {
183 208
    return $this->value;
184 209
  }
210

  
185 211
}

Formats disponibles : Unified diff