Merge "Add autocomplete for WhatLinksHere subpages"
[lhc/web/wiklou.git] / includes / skins / Skin.php
index 5604bc2..999dda8 100644 (file)
@@ -168,11 +168,9 @@ abstract class Skin extends ContextSource {
         * @param OutputPage $out
         */
        function initPage( OutputPage $out ) {
-               wfProfileIn( __METHOD__ );
 
                $this->preloadExistence();
 
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -259,7 +257,7 @@ abstract class Skin extends ContextSource {
                        $titles[] = $title->getTalkPage();
                }
 
-               wfRunHooks( 'SkinPreloadExistence', array( &$titles, $this ) );
+               Hooks::run( 'SkinPreloadExistence', array( &$titles, $this ) );
 
                if ( count( $titles ) ) {
                        $lb = new LinkBatch( $titles );
@@ -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
@@ -587,7 +586,7 @@ abstract class Skin extends ContextSource {
        protected function afterContentHook() {
                $data = '';
 
-               if ( wfRunHooks( 'SkinAfterContent', array( &$data, $this ) ) ) {
+               if ( Hooks::run( 'SkinAfterContent', array( &$data, $this ) ) ) {
                        // adding just some spaces shouldn't toggle the output
                        // of the whole <div/>, so we use trim() here
                        if ( trim( $data ) != '' ) {
@@ -624,7 +623,7 @@ abstract class Skin extends ContextSource {
                // OutputPage::getBottomScripts() which takes a Skin param. This should be cleaned
                // up at some point
                $bottomScriptText = $this->getOutput()->getBottomScripts();
-               wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
+               Hooks::run( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
 
                return $bottomScriptText;
        }
@@ -645,8 +644,9 @@ 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>' )
+                       ->escaped();
        }
 
        /**
@@ -684,7 +684,7 @@ abstract class Skin extends ContextSource {
                $out = $this->getOutput();
                $subpages = '';
 
-               if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this, $out ) ) ) {
+               if ( !Hooks::run( 'SkinSubPageSubtitle', array( &$subpages, $this, $out ) ) ) {
                        return $subpages;
                }
 
@@ -793,7 +793,7 @@ abstract class Skin extends ContextSource {
                // @todo Remove deprecated $forContent param from hook handlers and then remove here.
                $forContent = true;
 
-               wfRunHooks(
+               Hooks::run(
                        'SkinCopyrightFooter',
                        array( $this->getTitle(), $type, &$msg, &$link, &$forContent )
                );
@@ -840,7 +840,7 @@ abstract class Skin extends ContextSource {
                $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>';
-               wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );
+               Hooks::run( 'SkinGetPoweredBy', array( &$text, $this ) );
                return $text;
        }
 
@@ -860,13 +860,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 )->escaped();
                } else {
                        $s = '';
                }
 
                if ( wfGetLB()->getLaggedSlaveMode() ) {
-                       $s .= ' <strong>' . $this->msg( 'laggedslavemode' )->text() . '</strong>';
+                       $s .= ' <strong>' . $this->msg( 'laggedslavemode' )->parse() . '</strong>';
                }
 
                return $s;
@@ -940,7 +940,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 +950,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 +1043,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;
@@ -1217,16 +1221,14 @@ abstract class Skin extends ContextSource {
         */
        function buildSidebar() {
                global $wgMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
-               wfProfileIn( __METHOD__ );
 
                $key = wfMemcKey( 'sidebar', $this->getLanguage()->getCode() );
 
                if ( $wgEnableSidebarCache ) {
                        $cachedsidebar = $wgMemc->get( $key );
                        if ( $cachedsidebar ) {
-                               wfRunHooks( 'SidebarBeforeOutput', array( $this, &$cachedsidebar ) );
+                               Hooks::run( 'SidebarBeforeOutput', array( $this, &$cachedsidebar ) );
 
-                               wfProfileOut( __METHOD__ );
                                return $cachedsidebar;
                        }
                }
@@ -1234,14 +1236,13 @@ abstract class Skin extends ContextSource {
                $bar = array();
                $this->addToSidebar( $bar, 'sidebar' );
 
-               wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
+               Hooks::run( 'SkinBuildSidebar', array( $this, &$bar ) );
                if ( $wgEnableSidebarCache ) {
                        $wgMemc->set( $key, $bar, $wgSidebarCacheExpiry );
                }
 
-               wfRunHooks( 'SidebarBeforeOutput', array( $this, &$bar ) );
+               Hooks::run( 'SidebarBeforeOutput', array( $this, &$bar ) );
 
-               wfProfileOut( __METHOD__ );
                return $bar;
        }
 
@@ -1379,7 +1380,7 @@ abstract class Skin extends ContextSource {
                $out = $this->getOutput();
 
                // Allow extensions to disable or modify the new messages alert
-               if ( !wfRunHooks( 'GetNewMessagesAlert', array( &$newMessagesAlert, $newtalks, $user, $out ) ) ) {
+               if ( !Hooks::run( 'GetNewMessagesAlert', array( &$newMessagesAlert, $newtalks, $user, $out ) ) ) {
                        return '';
                }
                if ( $newMessagesAlert ) {
@@ -1467,8 +1468,6 @@ abstract class Skin extends ContextSource {
        private function getCachedNotice( $name ) {
                global $wgRenderHashAppend, $parserMemc, $wgContLang;
 
-               wfProfileIn( __METHOD__ );
-
                $needParse = false;
 
                if ( $name === 'default' ) {
@@ -1476,13 +1475,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 +1506,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 +1515,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 +1524,6 @@ abstract class Skin extends ContextSource {
                        $namespaceNotice = '';
                }
 
-               wfProfileOut( __METHOD__ );
                return $namespaceNotice;
        }
 
@@ -1539,10 +1533,9 @@ abstract class Skin extends ContextSource {
         * @return string HTML fragment
         */
        function getSiteNotice() {
-               wfProfileIn( __METHOD__ );
                $siteNotice = '';
 
-               if ( wfRunHooks( 'SiteNoticeBefore', array( &$siteNotice, $this ) ) ) {
+               if ( Hooks::run( 'SiteNoticeBefore', array( &$siteNotice, $this ) ) ) {
                        if ( is_object( $this->getUser() ) && $this->getUser()->isLoggedIn() ) {
                                $siteNotice = $this->getCachedNotice( 'sitenotice' );
                        } else {
@@ -1558,8 +1551,7 @@ abstract class Skin extends ContextSource {
                        }
                }
 
-               wfRunHooks( 'SiteNoticeAfter', array( &$siteNotice, $this ) );
-               wfProfileOut( __METHOD__ );
+               Hooks::run( 'SiteNoticeAfter', array( &$siteNotice, $this ) );
                return $siteNotice;
        }
 
@@ -1602,7 +1594,7 @@ abstract class Skin extends ContextSource {
                        . '<span class="mw-editsection-bracket">]</span>'
                        . '</span>';
 
-               wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result, $lang ) );
+               Hooks::run( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result, $lang ) );
                return $result;
        }