I had been having a lot of difficulty getting most of the settings to take effect. E.g., TinyMCE was filtering my content, and despite turning all of those options off through the module, TinyMCE behaved the same each time.

When I looked at the code, I got a little confused, and wanted to see if I was missing something here.

So the editor sets up the init array for each option. When we get to verify_html, we have something like...

$init['verify_html'] = $settings['verify_html'] ? $settings['verify_html'] : TRUE;

... but if it's set to false or 0 in the settings, isn't "$settings['verify_html']" going to evaluate to false, which will end up setting the $init value to the fallback value, TRUE? It seems like the intention would be to check that $settings['verify_html'] is defined, or that it's not blank, or something like that.

So indeed, when I change that line to:

$init['verify_html'] = isset( $settings['verify_html'] ) ? $settings['verify_html'] == TRUE : TRUE;

... it worked. And note that I used $settings['verify_html'] == TRUE for when the variable isset, because in my system at least the value in settings was coming out as a 1 or a 0, which TinyMCE did not seem to understand for some reason, whereas "true" or "false" as values do seem to work.

I was just curious, because right out of the box it doesn't seem like any of those "enabled/disabled" options are able to take effect. Even more obvious settings like "Default state" don't seem to do anything without changing that ternary code. But, if the original code is doing what it's supposed to, and I'm doing something wrong elsewhere, I would appreciate if I could find out where I might be going wrong.

Comments

sun’s picture

Well, that's possible. All of those $settings['verify_html'] ? $settings['verify_html'] : TRUE still need to be turned into $settings['verify_html'], because initialization of the $settings array needs to be ensured at the beginning of the function, just like in the administrative form builder function.

PeteS’s picture

Not sure if I follow... is the code that is there now supposed to work? If not, it seems like a pretty serious issue that most of the options essentially do nothing.

kevinquillen’s picture

It's entirely possible that some days I wear black, others green, and pizza.

sun’s picture

I'm not sure either (only using the default settings currently). If it is the case, all inline-ifs need to be removed. All profile configuration values need to be initialized like in wysiwyg_editor_profile_form() in wysiwyg_editor.admin.inc.

EDIT: Of course, that initialization code needs to be re-factored into an own function, so we do not repeat this code.

sun’s picture

Status: Active » Closed (duplicate)

Marking as duplicate of #304243: JavaScript interprets the string "0" as true, which contains a patch. Please test.