Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/comment/views_handler_field_ncs_last_comment_name.inc | ||
---|---|---|
11 | 11 |
* @ingroup views_field_handlers |
12 | 12 |
*/ |
13 | 13 |
class views_handler_field_ncs_last_comment_name extends views_handler_field { |
14 |
function query() { |
|
15 |
// last_comment_name only contains data if the user is anonymous. So we |
|
16 |
// have to join in a specially related user table. |
|
14 |
|
|
15 |
/** |
|
16 |
* {@inheritdoc} |
|
17 |
*/ |
|
18 |
public function query() { |
|
19 |
// 'last_comment_name' only contains data if the user is anonymous, so join |
|
20 |
// in a specially related user table. |
|
17 | 21 |
$this->ensure_my_table(); |
18 |
// join 'users' to this table via vid
|
|
22 |
// Join 'users' to this table via vid.
|
|
19 | 23 |
$join = new views_join(); |
20 | 24 |
$join->construct('users', $this->table_alias, 'last_comment_uid', 'uid'); |
21 | 25 |
$join->extra = array(array('field' => 'uid', 'operator' => '!=', 'value' => '0')); |
22 | 26 |
|
23 |
// ncs_user alias so this can work with the sort handler, below. |
|
24 |
// $this->user_table = $this->query->add_relationship(NULL, $join, 'users', $this->relationship); |
|
27 |
// 'ncs_user' alias so this can work with the sort handler, below. |
|
28 |
// $this->user_table = $this->query |
|
29 |
// ->add_relationship(NULL, $join, 'users', $this->relationship); |
|
25 | 30 |
$this->user_table = $this->query->ensure_table('ncs_users', $this->relationship, $join); |
26 | 31 |
|
27 | 32 |
$this->field_alias = $this->query->add_field(NULL, "COALESCE($this->user_table.name, $this->table_alias.$this->field)", $this->table_alias . '_' . $this->field); |
... | ... | |
30 | 35 |
$this->uid = $this->query->add_field($this->table_alias, 'last_comment_uid'); |
31 | 36 |
} |
32 | 37 |
|
33 |
function option_definition() { |
|
38 |
/** |
|
39 |
* {@inheritdoc} |
|
40 |
*/ |
|
41 |
public function option_definition() { |
|
34 | 42 |
$options = parent::option_definition(); |
35 | 43 |
|
36 | 44 |
$options['link_to_user'] = array('default' => TRUE, 'bool' => TRUE); |
... | ... | |
38 | 46 |
return $options; |
39 | 47 |
} |
40 | 48 |
|
41 |
function render($values) { |
|
49 |
/** |
|
50 |
* {@inheritdoc} |
|
51 |
*/ |
|
52 |
public function render($values) { |
|
42 | 53 |
if (!empty($this->options['link_to_user'])) { |
43 | 54 |
$account = new stdClass(); |
44 | 55 |
$account->name = $this->get_value($values); |
... | ... | |
51 | 62 |
return $this->sanitize_value($this->get_value($values)); |
52 | 63 |
} |
53 | 64 |
} |
65 |
|
|
54 | 66 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules