You are here

function views_calc_handler_sort::query in Views Calc 7

Same name and namespace in other branches
  1. 6.3 views_calc_handler_sort.inc \views_calc_handler_sort::query()
  2. 6 views_calc_handler_sort.inc \views_calc_handler_sort::query()

Called to add the sort to a query.

Overrides views_handler_sort::query

File

./views_calc_handler_sort.inc, line 7
Sort handler for views_calc module.

Class

views_calc_handler_sort
@file Sort handler for views_calc module.

Code

function query() {
  $result = _views_calc_fields();
  foreach ($result as $calc_field) {
    if ($this->field == "cid" . $calc_field->cid) {
      foreach (explode(',', $calc_field->tablelist) as $table) {
        $this->view->query
          ->add_table($table);
      }
      $this->view->query
        ->add_orderby(NULL, "({$calc_field->calc})", $this->options['order'], "cid" . $calc_field->cid);
      return;
    }
  }
}