Ugly fix for skins that dont extends Skin:specialPagesList such as Nostalgia. Pointed...
[lhc/web/wiklou.git] / includes / Skin.php
index 2e23733..1b35625 100644 (file)
@@ -1,18 +1,17 @@
 <?php
+# See skin.doc
 
-require_once( 'Feed.php' );
+require_once( 'Feed.php' );  // should not be called if the actual page isn't feed enabled
 require_once( 'Image.php' );
 
-# See skin.doc
-
 # These are the INTERNAL names, which get mapped
 # directly to class names.  For display purposes, the
 # Language class has internationalized names
 #
 /* private */ $wgValidSkinNames = array(
-       'standard' => 'Standard',
-       'nostalgia' => 'Nostalgia',
-       'cologneblue' => 'CologneBlue'
+       'standard'              => 'Standard',
+       'nostalgia'             => 'Nostalgia',
+       'cologneblue'   => 'CologneBlue'
 );
 if( $wgUsePHPTal ) {
     #$wgValidSkinNames[] = 'PHPTal';
@@ -63,6 +62,9 @@ class Skin {
        {
                return 'wikistandard.css';
        }
+       function getSkinName() {
+               return "standard";
+       }
 
        function qbSetting()
        {
@@ -152,20 +154,45 @@ class Skin {
        }
 
        function getHeadScripts() {
-               global $wgStylePath;
+               global $wgStylePath, $wgUser, $wgLang;
                $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/wikibits.js\"></script>\n";
+               if( $wgUser->getID() != 0 ) { # logged in       
+                       $userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
+                       $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript'));
+                       $r .= '<script type="text/javascript" src="'.$userjs."\"></script>\n";
+               }
                return $r;
        }
 
+       # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
+       function getUserStylesheet() {
+               global $wgOut, $wgStylePath, $wgLang, $wgUser, $wgRequest, $wgTitle;
+               $sheet = $this->getStylesheet();
+               $action = $wgRequest->getText('action');
+               $s = "@import \"$wgStylePath/$sheet\";\n";
+               if($wgLang->isRTL()) $s .= "@import \"$wgStylePath/common_rtl.css\";\n";
+               if( $wgUser->getID() != 0 ) { # logged in       
+                       if($wgTitle->isCssSubpage() and $action == 'submit' and  $wgTitle->userCanEditCssJsSubpage()) {
+                               $s .= $wgRequest->getText('wpTextbox1');
+                       } else {
+                               $userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
+                               $s.= '@import "'.$this->makeUrl($userpage.'/'.$this->getSkinName().'.css', 'action=raw&ctype=text/css').'";'."\n";
+                       }
+               }
+               $s .= $this->doGetUserStyles();
+               return $s."\n"; 
+       }
+       # placeholder, returns generated js in monobook
+       function getUserJs() {
+               return;
+       }
+       
        function getUserStyles()
        {
                global $wgOut, $wgStylePath, $wgLang;
-               $sheet = $this->getStylesheet();
                $s = "<style type='text/css'>\n";
                $s .= "/*/*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
-               $s .= "@import url(\"$wgStylePath/$sheet\");\n";
-               if($wgLang->isRTL()) $s .= "@import url(\"$wgStylePath/common_rtl.css\");\n";
-               $s .= $this->doGetUserStyles();
+               $s .= $this->getUserStylesheet();
                $s .= "/* */\n";
                $s .= "</style>\n";
                return $s;
@@ -374,7 +401,7 @@ class Skin {
                if($wgUseCategoryBrowser) {
                        $s .= '<br/><hr/>';
                        $catstack = array();
-                       $s.= $wgTitle->getAllParentCategories(&$catstack);
+                       $s.= $wgTitle->getAllParentCategories($catstack);
                }
                
                return $s;
@@ -1057,6 +1084,7 @@ class Skin {
        function specialPagesList()
        {
                global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
+               require_once('SpecialPage.php');
                $a = array();
                $pages = SpecialPage::getPages();
                
@@ -1531,7 +1559,7 @@ class Skin {
        # Pass a title object, not a title string
        function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '')
        {
-               global $wgOut, $wgTitle;
+               global $wgOut, $wgTitle, $wgInputEncoding;
 
                $fname = 'Skin::makeKnownLinkObj';
                wfProfileIn( $fname );
@@ -1547,7 +1575,12 @@ class Skin {
                        $u = $nt->escapeLocalURL( $query );
                }
                if ( '' != $nt->getFragment() ) {
-                       $u .= '#' . htmlspecialchars( $nt->getFragment() );
+                       $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT, $wgInputEncoding ) );
+                       $replacearray = array(
+                               '%3A' => ':',
+                               '%' => '.'
+                       );
+                       $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
                }
                if ( '' == $text ) {
                        $text = htmlspecialchars( $nt->getPrefixedText() );
@@ -2107,9 +2140,9 @@ class Skin {
                $rci = 'RCI'.$this->rcCacheIndex ;
                $rcl = 'RCL'.$this->rcCacheIndex ;
                $rcm = 'RCM'.$this->rcCacheIndex ;
-               $toggleLink = 'javascript:toggleVisibility("'.$rci.'","'.$rcm.'","'.$rcl.'")' ;
+               $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
                $arrowdir = $wgLang->isRTL() ? 'l' : 'r';
-               $tl  = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'"/images/Arr_'.$arrowdir.png.'" width="12" height="12" /></a></span>' ;
+               $tl  = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/images/Arr_'.$arrowdir.'.png" width="12" height="12" /></a></span>' ;
                $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/images/Arr_d.png" width="12" height="12" /></a></span>' ;
                $r .= $tl ;
 
@@ -2463,11 +2496,12 @@ class Skin {
                # is ignored
                while(preg_match('/\[\[(.*?)(\|(.*?))*\]\]/',$comment,$match)) {
 
-                       $medians = $wgLang->getNsText(Namespace::getMedia());
+                       $medians = $wgLang->getNsText(Namespace::getMedia()).':';
                        $func='makeLink';
                        if(preg_match('/^'.$medians.'/i',$match[1])) {
                                $func='makeMediaLink';
                        }
+                       # Handle link renaming [[foo|text]] will show link as "text"
                        if(isset($match[3]) ) {
                                $comment=
                                preg_replace('/\[\[(.*?)\]\]/',
@@ -2563,7 +2597,7 @@ class Skin {
                # try min-width & co when somebody gets a chance
                $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
                return
-               '<table border="0" id="toc"><tr><td align="center">'."\n".
+               '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
                '<b>'.wfMsg('toc').'</b>' .
                $hideline .
                '</td></tr><tr id="tocinside"><td>'."\n".
@@ -2577,7 +2611,7 @@ class Skin {
                        return $head;
                }
                $url = $wgTitle->escapeLocalURL( 'action=edit&section='.$section );
-               return '<span oncontextmenu="document.location="'.$url.'";return false;">'.$head.'</span>';
+               return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
        }
 
        function editSectionLink( $section ) {
@@ -2728,14 +2762,4 @@ class Skin {
        }
 
 }
-
-require_once( 'SkinStandard.php' );
-require_once( 'SkinNostalgia.php' );
-require_once( 'SkinCologneBlue.php' );
-
-if( $wgUsePHPTal ) {
-       require_once( 'SkinPHPTal.php' );
-}
-
-
 ?>