hide print-specific output from cologneblue and nostalgia, too
[lhc/web/wiklou.git] / includes / Skin.php
index 0bd52f4..2836a24 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+include_once( "Feed.php" );
+
 # See skin.doc
 
 # These are the INTERNAL names, which get mapped
@@ -6,23 +9,31 @@
 # Language class has internationalized names
 #
 /* private */ $wgValidSkinNames = array(
-       "Standard", "Nostalgia", "CologneBlue" #, "Smarty", "Montparnasse"
+       "Standard", "Nostalgia", "CologneBlue"
 );
+if( $wgUseSmarty ) {
+       $wgValidSkinNames[] = "Smarty";
+       $wgValidSkinNames[] = "Montparnasse";
+}
+if( $wgUsePHPTal ) {
+    #$wgValidSkinNames[] = "PHPTal";
+    $wgValidSkinNames[] = "DaVinci";
+}
 
 include_once( "RecentChange.php" );
 
 # For some odd PHP bug, this function can't be part of a class
 function getCategories ()
 {
-  global $wgOut , $wgTitle , $wgUseCategoryMagic , $wgUser ;
+  global $wgOut , $wgTitle , $wgUseCategoryMagic , $wgUser , $wgParser ;
   if ( !isset ( $wgUseCategoryMagic ) || !$wgUseCategoryMagic ) return "" ;
-  if ( count ( $wgOut->mCategoryLinks ) == 0 ) return "" ;
+  if ( count ( $wgParser->mCategoryLinks ) == 0 ) return "" ;
   if ( !$wgOut->isArticle() ) return "" ;
   $sk = $wgUser->getSkin() ;
   $s = "" ;
   $s .=  "\n<br>\n";
   $s .= $sk->makeKnownLink ( "Special:Categories" , "Categories" , "article=".$wgTitle->getDBkey() ) ;
-  $t = implode ( " | " , $wgOut->mCategoryLinks ) ;
+  $t = implode ( " | " , $wgParser->mCategoryLinks ) ;
   if ( $t != "" ) $s .= " : " ;
   $s .= $t ;
   return $s ;
@@ -126,14 +137,10 @@ class Skin {
        function getUserStyles()
        {
                global $wgOut, $wgStyleSheetPath;
-               if( $wgOut->isPrintable() ) {
-                       $sheet = "wikiprintable.css";
-               } else {
-                       $sheet = $this->getStylesheet();
-               }
+               $sheet = $this->getStylesheet();
                $s = "<style type='text/css'><!--\n";
-               $s .= "@import url(\"$wgStyleSheetPath/$sheet\");\n";
                $s .= "/*/*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
+               $s .= "@import url(\"$wgStyleSheetPath/$sheet\");\n";
                $s .= $this->doGetUserStyles();
                $s .= "/* */\n";
                $s .= "//--></style>\n";
@@ -175,14 +182,13 @@ class Skin {
                        (!$wgTitle->isProtected() || $wgUser->isSysop())
                        
                        ) {
-                       $n = $wgTitle->getPrefixedURL();
                        $t = wfMsg( "editthispage" );
                        $oid = $red = "";
                        if ( $redirect ) { $red = "&redirect={$redirect}"; }
                        if ( $oldid && ! isset( $diff ) ) {
                                $oid = "&oldid={$oldid}";
                        }
-                       $s = wfLocalUrlE($n,"action=edit{$oid}{$red}");
+                       $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
                        $s = "document.location = \"" .$s ."\";";
                        $a += array ("ondblclick" => $s);
 
@@ -200,8 +206,7 @@ class Skin {
                $link = str_replace( "_", " ", $link );
                $link = wfEscapeHTML( $link );
 
-               if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
-               else { $r = " class='external'"; }
+               $r = " class='external'";
 
                if ( 1 == $wgUser->getOption( "hover" ) ) {
                        $r .= " title=\"{$link}\"";
@@ -217,14 +222,12 @@ class Skin {
                $link = str_replace( "_", " ", $link );
                $link = wfEscapeHTML( $link );
 
-               if ( $wgOut->isPrintable() ) { 
-                       $r = " class='printable'"; 
-               } else if ( $broken == "stub" ) { 
+               if ( $broken == "stub" ) { 
                        $r = " class='stub'"; 
                } else if ( $broken == "yes" ) { 
                        $r = " class='new'"; 
                } else { 
-                       $r = " class='internal'"; 
+                       $r = ""; 
                }
 
                if ( 1 == $wgUser->getOption( "hover" ) ) {
@@ -237,14 +240,12 @@ class Skin {
        {
                global $wgUser, $wgOut;
 
-               if ( $wgOut->isPrintable() ) { 
-                       $r = " class='printable'"; 
-               } else if ( $broken == "stub" ) { 
+               if ( $broken == "stub" ) { 
                        $r = " class='stub'"; 
                } else if ( $broken == "yes" ) { 
                        $r = " class='new'"; 
                } else { 
-                       $r = " class='internal'"; 
+                       $r = ""; 
                }
 
                if ( 1 == $wgUser->getOption( "hover" ) ) {
@@ -266,11 +267,6 @@ class Skin {
        {
                global $wgUser, $wgOut, $wgSiteNotice;
 
-               if ( $wgOut->isPrintable() ) {
-                       $s = $this->pageTitle() . $this->pageSubtitle() . "\n";
-                       $s .= "\n<div class='bodytext'>";
-                       return $s;
-               }
                if( $wgSiteNotice ) {
                        $note = "\n<div id='notice' style='font-weight: bold; color: red; text-align: center'>$wgSiteNotice</div>\n";
                } else {
@@ -298,7 +294,7 @@ class Skin {
                }
 
                $s .= "\n<div id='content'>\n<div id='topbar'>" .
-                 "<table width='98%' border=0 cellspacing=0><tr>";
+                 "<table border=0 cellspacing=0><tr>";
 
                $shove = ($qb != 0);
                $left = ($qb == 1 || $qb == 3);
@@ -351,24 +347,17 @@ class Skin {
                global $wgUser, $wgOut, $wgServer;
                global $wgTitle, $wgLang;
                
-               if ( $wgOut->isPrintable() ) {
-                       $s = "\n</div>\n";
-
-                       $u = htmlspecialchars( $wgServer . $wgTitle->getFullURL() );
-                       $u = "<a href=\"$u\">$u</a>";
-                       $rf = wfMsg( "retrievedfrom", $u );
-
-                       if ( $wgOut->isArticle() ) {
-                               $lm = "<br>" . $this->lastModified();
-                       } else { $lm = ""; }
-
-                       $cr = wfMsg( "gnunote" );
-                       $s .= "<p>" . $wgLang->emphasize("{$rf}{$lm} {$cr}\n");
-                       return $s;
-               }
-               return $this->doAfterContent();
+               $printfooter = "<div class=\"printfooter\">" . $this->printFooter() . "</div>\n";
+               return $printfooter . $this->doAfterContent();
        }
-
+       
+       function printFooter() {
+               global $wgTitle;
+               $url = htmlspecialchars( $wgTitle->getFullURL() );
+               return "<p>" . wfMsg( "retrievedfrom", "<a href=\"$url\">$url</a>" ) .
+                       "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
+       }
+       
        function doAfterContent()
        {
                global $wgUser, $wgOut, $wgLang;
@@ -378,7 +367,7 @@ class Skin {
 
                $s = "\n</div><br clear=all>\n";
                $s .= "\n<div id='footer'>";
-               $s .= "<table width='98%' border=0 cellspacing=0><tr>";
+               $s .= "<table border=0 cellspacing=0><tr>";
                
                wfProfileOut( "$fname-1" );
                wfProfileIn( "$fname-2" );
@@ -401,7 +390,7 @@ class Skin {
                  . " | " . $this->aboutLink()
                  . " | " . $this->specialLink( "recentchanges" )
                  . " | " . $this->searchForm()
-                 . "<br>" . $this->pageStats();
+                 . "<br><span id='pagestats'>" . $this->pageStats() . "</span>";
 
                $s .= "</td>";
                if ( $shove && !$left ) { # Right
@@ -419,7 +408,7 @@ class Skin {
 
        function pageTitleLinks()
        {
-               global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang, $wgUseApproval ;
+               global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang, $wgUseApproval;
 
                $s = $this->printableLink();
                if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ;
@@ -473,17 +462,24 @@ class Skin {
 
        function printableLink()
        {
-               global $wgOut, $wgTitle, $oldid, $action;
+               global $wgOut, $wgFeedClasses, $wgRequest;
 
-               $q = "";
-               foreach( $_GET as $var => $val ) {
-                       if( $var != "title" && $var != "printable" )
-                               $q .= urlencode( $var ) . "=" . urlencode( $val );
+               $baseurl = $_SERVER['REQUEST_URI'];
+               if( strpos( "?", $baseurl ) == false ) {
+                       $baseurl .= "?";
+               } else {
+                       $baseurl .= "&";
                }
-               if( !empty( $q ) ) $q .= "&";
+               $baseurl = htmlspecialchars( $baseurl );
+               $printurl = $wgRequest->escapeAppendQuery( "printable=yes" );
                
-               $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
-                 WfMsg( "printableversion" ), "{$q}printable=yes" );
+               $s = "<a href=\"$printurl\">" . wfMsg( "printableversion" ) . "</a>";
+               if( $wgOut->isSyndicated() ) {
+                       foreach( $wgFeedClasses as $format => $class ) {
+                               $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
+                               $s .= " | <a href=\"$feedurl\">{$format}</a>";
+                       }
+               }
                return $s;
        }
 
@@ -669,12 +665,12 @@ class Skin {
                if ( $wgDisableCounters ) {
                        $s = "";
                } else {
-                       $count = $wgArticle->getCount();
+                       $count = $wgLang->formatNum( $wgArticle->getCount() );
                        $s = wfMsg( "viewcount", $count );
                }
                $s .= $this->lastModified();
                $s .= " " . wfMsg( "gnunote" );
-               return "<span id='pagestats'>{$s}</span>";
+               return $s;
        }
 
        function lastModified()
@@ -690,11 +686,12 @@ class Skin {
        {
                if ( "" != $align ) { $a = " align='{$align}'"; }
                else { $a = ""; }
-
+               
                $mp = wfMsg( "mainpage" );
-               $s = "<a href=\"" . wfLocalUrlE( urlencode( str_replace(' ','_',$mp) ) )
+               $titleObj = Title::newFromText( $mp );
+               $s = "<a href=\"" . $titleObj->escapeLocalURL()
                  . "\"><img{$a} border=0 src=\""
-                 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
+                 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\" /></a>";
                return $s;
        }
 
@@ -1035,7 +1032,7 @@ class Skin {
                global $wgTitle, $wgLang;
 
                $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
-                 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
+                 wfMsg( "contributions" ), "target=" . $wgTitle->getPartialURL() );
                return $s;
        }
 
@@ -1044,7 +1041,7 @@ class Skin {
                global $wgTitle, $wgLang;
 
                $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
-                 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
+                 wfMsg( "emailuser" ), "target=" . $wgTitle->getPartialURL() );
                return $s;
        }
 
@@ -1332,7 +1329,7 @@ class Skin {
                        $u = "";
                        if ( "" == $text ) { $text = $nt->getFragment(); }
                } else {
-                       $u = wfLocalUrlE( $link, $query );
+                       $u = $nt->escapeLocalURL( $query );
                }
                if ( "" != $nt->getFragment() ) {
                        $u .= "#" . wfEscapeHTML( $nt->getFragment() );
@@ -1360,11 +1357,12 @@ class Skin {
                $fname = "Skin::makeBrokenLinkObj";
                wfProfileIn( $fname );
 
-               $link = $nt->getPrefixedURL();
-
-               if ( "" == $query ) { $q = "action=edit"; }
-               else { $q = "action=edit&{$query}"; }
-               $u = wfLocalUrlE( $link, $q );
+               if ( "" == $query ) {
+                       $q = "action=edit";
+               } else {
+                       $q = "action=edit&{$query}";
+               }
+               $u = $nt->escapeLocalURL( $q );
 
                if ( "" == $text ) { $text = $nt->getPrefixedText(); }
                $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
@@ -1376,8 +1374,7 @@ class Skin {
                                $trail = $m[2];
                        }
                }
-               if ( $wgOut->isPrintable() ||
-                 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
+               if ( $wgUser->getOption( "highlightbroken" ) ) {
                        $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
                } else {
                        $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
@@ -1394,7 +1391,7 @@ class Skin {
 
                $link = $nt->getPrefixedURL();
 
-               $u = wfLocalUrlE( $link, $query );
+               $u = $nt->escapeLocalURL( $query );
 
                if ( "" == $text ) { $text = $nt->getPrefixedText(); }
                $style = $this->getInternalLinkAttributesObj( $nt, $text, "stub" );
@@ -1406,8 +1403,7 @@ class Skin {
                                $trail = $m[2];
                        }
                }
-               if ( $wgOut->isPrintable() ||
-                               ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
+               if ( $wgUser->getOption( "highlightbroken" ) ) {
                        $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
                } else {
                        $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
@@ -1428,7 +1424,7 @@ class Skin {
                global $wgOut;
 
                if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
-               $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
+               $s = "<img src=\"{$url}\" alt=\"{$alt}\" />";
                return $s;
        }
        
@@ -1439,7 +1435,6 @@ class Skin {
 
        function makeImageLinkObj( $nt, $alt = "" ) {
                global $wgLang, $wgUseImageResize;
-               $link  = $nt->getPrefixedURL();
                $name  = $nt->getDBKey();
                $url   = wfImageUrl( $name );
                $align = "";
@@ -1523,11 +1518,16 @@ class Skin {
                }
                $alt = htmlspecialchars( $alt );
 
-               $u = wfLocalUrlE( $link );
-               $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
-                 "<img border=\"0\" src=\"{$url}\" alt=\"{$alt}\"></a>";
+               $u = $nt->escapeLocalURL();
+               if ( $url == "" )
+               {
+                       $s = str_replace( "$1", $name, wfMsg("missingimage") );
+               } else {
+                       $s = "\n  <a href=\"{$u}\" class='image' title=\"{$alt}\">\n" .
+                               "  <img border=\"0\" src=\"{$url}\" alt=\"{$alt}\" />\n  </a>";
+               }
                if ( "" != $align ) {
-                       $s = "<div class=\"float{$align}\">{$s}</div>";
+                       $s = "<div class=\"float{$align}\">{$s}\n</div>";
                }
                return $prefix.$s.$postfix;
        }
@@ -1542,7 +1542,13 @@ class Skin {
                $thumbPath = wfImageThumbDir( $thumbName )."/".$thumbName;
                $thumbUrl  = wfImageThumbUrl( $thumbName );
 
-               if (     (! file_exists( $thumbPath ) && file_exists( $imgPath )) 
+               if ( ! file_exists( $imgPath ) )
+               {
+                       # If there is no image, there will be no thumbnail
+                       return "";
+               }
+
+               if (     (! file_exists( $thumbPath ) )
                ||  ( filemtime($thumbPath) < filemtime($imgPath) ) ) {
                        # Squid purging
                        if ( $wgUseSquid ) {
@@ -1629,10 +1635,9 @@ class Skin {
        }
 
        function makeThumbLinkObj( $nt, $label = "", $align = "right", $boxwidth = 180 ) {
-               global $wgUploadPath;
+               global $wgUploadPath, $wgLang;
                $name = $nt->getDBKey();
                $image = Title::makeTitle( Namespace::getImage(), $name );
-               $link = $image->getPrefixedURL();
                $url  = wfImageUrl( $name );
                $path = wfImagePath( $name );
                
@@ -1640,7 +1645,12 @@ class Skin {
                $alt = preg_replace( "/<[^>]*>/", "", $label);
                $alt = htmlspecialchars( $alt );
                
-               list($width, $height, $type, $attr) = getimagesize( $path );
+               if ( file_exists( $path ) )
+               {
+                       list($width, $height, $type, $attr) = getimagesize( $path );
+               } else {
+                       $width = $height = 200;
+               }
                $boxheight  = intval( $height/($width/$boxwidth) );
                if ( $boxwidth > $width ) {
                        $boxwidth  = $width;
@@ -1649,16 +1659,24 @@ class Skin {
                
                $thumbUrl = $this->createThumb( $name, $boxwidth );
 
-               $u = wfLocalUrlE( $link );
+               $u = $nt->escapeLocalURL();
 
-               $more = htmlspecialchars(wfMsg( "thumbnail-more" ));
-               
-               $s = "<div class=\"thumbnail-{$align}\" style=\"width:{$boxwidth}px;\">" .
-                 "<a href=\"{$u}\" class=\"internal\" title=\"{$alt}\">" .
-                 "<img border=\"0\" src=\"{$thumbUrl}\" alt=\"{$alt}\" width=\"{$boxwidth}\" height=\"{$boxheight}\"></a>" .
-                 "<a href=\"{$u}\" class=\"internal\" title=\"{$more}\">" .
-                   "<img border=\"0\" src=\"{$wgUploadPath}/magnify-clip.png\" width=\"26\" height=\"24\" align=\"right\" alt=\"{$more}\"></a>" .
-                 "<p>{$label}</p></div>";
+               $more = htmlspecialchars( wfMsg( "thumbnail-more" ) );
+               $magnifyalign = $wgLang->isRTL() ? "left" : "right";
+               $textalign = $wgLang->isRTL() ? " style=\"text-align:right\"" : "";
+
+               $s = "<div class=\"thumbnail-{$align}\" style=\"width:{$boxwidth}px;\">";
+               if ( $thumbUrl == "" ) {
+                       $s .= str_replace( "$1", $name, wfMsg("missingimage") );
+               } else {
+                       $s .= "\n".'  <a href="'.$u.'" class="internal" title="'.$alt.'">'."\n".
+                               '  <img border="0" src="'.$thumbUrl.'" alt="'.$alt.'" ' .
+                               '  width="'.$boxwidth.'" height="'.$boxheight.'" /></a>' ."\n".
+                               '  <a href="'.$u.'" class="internal" title="'.$more.'"> ' ."\n".
+                               '  <img border="0" src="'.$wgUploadPath.'/magnify-clip.png" ' .
+                               'width="26" height="24" align="'.$magnifyalign.'" alt="'.$more.'" /> </a>'."\n";
+               }
+               $s .= '  <p'.$textalign.'>'.$label."</p>\n</div>";
                return $s;
        }
 
@@ -1706,7 +1724,7 @@ class Skin {
        function beginImageHistoryList()
        {
                $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
-                 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
+                 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul class='special'>";
                return $s;
        }
 
@@ -1730,7 +1748,7 @@ class Skin {
                
                # Spacer image
                $r = "" ;
-               $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;              $r .= "<tt>" ;
+               $r .= "<img src='{$wgUploadPath}/Arr_.png' width='12' height='12' border='0' />" ;              $r .= "<tt>" ;
                
                if ( $rc_type == RC_MOVE ) {
                        $r .= "&nbsp;&nbsp;";
@@ -1815,10 +1833,10 @@ class Skin {
                $rci = "RCI{$this->rcCacheIndex}" ;
                $rcl = "RCL{$this->rcCacheIndex}" ;
                $rcm = "RCM{$this->rcCacheIndex}" ;
-               $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
-               $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
-               $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
-               $tl .= "</a>" ;
+               $toggleLink = "javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")" ;
+               $arrowdir = $wgLang->isRTL() ? "l" : "r";
+               $tl  = "<span id='{$rcm}'><a href='$toggleLink'><img src='{$wgUploadPath}/Arr_{$arrowdir}.png' width='12' height='12' border='0' /></a></span>" ;
+               $tl .= "<span id='{$rcl}' style='display:none'><a href='$toggleLink'><img src='{$wgUploadPath}/Arr_d.png' width='12' height='12' border='0' /></a></span>" ;
                $r .= $tl ;
 
                # Main line
@@ -1860,7 +1878,7 @@ class Skin {
                        # Get rc_xxxx variables
                        extract( $rcObj->mAttribs );
                        
-                       $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
+                       $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0 />";
                        $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
                        if ( $rc_new ) $r .= $N ;
                        else $r .= "&nbsp;" ;
@@ -1875,7 +1893,7 @@ class Skin {
                        if ( $rc_type == RC_LOG ) {
                                $link = $rcObj->timestamp ;
                        } else {
-                               $link = $this->makeKnownLink( $rcObj->getTitle(), $rcObj->timestamp , "{$curIdEq}&$o" ) ;
+                               $link = $this->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp , "{$curIdEq}&$o" ) ;
                        }
                        $link = "<tt>{$link}</tt>" ;
 
@@ -1903,16 +1921,16 @@ class Skin {
        {
                global $wgUploadPath ;
                if ( count ( $this->rc_cache ) == 0 ) return "" ;
-               #$k = array_keys ( $this->rc_cache ) ;
+               $blockOut = "";
                foreach ( $this->rc_cache AS $secureName => $block ) {
                        if ( count ( $block ) < 2 ) {
-                               $r .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
+                               $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
                        } else {
-                               $r .= $this->recentChangesBlockGroup ( $block ) ;
+                               $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
                        }
                }
 
-               return "<div align=left>{$r}</div>" ;
+               return "<div>{$blockOut}</div>" ;
        }
 
        # Called in a loop over all displayed RC entries
@@ -1941,7 +1959,7 @@ class Skin {
                $s = "";
                if ( $date != $this->lastdate ) {
                        if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
-                       $s .= "<h4>{$date}</h4>\n<ul>";
+                       $s .= "<h4>{$date}</h4>\n<ul class='special'>";
                        $this->lastdate = $date;
                }
                $s .= "<li> ";
@@ -2124,7 +2142,7 @@ class Skin {
                $secureName = $title->getPrefixedDBkey();
                if ( $rc_type == RC_MOVE ) {
                        # Use an @ character to prevent collision with page names
-                       $this->rc_cache["@@" . ($rcMoveIndex++)] = array($rc);
+                       $this->rc_cache["@@" . ($this->rcMoveIndex++)] = array($rc);
                } else {
                        if ( !isset ( $this->rc_cache[$secureName] ) ) $this->rc_cache[$secureName] = array() ;
                        array_push ( $this->rc_cache[$secureName] , $rc ) ;
@@ -2150,7 +2168,7 @@ class Skin {
                        $url = wfImageUrl( $img );
                        $rlink = $cur;
                        if ( $wgUser->isSysop() ) {
-                               $link = wfLocalUrlE( $wgTitle->getPrefixedText(), "image=" . $wgTitle->getURL() .
+                               $link = $wgTitle->escapeLocalURL( "image=" . $wgTitle->getPartialURL() . 
                                  "&action=delete" );
                                $style = $this->getInternalLinkAttributes( $link, $del );
 
@@ -2192,40 +2210,28 @@ class Skin {
        }
 
        function tocIndent($level) {
-
-               while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
-               return $rv;
-
+               return str_repeat( "<div class='tocindent'>\n", $level );
        }
 
        function tocUnindent($level) {
-               $rv = "";
-               while($level-->0) $rv.="</div>\n";
-               return $rv;
+               return str_repeat( "</div>\n", $level );
        }
 
-       // parameter level defines if we are on an indentation level
-       function tocLine($anchor,$tocline,$level) {
-               
-               if($level) { 
-               
-                       return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
-               } else { 
-
-                       return "<div style=\"margin-bottom:0px;\">\n".
-                       "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
-                       "</div>\n";
+       # parameter level defines if we are on an indentation level
+       function tocLine( $anchor, $tocline, $level ) {
+               $link = "<a href=\"#$anchor\">$tocline</a><br />";
+               if($level) {
+                       return "$link\n";
+               } else {
+                       return "<div class='tocline'>$link</div>\n";
                }
 
        }
 
        function tocTable($toc) {
-               // note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
-               global $printable;
-               
-               if (!$printable) {
-                       $hideline = " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>";
-               }
+               # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
+               # try min-width & co when somebody gets a chance
+               $hideline = " <script type='text/javascript'>showTocToggle(\"" . addslashes( wfMsg("showtoc") ) . "\",\"" . addslashes( wfMsg("hidetoc") ) . "\")</script>";
                return
                "<p><table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
                "<b>".wfMsg("toc")."</b>" .
@@ -2235,24 +2241,29 @@ class Skin {
        }
 
        # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
-       function editSectionScript($section,$head) {
-
-               global $wgTitle,$wgUser,$oldid;
-               if($oldid) return $head;
-               $url = wfLocalUrlE(urlencode(str_replace(' ','_',$wgTitle->getPrefixedText())),"action=edit&section=$section");
-               return "<span onContextMenu='document.location=\"".$url."\";return false;'>{$head}</span>";
+       function editSectionScript( $section, $head ) {
+               global $wgTitle, $wgRequest;
+               if( $wgRequest->getInt( "oldid" ) && ( $wgRequest->getVal( "diff" ) != "0" ) ) {
+                       return $head;
+               }
+               $url = $wgTitle->escapeLocalURL( "action=edit&section=$section" );
+               return "<span oncontextmenu='document.location=\"$url\";return false;'>{$head}</span>";
        }
 
-       function editSectionLink($section) {
-               global $printable,$oldid;
+       function editSectionLink( $section ) {
+               global $wgRequest;
                global $wgTitle, $wgUser, $wgLang;
-               
-               if( isset( $oldid ) ) return "";
-               if( isset( $printable ) ) return "";
-               
+
+               if( $wgRequest->getInt( "oldid" ) && ( $wgRequest->getVal( "diff" ) != "0" ) ) {
+                       # Section edit links would be out of sync on an old page.
+                       # But, if we're diffing to the current page, they'll be
+                       # correct.
+                       return "";
+               }
+
                $editurl = "&section={$section}";
                $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
-               
+
                if( $wgLang->isRTL() ) {
                        $farside = "left";
                        $nearside = "right";
@@ -2260,7 +2271,7 @@ class Skin {
                        $farside = "right";
                        $nearside = "left";
                }
-               return "<div style=\"float:$farside;margin-$nearside:5px;\"><small>[".$url."]</small></div>";
+               return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
 
        }
 
@@ -2333,24 +2344,24 @@ class Skin {
                                "sample"=>"",
                                "tip"=>wfMsg("hr_tip"))
                );
-               $toolbar.="<script type='text/javascript'>\n";
+               $toolbar ="<script type='text/javascript'>\n";
                $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
                foreach($toolarray as $tool) {
 
                        $image=$wgUploadPath."/".$tool["image"];
                        $open=$tool["open"];
                        $close=$tool["close"];
-                       $sample=$tool["sample"];
+                       $sample = addslashes( $tool["sample"] );
 
                        // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
                        // Older browsers show a "speedtip" type message only for ALT.
                        // Ideally these should be different, realistically they
                        // probably don't need to be.
-                       $tip=$tool["tip"];
+                       $tip = addslashes( $tool["tip"] );
                        $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
                }
 
-               $toolbar.="addInfobox('".wfMsg("infobox")."');\n";
+               $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "','" . addslashes(wfMsg("infobox_mozvote"))."');\n";
                $toolbar.="document.writeln(\"</div>\");\n</script>";
                return $toolbar;
        }
@@ -2360,6 +2371,12 @@ include_once( "SkinStandard.php" );
 include_once( "SkinNostalgia.php" );
 include_once( "SkinCologneBlue.php" );
 
-#include_once( "SkinSmarty.php" );
+if( $wgUseSmarty ) {
+       include_once( "SkinSmarty.php" );
+}
+if( $wgUsePHPTal ) {
+       include_once( "SkinPHPTal.php" );
+}
+
 
 ?>