You are here

function _views_calc_substitutions in Views Calc 5

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

Field substitutions for calculations.

3 calls to _views_calc_substitutions()
views_calc_fields_form in ./views_calc.module
Views Calc Fields tab on views list.
views_calc_fields_form_submit in ./views_calc.module
Save the views calc field settings
views_calc_fields_form_validate in ./views_calc.module
Validate the views calc settings

File

./views_calc.module, line 518
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() {
  $fields = _views_get_fields(true);
  $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(' ', '', $field);
    }
  }
  return $substitutions;
}