You are here

function quant_admin_settings in Quant 7

Same name and namespace in other branches
  1. 6 includes/forms.inc \quant_admin_settings()

Provide admin settings form

1 string reference to 'quant_admin_settings'
quant_menu in ./quant.module
Implements hook_menu().

File

./quant.admin.inc, line 11
Admin callbacks

Code

function quant_admin_settings($form, &$form_state) {
  $form['view'] = array(
    '#type' => 'fieldset',
    '#title' => t('View analytics'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['view']['view_link'] = array(
    '#markup' => l(t('Click here to view the analytics page'), 'analytics'),
  );
  $form['display'] = array(
    '#type' => 'fieldset',
    '#title' => t('Display settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['display']['quant_visible'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Show analytics for the following site items'),
    '#default_value' => _quant_quant_option_defaults(),
    '#options' => _quant_quant_options(),
    '#description' => t('The checked objects will be shown on the analytics page. If a quant object is missing from this list, try clearing the cache.'),
  );
  $form['display']['quant_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Chart width'),
    '#default_value' => variable_get('quant_width', 500),
    '#size' => 6,
    '#maxlength' => 4,
    '#required' => TRUE,
    '#description' => t('Specify the graph width in pixels. The Chart API will reject charts that are too wide.'),
  );
  $form['display']['quant_height'] = array(
    '#type' => 'textfield',
    '#title' => t('Chart height'),
    '#default_value' => variable_get('quant_height', 200),
    '#size' => 6,
    '#maxlength' => 4,
    '#required' => TRUE,
    '#description' => t('Specify the graph height in pixels. The Chart API will reject charts that are too tall.'),
  );
  $form['display']['quant_chart'] = array(
    '#type' => 'radios',
    '#title' => t('Chart plugin'),
    '#options' => _quant_chart_options(),
    '#default_value' => variable_get('quant_chart', 'table'),
    '#description' => t('Choose the plugin to render the charts in.'),
  );

  // Add settings for all chart plugins
  foreach (quant_get_quant_charts() as $plugin) {
    if ($chart_form = $plugin->chart
      ->adminSettings()) {
      $form['chart_plugin_options'][$plugin->id] = array(
        '#type' => 'fieldset',
        '#title' => $plugin->name,
        '#description' => $plugin->description,
      );
      $form['chart_plugin_options'][$plugin->id] += $chart_form;
    }
  }
  if (isset($form['chart_plugin_options'])) {
    $form['chart_plugin_options'] += array(
      '#type' => 'fieldset',
      '#title' => t('Chart plugin options'),
      '#collapsed' => TRUE,
      '#collapsible' => TRUE,
    );
  }
  return system_settings_form($form);
}