1 filter.module filter_get_js_settings($formats)

Retrieve JavaScript settings that should be added by each filter.

Parameters

array $formats: An array of formats as returned by filter_formats().

Return value

array: An array of JavaScript settings representing the configuration of the filters.

File

core/modules/filter/filter.module, line 1496
Framework for handling the filtering of content.

Code

function filter_get_js_settings($formats) {
  $settings = array();
  $filter_info = filter_get_filters();
  $editor_info = filter_get_editors();

  foreach ($formats as $format_name => $format) {
    // Don't add settings for formats that don't have associated editors.
    if (!$format->editor) {
      continue;
    }

    $filter_settings = array();
    foreach ($format->filters as $filter_name => $filter) {
      if ($filter->status && isset($filter_info[$filter_name]['js settings callback'])) {
        $function = $filter_info[$filter_name]['js settings callback'];
        $filter_settings += $function($filter, $format);
      }
    }
    $settings[$format_name] = array(
      'filterSettings' => $filter_settings,
      'editor' => $format->editor,
      'editorSettings' => array(),
    );

    if ($format->editor && isset($editor_info[$format->editor]['js settings callback'])) {
      $function = $editor_info[$format->editor]['js settings callback'];
      $settings[$format_name]['editorSettings'] = $function($format, $settings);
    }
  }

  backdrop_alter('filter_js_settings', $settings, $formats);

  return $settings;
}