* Fix bug with Protected namespace message when protected namespace is NS_MAIN.
authorDaniel Cannon <amidaniel@users.mediawiki.org>
Thu, 16 Aug 2007 07:05:38 +0000 (07:05 +0000)
committerDaniel Cannon <amidaniel@users.mediawiki.org>
Thu, 16 Aug 2007 07:05:38 +0000 (07:05 +0000)
* Clean up formatPermissionsErrorMessage .. no point building a list if there's only one item, and it casues lots of grossness on complicated custom messages (removing linebreaks, screwing up formatting, etc.).

includes/OutputPage.php
includes/Title.php

index 30cfd7d..1b47085 100644 (file)
@@ -966,22 +966,28 @@ class OutputPage {
        }
 
        /**
-        * @param array $errors An array returned by Title::getUserPermissionsErrors
+        * @param array $errors An array of arrays returned by Title::getUserPermissionsErrors
         * @return string The error-messages, formatted into a list.
         */
        public function formatPermissionsErrorMessage( $errors ) {
                $text = '';
 
-               $text .= wfMsgExt( 'permissionserrorstext', array( 'parse' ), count( $errors ) ) . "\n";
-               $text .= '<ul class="permissions-errors">' . "\n";
+               if (sizeof( $errors ) > 1) {
 
-               foreach( $errors as $error )
-               {
-                       $text .= '<li>';
-                       $text .= call_user_func_array( 'wfMsg', $error );
-                       $text .= "</li>\n";
+                       $text .= wfMsgExt( 'permissionserrorstext', array( 'parse' ), count( $errors ) ) . "\n";
+                       $text .= '<ul class="permissions-errors">' . "\n";
+
+                       foreach( $errors as $error )
+                       {
+                               $text .= '<li>';
+                               foreach ($error as $e) echo $e;
+                                       $text .= call_user_func_array( 'wfMsg', $error );
+                               $text .= "</li>\n";
+                       }
+                       $text .= '</ul>';
+               } else {
+                       $text .= call_user_func_array( 'wfMsg', $errors[0]);
                }
-               $text .= '</ul>';
 
                return $text;
        }
@@ -1322,4 +1328,4 @@ class OutputPage {
                }
        }
        
-}
\ No newline at end of file
+}
index a996764..73bf7ad 100644 (file)
@@ -1096,7 +1096,6 @@ class Title {
         * @return array Array of arrays of the arguments to wfMsg to explain permissions problems.
         */
        private function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) {
-               global $wgContLang;
                $fname = 'Title::userCan';
                wfProfileIn( $fname );
 
@@ -1111,7 +1110,12 @@ class Title {
                }
                
                if ( $this->isNamespaceProtected() ) {
-                       $errors[] = (NS_MEDIAWIKI == $this->mNamespace ? array('protectedinterface') : array( 'namespaceprotected', $wgContLang->getNSText( $this->mNamespace ) ) );
+                       $ns = $this->getNamespace() == NS_MAIN
+                               ? wfMsg( 'nstab-main' )
+                               : $this->getNsText();
+                       $errors[] = (NS_MEDIAWIKI == $this->mNamespace 
+                               ? array('protectedinterface') 
+                               : array( 'namespaceprotected',  $ns ) );
                }
 
                if( $this->mDbkeyform == '_' ) {