You are here

function wysiwyg_fckeditor_settings in Wysiwyg 7.2

Same name and namespace in other branches
  1. 5.2 editors/fckeditor.inc \wysiwyg_fckeditor_settings()
  2. 5 editors/fckeditor.inc \wysiwyg_fckeditor_settings()
  3. 6.2 editors/fckeditor.inc \wysiwyg_fckeditor_settings()
  4. 6 editors/fckeditor.inc \wysiwyg_fckeditor_settings()

Return runtime editor settings for a given wysiwyg profile.

Parameters

$editor: A processed hook_editor() array of editor properties.

$config: An array containing wysiwyg editor profile settings.

$theme: The name of a theme/GUI/skin to use.

Return value

A settings array to be populated in Drupal.settings.wysiwyg.configs.{editor}

1 string reference to 'wysiwyg_fckeditor_settings'
wysiwyg_fckeditor_editor in editors/fckeditor.inc
Plugin implementation of hook_editor().

File

editors/fckeditor.inc, line 164
Editor integration functions for FCKeditor.

Code

function wysiwyg_fckeditor_settings($editor, $config, $theme) {
  $settings = array(
    'EditorPath' => base_path() . $editor['library path'] . '/',
    'SkinPath' => base_path() . $editor['library path'] . '/editor/skins/' . $theme . '/',
    'CustomConfigurationsPath' => base_path() . drupal_get_path('module', 'wysiwyg') . '/editors/js/fckeditor.config.js',
    'Width' => '100%',
    'LinkBrowser' => FALSE,
    'LinkUpload' => FALSE,
    'ImageBrowser' => FALSE,
    'ImageUpload' => FALSE,
    'FlashBrowser' => FALSE,
    'FlashUpload' => FALSE,
    // By default, FCKeditor converts most characters into HTML entities. Since
    // it does not support a custom definition, but Drupal supports Unicode, we
    // disable at least the additional character sets. FCKeditor always converts
    // XML default characters '&', '<', '>'.
    // @todo Check whether completely disabling ProcessHTMLEntities is an option.
    'IncludeLatinEntities' => FALSE,
    'IncludeGreekEntities' => FALSE,
  );
  if (isset($config['FontFormats'])) {
    $settings['FontFormats'] = preg_replace('@\\s+@', '', $config['FontFormats']);
  }
  $check_if_set = array(
    'AutoDetectPasteFromWord',
    'ForcePasteAsPlainText',
    'FormatOutput',
    'FormatSource',
  );
  foreach ($check_if_set as $setting_name) {
    if (isset($config[$setting_name])) {
      $settings[$setting_name] = $config[$setting_name];
    }
  }
  if (isset($config['css_setting'])) {
    if ($config['css_setting'] == 'theme') {
      $settings['EditorAreaCSS'] = implode(',', wysiwyg_get_css(isset($config['css_theme']) ? $config['css_theme'] : ''));
    }
    elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
      $settings['EditorAreaCSS'] = strtr($config['css_path'], array(
        '%b' => base_path(),
        '%t' => drupal_get_path('theme', variable_get('theme_default', NULL)),
        '%q' => variable_get('css_js_query_string', ''),
      ));
    }
  }

  // Use our custom toolbar set.
  $settings['ToolbarSet'] = 'Wysiwyg';

  // Populate our custom toolbar set for fckeditor.config.js.
  $settings['buttons'] = array();
  if (!empty($config['buttons'])) {
    $plugins = wysiwyg_get_plugins($editor['name']);
    foreach ($config['buttons'] as $plugin => $buttons) {
      foreach ($buttons as $button => $enabled) {

        // Iterate separately over buttons and extensions properties.
        foreach (array(
          'buttons',
          'extensions',
        ) as $type) {

          // Skip unavailable plugins.
          if (!isset($plugins[$plugin][$type][$button])) {
            continue;
          }

          // Add buttons.
          if ($type == 'buttons') {
            $settings['buttons'][] = $button;
          }

          // Allow plugins to add or override global configuration settings.
          if (!empty($plugins[$plugin]['options'])) {
            $settings = array_merge($settings, $plugins[$plugin]['options']);
          }
        }
      }
    }
  }

  // For now, all buttons are placed into one row.
  $settings['buttons'] = array(
    $settings['buttons'],
  );
  return $settings;
}