Followup r91672: remove commented-out reference to removed file (rtl.css)
[lhc/web/wiklou.git] / includes / Skin.php
index 7fbce41..3dc7a3c 100644 (file)
@@ -16,12 +16,6 @@ if ( !defined( 'MEDIAWIKI' ) ) {
  * @ingroup Skins
  */
 abstract class Skin {
-       /**#@+
-        * @private
-        */
-       var $mWatchLinkNum = 0; // Appended to end of watch link id's
-       /**#@-*/
-       protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
        protected $skinname = 'standard';
        protected $mRelevantTitle = null;
        protected $mRelevantUser = null;
@@ -116,7 +110,7 @@ abstract class Skin {
 
                if ( isset( $skinNames[$key] ) ) {
                        return $key;
-               } else if ( isset( $skinNames[$wgDefaultSkin] ) ) {
+               } elseif ( isset( $skinNames[$wgDefaultSkin] ) ) {
                        return $wgDefaultSkin;
                } else {
                        return 'vector';
@@ -138,24 +132,28 @@ abstract class Skin {
                $className = "Skin{$skinName}";
 
                # Grab the skin class and initialise it.
-               if ( !class_exists( $className ) ) {
-                       // Preload base classes to work around APC/PHP5 bug
-                       $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
+               if ( !MWInit::classExists( $className ) ) {
 
-                       if ( file_exists( $deps ) ) {
-                               include_once( $deps );
+                       if ( !defined( 'MW_COMPILED' ) ) {
+                               // Preload base classes to work around APC/PHP5 bug
+                               $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
+                               if ( file_exists( $deps ) ) {
+                                       include_once( $deps );
+                               }
+                               require_once( "{$wgStyleDirectory}/{$skinName}.php" );
                        }
-                       require_once( "{$wgStyleDirectory}/{$skinName}.php" );
 
                        # Check if we got if not failback to default skin
-                       if ( !class_exists( $className ) ) {
+                       if ( !MWInit::classExists( $className ) ) {
                                # DO NOT die if the class isn't found. This breaks maintenance
                                # scripts and can cause a user account to be unrecoverable
                                # except by SQL manipulation if a previously valid skin name
                                # is no longer valid.
                                wfDebug( "Skin class does not exist: $className\n" );
                                $className = 'SkinVector';
-                               require_once( "{$wgStyleDirectory}/Vector.php" );
+                               if ( !defined( 'MW_COMPILED' ) ) {
+                                       require_once( "{$wgStyleDirectory}/Vector.php" );
+                               }
                        }
                }
                $skin = new $className;
@@ -175,7 +173,6 @@ abstract class Skin {
        function initPage( OutputPage $out ) {
                wfProfileIn( __METHOD__ );
 
-               $this->mRevisionId = $out->mRevisionId;
                $this->preloadExistence();
                $this->setMembers();
 
@@ -187,7 +184,7 @@ abstract class Skin {
         */
        function preloadExistence() {
                $user = $this->getContext()->getUser();
-               
+
                // User/talk link
                $titles = array( $user->getUserPage(), $user->getTalkPage() );
 
@@ -210,16 +207,6 @@ abstract class Skin {
         */
        protected function setMembers() {
                $this->userpage = $this->getContext()->getUser()->getUserPage()->getPrefixedText();
-               $this->usercss = false;
-       }
-
-       /**
-        * Whether the revision displayed is the latest revision of the page
-        *
-        * @return Boolean
-        */
-       public function isRevisionCurrent() {
-               return $this->mRevisionId == 0 || $this->mRevisionId == $this->getTitle()->getLatestRevID();
        }
 
        /**
@@ -260,6 +247,25 @@ abstract class Skin {
                return $this->getContext()->getUser();
        }
 
+       /**
+        * Get the current revision ID
+        *
+        * @return Integer
+        */
+       public function getRevisionId() {
+               return $this->getContext()->getOutput()->getRevisionId();
+       }
+
+       /**
+        * Whether the revision displayed is the latest revision of the page
+        *
+        * @return Boolean
+        */
+       public function isRevisionCurrent() {
+               $revID = $this->getRevisionId();
+               return $revID == 0 || $revID == $this->getTitle()->getLatestRevID();
+       }
+
        /**
         * Set the "relevant" title
         * @see self::getRelevantTitle()
@@ -276,6 +282,8 @@ abstract class Skin {
         * as their "relevant" title, this allows the skin system to display things
         * such as content tabs which belong to to that page instead of displaying
         * a basic special page tab which has almost no meaning.
+        *
+        * @return Title
         */
        public function getRelevantTitle() {
                if ( isset($this->mRelevantTitle) ) {
@@ -299,6 +307,7 @@ abstract class Skin {
         * Special:Contributions mark the user which they are relevant to so that
         * things like the toolbox can display the information they usually are only
         * able to display on a user's userpage and talkpage.
+        * @return User
         */
        public function getRelevantUser() {
                if ( isset($this->mRelevantUser) ) {
@@ -322,7 +331,7 @@ abstract class Skin {
 
        /**
         * Outputs the HTML generated by other functions.
-        * @param $out Object: instance of OutputPage
+        * @param $out OutputPage
         */
        abstract function outputPage( OutputPage $out );
 
@@ -333,7 +342,7 @@ abstract class Skin {
                        );
                } else {
                        return '';
-               } 
+               }
        }
 
        /**
@@ -366,48 +375,33 @@ abstract class Skin {
 
        /**
         * Generated JavaScript action=raw&gen=js
-        * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
-        * nated together.  For some bizarre reason, it does *not* return any
-        * custom user JS from subpages.  Huh?
-        *
-        * There's absolutely no reason to have separate Monobook/Common JSes.
-        * Any JS that cares can just check the skin variable generated at the
-        * top.  For now Monobook.js will be maintained, but it should be consi-
-        * dered deprecated.
+        * This used to load MediaWiki:Common.js and the skin-specific style
+        * before the ResourceLoader.
         *
+        * @deprecated since 1.18 Use the ResourceLoader instead. This may be removed at some
+        * point.
         * @param $skinName String: If set, overrides the skin name
-        * @return string
+        * @return String
         */
        public function generateUserJs( $skinName = null ) {
-               
-               // Stub - see ResourceLoaderSiteModule, CologneBlue, Simple and Standard skins override this
-               
                return '';
        }
 
        /**
         * Generate user stylesheet for action=raw&gen=css
+        *
+        * @deprecated since 1.18 Use the ResourceLoader instead. This may be removed at some
+        * point.
+        * @return String
         */
        public function generateUserStylesheet() {
-               
-               // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
-               
-               return '';
-       }
-
-       /**
-        * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
-        * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
-        */
-       protected function reallyGenerateUserStylesheet() {
-               
-               // Stub - see  ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
-               
                return '';
        }
 
        /**
         * @private
+        * @todo document
+        * @param $out OutputPage
         */
        function setupUserCss( OutputPage $out ) {
                global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs;
@@ -431,7 +425,7 @@ abstract class Skin {
                // Per-user custom styles
                if ( $wgAllowUserCss ) {
                        if ( $this->getTitle()->isCssSubpage() && $this->userCanPreview( $this->getContext()->getRequest()->getVal( 'action' ) ) ) {
-                               // @FIXME: properly escape the cdata!
+                               // @todo FIXME: Properly escape the cdata!
                                $out->addInlineStyle( $this->getContext()->getRequest()->getText( 'wpTextbox1' ) );
                        } else {
                                $out->addModuleStyles( 'user' );
@@ -465,18 +459,27 @@ abstract class Skin {
 
        /**
         * Add skin specific stylesheets
+        * Calling this method with an $out of anything but the same OutputPage
+        * inside ->getContext()->getOutput() is deprecated. The $out arg is kept
+        * for compatibility purposes with skins.
         * @param $out OutputPage
         * @delete
         */
        abstract function setupSkinUserCss( OutputPage $out );
 
+       /**
+        * TODO: document
+        * @param $title Title
+        * @return String
+        */
        function getPageClasses( $title ) {
+               global $wgRequest;
                $numeric = 'ns-' . $title->getNamespace();
 
                if ( $title->getNamespace() == NS_SPECIAL ) {
                        $type = 'ns-special';
                        // bug 23315: provide a class based on the canonical special page name without subpages
-                       list( $canonicalName ) = SpecialPage::resolveAliasWithSubpage( $title->getDBkey() );
+                       list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
                        if ( $canonicalName ) {
                                $type .= ' ' . Sanitizer::escapeClass( "mw-special-$canonicalName" );
                        } else {
@@ -489,14 +492,21 @@ abstract class Skin {
                }
 
                $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
-
-               return "$numeric $type $name";
+               
+               if ( $wgRequest->getVal('action') ) {
+                       $action = 'action-' . $wgRequest->getVal('action');
+               } else {
+                       $action = 'action-view';
+               }
+               return "$numeric $type $name $action";
        }
 
        /**
         * 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
         */
        function addToBodyAttributes( $out, &$bodyAttrs ) {
                // does nothing by default
@@ -504,42 +514,36 @@ abstract class Skin {
 
        /**
         * URL to the logo
+        * @return String
         */
        function getLogo() {
                global $wgLogo;
                return $wgLogo;
        }
 
-       /**
-        * The format without an explicit $out argument is deprecated
-        */
-       function getCategoryLinks( OutputPage $out=null ) {
-               global $wgUseCategoryBrowser, $wgContLang;
+       function getCategoryLinks() {
+               global $wgUseCategoryBrowser;
+
+               $out = $this->getContext()->getOutput();
 
                if ( count( $out->mCategoryLinks ) == 0 ) {
                        return '';
                }
 
-               # Separator
-               $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
-
-               // Use Unicode bidi embedding override characters,
-               // to make sure links don't smash each other up in ugly ways.
-               $dir = $wgContLang->getDir();
-               $embed = "<span dir='$dir'>";
-               $pop = '</span>';
+               $embed = "<li>";
+               $pop = "</li>";
 
                $allCats = $out->getCategoryLinks();
                $s = '';
                $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
 
                if ( !empty( $allCats['normal'] ) ) {
-                       $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
+                       $t = $embed . implode( "{$pop}{$embed}" , $allCats['normal'] ) . $pop;
 
                        $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
                        $s .= '<div id="mw-normal-catlinks">' .
-                               $this->link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
-                               . $colon . $t . '</div>';
+                               Linker::link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
+                               . $colon . '<ul>' . $t . '</ul>' . '</div>';
                }
 
                # Hidden categories
@@ -554,7 +558,7 @@ abstract class Skin {
 
                        $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
                                wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
-                               $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
+                               $colon . '<ul>' . $embed . implode( "{$pop}{$embed}" , $allCats['hidden'] ) . $pop . '</ul>' .
                                '</div>';
                }
 
@@ -567,7 +571,7 @@ abstract class Skin {
                        $parenttree = $this->getTitle()->getParentCategoryTree();
                        # Skin object passed by reference cause it can not be
                        # accessed under the method subfunction drawCategoryBrowser
-                       $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree, $this ) );
+                       $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree ) );
                        # Clean out bogus first entry and sort them
                        unset( $tempout[0] );
                        asort( $tempout );
@@ -581,10 +585,9 @@ abstract class Skin {
        /**
         * Render the array as a serie of links.
         * @param $tree Array: categories tree returned by Title::getParentCategoryTree
-        * @param &skin Object: skin passed by reference
         * @return String separated by &gt;, terminate with "\n"
         */
-       function drawCategoryBrowser( $tree, &$skin ) {
+       function drawCategoryBrowser( $tree ) {
                $return = '';
 
                foreach ( $tree as $element => $parent ) {
@@ -593,24 +596,21 @@ abstract class Skin {
                                $return .= "\n";
                        } else {
                                # grab the others elements
-                               $return .= $this->drawCategoryBrowser( $parent, $skin ) . ' &gt; ';
+                               $return .= $this->drawCategoryBrowser( $parent ) . ' &gt; ';
                        }
 
                        # add our current element to the list
                        $eltitle = Title::newFromText( $element );
-                       $return .=  $skin->link( $eltitle, $eltitle->getText() );
+                       $return .=  Linker::link( $eltitle, $eltitle->getText() );
                }
 
                return $return;
        }
 
-       /**
-        * The ->getCategories() form is deprecated, please instead use
-        * the ->getCategories( $out ) form with whatout OutputPage is on hand
-        */
-       function getCategories( OutputPage $out=null ) {
+       function getCategories() {
+               $out = $this->getContext()->getOutput();
 
-               $catlinks = $this->getCategoryLinks( $out );
+               $catlinks = $this->getCategoryLinks();
 
                $classes = 'catlinks';
 
@@ -638,7 +638,7 @@ abstract class Skin {
         * The output of this function gets processed in SkinTemplate::outputPage() for
         * the SkinTemplate based skins, all other skins should directly echo it.
         *
-        * Returns an empty string 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 = '';
@@ -666,11 +666,11 @@ abstract class Skin {
         * area.
         * @return String HTML containing debug data, if enabled (otherwise empty).
         */
-       protected function generateDebugHTML( OutputPage $out ) {
+       protected function generateDebugHTML() {
                global $wgShowDebug;
 
                if ( $wgShowDebug ) {
-                       $listInternals = $this->formatDebugHTML( $out->mDebugtext );
+                       $listInternals = $this->formatDebugHTML( $this->getContext()->getOutput()->mDebugtext );
                        return "\n<hr />\n<strong>Debug data:</strong><ul id=\"mw-debug-html\">" .
                                $listInternals . "</ul>\n";
                }
@@ -734,7 +734,10 @@ abstract class Skin {
         * @return String HTML-wrapped JS code to be put before </body>
         */
        function bottomScripts( $out ) {
-               $bottomScriptText = "\n" . $out->getHeadScripts( $this );
+               // TODO and the suckage continues. This function is really just a wrapper around
+               // OutputPage::getBottomScripts() which takes a Skin param. This should be cleaned
+               // up at some point
+               $bottomScriptText = $out->getBottomScripts( $this );
                wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
 
                return $bottomScriptText;
@@ -751,7 +754,9 @@ abstract class Skin {
 
                if ( $this->getContext()->getUser()->isAllowed( 'deletedhistory' ) &&
                        ( $this->getTitle()->getArticleId() == 0 || $action == 'history' ) ) {
-                       $n = $this->getTitle()->isDeleted();
+
+                       $includeSuppressed = $this->getContext()->getUser()->isAllowed( 'suppressrevision' );
+                       $n = $this->getTitle()->isDeleted( $includeSuppressed );
 
                        if ( $n ) {
                                if ( $this->getContext()->getUser()->isAllowed( 'undelete' ) ) {
@@ -762,7 +767,7 @@ abstract class Skin {
 
                                return wfMsg(
                                        $msg,
-                                       $this->link(
+                                       Linker::link(
                                                SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ),
                                                wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $this->getContext()->getLang()->formatNum( $n ) ),
                                                array(),
@@ -776,10 +781,7 @@ abstract class Skin {
                return '';
        }
 
-       /**
-        * The format without an explicit $out argument is deprecated
-        */
-       function subPageSubtitle( OutputPage $out=null ) {
+       function subPageSubtitle() {
                $out = $this->getContext()->getOutput();
                $subpages = '';
 
@@ -833,6 +835,7 @@ abstract class Skin {
 
        /**
         * Returns true if the IP should be shown in the header
+        * @return Bool
         */
        function showIPinHeader() {
                global $wgShowIPinHeader;
@@ -871,9 +874,9 @@ abstract class Skin {
 
                if ( $wgRightsPage ) {
                        $title = Title::newFromText( $wgRightsPage );
-                       $link = $this->linkKnown( $title, $wgRightsText );
+                       $link = Linker::linkKnown( $title, $wgRightsText );
                } elseif ( $wgRightsUrl ) {
-                       $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
+                       $link = Linker::makeExternalLink( $wgRightsUrl, $wgRightsText );
                } elseif ( $wgRightsText ) {
                        $link = $wgRightsText;
                } else {
@@ -930,7 +933,7 @@ abstract class Skin {
 
                $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
                $text = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
-               wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );       
+               wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );
                return $text;
        }
 
@@ -942,7 +945,7 @@ abstract class Skin {
         */
        protected function lastModified( $article ) {
                if ( !$this->isRevisionCurrent() ) {
-                       $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->mRevisionId );
+                       $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() );
                } else {
                        $timestamp = $article->getTimestamp();
                }
@@ -982,7 +985,8 @@ abstract class Skin {
        /**
         * Renders a $wgFooterIcons icon acording to the method's arguments
         * @param $icon Array: The icon to build the html for, see $wgFooterIcons for the format of this array
-        * @param $withImage Boolean: Whether to use the icon's image or output a text-only footericon
+        * @param $withImage Bool|String: 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 ) ) {
@@ -1007,7 +1011,7 @@ abstract class Skin {
         * @return string
         */
        function mainPageLink() {
-               $s = $this->link(
+               $s = Linker::link(
                        Title::newMainPage(),
                        wfMsg( 'mainpage' ),
                        array(),
@@ -1029,7 +1033,7 @@ abstract class Skin {
                        // but we make the link target be the one site-wide page.
                        $title = Title::newFromText( wfMsgForContent( $page ) );
 
-                       return $this->linkKnown(
+                       return Linker::linkKnown(
                                $title,
                                wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
                        );
@@ -1038,6 +1042,7 @@ abstract class Skin {
 
        /**
         * Gets the link to the wiki's privacy policy page.
+        * @return String HTML
         */
        function privacyLink() {
                return $this->footerLink( 'privacy', 'privacypage' );
@@ -1045,6 +1050,7 @@ abstract class Skin {
 
        /**
         * Gets the link to the wiki's about page.
+        * @return String HTML
         */
        function aboutLink() {
                return $this->footerLink( 'aboutsite', 'aboutpage' );
@@ -1052,6 +1058,7 @@ abstract class Skin {
 
        /**
         * Gets the link to the wiki's general disclaimers page.
+        * @return String HTML
         */
        function disclaimerLink() {
                return $this->footerLink( 'disclaimers', 'disclaimerpage' );
@@ -1068,7 +1075,7 @@ abstract class Skin {
                $options = array( 'action' => 'edit' );
 
                if ( !$this->isRevisionCurrent() ) {
-                       $options['oldid'] = intval( $this->mRevisionId );
+                       $options['oldid'] = intval( $this->getRevisionId() );
                }
 
                return $options;
@@ -1113,7 +1120,7 @@ abstract class Skin {
        }
 
        static function makeSpecialUrl( $name, $urlaction = '' ) {
-               $title = SpecialPage::getTitleFor( $name );
+               $title = SpecialPage::getSafeTitleFor( $name );
                return $title->getLocalURL( $urlaction );
        }
 
@@ -1138,6 +1145,8 @@ abstract class Skin {
        /**
         * If url string starts with http, consider as external URL, else
         * internal
+        * @param $name String
+        * @return String URL
         */
        static function makeInternalOrExternalUrl( $name ) {
                if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
@@ -1168,6 +1177,9 @@ abstract class Skin {
 
        /**
         * Make URL details where the article exists (or at least it's convenient to think so)
+        * @param $name String Article name
+        * @param $urlaction String
+        * @return Array
         */
        static function makeKnownUrlDetails( $name, $urlaction = '' ) {
                $title = Title::newFromText( $name );
@@ -1237,6 +1249,7 @@ abstract class Skin {
         * @since 1.17
         * @param &$bar array
         * @param $text string
+        * @return Array
         */
        function addToSidebarPlain( &$bar, $text ) {
                $lines = explode( "\n", $text );
@@ -1260,24 +1273,49 @@ abstract class Skin {
                                if ( strpos( $line, '|' ) !== false ) { // sanity check
                                        $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
                                        $line = array_map( 'trim', explode( '|', $line, 2 ) );
-                                       $link = wfMsgForContent( $line[0] );
+                                       $extraAttribs = array();
 
-                                       if ( $link == '-' ) {
-                                               continue;
+                                       $msgLink = wfMessage( $line[0] )->inContentLanguage();
+                                       if ( $msgLink->exists() ) {
+                                               $link = $msgLink->text();
+                                               if ( $link == '-' ) {
+                                                       continue;
+                                               }
+                                       } else {
+                                               $link = $line[0];
                                        }
 
-                                       $text = wfMsgExt( $line[1], 'parsemag' );
-
-                                       if ( wfEmptyMsg( $line[1] ) ) {
+                                       $msgText = wfMessage( $line[1] );
+                                       if ( $msgText->exists() ) {
+                                               $text = $msgText->text();
+                                       } else {
                                                $text = $line[1];
                                        }
 
-                                       if ( wfEmptyMsg( $line[0] ) ) {
-                                               $link = $line[0];
-                                       }
-
                                        if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
                                                $href = $link;
+                                               //Parser::getExternalLinkAttribs won't work here because of the Namespace things
+                                               global $wgNoFollowLinks;
+                                               if ( $wgNoFollowLinks ) {
+                                                       $extraAttribs['rel'] = 'nofollow';
+
+                                                       global $wgNoFollowDomainExceptions;
+                                                       if ( $wgNoFollowDomainExceptions ) {
+                                                               $bits = wfParseUrl( $url );
+                                                               if ( is_array( $bits ) && isset( $bits['host'] ) ) {
+                                                                       foreach ( $wgNoFollowDomainExceptions as $domain ) {
+                                                                               if ( substr( $bits['host'], -strlen( $domain ) ) == $domain ) {
+                                                                                       unset( $extraAttribs['rel'] );
+                                                                                       break;
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                               global $wgExternalLinkTarget;
+                                               if ( $wgExternalLinkTarget) {
+                                                       $extraAttribs['target'] = $wgExternalLinkTarget;
+                                               }
                                        } else {
                                                $title = Title::newFromText( $link );
 
@@ -1289,13 +1327,13 @@ abstract class Skin {
                                                }
                                        }
 
-                                       $bar[$heading][] = array(
+                                       $bar[$heading][] = array_merge( array(
                                                'text' => $text,
                                                'href' => $href,
-                                               'id' => 'n-' . strtr( $line[1], ' ', '-' ),
+                                               'id' => 'n-' . Sanitizer::escapeId( strtr( $line[1], ' ', '-' ), 'noninitial' ),
                                                'active' => false
-                                       );
-                               } else if ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
+                                       ), $extraAttribs );
+                               } elseif ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
                                        global $wgParser;
 
                                        $line = substr( $line, 2, strlen( $line ) - 4 );
@@ -1394,7 +1432,7 @@ abstract class Skin {
         * @return String: HTML fragment
         */
        private function getCachedNotice( $name ) {
-               global $wgRenderHashAppend, $parserMemc;
+               global $wgRenderHashAppend, $parserMemc, $wgContLang;
 
                wfProfileIn( __METHOD__ );
 
@@ -1436,7 +1474,8 @@ abstract class Skin {
                        $notice = $parsed;
                }
 
-               $notice = '<div id="localNotice">' .$notice . '</div>';
+               $notice = Html::rawElement( 'div', array( 'id' => 'localNotice',
+                       'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ), $notice );
                wfProfileOut( __METHOD__ );
                return $notice;
        }
@@ -1511,7 +1550,7 @@ abstract class Skin {
                if ( !is_null( $tooltip ) ) {
                        # Bug 25462: undo double-escaping.
                        $tooltip = Sanitizer::decodeCharReferences( $tooltip );
-                       $attribs['title'] = wfMsgReal( 'editsectionhint', array( $tooltip ), true, $lang );
+                       $attribs['title'] = wfMsgExt( 'editsectionhint', array( 'language' => $lang, 'parsemag' ), $tooltip );
                }
                $link = Linker::link( $nt, wfMsgExt( 'editsection', array( 'language' => $lang ) ),
                        $attribs,
@@ -1523,7 +1562,7 @@ abstract class Skin {
                # we can rid of it someday.
                $attribs = '';
                if ( $tooltip ) {
-                       $attribs = htmlspecialchars( wfMsgReal( 'editsectionhint', array( $tooltip ), true, $lang ) );
+                       $attribs = wfMsgExt( 'editsectionhint', array( 'language' => $lang, 'parsemag', 'escape' ), $tooltip );
                        $attribs = " title=\"$attribs\"";
                }
                $result = null;