You are here

function _views_view_build_sorts in Views (for Drupal 7) 5

1 call to _views_view_build_sorts()
_views_build_query in ./views_query.inc

File

./views_query.inc, line 191

Code

function _views_view_build_sorts(&$query, $view) {
  $sorts = _views_get_sorts();
  foreach ($view->sort as $i => $sort) {
    $sortinfo = $sorts[$sort['field']];
    $field = $sortinfo['field'];
    if (!$field) {
      $fieldbits = explode('.', $sort['field']);
      $field = $fieldbits[1];
    }
    $table = $sortinfo['table'];
    if (isset($sortinfo['handler']) && function_exists($sortinfo['handler'])) {
      $sortinfo['field'] = $field;
      $sortinfo['handler']('sort', $query, $sortinfo, $sort);
    }
    else {
      $query
        ->add_orderby($table, $field, $sort['sortorder']);
    }
  }
}