Merge "DatabaseMssql: Don't duplicate body of makeList()"
[lhc/web/wiklou.git] / includes / skins / Skin.php
index ce0c640..244a278 100644 (file)
@@ -168,11 +168,9 @@ abstract class Skin extends ContextSource {
         * @param OutputPage $out
         */
        function initPage( OutputPage $out ) {
-               wfProfileIn( __METHOD__ );
 
                $this->preloadExistence();
 
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -482,9 +480,10 @@ abstract class Skin extends ContextSource {
 
                        $msg = $this->msg( 'pagecategories' )->numParams( count( $allCats['normal'] ) )->escaped();
                        $linkPage = wfMessage( 'pagecategorieslink' )->inContentLanguage()->text();
+                       $title = Title::newFromText( $linkPage );
+                       $link = $title ? Linker::link( $title, $msg ) : $msg;
                        $s .= '<div id="mw-normal-catlinks" class="mw-normal-catlinks">' .
-                               Linker::link( Title::newFromText( $linkPage ), $msg )
-                               . $colon . '<ul>' . $t . '</ul>' . '</div>';
+                               $link . $colon . '<ul>' . $t . '</ul>' . '</div>';
                }
 
                # Hidden categories
@@ -645,18 +644,19 @@ abstract class Skin extends ContextSource {
                        $url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL() ) );
                }
 
-               return $this->msg( 'retrievedfrom', '<a dir="ltr" href="' . $url
-                       . '">' . $url . '</a>' )->text();
+               return $this->msg( 'retrievedfrom' )
+                       ->rawParams( '<a dir="ltr" href="' . $url. '">' . $url . '</a>' )
+                       ->parse();
        }
 
        /**
-        * @return string
+        * @return string HTML
         */
        function getUndeleteLink() {
                $action = $this->getRequest()->getVal( 'action', 'view' );
 
                if ( $this->getTitle()->userCan( 'deletedhistory', $this->getUser() ) &&
-                       ( $this->getTitle()->getArticleID() == 0 || $action == 'history' ) ) {
+                       ( !$this->getTitle()->exists() || $action == 'history' ) ) {
                        $n = $this->getTitle()->isDeleted();
 
                        if ( $n ) {
@@ -670,7 +670,7 @@ abstract class Skin extends ContextSource {
                                        Linker::linkKnown(
                                                SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ),
                                                $this->msg( 'restorelink' )->numParams( $n )->escaped() )
-                                       )->text();
+                                       )->escaped();
                        }
                }
 
