views_handler_sort_node_version_count.inc 509 B

12345678910111213141516171819
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_sort_node_version_count.
  5. */
  6. /**
  7. * A handler that sorts on the total count of versions/revisions of a node.
  8. *
  9. * @ingroup views_sort_handlers
  10. */
  11. class views_handler_sort_node_version_count extends views_handler_sort {
  12. function query() {
  13. $this->ensure_my_table();
  14. $this->query->add_orderby(NULL, '(SELECT COUNT(vid) FROM {node_revision} WHERE nid = {' . $this->table_alias . '}.nid)', $this->options['order'], 'sort_node_version_count');
  15. }
  16. }