You are here

function _views_view_build_fields in Views (for Drupal 7) 5

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

File

./views_query.inc, line 216

Code

function _views_view_build_fields(&$query, &$view) {
  $fields = _views_get_fields();
  foreach ($view->field as $field) {

    // Some fields are not actually fields but require special handlers
    // to display their data.
    $fieldname = $field['fullname'];

    // combined table & fieldname
    $fieldinfo = $fields[$fieldname];

    // laziness + readability
    if (isset($fieldinfo['query_handler']) && function_exists($fieldinfo['query_handler'])) {
      $fieldinfo['query_handler']($field, $fieldinfo, $query);
    }
    if (!$fieldinfo['notafield']) {
      if ($fieldinfo['field']) {
        $query
          ->add_field($fieldinfo['field'], $field['tablename'], $field['queryname']);
      }
      else {
        $query
          ->add_field($field['field'], $field['tablename'], $field['queryname']);
      }
    }

    // special handling
    if (is_array($fieldinfo['addlfields'])) {
      foreach ($fieldinfo['addlfields'] as $name) {
        $query
          ->add_field($name, $field['tablename'], "{$field['tablename']}_{$name}");
      }
    }
  }
  $plugins = _views_get_style_plugins();
  if ($view->page && $plugins[$view->page_type]['needs_table_header'] || $view->block && $plugins[$view->block_type]['needs_table_header']) {

    // table only
    $view->table_header = _views_construct_header($view, $fields);
    $query
      ->set_header($view->table_header);
  }
}