You are here

function wysiwyg_yui_button_setting in Wysiwyg 5.2

Same name and namespace in other branches
  1. 5 editors/yui.inc \wysiwyg_yui_button_setting()
  2. 6.2 editors/yui.inc \wysiwyg_yui_button_setting()
  3. 6 editors/yui.inc \wysiwyg_yui_button_setting()
  4. 7.2 editors/yui.inc \wysiwyg_yui_button_setting()

Create the JavaScript structure for a YUI button.

Parameters

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

$plugin: The internal name of a plugin.

$button: The internal name of a button, defined by $plugin.

$extra: (optional) An array containing arbitrary other elements to add to the resulting button.

1 call to wysiwyg_yui_button_setting()
wysiwyg_yui_settings in editors/yui.inc
Return runtime editor settings for a given wysiwyg profile.

File

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

Code

function wysiwyg_yui_button_setting($editor, $plugin, $button, $extra = array()) {
  static $plugins;
  if (!isset($plugins)) {

    // @todo Invoke all enabled plugins, not just internals.
    $plugins = wysiwyg_yui_plugins($editor);
  }

  // Return a simple separator.
  if ($button === 'separator') {
    return array(
      'type' => 'separator',
    );
  }

  // Setup defaults.
  $type = 'push';
  $label = $plugins[$plugin]['buttons'][$button];

  // Special handling for certain buttons.
  if (in_array($button, array(
    'heading',
    'fontname',
  ))) {
    $type = 'select';
    $label = $extra['menu'][0]['text'];
  }
  elseif (in_array($button, array(
    'fontsize',
  ))) {
    $type = 'spin';
  }
  elseif (in_array($button, array(
    'forecolor',
    'backcolor',
  ))) {
    $type = 'color';
  }
  $button = array(
    'type' => $type,
    'label' => $label,
    'value' => $button,
  );

  // Add arbitrary other elements, if defined.
  if (!empty($extra)) {
    $button = array_merge($button, $extra);
  }
  return $button;
}