You are here

function environment_indicator_ui_form in Environment Indicator 7.2

System settings form.

1 string reference to 'environment_indicator_ui_form'
environment_indicator_ui.inc in plugins/export_ui/environment_indicator_ui.inc

File

./environment_indicator.module, line 126
Module implementation file.

Code

function environment_indicator_ui_form(&$form, &$form_state) {
  $environment = $form_state['item'];
  $environment->color = '';
  $environment->text_color = '';
  $environment->weight = '';
  $environment->position = 'top';
  $environment->fixed = FALSE;
  if (!empty($environment->settings)) {
    $settings = $environment->settings;
    $environment->color = $settings['color'];
    $environment->text_color = $settings['text_color'];
    $environment->weight = $settings['weight'];
    $environment->position = $settings['position'];
    $environment->fixed = $settings['fixed'];
  }
  unset($form['info']);
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#description' => t('Name for this environment.'),
    '#default_value' => $environment->name,
    '#id' => 'name',
  );
  $form['machine'] = array(
    '#title' => t('Machine name'),
    '#type' => 'machine_name',
    '#default_value' => $environment->machine,
    '#maxlength' => 32,
    '#required' => TRUE,
    '#machine_name' => array(
      'exists' => 'environment_indicator_machine_available',
      'source' => array(
        'name',
      ),
    ),
    '#id' => 'machine-name',
  );
  $form['regexurl'] = array(
    '#type' => 'textfield',
    '#title' => t('Hostname'),
    '#description' => t('The hostname you want to detect. You can use a regular expression in this field. This regular expression will be run against the current URL to determine whether the environment is active or not. If you use a regular expression here this environment will <strong>not be available</strong> for environment switch.'),
    '#default_value' => $environment->regexurl,
  );
  $form['color_picker'] = array(
    '#markup' => '<div id="environment-indicator-color-picker"></div>',
  );
  $form['color'] = array(
    '#type' => 'textfield',
    '#title' => t('Color'),
    '#description' => t('Color for the indicator. Ex: #d0d0d0.'),
    '#default_value' => $environment->color ? $environment->color : '#d0d0d0',
    '#attached' => array(
      // Add Farbtastic color picker.
      'library' => array(
        array(
          'system',
          'farbtastic',
        ),
      ),
    ),
  );
  $form['text_color_picker'] = array(
    '#markup' => '<div id="environment-indicator-text-color-picker"></div>',
  );
  $form['text_color'] = array(
    '#type' => 'textfield',
    '#title' => t('Text Color'),
    '#description' => t('Text Color for the indicator. Ex: #ffffff.'),
    '#default_value' => $environment->text_color ? $environment->text_color : '#ffffff',
    '#attached' => array(
      // Add Farbtastic color picker.
      'library' => array(
        array(
          'system',
          'farbtastic',
        ),
      ),
    ),
  );
  $form['weight'] = array(
    '#type' => 'textfield',
    '#title' => t('Weight'),
    '#description' => t('Defines the order how the regular expressions are applied.'),
    '#default_value' => $environment->weight,
  );
  $form['position'] = array(
    '#title' => t('Position'),
    '#description' => t('Whether you want the indicator at the top or at the bottom. Please note that this setting has no effect when the user has access to the Toolbar or Admin Menu, since the coloring and indication happens in those bars.'),
    '#type' => 'radios',
    '#options' => array(
      'top' => t('Top'),
      'bottom' => t('Bottom'),
    ),
    '#default_value' => $environment->position,
  );
  $form['fixed'] = array(
    '#title' => t('Fixed'),
    '#description' => t('Check this if you want the indicator to be positioned fixed.'),
    '#type' => 'checkbox',
    '#default_value' => $environment->fixed,
  );
  return $form;
}