Added a User parameter to SpecialPageFactory::getUsablePages() so that it does not...
[lhc/web/wiklou.git] / includes / SpecialPage.php
index b943b51..7548200 100644 (file)
@@ -189,11 +189,13 @@ class SpecialPage {
         * Return categorised listable special pages which are available
         * for the current user, and everyone.
         *
+        * @param $user User object to check permissions, $wgUser will be used
+        *              if not provided
         * @return Associative array mapping page's name to its SpecialPage object
         * @deprecated since 1.18 call SpecialPageFactory method directly
         */
-       static function getUsablePages() {
-               return SpecialPageFactory::getUsablePages();
+       static function getUsablePages( User $user = null ) {
+               return SpecialPageFactory::getUsablePages( $user );
        }
 
        /**
@@ -558,7 +560,7 @@ class SpecialPage {
                } else {
                        $msg = $summaryMessageKey;
                }
-               if ( !wfMessage( $msg )->isBlank() and ! $this->including() ) {
+               if ( !$this->msg( $msg )->isBlank() && !$this->including() ) {
                        $this->getOutput()->wrapWikiMsg(
                                "<div class='mw-specialpage-summary'>\n$1\n</div>", $msg );
                }
@@ -576,7 +578,7 @@ class SpecialPage {
         * @return String
         */
        function getDescription() {
-               return wfMsg( strtolower( $this->mName ) );
+               return $this->msg( strtolower( $this->mName ) )->text();
        }
 
        /**
@@ -681,7 +683,12 @@ class SpecialPage {
         * @see wfMessage
         */
        public function msg( /* $args */ ) {
-               return call_user_func_array( array( $this->getContext(), 'msg' ), func_get_args() );
+               // Note: can't use func_get_args() directly as second or later item in
+               // a parameter list until PHP 5.3 or you get a fatal error.
+               // Works fine as the first parameter, which appears elsewhere in the
+               // code base. Sighhhh.
+               $args = func_get_args();
+               return call_user_func_array( array( $this->getContext(), 'msg' ), $args );
        }
 
        /**
@@ -690,14 +697,14 @@ class SpecialPage {
         * @param $params array
         */
        protected function addFeedLinks( $params ) {
-               global $wgFeedClasses, $wgOut;
+               global $wgFeedClasses;
 
                $feedTemplate = wfScript( 'api' ) . '?';
 
                foreach( $wgFeedClasses as $format => $class ) {
                        $theseParams = $params + array( 'feedformat' => $format );
                        $url = $feedTemplate . wfArrayToCGI( $theseParams );
-                       $wgOut->addFeedLink( $format, $url );
+                       $this->getOutput()->addFeedLink( $format, $url );
                }
        }
 }
@@ -737,9 +744,9 @@ abstract class FormSpecialPage extends SpecialPage {
 
                $form = new HTMLForm( $this->fields, $this->getContext() );
                $form->setSubmitCallback( array( $this, 'onSubmit' ) );
-               $form->setWrapperLegend( wfMessage( strtolower( $this->getName() ) . '-legend' ) );
+               $form->setWrapperLegend( $this->msg( strtolower( $this->getName() ) . '-legend' ) );
                $form->addHeaderText(
-                       wfMessage( strtolower( $this->getName() ) . '-text' )->parseAsBlock() );
+                       $this->msg( strtolower( $this->getName() ) . '-text' )->parseAsBlock() );
 
                // Retain query parameters (uselang etc)
                $params = array_diff_key(
@@ -1000,7 +1007,9 @@ class SpecialMypage extends RedirectSpecialPage {
        function __construct() {
                parent::__construct( 'Mypage' );
                $this->mAllowedRedirectParams = array( 'action' , 'preload' , 'editintro',
-                       'section', 'oldid', 'diff', 'dir' );
+                       'section', 'oldid', 'diff', 'dir',
+                       // Options for action=raw; missing ctype can break JS or CSS in some browsers
+                       'ctype', 'maxage', 'smaxage' );
        }
 
        function getRedirect( $subpage ) {