You are here

function wysiwyg_openwysiwyg_settings in Wysiwyg 5.2

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_openwysiwyg_settings'
wysiwyg_openwysiwyg_editor in editors/openwysiwyg.inc
Plugin implementation of hook_editor().

File

editors/openwysiwyg.inc, line 91
Editor integration functions for openWYSIWYG.

Code

function wysiwyg_openwysiwyg_settings($editor, $config, $theme) {
  $settings = array(
    'path' => base_path() . $editor['editor path'] . '/',
    'Width' => '100%',
  );
  if (isset($config['path_loc']) && $config['path_loc'] == 'none') {
    $settings['StatusBarEnabled'] = FALSE;
  }
  if (isset($config['css_setting'])) {
    if ($config['css_setting'] == 'theme') {
      $css = wysiwyg_get_css();
      $settings['CSSFile'] = reset($css);
    }
    else {
      if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
        $settings['CSSFile'] = strtr($config['css_path'], array(
          '%b' => base_path(),
          '%t' => path_to_theme(),
        ));
      }
    }
  }
  $settings['Toolbar'] = array();
  if (!empty($config['buttons'])) {
    $plugins = wysiwyg_get_plugins($editor['name']);
    foreach ($config['buttons'] as $plugin => $buttons) {
      foreach ($buttons as $button => $enabled) {
        foreach (array(
          'buttons',
          'extensions',
        ) as $type) {

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

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

  // @todo
  //  if (isset($config['block_formats'])) {
  //    $settings['DropDowns']['headings']['elements'] = explode(',', $config['block_formats']);
  //  }
  return $settings;
}