You are here

function statspro_views_data in Statistics Pro 6

Same name and namespace in other branches
  1. 6.2 views/statspro.views.inc \statspro_views_data()

Implementation of hook_views_data().

Return value

array

File

views/statspro.views.inc, line 14
Views support for statistcs pro module

Code

function statspro_views_data() {
  require_once drupal_get_path('module', 'statspro') . '/statspro.inc';

  // ----------------------------------------------------------------
  $data['statspro']['table']['group'] = t('Statistics Pro');
  $data['statspro_term']['table']['group'] = t('Statistics Pro');

  // Advertise this table as a possible base table
  $data['statspro']['table']['base'] = array(
    'field' => 'day',
    'title' => t('Statistics Pro'),
    'help' => t('Stores site statistics.'),
    'weight' => 10,
  );

  // For other base tables, explain how we join
  $data['statspro_term']['table']['join'] = array(
    'term_data' => array(
      'field' => 'tid',
      'left_field' => 'tid',
    ),
  );

  // DATE
  $data['statspro']['day'] = array(
    'title' => t('Date'),
    'help' => t('Date of statistics.'),
    'field' => array(
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // term amounts
  $data['statspro_term']['ncount'] = array(
    'title' => t('Amount nodes'),
    'help' => t('Amount of nodes for term'),
    'field' => array(
      'handler' => 'stastspro_views_handler_field_graph',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
  );

  // all data fields
  $statspro = new statspro();
  $data_fields = $statspro
    ->get_fields();
  foreach ($data_fields as $field => $field_desc) {
    $data['statspro'][$field] = array(
      'title' => strip_tags($field_desc),
      'help' => $field_desc,
      'field' => array(
        'handler' => 'stastspro_views_handler_field_graph_trend',
        'click sortable' => TRUE,
      ),
      'sort' => array(
        'handler' => 'views_handler_sort',
      ),
      'filter' => array(
        'handler' => 'views_handler_filter_numeric',
      ),
    );
  }
  return $data;
}