1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Definition of views_handler_sort_comment_thread.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Sort handler for ordering by thread.
|
10 |
|
|
*
|
11 |
|
|
* @ingroup views_sort_handlers
|
12 |
|
|
*/
|
13 |
|
|
class views_handler_sort_comment_thread extends views_handler_sort {
|
14 |
5d12d676
|
Assos Assos
|
|
15 |
|
|
/**
|
16 |
|
|
* {@inheritdoc}
|
17 |
|
|
*/
|
18 |
|
|
public function query() {
|
19 |
85ad3d82
|
Assos Assos
|
$this->ensure_my_table();
|
20 |
|
|
|
21 |
5d12d676
|
Assos Assos
|
// Read comment_render() in comment.module for an explanation of the
|
22 |
|
|
// thinking behind this sort.
|
23 |
85ad3d82
|
Assos Assos
|
if ($this->options['order'] == 'DESC') {
|
24 |
|
|
$this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
|
25 |
|
|
}
|
26 |
|
|
else {
|
27 |
|
|
$alias = $this->table_alias . '_' . $this->real_field . 'asc';
|
28 |
5d12d676
|
Assos Assos
|
// @todo Is this secure?
|
29 |
85ad3d82
|
Assos Assos
|
$this->query->add_orderby(NULL, "SUBSTRING({$this->table_alias}.{$this->real_field}, 1, (LENGTH({$this->table_alias}.{$this->real_field}) - 1))", $this->options['order'], $alias);
|
30 |
|
|
}
|
31 |
|
|
}
|
32 |
5d12d676
|
Assos Assos
|
|
33 |
85ad3d82
|
Assos Assos
|
} |