(bug 32748) unicode URL for articles print version
[lhc/web/wiklou.git] / includes / Skin.php
index 03a8338..8b10d7f 100644 (file)
@@ -22,7 +22,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * Fetch the set of available skins.
-        * @return array of strings
+        * @return array associative array of strings
         */
        static function getSkinNames() {
                global $wgValidSkinNames;
@@ -55,6 +55,18 @@ abstract class Skin extends ContextSource {
                }
                return $wgValidSkinNames;
        }
+       /**
+        * Fetch the skinname messages for available skins.
+        * @return array of strings
+        */
+       static function getSkinNameMessages() {
+               $messages = array();
+               foreach( self::getSkinNames() as $skinKey => $skinName ) {
+                       $messages[] = "skinname-$skinKey";
+               }
+               return $messages;
+       }
 
        /**
         * Fetch the list of usable skins in regards to $wgSkipSkins.
@@ -86,7 +98,7 @@ abstract class Skin extends ContextSource {
 
                $skinNames = Skin::getSkinNames();
 
-               if ( $key == '' ) {
+               if ( $key == '' || $key == 'default' ) {
                        // Don't return the default immediately;
                        // in a misconfiguration we need to fall back.
                        $key = $wgDefaultSkin;
@@ -301,6 +313,21 @@ abstract class Skin extends ContextSource {
                }
        }
 
+       /**
+        * Make a <script> tag containing global variables
+        *
+        * @deprecated in 1.19
+        * @param $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
         *
@@ -531,7 +558,7 @@ abstract class Skin extends ContextSource {
        protected function generateDebugHTML() {
                global $wgShowDebug;
 
-               $html = MWDebug::getDebugHTML();
+               $html = MWDebug::getDebugHTML( $this->getContext() );
 
                if ( $wgShowDebug ) {
                        $listInternals = $this->formatDebugHTML( $this->getOutput()->mDebugtext );
@@ -620,10 +647,10 @@ abstract class Skin extends ContextSource {
        function printSource() {
                $oldid = $this->getRevisionId();
                if ( $oldid ) {
-                       $url = htmlspecialchars( $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid ) );
+                       $url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid ) ) );
                } else {
                        // oldid not available for non existing pages
-                       $url = htmlspecialchars( $this->getTitle()->getCanonicalURL() );
+                       $url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL() ) );
                }
                return $this->msg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' )->text();
        }
@@ -635,7 +662,7 @@ abstract class Skin extends ContextSource {
                $action = $this->getRequest()->getVal( 'action', 'view' );
 
                if ( $this->getUser()->isAllowed( 'deletedhistory' ) &&
-                       ( $this->getTitle()->getArticleId() == 0 || $action == 'history' ) ) {
+                       ( $this->getTitle()->getArticleID() == 0 || $action == 'history' ) ) {
                        $n = $this->getTitle()->isDeleted();
 
 
@@ -775,7 +802,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 {
@@ -828,14 +855,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 ) {
@@ -866,7 +893,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>";
@@ -1151,13 +1178,13 @@ abstract class Skin extends ContextSource {
         * @return array
         */
        function buildSidebar() {
-               global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
+               global $wgMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
                wfProfileIn( __METHOD__ );
 
                $key = wfMemcKey( 'sidebar', $this->getLanguage()->getCode() );
 
                if ( $wgEnableSidebarCache ) {
-                       $cachedsidebar = $parserMemc->get( $key );
+                       $cachedsidebar = $wgMemc->get( $key );
                        if ( $cachedsidebar ) {
                                wfProfileOut( __METHOD__ );
                                return $cachedsidebar;
@@ -1169,7 +1196,7 @@ abstract class Skin extends ContextSource {
 
                wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
                if ( $wgEnableSidebarCache ) {
-                       $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
+                       $wgMemc->set( $key, $bar, $wgSidebarCacheExpiry );
                }
 
                wfProfileOut( __METHOD__ );
@@ -1217,6 +1244,12 @@ abstract class Skin extends ContextSource {
                                if ( strpos( $line, '|' ) !== false ) { // sanity check
                                        $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
                                        $line = array_map( 'trim', explode( '|', $line, 2 ) );
+                                       if ( count( $line ) !== 2 ) {
+                                               // Second sanity check, could be hit by people doing
+                                               // funky stuff with parserfuncs... (bug 33321)
+                                               continue;
+                                       }
+
                                        $extraAttribs = array();
 
                                        $msgLink = $this->msg( $line[0] )->inContentLanguage();
@@ -1228,7 +1261,6 @@ abstract class Skin extends ContextSource {
                                        } else {
                                                $link = $line[0];
                                        }
-
                                        $msgText = $this->msg( $line[1] );
                                        if ( $msgText->exists() ) {
                                                $text = $msgText->text();
@@ -1392,7 +1424,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;
        }
@@ -1467,7 +1499,7 @@ abstract class Skin extends ContextSource {
                if ( !is_null( $tooltip ) ) {
                        # Bug 25462: undo double-escaping.
                        $tooltip = Sanitizer::decodeCharReferences( $tooltip );
-                       $attribs['title'] = wfMsgExt( 'editsectionhint', array( 'language' => $lang, 'parsemag' ), $tooltip );
+                       $attribs['title'] = wfMsgExt( 'editsectionhint', array( 'language' => $lang, 'parsemag', 'replaceafter' ), $tooltip );
                }
                $link = Linker::link( $nt, wfMsgExt( 'editsection', array( 'language' => $lang ) ),
                        $attribs,
@@ -1479,7 +1511,7 @@ abstract class Skin extends ContextSource {
                # we can rid of it someday.
                $attribs = '';
                if ( $tooltip ) {
-                       $attribs = wfMsgExt( 'editsectionhint', array( 'language' => $lang, 'parsemag', 'escape' ), $tooltip );
+                       $attribs = wfMsgExt( 'editsectionhint', array( 'language' => $lang, 'parsemag', 'escape', 'replaceafter' ), $tooltip );
                        $attribs = " title=\"$attribs\"";
                }
                $result = null;
@@ -1508,6 +1540,7 @@ abstract class Skin extends ContextSource {
         *
         * @param $fname String Name of called method
         * @param $args Array Arguments to the method
+        * @return mixed
         */
        function __call( $fname, $args ) {
                $realFunction = array( 'Linker', $fname );