You are here

function n1ed_form_filter_admin_overview_alter in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2

Adds "N1ED" badges to affected text formats in the list.

File

./n1ed.module, line 69
Main code for N1ED module.

Code

function n1ed_form_filter_admin_overview_alter(&$form, FormStateInterface $form_state) {

  // Then splice in the name of each text editor for each text format.
  $editors = \Drupal::service('plugin.manager.editor')
    ->getDefinitions();
  foreach (Element::children($form['formats']) as $format_id) {
    $editor = editor_load($format_id);
    $editor_name = $editor && isset($editors[$editor
      ->getEditor()]) ? $editors[$editor
      ->getEditor()]['label'] : '—';
    $htmlN1ED = "";
    if ($editor != NULL) {
      $settings = $editor
        ->getSettings();
      $isN1EDEnabled = isset($settings["plugins"]["N1EDEco"]["enableN1EDEcoSystem"]) && $settings["plugins"]["N1EDEco"]["enableN1EDEcoSystem"] == 'true';
      if ($isN1EDEnabled) {
        $htmlN1ED = "<div style='display: inline-block;margin-left:10px;background: #3dcad7; background: linear-gradient(180deg, rgba(85,219,199,1) 0%, rgba(35,182,232,1) 100%);border-radius: 2px;padding:1px 5px;color:white;font-weight: bold' title='N1ED is enabled'>N1ED</div>";
      }
    }
    $editor_column['editor'] = [
      '#type' => 'inline_template',
      '#template' => $editor_name . $htmlN1ED,
    ];
    $form['formats'][$format_id]["0"] = $editor_column;
  }
}