You are here

function views_calc_table::options_form in Views Calc 7

Same name and namespace in other branches
  1. 6.3 views_calc_table.inc \views_calc_table::options_form()
  2. 6 views_calc_table.inc \views_calc_table::options_form()

Render the given style.

Overrides views_plugin_style_table::options_form

File

./views_calc_table.inc, line 31
Copied from the table style plugin.

Class

views_calc_table
Style plugin to render each item as a row in a table.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['#theme'] = 'views_calc_ui_table';
  $form['detailed_values'] = array(
    '#title' => t('Show details'),
    '#type' => 'select',
    '#options' => array(
      0 => t('Yes'),
      1 => t('No'),
    ),
    '#default_value' => $this->options['detailed_values'],
    '#description' => t("Select 'Yes' to show detailed values followed by column calculations, 'No' to surpress details and show only calculated column totals."),
  );
  $handlers = $this->display->handler
    ->get_handlers('field');
  $columns = $this
    ->sanitize_columns($this->options['columns']);
  foreach ($columns as $field => $column) {
    $safe = str_replace(array(
      '][',
      '_',
      ' ',
    ), '-', $field);
    $id = 'edit-style-options-columns-' . $safe;
    $form['info'][$field]['has_calc'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display calculation'),
      '#default_value' => isset($this->options['info'][$field]['has_calc']) ? $this->options['info'][$field]['has_calc'] : 0,
    );
    $options = _views_calc_calc_options();
    $form['info'][$field]['calc'] = array(
      '#type' => 'select',
      '#options' => $options,
      '#multiple' => TRUE,
      '#default_value' => isset($this->options['info'][$field]['calc']) ? $this->options['info'][$field]['calc'] : array(),
      '#states' => array(
        'visible' => array(
          ':checkbox[name="style_options[info][' . $field . '][has_calc]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );
  }
  $form['precision'] = array(
    '#type' => 'textfield',
    '#title' => t('Default precision'),
    '#default_value' => $this->options['precision'],
    '#description' => t('Specify how many digits to print after the decimal point in calculated values, if not specified in the field settings.'),
    '#dependency' => array(
      'edit-options-set-precision' => array(
        TRUE,
      ),
    ),
    '#size' => 2,
  );
  $form['decimal'] = array(
    '#type' => 'textfield',
    '#title' => t('Default decimal point'),
    '#default_value' => $this->options['decimal'],
    '#description' => t('What single character to use as a decimal point in calculated values, if not specified in the field settings.'),
    '#size' => 2,
  );
  $form['separator'] = array(
    '#type' => 'select',
    '#title' => t('Default thousands marker'),
    '#options' => array(
      '' => t('- None -'),
      ',' => t('Comma'),
      ' ' => t('Space'),
      '.' => t('Decimal'),
      '\'' => t('Apostrophe'),
    ),
    '#default_value' => $this->options['separator'],
    '#description' => t('What single character to use as the thousands separator in calculated values, if not specified in the field settings.'),
    '#size' => 2,
  );
}