diff sites/all/modules/imce_wysiwyg/imce_wysiwyg.module @ 0:ff03f76ab3fe

initial version
author danieleb <danielebarchiesi@me.com>
date Wed, 21 Aug 2013 18:51:11 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sites/all/modules/imce_wysiwyg/imce_wysiwyg.module	Wed Aug 21 18:51:11 2013 +0100
@@ -0,0 +1,82 @@
+<?php
+
+/**
+ * @file
+ * Makes IMCE available as plugin for client-side editors integrated via
+ * Wysiwyg API.
+ */
+
+/**
+ * Implements hook_wysiwyg_plugin().
+ */
+function imce_wysiwyg_plugin($editor, $version) {
+  static $integrated = array();
+
+  if (!module_invoke('imce', 'access')) {
+    return;
+  }
+  // Load our invocation scripts.
+  if (empty($integrated)) {
+    $imcepath = drupal_get_path('module', 'imce');
+    $path = drupal_get_path('module', 'imce_wysiwyg');
+    drupal_add_js($imcepath . '/js/imce.js');
+    drupal_add_js($imcepath . '/js/imce_set_app.js');
+    drupal_add_js($path . '/js/imce_wysiwyg.js');
+  }
+
+  switch ($editor) {
+    case 'tinymce':
+      if (!isset($integrated[$editor])) {
+        $integrated[$editor] = TRUE;
+        // @todo If some other editor also needs the URL to be passed via
+        //   Drupal.settings.imce, then we need another sub-key '$editor'.
+        $settings = array(
+          'imce' => array('url' => url('imce', array('query' => array('app' => $editor . '|url@')))),
+        );
+        drupal_add_js($settings, 'setting');
+      }
+      return array(
+        'imce' => array(
+          'extensions' => array('imce' => t('IMCE')),
+          'url' => 'http://drupal.org/project/imce',
+          'options' => array(
+            'file_browser_callback' => 'imceImageBrowser',
+            'inline_styles' => TRUE,
+          ),
+          'load' => FALSE,
+        ),
+      );
+
+   case 'ckeditor':
+      $integrated[$editor] = TRUE;
+      return array(
+        'imce' => array(
+          'extensions' => array('imce' => t('IMCE')),
+          'url' => 'http://drupal.org/project/imce',
+          'options' => array(
+            'filebrowserBrowseUrl' => url('imce', array('query' => array('app' => $editor . '|sendto@imceCkeditSendTo|params@'))),
+          ),
+          'load' => FALSE,
+        ),
+      );
+
+    case 'fckeditor':
+      $integrated[$editor] = TRUE;
+      return array(
+        'imce' => array(
+          'extensions' => array('imce' => t('IMCE')),
+          'url' => 'http://drupal.org/project/imce',
+          'options' => array(
+            'LinkBrowser' => TRUE,
+            'LinkBrowserURL' => url('imce', array('query' => array('app' => $editor . '|url@txtUrl'))),
+            'ImageBrowser' => TRUE,
+            'ImageBrowserURL' => url('imce', array('query' => array('app' => $editor . '|url@txtUrl|width@txtWidth|height@txtHeight'))),
+            'FlashBrowser' => TRUE,
+            'FlashBrowserURL' => url('imce', array('query' => array('app' => $editor . '|url@txtUrl'))),
+          ),
+          'load' => FALSE,
+        ),
+      );
+  }
+}
+