You are here

function high_contrast_settings_form in High contrast 7

Same name and namespace in other branches
  1. 6 high_contrast.module \high_contrast_settings_form()

Settings form.

1 string reference to 'high_contrast_settings_form'
high_contrast_menu in ./high_contrast.module
Implements hook_menu().

File

./high_contrast.module, line 120
High Contrast main module file.

Code

function high_contrast_settings_form() {
  $form = [];
  $theme_path = drupal_get_path('theme', variable_get('theme_default', NULL));
  $widgets = [
    'links' => 'Links',
  ];
  $form['high_contrast_switcher_widget'] = [
    '#type' => 'select',
    '#title' => t('Switcher widget'),
    '#default_value' => _high_contrast_variable_get('high_contrast_switcher_widget'),
    '#options' => $widgets,
    '#required' => TRUE,
  ];
  $form['high_contrast_switcher_label'] = [
    '#type' => 'textfield',
    '#title' => t('Switcher label'),
    '#default_value' => _high_contrast_variable_get('high_contrast_switcher_label'),
    '#required' => TRUE,
  ];
  $form['high_contrast_high_label'] = [
    '#type' => 'textfield',
    '#title' => t('High contrast label'),
    '#default_value' => _high_contrast_variable_get('high_contrast_high_label'),
    '#required' => TRUE,
  ];
  $form['high_contrast_separator'] = [
    '#type' => 'textfield',
    '#title' => t('Separator'),
    '#default_value' => _high_contrast_variable_get('high_contrast_separator'),
    '#required' => TRUE,
  ];
  $form['high_contrast_normal_label'] = [
    '#type' => 'textfield',
    '#title' => t('Normal contrast label'),
    '#default_value' => _high_contrast_variable_get('high_contrast_normal_label'),
    '#required' => TRUE,
  ];
  if (!_high_contrast_css_exists()) {
    $form['high_contrast_css_styles'] = [
      '#type' => 'textarea',
      '#title' => t('Used CSS styles'),
      '#default_value' => _high_contrast_get_current_css_styles(),
      '#required' => TRUE,
      '#attributes' => [
        'style' => 'width:50em; height:30em; line-height:1.2em; font-family:"Courier New", "Courier";',
      ],
      '#description' => 'To use css file, create high_contrast.css file under your theme css folder (' . HIGH_CONTRAST_CSS_PATH . ').',
    ];
    $form['high_contrast_css_styles']['#suffix'] = t('<p>Default CSS styles used to override the active theme:</p>');
    $form['high_contrast_css_styles']['#suffix'] .= '<div><pre>' . _high_contrast_get_default_css_styles() . '</pre></div>';
  }
  else {
    $form['high_contrast_css_styles'] = [
      '#type' => 'item',
      '#markup' => t('High contrast is using !css_path', [
        '!css_path' => $theme_path . '/' . HIGH_CONTRAST_CSS_PATH,
      ]),
    ];
  }
  $form['high_contrast_logo'] = [
    '#type' => 'fieldset',
    '#title' => t('High contrast logo image settings'),
    '#description' => t('If toggled on, the following high contrast logo will be displayed.'),
    '#attributes' => [
      'class' => [
        'theme-settings-bottom',
      ],
    ],
  ];
  $form['high_contrast_logo']['high_contrast_default_logo'] = [
    '#type' => 'checkbox',
    '#title' => t('Use the default logo (file named logo-hg in your theme folder if it exists'),
    '#default_value' => _high_contrast_variable_get('high_contrast_default_logo'),
    '#tree' => FALSE,
    '#description' => t('Check here if you want the theme to use the logo supplied with it.'),
  ];
  $form['high_contrast_logo']['high_contrast_settings'] = [
    '#type' => 'container',
    '#states' => [
      // Hide the logo settings when using the default logo.
      'invisible' => [
        'input[name="high_contrast_default_logo"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['high_contrast_logo']['high_contrast_settings']['high_contrast_logo_path'] = [
    '#type' => 'textfield',
    '#title' => t('Path to custom high contrast logo'),
    '#description' => t('The path to the file you would like to use as your logo file instead of the default logo.'),
    '#default_value' => _high_contrast_variable_get('high_contrast_logo_path'),
  ];
  $form['high_contrast_logo']['high_contrast_settings']['high_contrast_logo_upload'] = [
    '#type' => 'file',
    '#title' => t('Upload high contrast logo image'),
    '#maxlength' => 40,
    '#description' => t("If you don't have direct file access to the server, use this field to upload your logo."),
  ];
  $form = system_settings_form($form);

  // We don't want to call system_settings_form_submit(), so change #submit.
  array_pop($form['#submit']);
  $form['#submit'][] = 'high_contrast_settings_form_submit';
  $form['#validate'][] = 'high_contrast_settings_form_validate';
  return $form;
}