Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/translation/views_handler_relationship_translation.inc | ||
---|---|---|
12 | 12 |
* @ingroup views_relationship_handlers |
13 | 13 |
*/ |
14 | 14 |
class views_handler_relationship_translation extends views_handler_relationship { |
15 |
function option_definition() { |
|
15 |
|
|
16 |
/** |
|
17 |
* {@inheritdoc} |
|
18 |
*/ |
|
19 |
public function option_definition() { |
|
16 | 20 |
$options = parent::option_definition(); |
17 | 21 |
$options['language'] = array('default' => 'current'); |
18 | 22 |
|
... | ... | |
22 | 26 |
/** |
23 | 27 |
* Add a translation selector. |
24 | 28 |
*/ |
25 |
function options_form(&$form, &$form_state) { |
|
29 |
public function options_form(&$form, &$form_state) {
|
|
26 | 30 |
parent::options_form($form, $form_state); |
27 | 31 |
|
28 | 32 |
$options = array( |
... | ... | |
43 | 47 |
/** |
44 | 48 |
* Called to implement a relationship in a query. |
45 | 49 |
*/ |
46 |
function query() { |
|
50 |
public function query() {
|
|
47 | 51 |
// Figure out what base table this relationship brings to the party. |
48 | 52 |
$table_data = views_fetch_data($this->definition['base']); |
49 | 53 |
$base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field']; |
... | ... | |
68 | 72 |
'value' => '***CURRENT_LANGUAGE***', |
69 | 73 |
); |
70 | 74 |
break; |
75 |
|
|
71 | 76 |
case 'default': |
72 | 77 |
$def['extra'][] = array( |
73 | 78 |
'field' => 'language', |
74 | 79 |
'value' => '***DEFAULT_LANGUAGE***', |
75 | 80 |
); |
76 | 81 |
break; |
82 |
|
|
77 | 83 |
// Other values will be the language codes. |
78 | 84 |
default: |
79 | 85 |
$def['extra'][] = array( |
... | ... | |
92 | 98 |
} |
93 | 99 |
|
94 | 100 |
$join->definition = $def; |
101 |
$join->extra = "(%alias.tnid != 0 OR ({$def['left_table']}.tnid = 0 AND %alias.nid = {$def['left_table']}.nid))"; |
|
95 | 102 |
$join->construct(); |
96 | 103 |
$join->adjusted = TRUE; |
97 | 104 |
|
98 |
// use a short alias for this:
|
|
105 |
// Use a short alias for this.
|
|
99 | 106 |
$alias = $def['table'] . '_' . $this->table; |
100 | 107 |
|
101 | 108 |
$this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship); |
102 | 109 |
} |
110 |
|
|
103 | 111 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules