Index: tinymce.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tinymce/tinymce.module,v
retrieving revision 1.12
diff -u -F^f -r1.12 tinymce.module
--- tinymce.module	29 Mar 2005 15:07:24 -0000	1.12
+++ tinymce.module	1 Apr 2005 02:08:56 -0000
@@ -19,8 +19,34 @@
 function tinymce_menu($may_cache) {
   global $base_url;
   if (!$may_cache) {
+    if (variable_get('tinymce_all', 1)==2) {
+    $extra = '<script language="javascript" type="text/javascript">
+    function mceToggle(id, linkid) {
+      element = document.getElementById(id);
+      link = document.getElementById(linkid);
+      if (element.togg != "on") {
+        tinyMCE.addMCEControl(element, element.name);
+        element.togg = "on";
+        link.innerHTML = \''.t('turn off WYSIWYG').'\';
+        link.href = "javascript:mceToggle(\'"+id+"\', \'"+linkid+"\');";
+        link.blur();
+      } else {
+        tinyMCE.removeMCEControl(tinyMCE.getEditorId(element.name));
+        element.togg = "off";
+        link.innerHTML = \''.t('turn on WYSIWYG').'\';
+        link.href = "javascript:mceToggle(\'"+id+"\', \'"+linkid+"\');";
+        link.blur();
+   	  } 
+    }
+    </script>';
+    } else {
+      $extra = '';
+    }
+
     // For some crazy reason IE will only load this JS file if the absolute reference is given to it.
-    drupal_set_html_head('<script language="javascript" type="text/javascript" src="'. $base_url . '/'. drupal_get_path('module', 'tinymce') .'/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>');
+    drupal_set_html_head('<script language="javascript" type="text/javascript" src="'. $base_url . '/'. drupal_get_path('module', 'tinymce') .'/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>'.$extra);
+    
+    
     //We may need this so TinyMCE has the right path to Drupal to invoke drupal tinymce plugins.
     //drupal_set_html_head('<script language="javascript" type="text/javascript"> var baseUrl = "'. $base_url .'"; </script>');
     // We have to do this becuase of some unfocused CSS in certain themes. See http://drupal.org/node/18879 for details
@@ -104,11 +130,32 @@ function tinymce_settings() {
   $group = form_radios(t('Default theme'), 'tinymce_theme', variable_get('tinymce_theme', 'simple'), _tinymce_get_themes());
   $output = form_group(t('Themes'), $group);
 
-  $group = form_radios(t('access tinymce'), 'tinymce_all', variable_get('tinymce_all', 1), array(t('on specific pages'), t('on all textareas')));
+  $group = form_radios(t('access tinymce'), 'tinymce_all', variable_get('tinymce_all', 1), array(t('on specific pages'), t('on all textareas'), t('swap textareas dynamically')));
   if (!variable_get('tinymce_all', 1)) {
     $group .= form_textarea(t('Pages'), 'tinymce_pages', variable_get('tinymce_pages', tinymce_help('admin/settings/tinymce#pages')), 40, 5, t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '<em>blog</em>' for the blog page and '<em>blog/*</em>' for every personal blog. '<em>&lt;front&gt;</em>' is the front page."));
   }
   $output .= form_group('', $group);
+  // Advanced settings
+  $group = '';
+  $subgroup .= form_textfield(t('Editor Width'), 'tinymce_width', variable_get('tinymce_width', ''), 3, 5, t('Set width of editor. Leave blank to use size of textarea being replaced.'));
+  $subgroup .= form_textfield(t('Editor Height'), 'tinymce_height', variable_get('tinymce_height', ''), 3, 5, t('Set height of editor. Leave blank to use size of textarea being replaced.'));
+  $subgroup .= form_select(t('Toolbar Location'), 'tinymce_toolbar_loc', variable_get('tinymce_toolbar_loc', 'top'), array('top'=>'top', 'bottom'=>'bottom'), t('Show toolbar at the top or bottom of the editor area?'));
+  $subgroup .= form_select(t('Toolbar Align'), 'tinymce_toolbar_align', variable_get('tinymce_toolbar_align', 'left'), array('left'=>'left', 'center'=>'center', 'right'=>'right'), t('Align tools left, center, or right within the toolbar.'));
+  $subgroup .= form_select(t('Path Location'), 'tinymce_path_loc', variable_get('tinymce_path_loc', 'none'), array('top'=>'top', 'bottom'=>'bottom', 'none'=>'none'), t('Path to html elements (i.e. "body>table>tr>td"). Show at top, bottom, or not at all.'));
+  $group .= form_group(t('Editor Display'), $subgroup);
+  $group .= form_select(t('Auto Cleanup Word'), 'tinymce_word', variable_get('tinymce_word', 'false'), array('true'=>'true', 'false'=>'false'), t('Automatically cleanup MS Office/Word HTML will be executed automatically on paste operations. (Only works in Internet Explorer)'));
+  $group .= form_select(t('Verify HTML'), 'tinymce_verify_html', variable_get('tinymce_verify_html', 'false'), array('true'=>'true', 'false'=>'false'), t('Should the HTML contents be verified or not? Verifying will strip &lt;head&gt tags, so choose false if you will be editing full page HTML (such as massmailer html messages).'));
+  $group .= form_select(t('Preformatted'), 'tinymce_preformatted', variable_get('tinymce_preformatted', 'false'), array('true'=>'true', 'false'=>'false'), t('If this option is set to true, the editor will insert TAB characters on tab and preserve other whitespace characters just like a PRE HTML element does.'));
+  $subgroup = form_select(t('Editor CSS'), 'tinymce_css_setting', variable_get('tinymce_css_setting', 'theme'), array('theme'=>'use theme css', 'self'=>'define css', 'none'=>'tinyMCE default'), t('Defines the CSS to be used in the editor area.<br />use theme css - get css from current Drupal theme.<br/>define css - enter path for css file below.<br />tinyMCE default - uses default CSS from editor.'));
+  $subgroup .= form_textfield(t('CSS Path'), 'tinymce_css_path', variable_get('tinymce_css_path', ''), 40, 999, t('Enter path to CSS file (example: "/css/editor.css"). Select "define css" above.'));
+  $subgroup .= form_textfield(t('CSS Classes'), 'tinymce_css_classes', variable_get('tinymce_css_classes', ''), 40, 999, t('Adds CSS classes to the "styles" droplist. Format is "&lt;title&gt;=&lt;class&gt;;"<br/> Example: "Header 1=header1;Header 2=header2;Header 3=header3;"<br />Leave blank to automatically import list of CSS classes from style sheet.'));
+  $group .= form_group(t('CSS'), $subgroup);
+  $group .= form_textfield(t('Block Formats'), 'tinymce_block_formats', variable_get('tinymce_block_formats', 'p,address,pre,h1,h2,h3,h4,h5,h6'), 40, 999, t('Comma separated list of HTML block formats. Appears in dropdown menu.'));
+  $group .= form_select(t('Force BR New Lines'), 'tinymce_force_br', variable_get('tinymce_force_br', 'false'), array('true'=>'true', 'false'=>'false'), t('Use BR tags for new lines rather than P.'));
+  $group .= form_select(t('Force P New Lines'), 'tinymce_force_p', variable_get('tinymce_force_p', 'true'), array('true'=>'true', 'false'=>'false'), t('When enabled, Mozilla/Firefox will generate P elements on Enter/Return key and BR elements on Shift+Enter/Return..'));
+  $group .= form_select(t('Relative URLs'), 'tinymce_relative_urls', variable_get('tinymce_relative_urls', 'false'), array('true'=>'true', 'false'=>'false'), t('When true, absolute URLs are converted to relative URLs.'));
+  $group .= form_select(t('Remove Script Host'), 'tinymce_remove_script_host', variable_get('tinymce_remove_script_host', 'false'), array('true'=>'true', 'false'=>'false'), t('If enabled, the host and port from URLs are removed if they poiint within the same host as the script. For example if the editor is located on http://www.example.com, a link to http://www.example.com/somedir/somepage.html will result in /somedir/somepage.html, i.e. absolute within the same host.'));
+  $output .= form_group(t('Advanced options'), $group);
   return $output;
 }
 
@@ -123,7 +170,7 @@ function tinymce_textarea($op, $name) {
   $theme_name = $user->tinymce_theme ? $user->tinymce_theme : variable_get('tinymce_theme', 'simple');
   $user_status = $user->tinymce_status != NULL ? $user->tinymce_status : TRUE;
 
-  if ($op == 'pre' && _tinymce_page_match() && $user_status) {
+  if ($op == 'pre' && _tinymce_page_match() && $user_status && variable_get('tinymce_all', 1) != 2) {
     global $base_url;
 
     // Build a default list of TinyMCE settings.
@@ -153,6 +200,16 @@ function tinymce_textarea($op, $name) {
       $is_running = TRUE;
       drupal_set_html_head($output);
     }
+  } else if ($op == 'post' && _tinymce_page_match() && $user_status && variable_get('tinymce_all', 1) == 2) {
+    tinymce_head_script();
+    // make wysiwyg link
+    return '    <script language="javascript">
+    if (typeof(document.execCommand) == "undefined") {
+      document.write("<div style=\"font-size:x-small\">'.t('Your current web browser does not support WYSIWYG editing.').'</div>");
+      } else {
+      document.write("<div><a href=\"javascript:mceToggle(\'edit-'.$name.'\', \'wysiwyg4'.$name.'\');\" id=\"wysiwyg4'.$name.'\">'.t('turn on WYSIWYG').'</div></a>");
+    }
+    </script>';
   }
 }
 
@@ -174,6 +231,74 @@ function tinymce_user($type, &$edit, &$u
 }
 
 /**
+  * Format tinyMCE.init() arguments and place javascript in html head
+  *
+  */
+
+
+function tinymce_head_script() {
+  static $headscript = false;
+  if (!$headscript) {
+    global $user;
+    $mce_theme = $user->tinymce_theme ? $user->tinymce_theme : variable_get('tinymce_theme', 'simple');
+    $output = "theme : '". $mce_theme ."',\n";
+    $mce_mode = variable_get('tinymce_all', '2') == 2 ? "none" : "textareas";
+    $output .= "mode : '". $mce_mode ."',\n";
+    $output .= "verify_html : '". variable_get('tinymce_verify_html', 'false') ."',\n";
+    $output .= "auto_cleanup_word : '". variable_get('tinymce_word', 'false') ."',\n";
+    if (variable_get('tinymce_preformatted', 'false')=='true') {
+      $output .= "preformatted : 'true',\n";
+    }
+    $output .= "force_br_newlines : '". variable_get('tinymce_force_br', 'false') ."',\n";
+    $output .= "force_p_newlines : '". variable_get('tinymce_force_p', 'true') ."',\n";
+    $output .= "relative_urls : '". variable_get('tinymce_relative_urls', 'true') ."',\n";
+    $output .= "remove_script_host : '". variable_get('tinymce_remove_script_host', 'false') ."',\n";
+    if (variable_get('tinymce_width', '')) {
+      $output .= "width : ". variable_get('tinymce_width', 400) .",\n";
+    }
+    if (variable_get('tinymce_height', '')) {
+      $output .= "height : ". variable_get('tinymce_height', 500) .",\n";
+    }
+    $theme_path = drupal_get_path('theme', $GLOBALS['theme']);
+    switch (variable_get('tinymce_css_setting', 'theme')) {
+      case 'theme' :
+        $output .= "content_css : '".$GLOBALS['base_url'] ."/". $theme_path . "/style.css',\n";
+        break;
+      case 'self' :
+        $output .= "content_css : '".variable_get('tinymce_css_path', '')."',\n";
+        break;
+      case 'none' :
+    }
+    $output .= "theme_advanced_toolbar_location : '". variable_get('tinymce_toolbar_loc', 'top') ."',\n";
+    $output .= "theme_advanced_toolbar_align : '". variable_get('tinymce_toolbar_align', 'left') ."',\n";
+    $output .= "theme_advanced_path_location : '". variable_get('tinymce_path_loc', 'false') ."',\n";
+    $output .= "theme_advanced_blockformats : '". variable_get('tinymce_block_formats', 'p,address,pre,h1,h2,h3,h4,h5,h6') ."',\n";
+    if (variable_get('tinymce_css_classes', '')) {
+      $output .= "theme_advanced_styles : '". variable_get('tinymce_css_classes', '') ."',\n";
+    }
+    
+    if ($mce_theme == 'advanced') {
+      $output .=
+       "extended_valid_elements : 'a[href|target|name]',
+        plugins : 'table,emotions,iespell, print',
+        theme_advanced_buttons3_add_before : 'tablecontrols,separator',
+        theme_advanced_buttons3_add : 'emotions,iespell,separator,print',\n";
+    }
+    $output .= "document_base_url : '".$GLOBALS['base_url'] ."/',\n";
+    $output = '<script language="javascript" type="text/javascript">
+      //dynamic swap xxx
+      tinyMCE.init({ 
+        '. $output .' 
+      });
+      </script>';
+    drupal_set_html_head($output);
+    $headscript = true;
+  }
+}
+
+
+
+/**
  * @addtogroup themeable
  * @{
  */
