You are here

function ckeditor_load_plugins in CKEditor - WYSIWYG HTML editor 7

Same name and namespace in other branches
  1. 6 includes/ckeditor.lib.inc \ckeditor_load_plugins()

List of CKEditor plugins.

Parameters

boolean $render: Whether to generate plugin paths. Default to FALSE.

Return value

array

5 calls to ckeditor_load_plugins()
ckeditor_admin_profile_form in includes/ckeditor.admin.inc
Form builder for a profile
ckeditor_admin_values_to_settings in includes/ckeditor.admin.inc
Converts an array of form values to a serialized array that does not contain Drupal Form API values
ckeditor_modules_uninstalled in ./ckeditor.module
Implementation of hook_modules_uninstalled().
ckeditor_profile_settings_compile in includes/ckeditor.lib.inc
Compile settings of profile
ckeditor_toolbar_buttons_all in includes/ckeditor.admin.inc

File

includes/ckeditor.lib.inc, line 346
CKEditor - The text editor for the Internet - http://ckeditor.com Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.

Code

function ckeditor_load_plugins($render = FALSE) {
  $plugins = module_invoke_all('ckeditor_plugin');

  // [#2159403] introduced a slight change in CKEditor API, expecting the path
  // to a plugin returned by hook_ckeditor_plugin() to be a full URL. This
  // breaks backward compatibility for external plugins, so we're fixing it
  // below.
  foreach ($plugins as $i => &$plugin) {
    if (is_array($plugin['path'])) {
      $msg = t('<b>Plugins conflict detected.</b>');
      $msg .= t('There is more than one plugin with the same name: <b>%name</b>.', array(
        '%name' => $i,
      ));
      $msg .= t('Please remove duplicated plugins leaving only one version.');
      drupal_set_message($msg, 'warning', false);
      $msg = 'Plugins conflict detected. Multiple plugins with name: <b>%name</b>. Please remove duplicated plugins leaving only one version.';
      watchdog('CKEditor', $msg, array(
        '%name' => $i,
      ), WATCHDOG_WARNING);

      // Leave only the first plugin details
      foreach (array(
        'name',
        'desc',
        'path',
      ) as $field) {
        if (isset($plugin[$field]) && is_array($plugin[$field])) {
          $plugin[$field] = array_shift($plugin[$field]);
        }
      }
      foreach ($plugin['buttons'] as &$buttons) {
        foreach (array(
          'label',
          'icon',
        ) as $field) {
          if (isset($buttons[$field]) && is_array($buttons[$field])) {
            $buttons[$field] = array_shift($buttons[$field]);
          }
        }
      }
    }
    if (strpos($plugin['path'], '%') !== 0 && !preg_match('|^(http(s)?:)?\\/?\\/|i', $plugin['path'])) {
      $plugin['path'] = '%base_path%' . $plugin['path'];
    }
  }
  drupal_alter('ckeditor_plugin', $plugins);
  ksort($plugins);
  if ($render) {
    $plugins = ckeditor_plugins_render($plugins);
  }
  return $plugins;
}