Changeset 7679


Ignore:
Timestamp:
06/07/10 19:39:12 (2 years ago)
Author:
MichaelTempest
Message:

Item8294: Revert to using a <meta> tag, in accordance with Michael Daum's latest guidance, and back in line with how the code used to be before I tried EXPORTEDPREFERENCES.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/TinyMCEPlugin/lib/Foswiki/Plugins/TinyMCEPlugin.pm

    r7644 r7679  
    214214    my $tmceURL   = $pluginURL . '/tinymce/jscripts/tiny_mce'; 
    215215 
    216     # expand and URL-encode the init string 
     216    # expand the init string 
    217217    my $metainit = Foswiki::Func::expandCommonVariables($init); 
     218 
     219    # URL-encode the init string 
    218220    $metainit =~ s/([^0-9a-zA-Z-_.:~!*'\/%])/'%'.sprintf('%02x',ord($1))/ge; 
    219221 
    220     my $exportedPrefs = Foswiki::Func::getPreferencesValue('EXPORTEDPREFERENCES')||''; 
    221     if ($exportedPrefs) { 
    222         # Send the encoded JSON to foswiki_tiny.js via an exported preference 
    223         Foswiki::Func::setPreferencesValue( 'TINYMCEPLUGIN_INIT_ENCODED', $metainit); 
    224         my @list = split(/[,\s]+/, $exportedPrefs); 
    225         unless (grep { /^TINYMCEPLUGIN_INIT_ENCODED$/ } @list) { 
    226             push(@list, 'TINYMCEPLUGIN_INIT_ENCODED'); 
    227         } 
    228         Foswiki::Func::setPreferencesValue( 
    229             'EXPORTEDPREFERENCES', join(',', @list)); 
    230     } 
    231     else { 
    232         # There is no EXPORTEDPREFERENCES preference, so assume that preferences 
    233         # are not exported automatically and export it here explicitly 
    234     Foswiki::Func::addToZone('body', 'tinyMCE_init', <<"SCRIPT"); 
    235 <script language="javascript" type="text/javascript">foswiki.preferences['TINYMCEPLUGIN_INIT_ENCODED']="$metainit"</script> 
     222    # SMELL: meta tag now in a separate addToHEAD for Item8566, due to 
     223    # addToZONE shenanigans. <meta> tags really do have to be in the head! 
     224    Foswiki::Func::addToZone('head', 'tinyMCE::Meta', <<"SCRIPT"); 
     225<meta name="foswiki.TINYMCEPLUGIN_INIT_ENCODED" content="$metainit" /> 
    236226SCRIPT 
    237     } 
    238227 
    239228    my $behaving; 
     
    257246    $encodedVersion =~ s/([^0-9a-zA-Z-_.:~!*'\/%])/'%'.sprintf('%02x',ord($1))/ge; 
    258247 
    259  
    260248    Foswiki::Func::addToZone('body', 'tinyMCE', <<"SCRIPT", 'tinyMCE::Meta, JQUERYPLUGIN::FOSWIKI'); 
    261249<script language="javascript" type="text/javascript" src="$tmceURL/tiny_mce_jquery$USE_SRC.js?v=$encodedVersion"></script> 
Note: See TracChangeset for help on using the changeset viewer.