You are here

function _views_construct_header in Views (for Drupal 7) 5

Construct a header for a table view.

2 calls to _views_construct_header()
_views_get_query in ./views_cache.inc
_views_view_build_fields in ./views_query.inc

File

./views.module, line 1275

Code

function _views_construct_header($view, $fields) {
  foreach ($view->field as $field) {
    $header = array();
    $info = $fields[$field['fullname']];
    if ($field['sortable']) {
      $header['data'] = $field['label'] ? $field['label'] : $info['name'];
      if (function_exists($info['sort_handler'])) {
        $header['field'] = $info['sort_handler']($field, $info);
      }
      else {
        $header['field'] = $field['queryname'];
      }
    }
    else {
      if ($field['label']) {
        $header['data'] = $field['label'];
      }
    }
    if ($field['defaultsort']) {
      $header['sort'] = strtolower($field['defaultsort']);
    }

    // Add CSS id to table cell header cell.
    $header['class'] = "view-cell-header" . views_css_safe(' view-field-' . $field['queryname']);
    $headers[] = $header;
  }
  return $headers;
}