Patch #54242 : Improved img_assist integration, removed drupalimage, now part of...
authorTed Serbinski
Fri, 24 Mar 2006 06:48:58 +0000 (06:48 +0000)
committerTed Serbinski
Fri, 24 Mar 2006 06:48:58 +0000 (06:48 +0000)
plugins/drupalimage/README.txt [deleted file]
plugins/drupalimage/editor_plugin.js [deleted file]
plugins/drupalimage/editor_plugin_src.js [deleted file]
plugins/drupalimage/images/drupalimage.gif [deleted file]
plugins/drupalimage/images/readme.txt [deleted file]
plugins/drupalimage/langs/en.js [deleted file]
tinymce.module

diff --git a/plugins/drupalimage/README.txt b/plugins/drupalimage/README.txt
deleted file mode 100644 (file)
index f118f1e..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
- drupalimage plugin for TinyMCE\r
------------------------------\r
-\r
-About:\r
-  This plugin integrates the Drupal img_assist module with TinyMCE allowing you\r
-  to upload, browse and insert images into your post. You must first install\r
-  img_assist:\r
-\r
-    http://drupal.org/project/img_assist\r
-\r
-Installation instructions:\r
-  * Copy the drupalimage directory to the plugins directory of TinyMCE (/jscripts/tiny_mce/plugins).\r
-  * Open up plugin_reg.php and add the following lines to end of that file:\r  \r      $plugins['drupalimage'] = array();
-      $plugins['drupalimage']['theme_advanced_buttons2'] = array('drupalimage');
-      $plugins['drupalimage']['extended_valid_elements'] = array('a[name|href|target|title|onclick]');\r      \r  * Then enable this plugin under Admin > Settings > TinyMCE, under the Buttons & Plugins section\r
-\r
diff --git a/plugins/drupalimage/editor_plugin.js b/plugins/drupalimage/editor_plugin.js
deleted file mode 100644 (file)
index 436b568..0000000
+++ /dev/null
@@ -1 +0,0 @@
-tinyMCE.importPluginLanguagePack("drupalimage","en");function TinyMCE_drupalimage_getInfo(){return {longname:"Drupal img_assist",author:"Matt Westgate",infourl:"http://drupal.org/project/img_assist",version:"1.0"};}function TinyMCE_drupalimage_getControlHTML(_1){switch(_1){case "drupalimage":var _2="tinyMCE.execInstanceCommand('{$editor_id}','mceDrupalimage',true);return false;";return "<a href=\"javascript:"+_2+"\" onclick=\""+_2+"\" target=\"_self\" onmousedown=\"return false;\"><img id=\"{$editor_id}_drupalimage\" src=\"{$pluginurl}/images/drupalimage.gif\" title=\"{$lang_drupalimage_desc}\" width=\"20\" height=\"20\" class=\"mceButtonNormal\" onmouseover=\"tinyMCE.switchClass(this,'mceButtonOver');\" onmouseout=\"tinyMCE.restoreClass(this);\" onmousedown=\"tinyMCE.restoreAndSwitchClass(this,'mceButtonDown');\" /></a>";}return "";}function TinyMCE_drupalimage_execCommand(_3,_4,_5,_6,_7){switch(_5){case "mceDrupalimage":var _8=new Array();_8["file"]="index.php?q=img_assist/add&editor=tinymce";_8["width"]=500;_8["height"]=660;tinyMCE.openWindow(_8,{editor_id:_3,resizable:"yes",scrollbars:"yes"});return true;}return false;}
\ No newline at end of file
diff --git a/plugins/drupalimage/editor_plugin_src.js b/plugins/drupalimage/editor_plugin_src.js
deleted file mode 100644 (file)
index f870624..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('drupalimage', 'en');
-
-/**
- * Information about the plugin.
- */
-function TinyMCE_drupalimage_getInfo() {
-       return {
-               longname : 'Drupal img_assist',
-               author : 'Matt Westgate',
-               infourl : 'http://drupal.org/project/img_assist',
-               version : "1.0"
-       };
-};
-
-/**
- * Returns the HTML contents of the emotions control.
- */
-function TinyMCE_drupalimage_getControlHTML(control_name) {
-  switch (control_name) {
-    case "drupalimage":
-                       var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDrupalimage\',true);return false;';
-                       return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_drupalimage" src="{$pluginurl}/images/drupalimage.gif" title="{$lang_drupalimage_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
-  }
-  
-  return "";
-}
-
-/**
- * Executes the mceEmotion command.
- */
-function TinyMCE_drupalimage_execCommand(editor_id, element, command, user_interface, value) {
-  // Handle commands
-  switch (command) {
-    case "mceDrupalimage":
-      var template = new Array();
-
-      template['file'] = 'index.php?q=img_assist/add&editor=tinymce'; // Relative to theme
-      template['width'] = 500;
-      template['height'] = 660;
-
-      //WARNING: "resizable : 'yes'" below is painfully important otherwise
-      // tinymce will try to open a new window in IE using showModalDialog().
-      // And for some reason showModalDialog() doesn't respect the target="_top"
-      // attribute.
-
-      tinyMCE.openWindow(template, {editor_id : editor_id, resizable : 'yes', scrollbars : 'yes'});
-
-      return true;
-  }
-
-  // Pass to next handler in chain
-  return false;
-}
diff --git a/plugins/drupalimage/images/drupalimage.gif b/plugins/drupalimage/images/drupalimage.gif
deleted file mode 100644 (file)
index 8ee00c5..0000000
Binary files a/plugins/drupalimage/images/drupalimage.gif and /dev/null differ
diff --git a/plugins/drupalimage/images/readme.txt b/plugins/drupalimage/images/readme.txt
deleted file mode 100644 (file)
index 6e7716c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-The camera icon (camera.png) was taken from teh 'slick' icon pack for KDE.  As they are included in Debian, I'm assuming that they are compatible with the GPL.
diff --git a/plugins/drupalimage/langs/en.js b/plugins/drupalimage/langs/en.js
deleted file mode 100644 (file)
index dc07d6c..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-// English lang variables
-
-tinyMCELang['lang_insert_drupalimage_title'] = 'Insert image';
-tinyMCELang['lang_drupalimage_desc'] = 'Upload image';
-
index 96fc891..a2b672c 100644 (file)
@@ -58,53 +58,6 @@ function tinymce_perm() {
 }
 
 /**
- * Implementation of hook_img_assist_head().
- */
-function tinymce_img_assist_head() {
-  // The tinymce docs say to include tiny_mce_popup.js, but this was killing IE!
-  $popup_path = base_path() . drupal_get_path('module', 'tinymce'). '/tinymce/jscripts/tiny_mce/tiny_mce_popup.js';
-  $img_assist_prop = $img_template = '';
-  if (module_exist('img_assist')) {
-    $img_assist_prop = base_path() . drupal_get_path('module', 'img_assist'). '/properties.js';
-    $img_assist_prop = '<script type="text/javascript" src="'. $img_assist_prop .'"></script>';
-
-    $img_template = variable_get('img_assist_img_html', img_assist_help('img_assist/template'));
-    $nl = "\n";
-    $img_template = preg_replace('/\n|\r|(\r\n)/m', '\\'. $nl, $img_template);
-  }
-  $clean_url    = variable_get('clean_url', 0);
-
-$output = <<<EOD
-$img_assist_prop
-<script type="text/javascript">
-  var clean_url    = $clean_url;
-  var img_template = '$img_template';
-
-  function insertImage(form) {
-    if (window.opener) {
-      form['edit[filepath]'].value = window.opener.tinyMCE.convertURL(form['edit[filepath]'].value);
-      form['edit[nodePath]'].value = window.opener.tinyMCE.convertURL(form['edit[nodePath]'].value);
-
-      var img = generate_image_tag(form, 'html');
-      //img = img.replace(/\\r|\\n|\\t/g, '');
-
-      window.opener.tinyMCE.execInstanceCommand(myTextarea.name, 'mceInsertContent', false, img, true);
-    }
-  }
-</script>
-EOD;
-
-  return $output;
-}
-
-/**
- * Implementation of hook_img_assist_on_submit().
- */
-function tinymce_img_assist_on_submit() {
-  return 'parent.insertImage(this.form);';
-}
-
-/**
  * Implementation of hook_elements().
  */
 function tinymce_elements() {
@@ -160,13 +113,6 @@ function tinymce_process_textarea($element) {
     }
     $tinymce_settings = implode(",\n    ", $settings);
 
-    if (module_exist('img_assist')) {
-      $img_assist_js_on = base_path() . url('img_assist/add&editor=tinymce') .'&textarea=';
-      $img_assist_js_off = base_path() . url('img_assist/add') .'&textarea=';
-      $img_assist_on = base_path() . url('img_assist/add&editor=tinymce') .'&textarea=edit['. $textarea_name .']';
-      $img_assist_off = base_path() . url('img_assist/add') .'&textarea=edit['. $textarea_name .']';
-    }
-
     $enable  = t('enable rich-text');
     $disable = t('disable rich-text');
 
@@ -191,7 +137,7 @@ $js_toggle = <<<EOD
       link.innerHTML = '$disable';
       link.href = "javascript:mceToggle('" +id+ "', '" +linkid+ "');";
       if (img_assist)
-        img_assist.href = "$img_assist_js_on"+ element.name;
+        img_assist.innerHTML = '';
       link.blur();
     }
     else {
@@ -200,7 +146,7 @@ $js_toggle = <<<EOD
       link.innerHTML = '$enable';
       link.href = "javascript:mceToggle('" +id+ "', '" +linkid+ "');";
       if (img_assist)
-        img_assist.href = "$img_assist_js_off"+ element.name;
+        img_assist.innerHTML = img_assist_default_link;
       link.blur();
     }
   }
