You are here

function wysiwyg_get_editor_themes in Wysiwyg 5.2

Same name and namespace in other branches
  1. 5 wysiwyg.module \wysiwyg_get_editor_themes()
  2. 6.2 wysiwyg.module \wysiwyg_get_editor_themes()
  3. 6 wysiwyg.module \wysiwyg_get_editor_themes()
  4. 7.2 wysiwyg.module \wysiwyg_get_editor_themes()

Retrieve available themes for an editor.

Editor themes control the visual presentation of an editor.

Parameters

$profile: A wysiwyg editor profile; passed/altered by reference.

$selected_theme: An optional theme name that ought to be used.

Return value

An array of theme names, or a single, checked theme name if $selected_theme was given.

1 call to wysiwyg_get_editor_themes()
wysiwyg_process_form in ./wysiwyg.module
Process a textarea for Wysiwyg Editor.

File

./wysiwyg.module, line 468
Integrate client-side editors with Drupal.

Code

function wysiwyg_get_editor_themes(&$profile, $selected_theme = NULL) {
  static $themes = array();
  if (!isset($themes[$profile->editor])) {
    $editor = wysiwyg_get_editor($profile->editor);
    if (isset($editor['themes callback']) && function_exists($editor['themes callback'])) {
      $themes[$editor['name']] = $editor['themes callback']($editor, $profile);
    }
    else {
      $themes[$editor['name']] = array(
        'default',
      );
    }
  }

  // Check optional $selected_theme argument, if given.
  if (isset($selected_theme)) {

    // If the passed theme name does not exist, use the first available.
    if (!in_array($selected_theme, $themes[$profile->editor])) {
      $selected_theme = $profile->settings['theme'] = $themes[$profile->editor][0];
    }
  }
  return isset($selected_theme) ? $selected_theme : $themes[$profile->editor];
}