You are here

function _views_calc_substitutions in Views Calc 6

Same name and namespace in other branches
  1. 5 views_calc.module \_views_calc_substitutions()
  2. 6.3 views_calc.module \_views_calc_substitutions()
  3. 7 views_calc.module \_views_calc_substitutions()

Field substitutions for calculations.

4 calls to _views_calc_substitutions()
views_calc_export_form in ./views_calc.module
FAPI export_form.
views_calc_fields_form in ./views_calc.module
FAPI fields_form.
views_calc_fields_form_submit in ./views_calc.module
FAPI fields_form submit.
views_calc_fields_form_validate in ./views_calc.module
FAPI fields_form validate.

File

./views_calc.module, line 421
This module will allow you to add calculated fields to views tables and compute (SUM, COUNT, AVG, etc) columns of numeric data in a views table.

Code

function _views_calc_substitutions($base = 'node') {
  $fields = views_calc_views_fetch_fields($base, 'field');
  $substitutions['node.nid'] = '%Node.nid';
  $substitutions['node.uid'] = '%Node.uid';
  foreach ($fields as $key => $field) {

    // For now, omit calculated fields from available fields list.
    // Doing caculations on calculated fields will require some
    // complex additional logic, especially if they are nested
    // several levels deep.
    if (substr($key, 0, 4) != '.cid') {
      $substitutions[$key] = '%' . str_replace(' ', '', $key);
    }
  }
  return $substitutions;
}