You are here

function elfinder_wysiwyg_plugin in elFinder file manager 8.2

Same name and namespace in other branches
  1. 6.2 elfinder.module \elfinder_wysiwyg_plugin()
  2. 6 elfinder.module \elfinder_wysiwyg_plugin()
  3. 7.3 elfinder.module \elfinder_wysiwyg_plugin()
  4. 7 elfinder.module \elfinder_wysiwyg_plugin()
  5. 7.2 elfinder.module \elfinder_wysiwyg_plugin()

Implements hook_wysiwyg_plugin().

File

./elfinder.module, line 150

Code

function elfinder_wysiwyg_plugin($editor, $version) {
  $path = drupal_get_path('module', 'elfinder');
  drupal_add_js($path . '/js/elfinder.wysiwyg.init.js', array(
    'group' => JS_LIBRARY,
  ));
  $options = array(
    'elfinder_url' => \Drupal::url('elfinder', array(
      'query' => array(
        'app' => $editor,
      ),
    )),
    'homepage_url' => elfinder_homepage_url(),
    'path' => $path,
  );

  /* bueditor hack */
  if (preg_match('/^(bueditor|bue)/', $editor)) {
    $editor = 'bueditor';
  }

  // FIXME: $editor_plugins = elfinder_system_listing("$editor\.inc\$", $path . '/editors' , 'name', 0);
  $editor_plugins = array();

  /* loading editor plugin */
  $plugin_file = '';
  if (isset($editor_plugins[$editor])) {
    $plugin_file = $editor_plugins[$editor]->uri;
    if ($plugin_file) {
      $options['plugin_url_base'] = "{$path}/editors/{$editor}";
      require_once $plugin_file;
    }
  }

  /* hook for adding another editor support */

  //\Drupal::moduleHandler()->invokeAll('elfinder_editor_plugin');

  /* wysiwyg plugin generation func for selected editor */
  $pluginfunc = 'elfinder_' . $editor . '_elfinder_editor_plugin';

  /* returning elFinder wysiwyg editor plugin for selected editor */
  if (function_exists($pluginfunc)) {
    return call_user_func_array($pluginfunc, array(
      $options,
    ));
  }
}