You are here

function _better_statistics_views_field in Better Statistics 6

Returns Views field data for each of our defined fields.

Parameters

$field: The name of the field for which to return data.

Return value

An array representing the views field.

See also

better_statistics_views_data_alter()

1 call to _better_statistics_views_field()
better_statistics_views_data_alter in views/better_statistics.views.inc
Implements hook_views_data_alter().

File

./better_statistics.helpers.inc, line 54
Helper functions for the Better Statistics module.

Code

function _better_statistics_views_field($field) {
  $views_info = FALSE;

  // Define standard string handlers to use on string fields.
  $string_handlers = array(
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
      'allow empty' => TRUE,
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );
  switch ($field) {
    case 'cache':
      $views_info = array(
        'title' => t('Cache status'),
        'help' => t('The cache status of the page (HIT, MISS, or NULL).'),
      );

      // Append standard string handlers.
      $views_info += $string_handlers;
      break;
    case 'user_agent':
      $views_info = array(
        'title' => t('User-agent'),
        'help' => t('User-agent string of the user who visited your page.'),
      );

      // Append standard string handlers.
      $views_info += $string_handlers;
      break;
  }
  return $views_info;
}