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_relationship.inc
2 2

  
3 3
/**
4 4
 * @file
5
 * Views' relationship handlers.
5
 * Definition of views_handler_relationship.
6 6
 */
7 7

  
8 8
/**
......
12 12
 */
13 13

  
14 14
/**
15
 * Simple relationship handler that allows a new version of the primary table
16
 * to be linked in.
15
 * Relationship handler, allows a new version of the primary table to be linked.
17 16
 *
18
 * The base relationship handler can only handle a single join. Some relationships
19
 * are more complex and might require chains of joins; for those, you must
20
 * utilize a custom relationship handler.
17
 * The base relationship handler can only handle a single join. Some
18
 * relationships are more complex and might require chains of joins; for those,
19
 * you must use a custom relationship handler.
21 20
 *
22 21
 * Definition items:
23 22
 * - base: The new base table this relationship will be adding. This does not
......
36 35
 * @ingroup views_relationship_handlers
37 36
 */
38 37
class views_handler_relationship extends views_handler {
38

  
39 39
  /**
40
   * Init handler to let relationships live on tables other than
41
   * the table they operate on.
40
   * Let relationships live on tables other than the table they operate on.
42 41
   */
43
  function init(&$view, &$options) {
42
  public function init(&$view, &$options) {
44 43
    parent::init($view, $options);
45 44
    if (isset($this->definition['relationship table'])) {
46 45
      $this->table = $this->definition['relationship table'];
47 46
    }
48 47
    if (isset($this->definition['relationship field'])) {
49
      // Set both real_field and field so custom handler
50
      // can rely on the old field value.
48
      // Set both real_field and field so custom handler can rely on the old
49
      // field value.
51 50
      $this->real_field = $this->field = $this->definition['relationship field'];
52 51
    }
53 52
  }
......
55 54
  /**
56 55
   * Get this field's label.
57 56
   */
58
  function label() {
57
  public function label() {
59 58
    if (!isset($this->options['label'])) {
60 59
      return $this->ui_name();
61 60
    }
62 61
    return $this->options['label'];
63 62
  }
64 63

  
65
  function option_definition() {
64
  /**
65
   * {@inheritdoc}
66
   */
67
  public function option_definition() {
66 68
    $options = parent::option_definition();
67 69

  
68 70

  
69
    // Relationships definitions should define a default label, but if they aren't get another default value.
71
    // Relationships definitions should define a default label, but if they
72
    // aren't get another default value.
70 73
    if (!empty($this->definition['label'])) {
71 74
      $label = $this->definition['label'];
72 75
    }
......
81 84
  }
82 85

  
83 86
  /**
84
   * Default options form that provides the label widget that all fields
85
   * should have.
87
   * Provide the label widget that all fields should have.
86 88
   */
87
  function options_form(&$form, &$form_state) {
89
  public function options_form(&$form, &$form_state) {
88 90
    parent::options_form($form, $form_state);
89 91
    $form['label'] = array(
90 92
      '#type' => 'textfield',
......
105 107
  /**
106 108
   * Called to implement a relationship in a query.
107 109
   */
108
  function query() {
110
  public function query() {
109 111
    // Figure out what base table this relationship brings to the party.
110 112
    $table_data = views_fetch_data($this->definition['base']);
111 113
    $base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field'];
......
126 128
    }
127 129

  
128 130
    if (!empty($def['join_handler']) && class_exists($def['join_handler'])) {
129
      $join = new $def['join_handler'];
131
      $join = new $def['join_handler']();
130 132
    }
131 133
    else {
132 134
      $join = new views_join();
......
137 139
    $join->construct();
138 140
    $join->adjusted = TRUE;
139 141

  
140
    // use a short alias for this:
142
    // Use a short alias for this.
141 143
    $alias = $def['table'] . '_' . $this->table;
142 144

  
143 145
    $this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
......
152 154
  /**
153 155
   * You can't groupby a relationship.
154 156
   */
155
  function use_group_by() {
157
  public function use_group_by() {
156 158
    return FALSE;
157 159
  }
160

  
158 161
}
159 162

  
160 163
/**
......
163 166
 * @ingroup views_relationship_handlers
164 167
 */
165 168
class views_handler_relationship_broken extends views_handler_relationship {
166
  function ui_name($short = FALSE) {
169

  
170
  /**
171
   * {@inheritdoc}
172
   */
173
  public function ui_name($short = FALSE) {
167 174
    return t('Broken/missing handler');
168 175
  }
169 176

  
170
  function ensure_my_table() { /* No table to ensure! */ }
171
  function query() { /* No query to run */ }
172
  function options_form(&$form, &$form_state) {
177
  /**
178
   * {@inheritdoc}
179
   */
180
  public function ensure_my_table() {
181
    // No table to ensure!
182
  }
183

  
184
  /**
185
   * {@inheritdoc}
186
   */
187
  public function query() {
188
    // No query to run.
189
  }
190

  
191
  /**
192
   * {@inheritdoc}
193
   */
194
  public function options_form(&$form, &$form_state) {
173 195
    $form['markup'] = array(
174 196
      '#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>',
175 197
    );
176 198
  }
177 199

  
178 200
  /**
179
   * Determine if the handler is considered 'broken'
201
   * {@inheritdoc}
180 202
   */
181
  function broken() { return TRUE; }
203
  public function broken() {
204
    return TRUE;
205
  }
206

  
182 207
}
183 208

  
184 209
/**

Formats disponibles : Unified diff