Fix fatal error in Special:Export -- invalid title when using Template inclusion
[lhc/web/wiklou.git] / includes / Skin.php
index bb22247..5610f3b 100644 (file)
@@ -153,7 +153,7 @@ class Skin extends Linker {
        }
 
        function initPage( &$out ) {
-               global $wgFavicon, $wgAppleTouchIcon, $wgScriptPath, $wgSitename, $wgContLang, $wgScriptExtension;
+               global $wgFavicon, $wgAppleTouchIcon, $wgScriptPath, $wgScriptExtension;
 
                wfProfileIn( __METHOD__ );
 
@@ -165,16 +165,12 @@ class Skin extends Linker {
                        $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
                }               
 
-               $code = $wgContLang->getCode();
-               $name = $wgContLang->getLanguageName( $code );
-               $langName = $name ? $name : $code;
-
                # OpenSearch description link
                $out->addLink( array( 
                        'rel' => 'search', 
                        'type' => 'application/opensearchdescription+xml',
                        'href' => "$wgScriptPath/opensearch_desc{$wgScriptExtension}",
-                       'title' => "$wgSitename ($langName)",
+                       'title' => wfMsgForContent( 'opensearch-desc' ),
                ));
 
                $this->addMetadataLinks($out);
@@ -300,9 +296,10 @@ class Skin extends Linker {
                global $wgScript, $wgStylePath, $wgUser;
                global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
                global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
-               global $wgBreakFrames, $wgRequest;
+               global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
                global $wgUseAjax, $wgAjaxWatch;
                global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
+               global $wgRestrictionTypes, $wgLivePreview;
 
                $ns = $wgTitle->getNamespace();
                $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ? $wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
@@ -313,6 +310,8 @@ class Skin extends Linker {
                        'wgArticlePath' => $wgArticlePath,
                        'wgScriptPath' => $wgScriptPath,
                        'wgScript' => $wgScript,
+                       'wgVariantArticlePath' => $wgVariantArticlePath,
+                       'wgActionPaths' => $wgActionPaths,
                        'wgServer' => $wgServer,
                        'wgCanonicalNamespace' => $nsname,
                        'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias( $wgTitle->getDBkey() ),
@@ -320,8 +319,6 @@ class Skin extends Linker {
                        'wgPageName' => $wgTitle->getPrefixedDBKey(),
                        'wgTitle' => $wgTitle->getText(),
                        'wgAction' => $wgRequest->getText( 'action', 'view' ),
-                       'wgRestrictionEdit' => $wgTitle->getRestrictions( 'edit' ),
-                       'wgRestrictionMove' => $wgTitle->getRestrictions( 'move' ),
                        'wgArticleId' => $wgTitle->getArticleId(),
                        'wgIsArticle' => $wgOut->isArticle(),
                        'wgUserName' => $wgUser->isAnon() ? NULL : $wgUser->getName(),
@@ -335,7 +332,9 @@ class Skin extends Linker {
                        'wgEnableWriteAPI' => $wgEnableWriteAPI,
                );
 
-               global $wgLivePreview;
+               foreach( $wgRestrictionTypes as $type )
+                       $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
+
                if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
                        $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
                        $vars['wgLivepreviewMessageReady']   = wfMsg( 'livepreview-ready' );
@@ -541,8 +540,10 @@ END;
                        }
                        $a['onload'] .= 'setupRightClickEdit()';
                }
-               $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ? "rtl" : "ltr").
-               ' '.Sanitizer::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
+               $a['class'] =
+                       'mediawiki ns-'.$wgTitle->getNamespace().
+                       ' '.($wgContLang->isRTL() ? "rtl" : "ltr").
+                       ' '.Sanitizer::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
                return $a;
        }
 
@@ -625,9 +626,9 @@ END;
        }
 
 
-       function getCategoryLinks () {
+       function getCategoryLinks() {
                global $wgOut, $wgTitle, $wgUseCategoryBrowser;
-               global $wgContLang;
+               global $wgContLang, $wgUser;
 
                if( count( $wgOut->mCategoryLinks ) == 0 ) return '';
 
@@ -639,11 +640,33 @@ END;
                $dir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
                $embed = "<span dir='$dir'>";
                $pop = '</span>';
-               $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks ) . $pop;
 
-               $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks ) );
-               $s = $this->makeLinkObj( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
-                       . ': ' . $t;
+               $allCats = $wgOut->getCategoryLinks();
+               $s = '';
+               $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
+               if ( !empty( $allCats['normal'] ) ) {
+                       $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
+       
+                       $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
+                       $s .= '<div id="mw-normal-catlinks">' .
+                               $this->makeLinkObj( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
+                               . $colon . $t . '</div>';
+               }
+
+               # Hidden categories
+               if ( isset( $allCats['hidden'] ) ) {
+                       if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
+                               $class ='mw-hidden-cats-user-shown';
+                       } elseif ( $wgTitle->getNamespace() == NS_CATEGORY ) {
+                               $class = 'mw-hidden-cats-ns-shown';
+                       } else {
+                               $class = 'mw-hidden-cats-hidden';
+                       }
+                       $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 .
+                               "</div>";
+               }
 
                # optional 'dmoz-like' category browser. Will be shown under the list
                # of categories an article belong to
@@ -689,8 +712,15 @@ END;
 
        function getCategories() {
                $catlinks=$this->getCategoryLinks();
+               
+               $classes = 'catlinks';
+               
+               if(FALSE === strpos($catlinks,'<div id="mw-normal-catlinks">')) {
+                       $classes .= ' catlinks-allhidden';
+               }
+               
                if(!empty($catlinks)) {
-                       return "<p class='catlinks'>{$catlinks}</p>";
+                       return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
                }
        }
 
@@ -1602,7 +1632,7 @@ END;
         * @private
         */
        function buildSidebar() {
-               global $parserMemc, $wgEnableSidebarCache;
+               global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
                global $wgLang, $wgContLang;
 
                $fname = 'SkinTemplate::buildSidebar';
@@ -1663,7 +1693,7 @@ END;
                        }
                }
                if ($cacheSidebar)
-                       $parserMemc->set( $key, $bar, 86400 );
+                       $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
                wfProfileOut( $fname );
                return $bar;
        }