You are here

function editor_get_js_settings in Editor 7

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.

1 call to editor_get_js_settings()
editor_get_attached in ./editor.module
Adds filter configuration information to the page for access by JavaScript.

File

./editor.module, line 710
Allows rich text fields to be edited using WYSIWYG client-side editors.

Code

function editor_get_js_settings($formats) {
  $settings = array();
  $filter_info = filter_get_filters();
  $editor_info = editor_get_editors();
  foreach ($formats as $format_name => $format) {
    editor_format_ensure_additional_properties($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(
      'format' => $format,
      '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);
    }
  }
  drupal_alter('filter_js_settings', $settings, $formats);
  return $settings;
}