You are here

function clients_views_handler_field::add_additional_fields in Web Service Clients 7

Same name and namespace in other branches
  1. 6 clients/clients_views/handlers/clients_views_handler_field.inc \clients_views_handler_field::add_additional_fields()

Add 'additional' fields to the query.

array(
  'table' => $tablename,
  'field' => $fieldname,
);

Parameters

$fields: An array of fields. The key is an identifier used to later find the field alias used. The value is either a string in which case it's assumed to be a field on this handler's table; or it's an array in the form of

Overrides views_handler_field::add_additional_fields

File

clients/clients_views/handlers/clients_views_handler_field.inc, line 46

Class

clients_views_handler_field
@todo Is this handler doing anything useful or can it be removed??

Code

function add_additional_fields($fields = NULL) {
  if (!isset($fields)) {

    // notice check
    if (empty($this->additional_fields)) {
      return;
    }
    $fields = $this->additional_fields;
  }
  if (!empty($fields) && is_array($fields)) {
    foreach ($fields as $identifier => $info) {
      if (is_array($info)) {
        if (isset($info['table'])) {
          $table_alias = $this->query
            ->ensure_table($info['table'], $this->relationship);
        }
        else {
          $table_alias = $this->table_alias;
        }
        $this->aliases[$identifier] = $this->query
          ->add_field($table_alias, $info['field']);
      }
      else {
        $this->aliases[$info] = $this->query
          ->add_field($this->table_alias, $info);
      }
    }
  }
}