You are here

public function HighlightSettingsForm::buildForm in Highlight 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/HighlightSettingsForm.php, line 39

Class

HighlightSettingsForm
Configure highlight settings for this site.

Namespace

Drupal\highlight\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config(static::SETTINGS);
  $form['area'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Highlight area'),
    '#default_value' => $config
      ->get('area'),
    '#description' => $this
      ->t('Use jQuery selector to set the part of HTML you want to highlight.'),
  ];
  $form['class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Highlight CSS class'),
    '#default_value' => $config
      ->get('class'),
    '#description' => $this
      ->t('Set the highlight CSS class that will be used for the enclosing highlight HTML tag.'),
  ];
  $form['color'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Highlight color'),
    '#default_value' => $config
      ->get('color'),
    '#description' => $this
      ->t('Set the highlight color with CSS value.'),
  ];
  $form['text_color'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Highlighted text color'),
    '#default_value' => $config
      ->get('text_color'),
    '#description' => $this
      ->t('Set the highlight color with CSS value.'),
  ];
  $form['wordsonly'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Highlight words'),
    '#default_value' => $config
      ->get('wordsonly'),
    '#description' => $this
      ->t('Highlight only full words.'),
  ];
  $form['patterns'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Local search patterns'),
    '#default_value' => implode("\n", $config
      ->get('patterns')),
    '#description' => $this
      ->t('Set the patterns to get local search keywords to highlight. Use JavaScript Regex and put each parttern per line.'),
  ];
  $form['patterns_referrer'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Referrer patterns'),
    '#default_value' => implode("\n", $config
      ->get('patterns_referrer')),
    '#description' => $this
      ->t('Set the referrer patterns for search engines. Use JavaScript Regex and put each parttern per line.'),
  ];
  $form['stopwords'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Stopwords'),
    '#default_value' => $config
      ->get('stopwords'),
    '#description' => $this
      ->t("Stopwords which shouldn't be highlighted."),
  ];
  return parent::buildForm($form, $form_state);
}