views_handler_sort_comment_thread.inc

  1. 3.x modules/comment/views_handler_sort_comment_thread.inc
  2. 2.x modules/comment/views_handler_sort_comment_thread.inc

Definition of views_handler_sort_comment_thread.

File

modules/comment/views_handler_sort_comment_thread.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_sort_comment_thread.
  5. */
  6. /**
  7. * Sort handler for ordering by thread.
  8. *
  9. * @ingroup views_sort_handlers
  10. */
  11. class views_handler_sort_comment_thread extends views_handler_sort {
  12. function query() {
  13. $this->ensure_my_table();
  14. //Read comment_render() in comment.module for an explanation of the
  15. //thinking behind this sort.
  16. if ($this->options['order'] == 'DESC') {
  17. $this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
  18. }
  19. else {
  20. $alias = $this->table_alias . '_' . $this->real_field . 'asc';
  21. //@todo is this secure?
  22. $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);
  23. }
  24. }
  25. }