| 1 |
<?php
|
| 2 |
// $Id: views_calc.views.inc,v 1.7 2009/05/17 11:11:17 karens Exp $
|
| 3 |
/**
|
| 4 |
* Implementation of hook_views_handlers().
|
| 5 |
*/
|
| 6 |
function views_calc_views_handlers() {
|
| 7 |
return array(
|
| 8 |
'info' => array(
|
| 9 |
'path' => drupal_get_path('module', 'views_calc'),
|
| 10 |
),
|
| 11 |
'handlers' => array(
|
| 12 |
'views_calc_field_handler' => array(
|
| 13 |
'parent' => 'views_handler_field',
|
| 14 |
),
|
| 15 |
),
|
| 16 |
);
|
| 17 |
}
|
| 18 |
|
| 19 |
/**
|
| 20 |
* Implementation of hook_views_data().
|
| 21 |
*
|
| 22 |
* Add calc fields to views field list.
|
| 23 |
*/
|
| 24 |
function views_calc_views_data() {
|
| 25 |
$data = array();
|
| 26 |
$results = _views_calc_fields();
|
| 27 |
while($field = db_fetch_array($results)) {
|
| 28 |
$data[$field['base']]['cid'. $field['cid']] = array(
|
| 29 |
'group' => t('Views Calc'),
|
| 30 |
'title' => t($field['label']),
|
| 31 |
'help' => $field['calc'],
|
| 32 |
'field' => array(
|
| 33 |
'field' => 'cid'. $field['cid'],
|
| 34 |
'table' => 'node',
|
| 35 |
'handler' => 'views_calc_field_handler',
|
| 36 |
'click sortable' => TRUE,
|
| 37 |
'allow empty' => TRUE,
|
| 38 |
'cid' => $field['cid'],
|
| 39 |
'format' => $field['format'],
|
| 40 |
'custom' => $field['custom'],
|
| 41 |
'calc' => $field['calc'],
|
| 42 |
),
|
| 43 |
);
|
| 44 |
}
|
| 45 |
return $data;
|
| 46 |
}
|
| 47 |
|
| 48 |
/**
|
| 49 |
* Implementation of hook_views_plugins
|
| 50 |
*/
|
| 51 |
function views_calc_views_plugins() {
|
| 52 |
$path = drupal_get_path('module', 'views_calc');
|
| 53 |
$views_path = drupal_get_path('module', 'views');
|
| 54 |
require_once "./$path/theme.inc";
|
| 55 |
|
| 56 |
$data = array(
|
| 57 |
'module' => 'views_calc', // This just tells our themes are elsewhere.
|
| 58 |
'style' => array(
|
| 59 |
// Style plugin for the navigation.
|
| 60 |
'views_calc' => array(
|
| 61 |
'title' => t('Views Calc Table'),
|
| 62 |
'help' => t('Creates a table with column calculations.'),
|
| 63 |
'handler' => 'views_calc_table',
|
| 64 |
'path' => $path,
|
| 65 |
'parent' => 'table',
|
| 66 |
'theme' => 'views_calc_table',
|
| 67 |
'theme file' => 'theme.inc',
|
| 68 |
'theme path' => "$path",
|
| 69 |
'uses row plugin' => FALSE,
|
| 70 |
'uses fields' => TRUE,
|
| 71 |
'uses options' => TRUE,
|
| 72 |
'type' => 'normal',
|
| 73 |
'even empty' => FALSE,
|
| 74 |
),
|
| 75 |
)
|
| 76 |
);
|
| 77 |
return $data;
|
| 78 |
}
|