views_aggregator.module in Views Aggregator Plus 7
File
views_aggregator.module
View source
<?php
module_load_include('inc', 'views_aggregator', 'views_aggregator_functions');
function views_aggregator_help($path, $arg) {
switch ($path) {
case 'admin/help#views_aggregator':
return t('See the <a href="@README">README</a> for View configuration instructions and examples or browse the <a href="@project">project</a> support queue.', array(
'@project' => url('http://drupal.org/project/views_aggregator'),
'@README' => url(drupal_get_path('module', 'views_aggregator') . '/README.txt'),
));
}
}
function views_aggregator_theme() {
$base_path = drupal_get_path('module', 'views_aggregator');
$themes = array(
'views_aggregator_plugin_style_table' => array(
'render element' => 'form',
'path' => $base_path . '/views',
'file' => 'theme_views_aggregator_plugin_style_table.inc',
),
);
return $themes;
}
function views_aggregator_views_api() {
return array(
'api' => views_api_version(),
'path' => drupal_get_path('module', 'views_aggregator') . '/views',
);
}
function views_aggregator_get_aggregation_functions_info($name = NULL) {
$aggregation_functions =& drupal_static(__FUNCTION__);
if (empty($aggregation_functions)) {
$aggregation_functions = module_invoke_all('views_aggregation_functions_info');
ksort($aggregation_functions);
drupal_alter('views_aggregation_functions_info', $aggregation_functions);
}
if (empty($name)) {
return $aggregation_functions;
}
return isset($aggregation_functions[$name]) ? $aggregation_functions[$name] : array();
}
function views_aggregator_get_cell($field_handler, $row_num, $rendered = FALSE) {
if (isset($field_handler->view->style_plugin)) {
return $field_handler->view->style_plugin
->get_cell($field_handler, $row_num, $rendered);
}
}
function template_preprocess_views_aggregator_results_table(&$vars) {
$view = $vars['view'];
$vars['grouping_field'] = '';
foreach ($view->style_plugin->options['info'] as $field_name => $info) {
if (!empty($info['has_aggr']) && !empty($info['aggr']['views_aggregator_group_and_compress'])) {
$vars['grouping_field'] = $field_name;
break;
}
}
$vars['grouping_field_class'] = $view->style_plugin->options['group_aggregation']['grouping_field_class'];
if (!empty($view->totals) && array_filter($view->totals) != array()) {
$vars['totals'] = $view->totals;
}
$vars['totals_row_position'] = $view->style_plugin->options['column_aggregation']['totals_row_position'][1] + $view->style_plugin->options['column_aggregation']['totals_row_position'][2];
$vars['totals_row_class'] = $view->style_plugin->options['column_aggregation']['totals_row_class'];
if (!isset($view->row_index)) {
$view->row_index = 0;
}
$options = $view->style_plugin->options;
$columns = $view->style_plugin
->sanitize_columns($options['columns'], $view->field);
foreach ($columns as $field => $column) {
if ($field == $column) {
$view->field[$field]->definition['click sortable'] = TRUE;
}
}
$vars['attributes_array']['id'] = drupal_html_id('views_aggregator_datatable');
template_preprocess_views_view_table($vars);
}