@@ -211,15 +157,22 @@ $status = tinymce_user_get_status($user, $profile);
 
 // note we test for string == true because we save our settings as strings
 $link_text = $status == 'true' ? $disable : $enable;
+$img_assist_link = ($status == 'true') ? 'yes' : 'no';
 $no_wysiwyg = t('Your current web browser does not support WYSIWYG editing.');
 $wysiwyg_link = <<<EOD
 <script type="text/javascript">
   img_assist = document.getElementById('img_assist-link-edit-$textarea_name');
   if (img_assist) {
-    img_assist.href = tinyMCE.getEditorId('edit-$textarea_name') == null ? "$img_assist_on" : "$img_assist_off";
+    var img_assist_default_link = img_assist.innerHTML;
+    if ('$img_assist_link' == 'yes') {
+      img_assist.innerHTML = tinyMCE.getEditorId('edit-$textarea_name') == null ? '' : img_assist_default_link;
+    } 
+    else {
+      img_assist.innerHTML = tinyMCE.getEditorId('edit-$textarea_name') == null ? img_assist_default_link : '';
+    }
   }
   if (typeof(document.execCommand) == 'undefined') {
-    img_assist.href = "$img_assist_off";
+    img_assist.innerHTML = img_assist_default_link;
     document.write('<div style="font-size:x-small">$no_wysiwyg</div>');
   }
   else {
@@ -411,6 +364,7 @@ function _tinymce_get_themes() {
 function _tinymce_get_buttons($skip_metadata = TRUE) {
   include_once(drupal_get_path('module', 'tinymce'). '/plugin_reg.php');
   $plugins = _tinymce_plugins();
+       
   if ($skip_metadata == FALSE && is_array($plugins)) {
     foreach ($plugins as $name => $plugin) {
       $file = drupal_get_path('module', 'tinymce'). '/tinymce/jscripts/tiny_mce/plugins/'. $name .'/editor_plugin_src.js';