You are here

function wysiwyg_yui_settings in Wysiwyg 6.2

Same name and namespace in other branches
  1. 5.2 editors/yui.inc \wysiwyg_yui_settings()
  2. 5 editors/yui.inc \wysiwyg_yui_settings()
  3. 6 editors/yui.inc \wysiwyg_yui_settings()
  4. 7.2 editors/yui.inc \wysiwyg_yui_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_yui_settings'
wysiwyg_yui_editor in editors/yui.inc
Plugin implementation of hook_editor().

File

editors/yui.inc, line 183
Editor integration functions for YUI editor.

Code

function wysiwyg_yui_settings($editor, $config, $theme) {
  $settings = array(
    'theme' => $theme,
    'animate' => TRUE,
    'handleSubmit' => TRUE,
    'markup' => 'xhtml',
    'ptags' => TRUE,
  );
  if (!empty($config['autoHeight'])) {
    $settings['autoHeight'] = TRUE;
  }
  $settings += array(
    'toolbar' => array(
      'collapse' => FALSE,
      'draggable' => TRUE,
      'buttonType' => 'advanced',
      'buttons' => array(),
    ),
  );
  if (!empty($config['buttons'])) {
    $buttons = array();
    foreach ($config['buttons'] as $plugin => $enabled_buttons) {
      foreach ($enabled_buttons as $button => $enabled) {
        $extra = array();
        if ($button == 'heading') {
          $extra = array(
            'menu' => array(
              array(
                'text' => 'Normal',
                'value' => 'none',
                'checked' => TRUE,
              ),
            ),
          );
          if (!empty($config['block_formats'])) {
            $headings = array(
              'p' => array(
                'text' => 'Paragraph',
                'value' => 'p',
              ),
              'h1' => array(
                'text' => 'Heading 1',
                'value' => 'h1',
              ),
              'h2' => array(
                'text' => 'Heading 2',
                'value' => 'h2',
              ),
              'h3' => array(
                'text' => 'Heading 3',
                'value' => 'h3',
              ),
              'h4' => array(
                'text' => 'Heading 4',
                'value' => 'h4',
              ),
              'h5' => array(
                'text' => 'Heading 5',
                'value' => 'h5',
              ),
              'h6' => array(
                'text' => 'Heading 6',
                'value' => 'h6',
              ),
            );
            foreach (explode(',', preg_replace('@\\s+@', '', $config['block_formats'])) as $tag) {
              if (isset($headings[$tag])) {
                $extra['menu'][] = $headings[$tag];
              }
            }
          }
        }
        elseif ($button == 'fontname') {
          $extra = array(
            'menu' => array(
              array(
                'text' => 'Arial',
                'checked' => TRUE,
              ),
              array(
                'text' => 'Arial Black',
              ),
              array(
                'text' => 'Comic Sans MS',
              ),
              array(
                'text' => 'Courier New',
              ),
              array(
                'text' => 'Lucida Console',
              ),
              array(
                'text' => 'Tahoma',
              ),
              array(
                'text' => 'Times New Roman',
              ),
              array(
                'text' => 'Trebuchet MS',
              ),
              array(
                'text' => 'Verdana',
              ),
            ),
          );
        }
        $buttons[] = wysiwyg_yui_button_setting($editor, $plugin, $button, $extra);
      }
    }

    // Group buttons in a dummy group.
    $buttons = array(
      'group' => 'default',
      'label' => '',
      'buttons' => $buttons,
    );
    $settings['toolbar']['buttons'] = array(
      $buttons,
    );
  }
  if (isset($config['css_setting'])) {
    if ($config['css_setting'] == 'theme') {
      $settings['extracss'] = wysiwyg_get_css();
    }
    elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
      $settings['extracss'] = strtr($config['css_path'], array(
        '%b' => base_path(),
        '%t' => path_to_theme(),
        '%q' => variable_get('css_js_query_string', ''),
      ));
      $settings['extracss'] = explode(',', $settings['extracss']);
    }

    // YUI only supports inline CSS, so we need to use @import directives.
    // Syntax: '@import "/base/path/to/theme/style.css"; '
    if (!empty($settings['extracss'])) {
      $settings['extracss'] = '@import "' . implode('"; @import "', $settings['extracss']) . '";';
    }
  }
  return $settings;
}