content_views_field_tables

Versions
5
content_views_field_tables($field)

▾ 2 functions call content_views_field_tables()

content_views_tables in contributions/cck/content_views.inc
Implementation of hook_views_tables().
hook_field_settings in contributions/cck/field.php
Handle the parameters for a field.

Code

contributions/cck/content_views.inc, line 29

<?php
function content_views_field_tables($field) {
  $field_types = _content_field_types();
  $db_info = content_database_info($field);

  if (count($db_info['columns'])) {
    $table = array();

    $table['name'] = $db_info['table'];
    $table['join'] = array(
      'left' => array(
        'table' => 'node',
        'field' => 'vid',
      ),
      'right' => array(
        'field' => 'vid',
      ),
    );

    $module = $field_types[$field['type']]['module'];

    $formatters = array();
    if (is_array($field_types[$field['type']]['formatters'])) {
      foreach ($field_types[$field['type']]['formatters'] as $name => $info) {
        $formatters[$name] = $info['label'];
      }
    }

    $columns = $db_info['columns'];
    $main_column = array_shift($columns);
    $addlfields = array();
    foreach ($columns as $column => $attributes) {
      $addlfields[] = $attributes['column'];
    }
    if ($field['multiple']) {
      $addlfields[] = 'delta';
    }

    $table['fields'] = array();
    $table['fields'][$main_column['column']] = array(
      'name' => $field_types[$field['type']]['label'] .': '. $field['widget']['label'] .' ('. $field['field_name'] .')',
      'addlfields' => $addlfields,
      'sortable' => isset($main_column['sortable']) ? $main_column['sortable'] : FALSE,
      'query_handler' => 'content_views_field_query_handler',
      'handler' => array(
        'content_views_field_handler_group' => t('Group multiple values'),
        'content_views_field_handler_ungroup' => t('Do not group multiple values'),
        'content_views_field_handler_first' => t('Show first value only'),
        'content_views_field_handler_last' => t('Show last value only'),
      ),
      'option' => array('#type' => 'select', '#options' => $formatters),
      'content_db_info' => $db_info,
      'content_field' => $field,
      'content_field_module' => $module,
    );
    if (isset($main_column['sortable']) && $main_column['sortable']) {
      $table['sorts'] = array();
      $table['sorts'][$main_column['column']] = array(
        'name' => $field_types[$field['type']]['label'] .': '. $field['widget']['label'] .' ('. $field['field_name'] .')',
        'field' => $main_column['column'],
        'content_db_info' => $db_info,
        'content_field' => $field,
        'content_field_module' => $module,
      );
    }

    $filters = module_invoke($module, 'field_settings', 'filters', $field);
    if (is_array($filters) && count($filters)) {
      $table['filters'] = array();
      foreach ($filters as $key => $filter) {
        $filter_name = '';
        if (count($filters) > 1) {
          $filter_name = (!empty($filter['name'])) ? $filter['name'] : $key;
          $filter_name = ' - '.$filter_name;
        }
        $name = $field_types[$field['type']]['label'] .': '. $field['widget']['label'] . $filter_name .' ('. $field['field_name'] .')';
        $init = array(
          'name' => $name,
          'field' => $main_column['column'],
          'content_db_info' => $db_info,
          'content_field' => $field,
          'content_field_module' => $module,
        );
        $table['filters'][$main_column['column'] .'_'. $key] = array_merge($filter, $init);
      }
    }

    // We don't use $db_info['table'] for the key, since that may change during
    // the lifetime of the field and we don't want to require users to redefine
    // their views.
    return array('node_data_'. $field['field_name'] => $table);
  }
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.