As tinymce striped the code when inserting an iframe, I modified the file tinymce.inc

from $settings['extended_valid_elements'] = array();
to $settings['extended_valid_elements'] = array('script[language|type|src]');

After that the iframe code worked, but I had an issue with javascript. So I decided to remove the code, I added previously to return to the original state.

But nothing happened: Tinymce excepts still the iframe code, but strips javascript code.

I deleted tinymce and the wysiwyg modul completely and installed it again.

Still the same. It is as if my modifications to the tinymce.inc file is stored somewhere else.

Can anybody tell me, how to reset tinymce and/or the wysiwyg module? (deleting and reinstallation didn´t work).

Why is tinymce.inc not responding at all to modifications made the $settings line?

GalainHH

Comments

TwoD’s picture

Category: bug » support

There's no resetting as Drupal doesn't cache code on its own. If you removed the module and put the original version back, you should get the original behavior unless an opcode caching PHP extension is enabled.

If you have an opcode caching PHP extension enabled, such as APC, you may need to figure out how to clear its cache or reconfigure it to verify PHP files haven't changed before executing their cached opcode.

However, a module may implement hook_wysiwyg_editor_settings_alter() (see wysiwyg.api.php) and override the editor settings generated by Wysiwyg itself. (Plugins can do something similar too.) I would strongly recommend you create your own module and implement the same hook to make modifications to editor settings rather than hacking Wysiwyg itself. The extended_valid_elements setting is a bit tricky since TinyMCE can bork out if an element is defined twice. There's also a bug in Wysiwyg affecting this setting and how plugins override it: #372165: TinyMCE 3: extended_valid_elements merged wrongly
To make sure your override works the way it should, don't just append something to the existing (string) value of $settings['extended_valid_elements'] in hook_wysiwyg_editor_settings(). Figure out exactly what you want the value to be and overwrite the existing value. If your custom module's weight is higher than any other module which implements that hook, the editor will always be given exactly what you set it to.

You might also have two or more Wysiwyg modules installed anywhere under a sites/*/modules/* directoy, but only one will be used by Drupal. Modify the wrong one and you won't see any changes.
Delete the module again and check the Modules page to make sure it's not still listed. If so, check the system database table to know from which path Drupal actually loads the module, and delete that version too before reinstalling. (Also delete the entry from the system table. Be CAREFUL when doing this, you could break Drupal so make backups!)

GalainHH’s picture

I´m sorry, I made a mistake.

I was shure, that I had doublechecked that my errors don´t depend on tinymce´s version. But in facts it is just that.

Nearly at the same time, as I played with a solution to make iframes work, I installed a newer version of tinymce.
Before, I had an older Version 3.3.9.3 and installed an upgrade to version 3.4.9

It turned out, that the striping of javascript code only depends on the tinymce version. After reinstalling the 3.3.9.3 Version, I was able to "reset" everything to the environment, I had before.

So the real Problem is tinymce 3.4.x:

I installed 3.4.7, 3.4.8 and 3.4.9. All Version produced the same error: This code is striped:

<div id="1000artikelgambiooxid_hype_container" style="position: relative; overflow: hidden; width: 1100px; height: 500px;">
<script src="/mcn_basis/images/Banner/1000_Artikel_Gambio_Oxid_Resources/1000artikelgambiooxid_hype_generated_script.js?58040" type="text/javascript"></script>
</div>

So, what do you think: Shall I open a new thread "wysiwyg with tinymce 3.4.x stipes embedded javascript"?

GalainHH

TwoD’s picture

Status: Active » Fixed

I don't think a new issue is needed.

Adding the script tag and its attribute to extended_valid_elements does work for me, but only if the script tag isn't wrapped in a div tag.
I tried it on the official TinyMCE demo too to be sure this is a TinyMCE problem and not something we're doing wrong.

  1. Navigate to http://www.tinymce.com/tryit/full.php (I tested with IE8.)
  2. Click the HTML button in the toolbar.
  3. Paste <script src="foo"></script> somewhere in the source, outside any div tags.
  4. Save the source and open the HTML dialog again.
  5. Observe that the script is still there (with some proper attributes, like type, added to it).
  6. Now put <div><script src="foo"></script></div> at the same position instead.
  7. Save the source and open the HTML dialog again.
  8. Observe that the script tag is gone and <div>&nbsp;</div> is all that is left.

Since this does appear to be a TinyMCE problem (or perhaps something forbidden by the doctype used, I haven't checked), I'm closing this support request.

To work around this maybe you could use/create a Drupal text filter which turns [[adscript|/mcn_basis/images/Banner/1000_Artikel_Gambio_Oxid_Resources/1000artikelgambiooxid_hype_generated_script.js?58040]] markers into a script tag when the content is rendered (perhaps including the wrapping div if it's the same everywhere)?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

inversed’s picture