Localisation updates for core and extension messages from translatewiki.net
[lhc/web/wiklou.git] / includes / Skin.php
index 5d0f877..9ecb615 100644 (file)
@@ -165,6 +165,9 @@ abstract class Skin extends ContextSource {
                return $this->skinname;
        }
 
+       /**
+        * @param $out OutputPage
+        */
        function initPage( OutputPage $out ) {
                wfProfileIn( __METHOD__ );
 
@@ -284,6 +287,10 @@ abstract class Skin extends ContextSource {
         */
        abstract function outputPage( OutputPage $out = null );
 
+       /**
+        * @param $data array
+        * @return string
+        */
        static function makeVariablesScript( $data ) {
                if ( $data ) {
                        return Html::inlineScript(
@@ -294,6 +301,21 @@ abstract class Skin extends ContextSource {
                }
        }
 
+       /**
+        * Make a <script> tag containing global variables
+        *
+        * @deprecated in 1.19
+        * @param $unused Unused
+        * @return string HTML fragment
+        */
+       public static function makeGlobalVariablesScript( $unused ) {
+               global $wgOut;
+
+               wfDeprecated( __METHOD__, '1.19' );
+
+               return self::makeVariablesScript( $wgOut->getJSVars() );
+       }
+
        /**
         * Get the query to generate a dynamic stylesheet
         *
@@ -369,6 +391,9 @@ abstract class Skin extends ContextSource {
                return $wgLogo;
        }
 
+       /**
+        * @return string
+        */
        function getCategoryLinks() {
                global $wgUseCategoryBrowser;
 
@@ -456,6 +481,9 @@ abstract class Skin extends ContextSource {
                return $return;
        }
 
+       /**
+        * @return string
+        */
        function getCategories() {
                $out = $this->getOutput();
 
@@ -518,15 +546,21 @@ abstract class Skin extends ContextSource {
        protected function generateDebugHTML() {
                global $wgShowDebug;
 
+               $html = MWDebug::getDebugHTML( $this->getContext() );
+
                if ( $wgShowDebug ) {
                        $listInternals = $this->formatDebugHTML( $this->getOutput()->mDebugtext );
-                       return "\n<hr />\n<strong>Debug data:</strong><ul id=\"mw-debug-html\">" .
+                       $html .= "\n<hr />\n<strong>Debug data:</strong><ul id=\"mw-debug-html\">" .
                                $listInternals . "</ul>\n";
                }
 
-               return '';
+               return $html;
        }
 
+       /**
+        * @param $debugText string
+        * @return string
+        */
        private function formatDebugHTML( $debugText ) {
                global $wgDebugTimestamps;
 
@@ -538,7 +572,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 +643,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 +672,9 @@ abstract class Skin extends ContextSource {
                return '';
        }
 
+       /**
+        * @return string
+        */
        function subPageSubtitle() {
                $out = $this->getOutput();
                $subpages = '';
@@ -693,15 +733,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 $type string
+        * @return string
+        */
        function getCopyright( $type = 'detect' ) {
                global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgContLang;
 
@@ -740,7 +790,7 @@ abstract class Skin extends ContextSource {
                if ( $forContent ) {
                        $msg = $msgObj->inContentLanguage()->text();
                        if ( $this->getLanguage()->getCode() !== $wgContLang->getCode() ) {
-                               $msg = Html::rawElement( 'span', array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ), $msg );
+                               $msg = Html::rawElement( 'span', array( 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ), $msg );
                        }
                        return $msg;
                } else {
@@ -748,6 +798,9 @@ abstract class Skin extends ContextSource {
                }
        }
 
+       /**
+        * @return null|string
+        */
        function getCopyrightIcon() {
                global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
 
@@ -790,14 +843,14 @@ abstract class Skin extends ContextSource {
        /**
         * Get the timestamp of the latest revision, formatted in user language
         *
-        * @param $page WikiPage object. Used if we're working with the current revision
         * @return String
         */
-       protected function lastModified( $page ) {
-               if ( !$this->isRevisionCurrent() ) {
+       protected function lastModified() {
+               $timestamp = $this->getOutput()->getRevisionTimestamp();
+
+               # No cached timestamp, load it from the database
+               if ( $timestamp === null ) {
                        $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() );
-               } else {
-                       $timestamp = $page->getTimestamp();
                }
 
                if ( $timestamp ) {
@@ -815,6 +868,10 @@ abstract class Skin extends ContextSource {
                return $s;
        }
 
+       /**
+        * @param $align string
+        * @return string
+        */
        function logoText( $align = '' ) {
                if ( $align != '' ) {
                        $a = " align='{$align}'";
@@ -824,7 +881,7 @@ abstract class Skin extends ContextSource {
 
                $mp = $this->msg( 'mainpage' )->escaped();
                $mptitle = Title::newMainPage();
-               $url = ( is_object( $mptitle ) ? $mptitle->escapeLocalURL() : '' );
+               $url = ( is_object( $mptitle ) ? htmlspecialchars( $mptitle->getLocalURL() ) : '' );
 
                $logourl = $this->getLogo();
                $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
@@ -869,6 +926,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 +990,10 @@ abstract class Skin extends ContextSource {
                return $options;
        }
 
+       /**
+        * @param $id User|int
+        * @return bool
+        */
        function showEmailUser( $id ) {
                if ( $id instanceof User ) {
                        $targetUser = $id;
@@ -963,6 +1029,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 +1041,43 @@ abstract class Skin extends ContextSource {
                return $title->getLocalURL( $urlaction );
        }
 
+       /**
+        * @param $name string
+        * @param $urlaction string
+        * @return String
+        */
        static function makeSpecialUrl( $name, $urlaction = '' ) {
                $title = SpecialPage::getSafeTitleFor( $name );
                return $title->getLocalURL( $urlaction );
        }
 
+       /**
+        * @param $name string
+        * @param $subpage string
+        * @param $urlaction string
+        * @return String
+        */
        static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
                $title = SpecialPage::getSafeTitleFor( $name, $subpage );
                return $title->getLocalURL( $urlaction );
        }
 
+       /**
+        * @param $name string
+        * @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 string
+        * @param $urlaction string
+        * @return String
+        */
        static function makeUrl( $name, $urlaction = '' ) {
                $title = Title::newFromText( $name );
                self::checkTitle( $title, $name );
@@ -1007,7 +1099,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 +1113,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 +1145,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 string
+        */
        static function checkTitle( &$title, $name ) {
                if ( !is_object( $title ) ) {
                        $title = Title::newFromText( $name );
@@ -1088,7 +1196,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 +1206,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 +1253,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;
@@ -1299,7 +1407,7 @@ abstract class Skin extends ContextSource {
                }
 
                $notice = Html::rawElement( 'div', array( 'id' => 'localNotice',
-                       'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ), $notice );
+                       'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ), $notice );
                wfProfileOut( __METHOD__ );
                return $notice;
        }