http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74119

Revision: 74119
Author:   kaldari
Date:     2010-10-01 22:45:08 +0000 (Fri, 01 Oct 2010)

Log Message:
-----------
alert for document.write issue

Modified Paths:
--------------
    trunk/extensions/CentralNotice/CentralNotice.i18n.php
    trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
    trunk/extensions/CentralNotice/centralnotice.js

Modified: trunk/extensions/CentralNotice/CentralNotice.i18n.php
===================================================================
--- trunk/extensions/CentralNotice/CentralNotice.i18n.php       2010-10-01 
22:32:56 UTC (rev 74118)
+++ trunk/extensions/CentralNotice/CentralNotice.i18n.php       2010-10-01 
22:45:08 UTC (rev 74119)
@@ -132,6 +132,7 @@
        'centralnotice-no-allocation' => 'No banners allocated.',
        'centralnotice-allocation-description' => 'Banner allocation for $1.$2 
in $3:',
        'centralnotice-percentage' => 'Percentage',
+       'centralnotice-documentwrite-error' => "document.write() cannot be used 
within a banner.\nSee http://meta.wikimedia.org/wiki/Help:CentralNotice for 
more information.",
        
        'right-centralnotice-admin' => 'Manage central notices',
        'right-centralnotice-translate' => 'Translate central notices',

Modified: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialNoticeTemplate.php    2010-10-01 
22:32:56 UTC (rev 74118)
+++ trunk/extensions/CentralNotice/SpecialNoticeTemplate.php    2010-10-01 
22:45:08 UTC (rev 74119)
@@ -25,6 +25,12 @@
                // Add style file to the output headers
                $wgOut->addExtensionStyle( 
"$wgScriptPath/extensions/CentralNotice/centralnotice.css" );
                
+               // Add localized script error messages
+               $scriptVars = array(
+                       'documentWriteError' => wfMsg( 
'centralnotice-documentwrite-error' )
+               );
+               $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) );
+               
                // Add script file to the output headers
                $wgOut->addScriptFile( 
"$wgScriptPath/extensions/CentralNotice/centralnotice.js" );
 
@@ -213,7 +219,7 @@
                // Build HTML
                $htmlOut = '';
                $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 
'prefsection' ) );
-               $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post' 
) );
+               $htmlOut .= Xml::openElement( 'form', array( 'method' => 
'post', 'onsubmit' => 'return validateBannerForm(this)' ) );
                $htmlOut .= Xml::element( 'h2', null, wfMsg( 
'centralnotice-add-template' ) );
                $htmlOut .= Xml::hidden( 'wpMethod', 'addTemplate' );
                $htmlOut .= Xml::tags( 'p', null,
@@ -461,7 +467,7 @@
        
                        // Show edit form
                        if ( $this->editable ) {
-                               $htmlOut .= Xml::openElement( 'form', array( 
'method' => 'post' ) );
+                               $htmlOut .= Xml::openElement( 'form', array( 
'method' => 'post', 'onsubmit' => 'return validateBannerForm(this)' ) );
                                $htmlOut .= Xml::hidden( 'wpMethod', 
'editTemplate' );
                        }
                        

Modified: trunk/extensions/CentralNotice/centralnotice.js
===================================================================
--- trunk/extensions/CentralNotice/centralnotice.js     2010-10-01 22:32:56 UTC 
(rev 74118)
+++ trunk/extensions/CentralNotice/centralnotice.js     2010-10-01 22:45:08 UTC 
(rev 74119)
@@ -1,4 +1,4 @@
-function selectLanguages(selectAll) {
+function selectLanguages( selectAll ) {
        var selectBox = document.getElementById('project_languages[]');
        var firstSelect = selectBox.options.length - 1;
        for (var i = firstSelect; i >= 0; i--) {
@@ -46,6 +46,18 @@
        }
        bannerField.focus();
 }
+function validateBannerForm( form ) {
+       var output = '';
+       var pos = form.templateBody.value.indexOf("document.write");
+       if( pos > -1 ) {
+               output += documentWriteError + '\n';
+       }
+       if( output ) {
+               alert( output );
+               return false;
+       }
+       return true;
+}
 // Handle revealing the geoMultiSelector when the geotargetted checkbox is 
checked
 ( function( $ ) {
        $(document).ready(function() {



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to