Project:TinyMCE
Version:6.x-1.x-dev
Component:Code
Category:support request
Priority:critical
Assigned:Unassigned
Status:active

Issue Summary

Hi,
not sure if this a bug or a design problem that can't be solved: I have user adding some php code to a page, using the php input filter. Now a second user edits the page using tinymce. Then he doesn't see the php code in the editor, and when saving the page, the php code is completely gone from the page!

Thus, someone using tinymce can accidentally delete possibly huge parts of a page without knowing, because he doesn't see anything of the php code in the editor...

Is this a bug? Or can this be changed by some setting I missed so far?

cu,
Frank

Comments

#1

No one who can tell me if tinymce is supposed to silently remove php code from pages or if this is a bug?

#2

I am having the same issue with YUI - I was hoping to solve this problem by using TinyMCE... Looks like I'll have to wait until it gets figured out...

#3

the second user editing the page ? has ability to use php input format ? if not, that may be the reason for deletion.

#4

Hmm, if that was the case it should not delete it but display it as text. Anyway, it happens even for the user who created the php code and then switches to tinymce once to re-edit the page. Then his own code is gone...

#5

I too am having the same issues ... nobody seems to have answers???

#6

Priority:normal» critical

I wish there was a way to disable the editor on the fly, i.e. using the Input Settings, so I have the choice of Filtered HTML, Full HTML, PHP Code, OR TinyMCE. Otherwise it just doesn't seem practical - an administrator may want to add PHP code or use the WYSIWYG editor depending on the content.

#7

you can create your own input format called TinyMCE which can then be shut off when necessary.

#8

However, as long as tinymce just removes all php code from a node when you use it once, it all doesn't make much sense...

#9

I was having this problem with Drupal 6.2 with tinymce-6.x-1.1-dev

The tinymce.module file has some code that is supposed to automatically disable the tinyMCE editor for PHP content. This code was commented out.

You can work around this problem by inserting the following 'if' statement at the top of the _tinymce_page_match() function. Note the inline comment. In Drupal 6.x, your format number for PHP may not be '3' as is shown below. Check the database table 'filter_formats' to see what value your system uses.

This is clearly not a robust solution - mainly I wanted to present a work-around, and alert the module developer so they could implement something better for the next release:

function _tinymce_page_match($edit) {
  $page_match = FALSE;

  // Kill TinyMCE if we're editing a textarea with PHP in it!
  // WARNING: PHP input formats are #3 in my filter_formats table - your value may differ!!
  if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'edit') {
    $node = node_load(arg(1));
    if ($node->format == '3') {
      return FALSE;
    }
  }
  ...

This code protects PHP nodes only. I hope this helps!

Dave.

#10

The only work-around I can think of is to set the default state to "off" but allow users to turn it on as they need it. I have a webform implementation on my site and there are links to external processing and validation scripts in the "webform advanced settings" fields. These fields are text areas and so, of course, TinyMCE will convert them to RTE and delete the PHP code. To avoid this I've had to disable the RTE by default and tell all the editors and admins to click the "enable rich text" link on any text area they want to edit.

It's not a great work-around but I can't think of any other way to preserve PHP code. (BTW, I'm using drupal 5.7 - I hope this advice is still valid on 6.x)

UPDATE:
OK, forget all that. Just add the text area in question to the "off-limits" list

http://drupal.org/node/72940#comment-152119

and

http://drupal.org/node/72940#comment-219585

Again, apologies if this is no longer valid in 6.x but I just thought I should add the latest info to my post.

#11

the code above is already in my (latest Dr5 ver) of Tiny but this is only part of the solution, i also get Tiny wiping my PHP code if i do a preview.

adding this code below the code above fixes the preview issue:

  // do same if we are doing Preview and format is PHP (2)
  if ($_POST['op'] == 'Preview' && $_POST['format'] == 2) {
    return FALSE;
  }
nobody click here