Projet

Général

Profil

Paste
Télécharger (885 octets) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / comment / views_handler_sort_comment_thread.inc @ 5d12d676

1
<?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

    
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function query() {
19
    $this->ensure_my_table();
20

    
21
    // Read comment_render() in comment.module for an explanation of the
22
    // thinking behind this sort.
23
    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
      // @todo Is this secure?
29
      $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

    
33
}