@@ -837,9 +837,12 @@ abstract class Skin extends ContextSource {
        function getPoweredBy() {
                global $wgResourceBasePath;
 
-               $url = htmlspecialchars( "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png" );
-               $text = '<a href="//www.mediawiki.org/"><img src="' . $url
-                       . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
+               $url1 = htmlspecialchars( "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png" );
+               $url1_5 = htmlspecialchars( "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png" );
+               $url2 = htmlspecialchars( "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png" );
+               $text = '<a href="//www.mediawiki.org/"><img src="' . $url1
+                       . '" srcset="' . $url1_5 . ' 1.5x, ' . $url2 . ' 2x" '
+                       . 'height="31" width="88" alt="Powered by MediaWiki" /></a>';
                Hooks::run( 'SkinGetPoweredBy', array( &$text, $this ) );
                return $text;
        }
@@ -860,13 +863,13 @@ abstract class Skin extends ContextSource {
                if ( $timestamp ) {
                        $d = $this->getLanguage()->userDate( $timestamp, $this->getUser() );
                        $t = $this->getLanguage()->userTime( $timestamp, $this->getUser() );
-                       $s = ' ' . $this->msg( 'lastmodifiedat', $d, $t )->text();
+                       $s = ' ' . $this->msg( 'lastmodifiedat', $d, $t )->parse();
                } else {
                        $s = '';
                }
 
                if ( wfGetLB()->getLaggedSlaveMode() ) {
-                       $s .= ' <strong>' . $this->msg( 'laggedslavemode' )->text() . '</strong>';
+                       $s .= ' <strong>' . $this->msg( 'laggedslavemode' )->parse() . '</strong>';
                }
 
                return $s;
@@ -940,7 +943,6 @@ abstract class Skin extends ContextSource {
         * @return string HTML anchor
         */
        public function footerLink( $desc, $page ) {
-               $section = new ProfileSection( __METHOD__ );
                // if the link description has been set to "-" in the default language,
                if ( $this->msg( $desc )->inContentLanguage()->isDisabled() ) {
                        // then it is disabled, for all languages.
@@ -951,6 +953,10 @@ abstract class Skin extends ContextSource {
                        // but we make the link target be the one site-wide page.
                        $title = Title::newFromText( $this->msg( $page )->inContentLanguage()->text() );
 
+                       if ( !$title ) {
+                               return '';
+                       }
+
                        return Linker::linkKnown(
                                $title,
                                $this->msg( $desc )->escaped()
@@ -1040,6 +1046,7 @@ abstract class Skin extends ContextSource {
         *
         * @param string $name The name or path of a skin resource file
         * @return string The fully resolved style path url including styleversion
+        * @throws MWException
         */
        function getSkinStylePath( $name ) {
                global $wgStylePath, $wgStyleVersion;
@@ -1159,7 +1166,7 @@ abstract class Skin extends ContextSource {
 
                return array(
                        'href' => $title->getLocalURL( $urlaction ),
-                       'exists' => $title->getArticleID() != 0,
+                       'exists' => $title->isKnown(),
                );
        }
 
@@ -1217,7 +1224,6 @@ abstract class Skin extends ContextSource {
         */
        function buildSidebar() {
                global $wgMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
-               wfProfileIn( __METHOD__ );
 
                $key = wfMemcKey( 'sidebar', $this->getLanguage()->getCode() );
 
@@ -1226,7 +1232,6 @@ abstract class Skin extends ContextSource {
                        if ( $cachedsidebar ) {
                                Hooks::run( 'SidebarBeforeOutput', array( $this, &$cachedsidebar ) );
 
-                               wfProfileOut( __METHOD__ );
                                return $cachedsidebar;
                        }
                }
@@ -1241,7 +1246,6 @@ abstract class Skin extends ContextSource {
 
                Hooks::run( 'SidebarBeforeOutput', array( $this, &$bar ) );
 
-               wfProfileOut( __METHOD__ );
                return $bar;
        }
 
@@ -1467,8 +1471,6 @@ abstract class Skin extends ContextSource {
        private function getCachedNotice( $name ) {
                global $wgRenderHashAppend, $parserMemc, $wgContLang;
 
-               wfProfileIn( __METHOD__ );
-
                $needParse = false;
 
                if ( $name === 'default' ) {
@@ -1476,13 +1478,11 @@ abstract class Skin extends ContextSource {
                        global $wgSiteNotice;
                        $notice = $wgSiteNotice;
                        if ( empty( $notice ) ) {
-                               wfProfileOut( __METHOD__ );
                                return false;
                        }
                } else {
                        $msg = $this->msg( $name )->inContentLanguage();
                        if ( $msg->isDisabled() ) {
-                               wfProfileOut( __METHOD__ );
                                return false;
                        }
                        $notice = $msg->plain();
@@ -1509,7 +1509,6 @@ abstract class Skin extends ContextSource {
 
                $notice = Html::rawElement( 'div', array( 'id' => 'localNotice',
                        'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ), $notice );
-               wfProfileOut( __METHOD__ );
                return $notice;
        }
 
@@ -1519,7 +1518,6 @@ abstract class Skin extends ContextSource {
         * @return string HTML fragment
         */
        function getNamespaceNotice() {
-               wfProfileIn( __METHOD__ );
 
                $key = 'namespacenotice-' . $this->getTitle()->getNsText();
                $namespaceNotice = $this->getCachedNotice( $key );
@@ -1529,7 +1527,6 @@ abstract class Skin extends ContextSource {
                        $namespaceNotice = '';
                }
 
-               wfProfileOut( __METHOD__ );
                return $namespaceNotice;
        }
 
@@ -1539,7 +1536,6 @@ abstract class Skin extends ContextSource {
         * @return string HTML fragment
         */
        function getSiteNotice() {
-               wfProfileIn( __METHOD__ );
                $siteNotice = '';
 
                if ( Hooks::run( 'SiteNoticeBefore', array( &$siteNotice, $this ) ) ) {
@@ -1559,7 +1555,6 @@ abstract class Skin extends ContextSource {
                }
 
                Hooks::run( 'SiteNoticeAfter', array( &$siteNotice, $this ) );
-               wfProfileOut( __METHOD__ );
                return $siteNotice;
        }