Revert r104659 and its followup r104665: break the unit tests with a fatal error...
[lhc/web/wiklou.git] / includes / Skin.php
index 43176f2..d69408f 100644 (file)
@@ -165,6 +165,9 @@ abstract class Skin extends ContextSource {
                return $this->skinname;
        }
 
+       /**
+        * @param $out OutputPage
+        */
        function initPage( OutputPage $out ) {
                wfProfileIn( __METHOD__ );
 
@@ -269,7 +272,7 @@ abstract class Skin extends ContextSource {
                                $this->mRelevantUser = User::newFromName( $rootUser, false );
                        } else {
                                $user = User::newFromName( $rootUser, false );
-                               if ( $user->isLoggedIn() ) {
+                               if ( $user && $user->isLoggedIn() ) {
                                        $this->mRelevantUser = $user;
                                }
                        }
@@ -284,6 +287,10 @@ abstract class Skin extends ContextSource {
         */
        abstract function outputPage( OutputPage $out = null );
 
+       /**
+        * @param $data
+        * @return string
+        */
        static function makeVariablesScript( $data ) {
                if ( $data ) {
                        return Html::inlineScript(
@@ -369,6 +376,9 @@ abstract class Skin extends ContextSource {
                return $wgLogo;
        }
 
+       /**
+        * @return string
+        */
        function getCategoryLinks() {
                global $wgUseCategoryBrowser;
 
@@ -456,6 +466,9 @@ abstract class Skin extends ContextSource {
                return $return;
        }
 
+       /**
+        * @return string
+        */
        function getCategories() {
                $out = $this->getOutput();
 
@@ -527,6 +540,10 @@ abstract class Skin extends ContextSource {
                return '';
        }
 
+       /**
+        * @param $debugText
+        * @return string
+        */
        private function formatDebugHTML( $debugText ) {
                global $wgDebugTimestamps;
 
@@ -538,7 +555,7 @@ abstract class Skin extends ContextSource {
                        $pre = '';
                        if ( $wgDebugTimestamps ) {
                                $matches = array();
-                               if ( preg_match( '/^(\d+\.\d+   \d+.\dM\s{2})/', $line, $matches ) ) {
+                               if ( preg_match( '/^(\d+\.\d+ {1,3}\d+.\dM\s{2})/', $line, $matches ) ) {
                                        $pre = $matches[1];
                                        $line = substr( $line, strlen( $pre ) );
                                }
@@ -609,6 +626,9 @@ abstract class Skin extends ContextSource {
                return $this->msg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' )->text();
        }
 
+       /**
+        * @return String
+        */
        function getUndeleteLink() {
                $action = $this->getRequest()->getVal( 'action', 'view' );
 
@@ -635,6 +655,9 @@ abstract class Skin extends ContextSource {
                return '';
        }
 
+       /**
+        * @return string
+        */
        function subPageSubtitle() {
                $out = $this->getOutput();
                $subpages = '';
@@ -693,15 +716,25 @@ abstract class Skin extends ContextSource {
                return $wgShowIPinHeader && session_id() != '';
        }
 
+       /**
+        * @return String
+        */
        function getSearchLink() {
                $searchPage = SpecialPage::getTitleFor( 'Search' );
                return $searchPage->getLocalURL();
        }
 
+       /**
+        * @return string
+        */
        function escapeSearchLink() {
                return htmlspecialchars( $this->getSearchLink() );
        }
 
+       /**
+        * @param string $type
+        * @return string
+        */
        function getCopyright( $type = 'detect' ) {
                global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgContLang;
 
@@ -739,7 +772,7 @@ abstract class Skin extends ContextSource {
                $msgObj = $this->msg( $msg )->rawParams( $link );
                if ( $forContent ) {
                        $msg = $msgObj->inContentLanguage()->text();
-                       if ( $this->getLang()->getCode() !== $wgContLang->getCode() ) {
+                       if ( $this->getLanguage()->getCode() !== $wgContLang->getCode() ) {
                                $msg = Html::rawElement( 'span', array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ), $msg );
                        }
                        return $msg;
@@ -748,6 +781,9 @@ abstract class Skin extends ContextSource {
                }
        }
 
+       /**
+        * @return null|string
+        */
        function getCopyrightIcon() {
                global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
 
@@ -790,19 +826,19 @@ abstract class Skin extends ContextSource {
        /**
         * Get the timestamp of the latest revision, formatted in user language
         *
-        * @param $article Article object. Used if we're working with the current revision
+        * @param $page WikiPage object. Used if we're working with the current revision
         * @return String
         */
-       protected function lastModified( $article ) {
+       protected function lastModified( $page ) {
                if ( !$this->isRevisionCurrent() ) {
                        $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() );
                } else {
-                       $timestamp = $article->getTimestamp();
+                       $timestamp = $page->getTimestamp();
                }
 
                if ( $timestamp ) {
-                       $d = $this->getLang()->userDate( $timestamp, $this->getUser() );
-                       $t = $this->getLang()->userTime( $timestamp, $this->getUser() );
+                       $d = $this->getLanguage()->userDate( $timestamp, $this->getUser() );
+                       $t = $this->getLanguage()->userTime( $timestamp, $this->getUser() );
                        $s = ' ' . $this->msg( 'lastmodifiedat', $d, $t )->text();
                } else {
                        $s = '';
@@ -815,6 +851,10 @@ abstract class Skin extends ContextSource {
                return $s;
        }
 
+       /**
+        * @param $align string
+        * @return string
+        */
        function logoText( $align = '' ) {
                if ( $align != '' ) {
                        $a = " align='{$align}'";
@@ -869,6 +909,11 @@ abstract class Skin extends ContextSource {
                return $s;
        }
 
+       /**
+        * @param $desc
+        * @param $page
+        * @return string
+        */
        public function footerLink( $desc, $page ) {
                // if the link description has been set to "-" in the default language,
                if ( $this->msg( $desc )->inContentLanguage()->isDisabled() ) {
@@ -928,6 +973,10 @@ abstract class Skin extends ContextSource {
                return $options;
        }
 
+       /**
+        * @param $id
+        * @return bool
+        */
        function showEmailUser( $id ) {
                if ( $id instanceof User ) {
                        $targetUser = $id;
@@ -963,6 +1012,11 @@ abstract class Skin extends ContextSource {
        }
 
        /* these are used extensively in SkinTemplate, but also some other places */
+
+       /**
+        * @param $urlaction string
+        * @return String
+        */
        static function makeMainPageUrl( $urlaction = '' ) {
                $title = Title::newMainPage();
                self::checkTitle( $title, '' );
@@ -970,22 +1024,43 @@ abstract class Skin extends ContextSource {
                return $title->getLocalURL( $urlaction );
        }
 
+       /**
+        * @param $name
+        * @param $urlaction string
+        * @return String
+        */
        static function makeSpecialUrl( $name, $urlaction = '' ) {
                $title = SpecialPage::getSafeTitleFor( $name );
                return $title->getLocalURL( $urlaction );
        }
 
+       /**
+        * @param $name
+        * @param $subpage
+        * @param $urlaction string
+        * @return String
+        */
        static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
                $title = SpecialPage::getSafeTitleFor( $name, $subpage );
                return $title->getLocalURL( $urlaction );
        }
 
+       /**
+        * @param $name
+        * @param $urlaction string
+        * @return String
+        */
        static function makeI18nUrl( $name, $urlaction = '' ) {
                $title = Title::newFromText( wfMsgForContent( $name ) );
                self::checkTitle( $title, $name );
                return $title->getLocalURL( $urlaction );
        }
 
+       /**
+        * @param $name
+        * @param $urlaction string
+        * @return String
+        */
        static function makeUrl( $name, $urlaction = '' ) {
                $title = Title::newFromText( $name );
                self::checkTitle( $title, $name );
@@ -1007,7 +1082,13 @@ abstract class Skin extends ContextSource {
                }
        }
 
-       # this can be passed the NS number as defined in Language.php
+       /**
+        * this can be passed the NS number as defined in Language.php
+        * @param $name
+        * @param $urlaction string
+        * @param $namespace int
+        * @return String
+        */
        static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
                $title = Title::makeTitleSafe( $namespace, $name );
                self::checkTitle( $title, $name );
@@ -1015,7 +1096,12 @@ abstract class Skin extends ContextSource {
                return $title->getLocalURL( $urlaction );
        }
 
-       /* these return an array with the 'href' and boolean 'exists' */
+       /**
+        * these return an array with the 'href' and boolean 'exists'
+        * @param $name
+        * @param $urlaction string
+        * @return array
+        */
        static function makeUrlDetails( $name, $urlaction = '' ) {
                $title = Title::newFromText( $name );
                self::checkTitle( $title, $name );
@@ -1042,7 +1128,12 @@ abstract class Skin extends ContextSource {
                );
        }
 
-       # make sure we have some title to operate on
+       /**
+        * make sure we have some title to operate on
+        *
+        * @param $title Title
+        * @param $name
+        */
        static function checkTitle( &$title, $name ) {
                if ( !is_object( $title ) ) {
                        $title = Title::newFromText( $name );
@@ -1061,7 +1152,7 @@ abstract class Skin extends ContextSource {
                global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
                wfProfileIn( __METHOD__ );
 
-               $key = wfMemcKey( 'sidebar', $this->getLang()->getCode() );
+               $key = wfMemcKey( 'sidebar', $this->getLanguage()->getCode() );
 
                if ( $wgEnableSidebarCache ) {
                        $cachedsidebar = $parserMemc->get( $key );
@@ -1088,7 +1179,7 @@ abstract class Skin extends ContextSource {
         *
         * This is just a wrapper around addToSidebarPlain() for backwards compatibility
         *
-        * @param &$bar array
+        * @param $bar array
         * @param $message String
         */
        function addToSidebar( &$bar, $message ) {
@@ -1098,7 +1189,7 @@ abstract class Skin extends ContextSource {
        /**
         * Add content from plain text
         * @since 1.17
-        * @param &$bar array
+        * @param $bar array
         * @param $text string
         * @return Array
         */
@@ -1145,13 +1236,13 @@ abstract class Skin extends ContextSource {
 
                                        if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
                                                $href = $link;
-                                               
+
                                                // Parser::getExternalLinkAttribs won't work here because of the Namespace things
                                                global $wgNoFollowLinks, $wgNoFollowDomainExceptions;
                                                if ( $wgNoFollowLinks && !wfMatchesDomainList( $href, $wgNoFollowDomainExceptions ) ) {
                                                        $extraAttribs['rel'] = 'nofollow';
                                                }
-                                               
+
                                                global $wgExternalLinkTarget;
                                                if ( $wgExternalLinkTarget) {
                                                        $extraAttribs['target'] = $wgExternalLinkTarget;