Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc | ||
---|---|---|
11 | 11 |
* @ingroup views_field_handlers |
12 | 12 |
*/ |
13 | 13 |
class views_handler_field_term_node_tid extends views_handler_field_prerender_list { |
14 |
function init(&$view, &$options) { |
|
14 |
|
|
15 |
/** |
|
16 |
* {@inheritdoc} |
|
17 |
*/ |
|
18 |
public function init(&$view, &$options) { |
|
15 | 19 |
parent::init($view, $options); |
16 |
// @todo: Wouldn't it be possible to use $this->base_table and no if here?
|
|
20 |
// @todo Wouldn't it be possible to use $this->base_table and no if here? |
|
17 | 21 |
if ($view->base_table == 'node_revision') { |
18 | 22 |
$this->additional_fields['nid'] = array('table' => 'node_revision', 'field' => 'nid'); |
19 | 23 |
} |
... | ... | |
32 | 36 |
} |
33 | 37 |
} |
34 | 38 |
|
35 |
function option_definition() { |
|
39 |
/** |
|
40 |
* {@inheritdoc} |
|
41 |
*/ |
|
42 |
public function option_definition() { |
|
36 | 43 |
$options = parent::option_definition(); |
37 | 44 |
|
38 | 45 |
$options['link_to_taxonomy'] = array('default' => TRUE, 'bool' => TRUE); |
... | ... | |
45 | 52 |
/** |
46 | 53 |
* Provide "link to term" option. |
47 | 54 |
*/ |
48 |
function options_form(&$form, &$form_state) { |
|
55 |
public function options_form(&$form, &$form_state) {
|
|
49 | 56 |
$form['link_to_taxonomy'] = array( |
50 | 57 |
'#title' => t('Link this field to its term page'), |
51 | 58 |
'#type' => 'checkbox', |
... | ... | |
55 | 62 |
$form['limit'] = array( |
56 | 63 |
'#type' => 'checkbox', |
57 | 64 |
'#title' => t('Limit terms by vocabulary'), |
58 |
'#default_value'=> $this->options['limit'], |
|
65 |
'#default_value' => $this->options['limit'],
|
|
59 | 66 |
); |
60 | 67 |
|
61 | 68 |
$options = array(); |
... | ... | |
78 | 85 |
} |
79 | 86 |
|
80 | 87 |
/** |
81 |
* Add this term to the query |
|
88 |
* Add this term to the query.
|
|
82 | 89 |
*/ |
83 |
function query() { |
|
90 |
public function query() {
|
|
84 | 91 |
$this->add_additional_fields(); |
85 | 92 |
} |
86 | 93 |
|
87 |
function pre_render(&$values) { |
|
94 |
/** |
|
95 |
* {@inheritdoc} |
|
96 |
*/ |
|
97 |
public function pre_render(&$values) { |
|
88 | 98 |
$this->field_alias = $this->aliases['nid']; |
89 | 99 |
$nids = array(); |
90 | 100 |
foreach ($values as $result) { |
... | ... | |
125 | 135 |
} |
126 | 136 |
} |
127 | 137 |
|
128 |
function render_item($count, $item) { |
|
138 |
/** |
|
139 |
* {@inheritdoc} |
|
140 |
*/ |
|
141 |
public function render_item($count, $item) { |
|
129 | 142 |
return $item['name']; |
130 | 143 |
} |
131 | 144 |
|
132 |
function document_self_tokens(&$tokens) { |
|
145 |
/** |
|
146 |
* {@inheritdoc} |
|
147 |
*/ |
|
148 |
public function document_self_tokens(&$tokens) { |
|
133 | 149 |
$tokens['[' . $this->options['id'] . '-tid' . ']'] = t('The taxonomy term ID for the term.'); |
134 | 150 |
$tokens['[' . $this->options['id'] . '-name' . ']'] = t('The taxonomy term name for the term.'); |
135 | 151 |
$tokens['[' . $this->options['id'] . '-vocabulary-machine-name' . ']'] = t('The machine name for the vocabulary the term belongs to.'); |
136 | 152 |
$tokens['[' . $this->options['id'] . '-vocabulary' . ']'] = t('The name for the vocabulary the term belongs to.'); |
137 | 153 |
} |
138 | 154 |
|
139 |
function add_self_tokens(&$tokens, $item) { |
|
140 |
foreach(array('tid', 'name', 'vocabulary_machine_name', 'vocabulary') as $token) { |
|
155 |
/** |
|
156 |
* {@inheritdoc} |
|
157 |
*/ |
|
158 |
public function add_self_tokens(&$tokens, $item) { |
|
159 |
foreach (array('tid', 'name', 'vocabulary_machine_name', 'vocabulary') as $token) { |
|
141 | 160 |
// Replace _ with - for the vocabulary machine name. |
142 |
$tokens['[' . $this->options['id'] . '-' . str_replace('_', '-', $token). ']'] = isset($item[$token]) ? $item[$token] : ''; |
|
161 |
$tokens['[' . $this->options['id'] . '-' . str_replace('_', '-', $token) . ']'] = isset($item[$token]) ? $item[$token] : '';
|
|
143 | 162 |
} |
144 | 163 |
} |
164 |
|
|
145 | 165 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules