Localisation updates from https://translatewiki.net.
[lhc/web/wiklou.git] / includes / Skin.php
index 59c2242..9d1034b 100644 (file)
@@ -39,7 +39,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * Fetch the set of available skins.
-        * @return array associative array of strings
+        * @return array Associative array of strings
         */
        static function getSkinNames() {
                global $wgValidSkinNames;
@@ -77,7 +77,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * Fetch the skinname messages for available skins.
-        * @return array of strings
+        * @return string[]
         */
        static function getSkinNameMessages() {
                $messages = array();
@@ -193,14 +193,14 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * @return string skin name
+        * @return string Skin name
         */
        public function getSkinName() {
                return $this->skinname;
        }
 
        /**
-        * @param $out OutputPage
+        * @param OutputPage $out
         */
        function initPage( OutputPage $out ) {
                wfProfileIn( __METHOD__ );
@@ -214,7 +214,7 @@ abstract class Skin extends ContextSource {
         * Defines the ResourceLoader modules that should be added to the skin
         * It is recommended that skins wishing to override call parent::getDefaultModules()
         * and substitute out any modules they wish to change by using a key to look them up
-        * @return Array of modules with helper keys for easy overriding
+        * @return array Array of modules with helper keys for easy overriding
         */
        public function getDefaultModules() {
                global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax,
@@ -296,7 +296,7 @@ abstract class Skin extends ContextSource {
        /**
         * Get the current revision ID
         *
-        * @return Integer
+        * @return int
         */
        public function getRevisionId() {
                return $this->getOutput()->getRevisionId();
@@ -305,7 +305,7 @@ abstract class Skin extends ContextSource {
        /**
         * Whether the revision displayed is the latest revision of the page
         *
-        * @return Boolean
+        * @return bool
         */
        public function isRevisionCurrent() {
                $revID = $this->getRevisionId();
@@ -315,7 +315,7 @@ abstract class Skin extends ContextSource {
        /**
         * Set the "relevant" title
         * @see self::getRelevantTitle()
-        * @param $t Title object to use
+        * @param Title $t
         */
        public function setRelevantTitle( $t ) {
                $this->mRelevantTitle = $t;
@@ -341,7 +341,7 @@ abstract class Skin extends ContextSource {
        /**
         * Set the "relevant" user
         * @see self::getRelevantUser()
-        * @param $u User object to use
+        * @param User $u
         */
        public function setRelevantUser( $u ) {
                $this->mRelevantUser = $u;
@@ -377,12 +377,12 @@ abstract class Skin extends ContextSource {
 
        /**
         * Outputs the HTML generated by other functions.
-        * @param $out OutputPage
+        * @param OutputPage $out
         */
        abstract function outputPage( OutputPage $out = null );
 
        /**
-        * @param $data array
+        * @param array $data
         * @return string
         */
        static function makeVariablesScript( $data ) {
@@ -399,7 +399,7 @@ abstract class Skin extends ContextSource {
         * Make a "<script>" tag containing global variables
         *
         * @deprecated since 1.19
-        * @param $unused
+        * @param mixed $unused
         * @return string HTML fragment
         */
        public static function makeGlobalVariablesScript( $unused ) {
@@ -432,15 +432,15 @@ abstract class Skin extends ContextSource {
         * Calling this method with an $out of anything but the same OutputPage
         * inside ->getOutput() is deprecated. The $out arg is kept
         * for compatibility purposes with skins.
-        * @param $out OutputPage
+        * @param OutputPage $out
         * @todo delete
         */
        abstract function setupSkinUserCss( OutputPage $out );
 
        /**
         * TODO: document
-        * @param $title Title
-        * @return String
+        * @param Title $title
+        * @return string
         */
        function getPageClasses( $title ) {
                $numeric = 'ns-' . $title->getNamespace();
@@ -482,8 +482,8 @@ abstract class Skin extends ContextSource {
         * This will be called by OutputPage::headElement when it is creating the
         * "<body>" tag, skins can override it if they have a need to add in any
         * body attributes or classes of their own.
-        * @param $out OutputPage
-        * @param $bodyAttrs Array
+        * @param OutputPage $out
+        * @param array $bodyAttrs
         */
        function addToBodyAttributes( $out, &$bodyAttrs ) {
                // does nothing by default
@@ -491,7 +491,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * URL to the logo
-        * @return String
+        * @return string
         */
        function getLogo() {
                global $wgLogo;
@@ -565,8 +565,8 @@ abstract class Skin extends ContextSource {
 
        /**
         * Render the array as a series of links.
-        * @param array $tree categories tree returned by Title::getParentCategoryTree
-        * @return String separated by &gt;, terminate with "\n"
+        * @param array $tree Categories tree returned by Title::getParentCategoryTree
+        * @return string Separated by &gt;, terminate with "\n"
         */
        function drawCategoryBrowser( $tree ) {
                $return = '';
@@ -622,7 +622,7 @@ abstract class Skin extends ContextSource {
         * The output of this function gets processed in SkinTemplate::outputPage() for
         * the SkinTemplate based skins, all other skins should directly echo it.
         *
-        * @return String, empty by default, if not changed by any hook function.
+        * @return string Empty by default, if not changed by any hook function.
         */
        protected function afterContentHook() {
                $data = '';
@@ -648,7 +648,7 @@ abstract class Skin extends ContextSource {
        /**
         * Generate debug data HTML for displaying at the bottom of the main content
         * area.
-        * @return String HTML containing debug data, if enabled (otherwise empty).
+        * @return string HTML containing debug data, if enabled (otherwise empty).
         */
        protected function generateDebugHTML() {
                return MWDebug::getHTMLDebugLog();
@@ -657,7 +657,7 @@ abstract class Skin extends ContextSource {
        /**
         * This gets called shortly before the "</body>" tag.
         *
-        * @return String HTML-wrapped JS code to be put before "</body>"
+        * @return string HTML-wrapped JS code to be put before "</body>"
         */
        function bottomScripts() {
                // TODO and the suckage continues. This function is really just a wrapper around
@@ -678,16 +678,19 @@ abstract class Skin extends ContextSource {
        function printSource() {
                $oldid = $this->getRevisionId();
                if ( $oldid ) {
-                       $url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid ) ) );
+                       $canonicalUrl = $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid );
+                       $url = htmlspecialchars( wfExpandIRI( $canonicalUrl ) );
                } else {
                        // oldid not available for non existing pages
                        $url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL() ) );
                }
-               return $this->msg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' )->text();
+
+               return $this->msg( 'retrievedfrom', '<a dir="ltr" href="' . $url
+                       . '">' . $url . '</a>' )->text();
        }
 
        /**
-        * @return String
+        * @return string
         */
        function getUndeleteLink() {
                $action = $this->getRequest()->getVal( 'action', 'view' );
@@ -769,7 +772,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * Returns true if the IP should be shown in the header
-        * @return Bool
+        * @return bool
         */
        function showIPinHeader() {
                global $wgShowIPinHeader;
@@ -777,7 +780,7 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * @return String
+        * @return string
         */
        function getSearchLink() {
                $searchPage = SpecialPage::getTitleFor( 'Search' );
@@ -792,14 +795,16 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * @param $type string
+        * @param string $type
         * @return string
         */
        function getCopyright( $type = 'detect' ) {
                global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgContLang;
 
                if ( $type == 'detect' ) {
-                       if ( !$this->isRevisionCurrent() && !$this->msg( 'history_copyright' )->inContentLanguage()->isDisabled() ) {
+                       if ( !$this->isRevisionCurrent()
+                               && !$this->msg( 'history_copyright' )->inContentLanguage()->isDisabled()
+                       ) {
                                $type = 'history';
                        } else {
                                $type = 'normal';
@@ -827,14 +832,21 @@ abstract class Skin extends ContextSource {
                // Allow for site and per-namespace customization of copyright notice.
                $forContent = true;
 
-               wfRunHooks( 'SkinCopyrightFooter', array( $this->getTitle(), $type, &$msg, &$link, &$forContent ) );
+               wfRunHooks(
+                       'SkinCopyrightFooter',
+                       array( $this->getTitle(), $type, &$msg, &$link, &$forContent )
+               );
 
                $msgObj = $this->msg( $msg )->rawParams( $link );
                if ( $forContent ) {
                        $msg = $msgObj->inContentLanguage()->text();
                        if ( $this->getLanguage()->getCode() !== $wgContLang->getCode() ) {
-                               $msg = Html::rawElement( 'span', array( 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ), $msg );
+                               $msg = Html::rawElement( 'span', array(
+                                       'lang' => $wgContLang->getHtmlCode(),
+                                       'dir' => $wgContLang->getDir()
+                               ), $msg );
                        }
+
                        return $msg;
                } else {
                        return $msgObj->text();
@@ -878,7 +890,8 @@ abstract class Skin extends ContextSource {
                global $wgStylePath;
 
                $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
-               $text = '<a href="//www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
+               $text = '<a href="//www.mediawiki.org/"><img src="' . $url
+                       . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
                wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );
                return $text;
        }
@@ -886,7 +899,7 @@ abstract class Skin extends ContextSource {
        /**
         * Get the timestamp of the latest revision, formatted in user language
         *
-        * @return String
+        * @return string
         */
        protected function lastModified() {
                $timestamp = $this->getOutput()->getRevisionTimestamp();
@@ -912,7 +925,7 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * @param $align string
+        * @param string $align
         * @return string
         */
        function logoText( $align = '' ) {
@@ -934,9 +947,11 @@ abstract class Skin extends ContextSource {
 
        /**
         * Renders a $wgFooterIcons icon according to the method's arguments
-        * @param array $icon The icon to build the html for, see $wgFooterIcons for the format of this array
-        * @param bool|String $withImage Whether to use the icon's image or output a text-only footericon
-        * @return String HTML
+        * @param array $icon The icon to build the html for, see $wgFooterIcons
+        *   for the format of this array.
+        * @param bool|string $withImage Whether to use the icon's image or output
+        *   a text-only footericon.
+        * @return string HTML
         */
        function makeFooterIcon( $icon, $withImage = 'withImage' ) {
                if ( is_string( $icon ) ) {
@@ -945,7 +960,8 @@ abstract class Skin extends ContextSource {
                        $url = isset( $icon["url"] ) ? $icon["url"] : null;
                        unset( $icon["url"] );
                        if ( isset( $icon["src"] ) && $withImage === 'withImage' ) {
-                               $html = Html::element( 'img', $icon ); // do this the lazy way, just pass icon data as an attribute array
+                               // do this the lazy way, just pass icon data as an attribute array
+                               $html = Html::element( 'img', $icon );
                        } else {
                                $html = htmlspecialchars( $icon["alt"] );
                        }
@@ -995,7 +1011,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * Gets the link to the wiki's privacy policy page.
-        * @return String HTML
+        * @return string HTML
         */
        function privacyLink() {
                return $this->footerLink( 'privacy', 'privacypage' );
@@ -1003,7 +1019,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * Gets the link to the wiki's about page.
-        * @return String HTML
+        * @return string HTML
         */
        function aboutLink() {
                return $this->footerLink( 'aboutsite', 'aboutpage' );
@@ -1011,7 +1027,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * Gets the link to the wiki's general disclaimers page.
-        * @return String HTML
+        * @return string HTML
         */
        function disclaimerLink() {
                return $this->footerLink( 'disclaimers', 'disclaimerpage' );
@@ -1035,7 +1051,7 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * @param $id User|int
+        * @param User|int $id
         * @return bool
         */
        function showEmailUser( $id ) {
@@ -1044,8 +1060,11 @@ abstract class Skin extends ContextSource {
                } else {
                        $targetUser = User::newFromId( $id );
                }
-               return $this->getUser()->canSendEmail() && # the sending user must have a confirmed email address
-                       $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
+
+               # The sending user must have a confirmed email address and the target
+               # user must have a confirmed email address and allow emails from users.
+               return $this->getUser()->canSendEmail() &&
+                       $targetUser->canReceiveEmail();
        }
 
        /**
@@ -1053,7 +1072,7 @@ abstract class Skin extends ContextSource {
         * This method returns a url resolved using the configured skin style path
         * and includes the style version inside of the url.
         * @param string $name The name or path of a skin resource file
-        * @return String The fully resolved style path url including styleversion
+        * @return string The fully resolved style path url including styleversion
         */
        function getCommonStylePath( $name ) {
                global $wgStylePath, $wgStyleVersion;
@@ -1065,7 +1084,7 @@ abstract class Skin extends ContextSource {
         * This method returns a url resolved using the configured skin style path
         * and includes the style version inside of the url.
         * @param string $name The name or path of a skin resource file
-        * @return String The fully resolved style path url including styleversion
+        * @return string The fully resolved style path url including styleversion
         */
        function getSkinStylePath( $name ) {
                global $wgStylePath, $wgStyleVersion;
@@ -1075,8 +1094,8 @@ abstract class Skin extends ContextSource {
        /* these are used extensively in SkinTemplate, but also some other places */
 
        /**
-        * @param $urlaction string
-        * @return String
+        * @param string $urlaction
+        * @return string
         */
        static function makeMainPageUrl( $urlaction = '' ) {
                $title = Title::newMainPage();
@@ -1093,8 +1112,8 @@ abstract class Skin extends ContextSource {
         *
         * @param string $name Name of the Special page
         * @param string $urlaction Query to append
-        * @param $proto Protocol to use or null for a local URL
-        * @return String
+        * @param string|null $proto Protocol to use or null for a local URL
+        * @return string
         */
        static function makeSpecialUrl( $name, $urlaction = '', $proto = null ) {
                $title = SpecialPage::getSafeTitleFor( $name );
@@ -1106,10 +1125,10 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * @param $name string
-        * @param $subpage string
-        * @param $urlaction string
-        * @return String
+        * @param string $name
+        * @param string $subpage
+        * @param string $urlaction
+        * @return string
         */
        static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
                $title = SpecialPage::getSafeTitleFor( $name, $subpage );
@@ -1117,9 +1136,9 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * @param $name string
-        * @param $urlaction string
-        * @return String
+        * @param string $name
+        * @param string $urlaction
+        * @return string
         */
        static function makeI18nUrl( $name, $urlaction = '' ) {
                $title = Title::newFromText( wfMessage( $name )->inContentLanguage()->text() );
@@ -1128,9 +1147,9 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * @param $name string
-        * @param $urlaction string
-        * @return String
+        * @param string $name
+        * @param string $urlaction
+        * @return string
         */
        static function makeUrl( $name, $urlaction = '' ) {
                $title = Title::newFromText( $name );
@@ -1142,8 +1161,8 @@ abstract class Skin extends ContextSource {
        /**
         * If url string starts with http, consider as external URL, else
         * internal
-        * @param $name String
-        * @return String URL
+        * @param string $name
+        * @return string URL
         */
        static function makeInternalOrExternalUrl( $name ) {
                if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $name ) ) {
@@ -1155,10 +1174,10 @@ abstract class Skin extends ContextSource {
 
        /**
         * this can be passed the NS number as defined in Language.php
-        * @param $name
-        * @param $urlaction string
-        * @param $namespace int
-        * @return String
+        * @param string $name
+        * @param string $urlaction
+        * @param int $namespace
+        * @return string
         */
        static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
                $title = Title::makeTitleSafe( $namespace, $name );
@@ -1169,8 +1188,8 @@ abstract class Skin extends ContextSource {
 
        /**
         * these return an array with the 'href' and boolean 'exists'
-        * @param $name
-        * @param $urlaction string
+        * @param string $name
+        * @param string $urlaction
         * @return array
         */
        static function makeUrlDetails( $name, $urlaction = '' ) {
@@ -1186,8 +1205,8 @@ abstract class Skin extends ContextSource {
        /**
         * Make URL details where the article exists (or at least it's convenient to think so)
         * @param string $name Article name
-        * @param $urlaction String
-        * @return Array
+        * @param string $urlaction
+        * @return array
         */
        static function makeKnownUrlDetails( $name, $urlaction = '' ) {
                $title = Title::newFromText( $name );
@@ -1202,8 +1221,8 @@ abstract class Skin extends ContextSource {
        /**
         * make sure we have some title to operate on
         *
-        * @param $title Title
-        * @param $name string
+        * @param Title $title
+        * @param string $name
         */
        static function checkTitle( &$title, $name ) {
                if ( !is_object( $title ) ) {
@@ -1244,6 +1263,8 @@ abstract class Skin extends ContextSource {
                if ( $wgEnableSidebarCache ) {
                        $cachedsidebar = $wgMemc->get( $key );
                        if ( $cachedsidebar ) {
+                               wfRunHooks( 'SidebarBeforeOutput', array( $this, &$cachedsidebar ) );
+
                                wfProfileOut( __METHOD__ );
                                return $cachedsidebar;
                        }
@@ -1257,6 +1278,8 @@ abstract class Skin extends ContextSource {
                        $wgMemc->set( $key, $bar, $wgSidebarCacheExpiry );
                }
 
+               wfRunHooks( 'SidebarBeforeOutput', array( $this, &$bar ) );
+
                wfProfileOut( __METHOD__ );
                return $bar;
        }
@@ -1267,8 +1290,8 @@ abstract class Skin extends ContextSource {
         *
         * This is just a wrapper around addToSidebarPlain() for backwards compatibility
         *
-        * @param $bar array
-        * @param $message String
+        * @param array $bar
+        * @param string $message
         */
        function addToSidebar( &$bar, $message ) {
                $this->addToSidebarPlain( $bar, wfMessage( $message )->inContentLanguage()->plain() );
@@ -1277,9 +1300,9 @@ abstract class Skin extends ContextSource {
        /**
         * Add content from plain text
         * @since 1.17
-        * @param $bar array
-        * @param $text string
-        * @return Array
+        * @param array $bar
+        * @param string $text
+        * @return array
         */
        function addToSidebarPlain( &$bar, $text ) {
                $lines = explode( "\n", $text );
@@ -1385,7 +1408,7 @@ abstract class Skin extends ContextSource {
        /**
         * Gets new talk page messages for the current user and returns an
         * appropriate alert message (or an empty string if there are no messages)
-        * @return String
+        * @return string
         */
        function getNewtalks() {
 
@@ -1477,8 +1500,8 @@ abstract class Skin extends ContextSource {
        /**
         * Get a cached notice
         *
-        * @param string $name message name, or 'default' for $wgSiteNotice
-        * @return String: HTML fragment
+        * @param string $name Message name, or 'default' for $wgSiteNotice
+        * @return string HTML fragment
         */
        private function getCachedNotice( $name ) {
                global $wgRenderHashAppend, $parserMemc, $wgContLang;
@@ -1532,7 +1555,7 @@ abstract class Skin extends ContextSource {
        /**
         * Get a notice based on page's namespace
         *
-        * @return String: HTML fragment
+        * @return string HTML fragment
         */
        function getNamespaceNotice() {
                wfProfileIn( __METHOD__ );
@@ -1552,7 +1575,7 @@ abstract class Skin extends ContextSource {
        /**
         * Get the site notice
         *
-        * @return String: HTML fragment
+        * @return string HTML fragment
         */
        function getSiteNotice() {
                wfProfileIn( __METHOD__ );
@@ -1583,13 +1606,13 @@ abstract class Skin extends ContextSource {
         * Create a section edit link.  This supersedes editSectionLink() and
         * editSectionLinkForOther().
         *
-        * @param $nt Title  The title being linked to (may not be the same as
+        * @param Title $nt The title being linked to (may not be the same as
         *   the current page, if the section is included from a template)
         * @param string $section The designation of the section being pointed to,
         *   to be included in the link, like "&section=$section"
         * @param string $tooltip The tooltip to use for the link: will be escaped
         *   and wrapped in the 'editsectionhint' message
-        * @param $lang string Language code
+        * @param string $lang Language code
         * @return string HTML to use for edit link
         */
        public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) {