Moved globals $utfCombiningClass, $utfCanonicalComp, $utfCanonicalDecomp, $utfCheckNF...
[lhc/web/wiklou.git] / includes / Skin.php
index 209b8f3..f000fbf 100644 (file)
@@ -115,8 +115,10 @@ class Skin extends Linker {
 
                if( isset( $skinNames[$key] ) ) {
                        return $key;
+               } else if( isset( $skinNames[$wgDefaultSkin] ) ) {
+                       return $wgDefaultSkin;
                } else {
-                       return 'monobook';
+                       return 'vector';
                }
        }
 
@@ -150,8 +152,8 @@ class Skin extends Linker {
                                # except by SQL manipulation if a previously valid skin name
                                # is no longer valid.
                                wfDebug( "Skin class does not exist: $className\n" );
-                               $className = 'SkinMonobook';
-                               require_once( "{$wgStyleDirectory}/MonoBook.php" );
+                               $className = 'SkinVector';
+                               require_once( "{$wgStyleDirectory}/Vector.php" );
                        }
                }
                $skin = new $className;
@@ -370,7 +372,7 @@ class Skin extends Linker {
                global $wgUseAjax, $wgAjaxWatch;
                global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
                global $wgRestrictionTypes;
-               global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
+               global $wgDBname, $wgEnableMWSuggest;
                global $wgSitename;
 
                $ns = $wgTitle->getNamespace();
@@ -388,7 +390,7 @@ class Skin extends Linker {
                        implode( "\t", $digitTransTable ),
                );
 
-               $mainPage = Title::newFromText( wfMsgForContent( 'mainpage' ) );
+               $mainPage = Title::newMainPage();
                $vars = array(
                        'skin' => $skinName,
                        'stylepath' => $wgStylePath,
@@ -432,7 +434,7 @@ class Skin extends Linker {
 
                // if on upload page output the extension list & js_upload
                if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == 'Upload' ) {
-                       global $wgFileExtensions, $wgAjaxUploadInterface;
+                       global $wgFileExtensions;
                        $vars['wgFileExtensions'] = $wgFileExtensions;
                }
 
@@ -595,8 +597,8 @@ CSS;
         * @private
         */
        function setupUserCss( OutputPage $out ) {
-               global $wgRequest, $wgContLang, $wgUser;
-               global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
+               global $wgRequest, $wgUser;
+               global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage;
 
                wfProfileIn( __METHOD__ );
 
@@ -616,11 +618,7 @@ CSS;
                // Per-site custom styles
                if( $wgUseSiteCss ) {
                        global $wgHandheldStyle;
-                       $query = wfArrayToCGI( array(
-                               'usemsgcache' => 'yes',
-                               'ctype' => 'text/css',
-                               'smaxage' => $wgSquidMaxage
-                       ) + $siteargs );
+                       $query = wfArrayToCGI( self::getDynamicStylesheetQuery() );
                        # Site settings must override extension css! (bug 15025)
                        $out->addStyle( self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) );
                        $out->addStyle( self::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI ), 'print' );
@@ -666,6 +664,22 @@ CSS;
 
                wfProfileOut( __METHOD__ );
        }
+       
+       /**
+        * Get the query to generate a dynamic stylesheet
+        * 
+        * @return array
+        */
+       public static function getDynamicStylesheetQuery() {
+               global $wgSquidMaxage;
+               return array(
+                               'action' => 'raw',
+                               'maxage' => $wgSquidMaxage,
+                               'usemsgcache' => 'yes',
+                               'ctype' => 'text/css',
+                               'smaxage' => $wgSquidMaxage,
+                       );
+       }
 
        /**
         * Add skin specific stylesheets
@@ -824,7 +838,7 @@ CSS;
                        $parenttree = $this->mTitle->getParentCategoryTree();
                        # Skin object passed by reference cause it can not be
                        # accessed under the method subfunction drawCategoryBrowser
-                       $tempout = explode( "\n", Skin::drawCategoryBrowser( $parenttree, $this ) );
+                       $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree, $this ) );
                        # Clean out bogus first entry and sort them
                        unset( $tempout[0] );
                        asort( $tempout );
@@ -849,7 +863,7 @@ CSS;
                                $return .= "\n";
                        } else {
                                # grab the others elements
-                               $return .= Skin::drawCategoryBrowser( $parent, $skin ) . ' > ';
+                               $return .= $this->drawCategoryBrowser( $parent, $skin ) . ' > ';
                        }
                        # add our current element to the list
                        $eltitle = Title::newFromText( $element );
@@ -877,7 +891,7 @@ CSS;
        }
 
        function getQuickbarCompensator( $rows = 1 ) {
-               return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
+               return "<td width='152' rowspan='{$rows}'>&#160;</td>";
        }
 
        /**
@@ -1074,7 +1088,7 @@ CSS;
        }
 
        function getUndeleteLink() {
-               global $wgUser, $wgContLang, $wgLang, $wgRequest;
+               global $wgUser, $wgLang, $wgRequest;
 
                $action = $wgRequest->getVal( 'action', 'view' );
 
@@ -1277,7 +1291,7 @@ CSS;
                  . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
 
                if( $wgUseTwoButtonsSearchForm ) {
-                       $s .= '&nbsp;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
+                       $s .= '&#160;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
                } else {
                        $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
                }
@@ -1511,11 +1525,16 @@ CSS;
                        return $out;
                }
                // Allow for site and per-namespace customization of copyright notice.
+               $forContent = true;
                if( isset( $wgArticle ) ) {
-                       wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
+                       wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link, &$forContent ) );
                }
 
-               $out .= wfMsgForContent( $msg, $link );
+               if ( $forContent ) {
+                       $out .= wfMsgForContent( $msg, $link );
+               } else {
+                       $out .= wfMsg( $msg, $link );
+               }
                return $out;
        }
 
@@ -1590,7 +1609,7 @@ CSS;
         * Show a drop-down box of special pages
         */
        function specialPagesList() {
-               global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
+               global $wgContLang, $wgServer, $wgRedirectScript;
                $pages = array_merge( SpecialPage::getRegularPages(), SpecialPage::getRestrictedPages() );
                foreach ( $pages as $name => $page ) {
                        $pages[$name] = $page->getDescription();
@@ -1894,12 +1913,13 @@ CSS;
                        $nt = Title::newFromText( $l );
                        $url = $nt->escapeFullURL();
                        $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
+                       $title = htmlspecialchars( $nt->getText() );
 
                        if ( $text == '' ) {
                                $text = $l;
                        }
                        $style = $this->getExternalLinkAttributes();
-                       $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
+                       $s .= "<a href=\"{$url}\" title=\"{$title}\"{$style}>{$text}</a>";
                }
                if( $wgContLang->isRTL() ) {
                        $s .= '</span>';
@@ -1988,23 +2008,21 @@ CSS;
                );
        }
 
-       function uploadLink() {
+       function getUploadLink() {
                global $wgUploadNavigationUrl;
 
                if( $wgUploadNavigationUrl ) {
-                       $title = Title::newFromText( $wgUploadNavigationUrl );
-               }
-               if( !isset( $title ) ) {
-                       $title = SpecialPage::getTitleFor('Upload');
+                       # Using an empty class attribute to avoid automatic setting of "external" class
+                       return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '') );
+               } else {
+                       return $this->link(
+                               SpecialPage::getTitleFor('Upload'),
+                               wfMsgHtml( 'upload' ),
+                               array(),
+                               array(),
+                               array( 'known', 'noclasses' )
+                       );
                }
-
-               return $this->link(
-                        $title,
-                        wfMsgHtml( 'upload' ),
-                        array(),
-                        array(),
-                        array( 'known', 'noclasses' )
-                );
        }
 
        /* these are used extensively in SkinTemplate, but also some other places */
