Skip to content

Commit

Permalink
Item8294: Revert to using a <meta> tag, in accordance with Michael Da…
Browse files Browse the repository at this point in the history
…um's latest guidance, and back in line with how the code used to be before I tried EXPORTEDPREFERENCES.

git-svn-id: http://svn.foswiki.org/trunk@7679 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelTempest authored and MichaelTempest committed Jun 7, 2010
1 parent c719ad5 commit b04388a
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions TinyMCEPlugin/lib/Foswiki/Plugins/TinyMCEPlugin.pm
Expand Up @@ -213,28 +213,17 @@ sub beforeEditHandler {
my $pluginURL = '%PUBURLPATH%/%SYSTEMWEB%/TinyMCEPlugin';
my $tmceURL = $pluginURL . '/tinymce/jscripts/tiny_mce';

# expand and URL-encode the init string
# expand the init string
my $metainit = Foswiki::Func::expandCommonVariables($init);

# URL-encode the init string
$metainit =~ s/([^0-9a-zA-Z-_.:~!*'\/%])/'%'.sprintf('%02x',ord($1))/ge;

my $exportedPrefs = Foswiki::Func::getPreferencesValue('EXPORTEDPREFERENCES')||'';
if ($exportedPrefs) {
# Send the encoded JSON to foswiki_tiny.js via an exported preference
Foswiki::Func::setPreferencesValue( 'TINYMCEPLUGIN_INIT_ENCODED', $metainit);
my @list = split(/[,\s]+/, $exportedPrefs);
unless (grep { /^TINYMCEPLUGIN_INIT_ENCODED$/ } @list) {
push(@list, 'TINYMCEPLUGIN_INIT_ENCODED');
}
Foswiki::Func::setPreferencesValue(
'EXPORTEDPREFERENCES', join(',', @list));
}
else {
# There is no EXPORTEDPREFERENCES preference, so assume that preferences
# are not exported automatically and export it here explicitly
Foswiki::Func::addToZone('body', 'tinyMCE_init', <<"SCRIPT");
<script language="javascript" type="text/javascript">foswiki.preferences['TINYMCEPLUGIN_INIT_ENCODED']="$metainit"</script>
# SMELL: meta tag now in a separate addToHEAD for Item8566, due to
# addToZONE shenanigans. <meta> tags really do have to be in the head!
Foswiki::Func::addToZone('head', 'tinyMCE::Meta', <<"SCRIPT");
<meta name="foswiki.TINYMCEPLUGIN_INIT_ENCODED" content="$metainit" />
SCRIPT
}

my $behaving;
eval {
Expand All @@ -256,7 +245,6 @@ SCRIPT
# but Foswiki::Func.pm does not expose that function, so plugins may not use it
$encodedVersion =~ s/([^0-9a-zA-Z-_.:~!*'\/%])/'%'.sprintf('%02x',ord($1))/ge;


Foswiki::Func::addToZone('body', 'tinyMCE', <<"SCRIPT", 'tinyMCE::Meta, JQUERYPLUGIN::FOSWIKI');
<script language="javascript" type="text/javascript" src="$tmceURL/tiny_mce_jquery$USE_SRC.js?v=$encodedVersion"></script>
<script language="javascript" type="text/javascript" src="$pluginURL/foswiki_tiny$USE_SRC.js?v=$encodedVersion"></script>
Expand Down

0 comments on commit b04388a

Please sign in to comment.