You are here

public function FilterOnomasticon::settingsForm in Onomasticon 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Filter/FilterOnomasticon.php \Drupal\onomasticon\Plugin\Filter\FilterOnomasticon::settingsForm()

Filter settings form.

Parameters

array $form:

\Drupal\Core\Form\FormStateInterface $form_state:

Return value

array

Overrides FilterBase::settingsForm

File

src/Plugin/Filter/FilterOnomasticon.php, line 379

Class

FilterOnomasticon
Plugin annotation @Filter( id = "filter_onomasticon", title = @Translation("Onomasticon Filter"), description = @Translation("Adds glossary information to words."), type = Drupal\filter\Plugin\FilterInterface::TYPE_MARKUP_LANGUAGE, settings…

Namespace

Drupal\onomasticon\Plugin\Filter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $vocabularies = Vocabulary::loadMultiple();
  $options = array();
  foreach ($vocabularies as $vocabulary) {
    $options[$vocabulary
      ->id()] = $vocabulary
      ->get('name');
  }
  $form['onomasticon_vocabulary'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Vocabulary'),
    '#options' => $options,
    '#default_value' => $this->settings['onomasticon_vocabulary'],
    '#description' => $this
      ->t('Choose the vocabulary that holds the glossary terms.'),
  );
  $form['onomasticon_tag'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('HTML tag'),
    '#options' => array(
      'dfn' => $this
        ->t('Definition (dfn)'),
      'abbr' => $this
        ->t('Abbreviation (abbr)'),
      'cite' => $this
        ->t('Title of work (cite)'),
    ),
    '#default_value' => $this->settings['onomasticon_tag'],
    '#description' => $this
      ->t('Choose the HTML tag to contain the glossary term.'),
  );
  $form['onomasticon_disabled'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Disabled tags'),
    '#default_value' => $this->settings['onomasticon_disabled'],
    '#description' => $this
      ->t('Enter all HTML elements in which terms should not be replaced. Anchor tag as well as the default HTML tag are added to that list automatically.'),
  );
  $form['onomasticon_implement'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Implementation'),
    '#options' => array(
      'extra_element' => $this
        ->t('Extra element'),
      'attr_title' => $this
        ->t('Title attribute'),
    ),
    '#default_value' => $this->settings['onomasticon_implement'],
    '#description' => $this
      ->t('Choose the implementation of the glossary term description. Due to HTML convention, the description will be stripped of any tags as they are not allowed in a tag\'s attribute.'),
  );
  $form['onomasticon_orientation'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Orientation'),
    '#options' => array(
      'above' => $this
        ->t('Above'),
      'below' => $this
        ->t('Below'),
    ),
    '#default_value' => $this->settings['onomasticon_orientation'],
    '#description' => $this
      ->t('Choose whether the tooltip should appear above or below the hovered glossary term.'),
    '#states' => array(
      'visible' => array(
        'select[name="filters[filter_onomasticon][settings][onomasticon_implement]"]' => array(
          'value' => 'extra_element',
        ),
      ),
    ),
  );
  $form['onomasticon_cursor'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Mouse cursor'),
    '#options' => array(
      'default' => $this
        ->t('Default (Text cursor)'),
      'help' => $this
        ->t('Help cursor'),
      'none' => $this
        ->t('Hide cursor'),
    ),
    '#default_value' => $this->settings['onomasticon_cursor'],
    '#description' => $this
      ->t('Choose a style the mouse cursor will change to when hovering a glossary term.'),
  );
  $form['onomasticon_ignorecase'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Ignore case'),
    '#default_value' => $this->settings['onomasticon_ignorecase'],
    '#description' => $this
      ->t('If checked, Onomasticon will find all occurrences of a term regardless of case (even CamelCase will work). If not checked, Onomasticon will only find the exact cased term or with the first letter capitalized (i.e. for start of sentences).'),
  );
  $form['onomasticon_repetition'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Add definition to first occurrence of term in text, only.'),
    '#default_value' => $this->settings['onomasticon_repetition'],
    '#description' => $this
      ->t('Disable this option to add definitions to all occurrences in text. This option\'s scope is a single text area.'),
  );
  $form['onomasticon_termlink'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Add a link to the term entity.'),
    '#default_value' => $this->settings['onomasticon_termlink'],
    '#description' => $this
      ->t('If you enable this option the tooltip will be extended by a link to the full term entity which enables you to show even more information. This only works if the implementation is done with an extra element.'),
  );
  return $form;
}