@@ -2138,6 +2156,8 @@ CSS;
         */
        function addToSidebarPlain( &$bar, $text ) {
                $lines = explode( "\n", $text );
+               $wikiBar = array(); # We need to handle the wikitext on a different variable, to avoid trying to do an array operation on text, which would be a fatal error.
+
                $heading = '';
                foreach( $lines as $line ) {
                        if( strpos( $line, '*' ) !== 0 ) {
@@ -2149,8 +2169,9 @@ CSS;
                                        $bar[$heading] = array();
                                }
                        } else {
+                               $line = trim( $line, '* ' );
                                if( strpos( $line, '|' ) !== false ) { // sanity check
-                                       $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
+                                       $line = array_map( 'trim', explode( '|', $line, 2 ) );
                                        $link = wfMsgForContent( $line[0] );
                                        if( $link == '-' ) {
                                                continue;
@@ -2182,11 +2203,26 @@ CSS;
                                                'id' => 'n-' . strtr( $line[1], ' ', '-' ),
                                                'active' => false
                                        );
+                               } else if ( (substr($line, 0, 2) == '{{') && (substr($line, -2) == '}}') ) {
+                                       global $wgParser, $wgTitle;
+                                       
+                                       $line = substr($line, 2, strlen($line) - 4 );
+                                       
+                                       if (is_null($wgParser->mOptions))
+                                               $wgParser->mOptions = new ParserOptions();
+                                       
+                                       $wgParser->mOptions->setEditSection(false);
+                                       $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $wgParser->mOptions )->getText();
                                } else {
                                        continue;
                                }
                        }
                }
+               
+               if ( count($wikiBar) > 0 )
+                       $bar = array_merge($bar, $wikiBar);
+               
+               return $bar;
        }
 
        /**