Fix r80982, re-add accidental removed AND during debugging
[lhc/web/wiklou.git] / includes / ProtectionForm.php
index 655b0be..9fb1337 100644 (file)
@@ -330,18 +330,18 @@ class ProtectionForm {
         * @return String: HTML form
         */
        function buildForm() {
-               global $wgUser, $wgLang;
+               global $wgUser, $wgLang, $wgOut;
 
                $mProtectreasonother = Xml::label( wfMsg( 'protectcomment' ), 'wpProtectReasonSelection' );
                $mProtectreason = Xml::label( wfMsg( 'protect-otherreason' ), 'mwProtect-reason' );
 
                $out = '';
                if( !$this->disabled ) {
-                       $out .= $this->buildScript();
+                       $wgOut->addModules( 'mediawiki.legacy.protect' );
                        $out .= Xml::openElement( 'form', array( 'method' => 'post',
                                'action' => $this->mTitle->getLocalUrl( 'action=protect' ),
                                'id' => 'mw-Protect-Form', 'onsubmit' => 'ProtectionForm.enableUnchainedInputs(true)' ) );
-                       $out .= Xml::hidden( 'wpEditToken',$wgUser->editToken() );
+                       $out .= Html::hidden( 'wpEditToken',$wgUser->editToken() );
                }
 
                $out .= Xml::openElement( 'fieldset' ) .
@@ -351,13 +351,10 @@ class ProtectionForm {
 
                foreach( $this->mRestrictions as $action => $selected ) {
                        /* Not all languages have V_x <-> N_x relation */
-                       $msg = wfMsg( 'restriction-' . $action );
-                       if( wfEmptyMsg( 'restriction-' . $action, $msg ) ) {
-                               $msg = $action;
-                       }
+                       $msg = wfMessage( 'restriction-' . $action );
                        $out .= "<tr><td>".
                        Xml::openElement( 'fieldset' ) .
-                       Xml::element( 'legend', null, $msg ) .
+                       Xml::element( 'legend', null, $msg->exists() ? $action : $msg->text() ) .
                        Xml::openElement( 'table', array( 'id' => "mw-protect-table-$action" ) ) .
                                "<tr><td>" . $this->buildSelector( $action, $selected ) . "</td></tr><tr><td>";
 
@@ -508,8 +505,8 @@ class ProtectionForm {
                }
 
                if ( !$this->disabled ) {
-                       $out .= Xml::closeElement( 'form' ) .
-                               $this->buildCleanupScript();
+                       $out .= Xml::closeElement( 'form' );
+                       $wgOut->addScript( $this->buildCleanupScript() );
                }
 
                return $out;
@@ -565,19 +562,14 @@ class ProtectionForm {
                if( $permission == '' ) {
                        return wfMsg( 'protect-default' );
                } else {
-                       $key = "protect-level-{$permission}";
-                       $msg = wfMsg( $key );
-                       if( wfEmptyMsg( $key, $msg ) )
-                               $msg = wfMsg( 'protect-fallback', $permission );
-                       return $msg;
+                       $msg = wfMessage( "protect-level-{$permission}" );
+                       if( !$msg->exists() ) {
+                               return $msg->text();
+                       }
+                       return wfMsg( 'protect-fallback', $permission );
                }
        }
-
-       function buildScript() {
-               global $wgStylePath, $wgStyleVersion;
-               return Html::linkedScript( "$wgStylePath/common/protect.js?$wgStyleVersion.1" );
-       }
-
+       
        function buildCleanupScript() {
                global $wgRestrictionLevels, $wgGroupPermissions;
                $script = 'var wgCascadeableLevels=';
@@ -597,7 +589,7 @@ class ProtectionForm {
                $encOptions = Xml::encodeJsVar( $options );
 
                $script .= "ProtectionForm.init($encOptions)";
-               return Html::inlineScript( $script );
+               return Html::inlineScript( "if ( window.mediaWiki ) { $script }" );
        }
 
        /**