You are here

function editor_display_toolbars in Editor 6

Same name and namespace in other branches
  1. 5 editor.module \editor_display_toolbars()

@todo: handle different toolbars etc? or all themeing?

1 call to editor_display_toolbars()
editor_attach in ./editor.module

File

./editor.module, line 123
Extendable WYSIWYG editor @author Tj Holowaychuk <http://www.350designs.com/> @package Editor

Code

function editor_display_toolbars($profile) {
  $items = array();
  $plugins = editor_profile_plugins($profile);
  $plugin_count = count($plugins);
  if (count($plugins)) {
    foreach ($plugins as $i => $plugin) {

      // Ignore processing hidden plugins
      if ($plugin->type == 'hidden') {
        continue;
      }

      // Check for spacers
      if ($plugin == '|') {

        // No need for spacers at the beginning or end or the toolbars
        if ($i != 0 && $i != $plugin_count - 1) {
          $items[] = theme('editor_spacer');
        }
        continue;
      }

      // Invoke alter op
      editor_invoke_plugin_api('alter', $plugin);
      $plugin_type = editor_plugin_type_get($plugin->type);

      // Type must be available
      if ($plugin && $plugin_type) {

        // Theme must be available
        $theme = 'theme_' . $plugin_type->theme;
        if (function_exists($theme)) {
          $args = array();
          $args[] = $plugin_type->theme;
          $args[] = $plugin;
          if (count($plugin->theme_args)) {

            // @todo: $args += array()??
            foreach ($plugin->theme_args as $arg) {
              $args[] = $arg;
            }
          }
          $items[] = @call_user_func_array('theme', $args);
        }
      }
    }
  }
  return theme('editor_toolbar', implode(' ', $items));
}