I realized that the module starts with

<?php
if (function_exists('user_access')) {
   
   // *********************************
   // Link the necessary scripts
   // *********************************
   $path = drupal_get_path('module', 'tinytinymce');
   drupal_add_js($path.'/tinymce/jscripts/tiny_mce/tiny_mce.js', 'module', 'header', false, true, false);
   drupal_add_js(tinytinymce_init().tinytinymce_toggle(), 'inline');
} else {
   drupal_set_message(t('Tiny Tiny MCE is not correctly installed - please check the installation notes'));
}
?>

But this means that the tiny_mce.js file are loaded for users that might never use TINYMCE

I propose to get rid of this part of the code and load the .js file when needed
inside the phptemplate_textarea() call

<?php
....
   if (!$excluded && (user_access('use tinytinymce advanced') === true || user_access('use tinytinymce simple') === true)) {
     $path = drupal_get_path('module', 'tinytinymce');
     drupal_add_js($path.'/tinymce/jscripts/tiny_mce/tiny_mce.js', 'module', 'header', false, true, false);
     drupal_add_js(tinytinymce_init().tinytinymce_toggle(), 'inline');
      $pos = strrpos($out, '</div>');
....
?>

Comments

Steve Lockwood’s picture

This looks like an improvement, thanks.

I suggest that you wrap the section of code in
if (function_exists('user_access')) {
...
}

This was to prevent the module from crashing in cases where it was not installed in the right place or if the wrong caching settings were being used.

I will take a proper look at your code and incorporate in a future release.

Steve

giorgosk’s picture

Steve I think your problem with caching lies in the fact
that your are overiding the theme_textarea()
(maybe the wrong approach)

I am looking into how tinymce module does its magic
and I think you should look closely into

/**
 * Implementation of hook_elements().
 */
function tinymce_elements() {
  $type = array();

  if (user_access('access tinymce')) {
    // Let TinyMCE potentially process each textarea.
    $type['textarea'] = array('#process' => array('tinymce_process_textarea' => array()));
  }

  return $type;
}

Because I think that is where it all starts

Steve Lockwood’s picture

Status: Active » Fixed
Steve Lockwood’s picture

Status: Fixed » Closed (fixed)
giorgosk’s picture

Steve I believe issues are closed automatically
after 2 weeks of inactivity