You are here

function quant_admin_settings in Quant 6

Same name and namespace in other branches
  1. 7 quant.admin.inc \quant_admin_settings()

Provide admin settings form

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

File

includes/forms.inc, line 144
Form-building functions

Code

function quant_admin_settings() {
  quant_include('chart');
  $form = array();
  $form['view'] = array(
    '#type' => 'fieldset',
    '#title' => t('View analytics'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['view']['view_link'] = array(
    '#type' => 'item',
    '#value' => l(t('Click here to view the analytics page'), 'analytics'),
  );

  // Get available quants
  $options = array();
  $quants = quant_get_quants();
  foreach ($quants as $quant) {
    $options[$quant->id] = $quant->label;
  }

  // Generate default quant selection
  $default = array();
  if (!($default = variable_get('quant_visible', array()))) {
    if (empty($default)) {
      foreach ($options as $id => $label) {
        $default[] = $id;
      }
    }
  }
  $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' => $default,
    '#options' => $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_use_images'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use chart images'),
    '#default_value' => variable_get('quant_use_images', 1),
    '#description' => t('If selected, chart images will be used to display the data, otherwise tables will be used.'),
  );

  // Generate the color palette
  $palette = _quant_load_palette();
  $form['color'] = array(
    '#type' => 'fieldset',
    '#title' => t('Color settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t('Specify the colors that the charts will be rendered in.'),
  );
  for ($i = 0; $i < QUANT_PALETTE_AMOUNT; $i++) {
    $form['color']['quant_palette_color_' . $i] = array(
      '#type' => 'textfield',
      '#title' => t('Color') . ' #' . ($i + 1),
      '#default_value' => $palette[$i],
      '#field_prefix' => '#',
      '#size' => 10,
      '#maxlength' => 6,
    );
  }
  return system_settings_form($form);
}