include_once -> require_once
[lhc/web/wiklou.git] / includes / Skin.php
index 0b677fa..2720aff 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
-include_once( "Feed.php" );
+require_once( "Feed.php" );
+require_once( "Image.php" );
 
 # See skin.doc
 
@@ -9,31 +10,19 @@ include_once( "Feed.php" );
 # Language class has internationalized names
 #
 /* private */ $wgValidSkinNames = array(
-       "Standard", "Nostalgia", "CologneBlue"
+       'standard' => "Standard",
+       'nostalgia' => "Nostalgia",
+       'cologneblue' => "CologneBlue"
 );
-if( $wgUseSmarty ) {
-       $wgValidSkinNames[] = "Smarty";
-       $wgValidSkinNames[] = "Montparnasse";
+if( $wgUsePHPTal ) {
+    #$wgValidSkinNames[] = "PHPTal";
+    #$wgValidSkinNames['davinci'] = "DaVinci";
+    #$wgValidSkinNames['mono'] = "Mono";
+    $wgValidSkinNames['monobook'] = "MonoBook";
+    #$wgValidSkinNames['monobookminimal'] = "MonoBookMinimal";
 }
 
-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 , $wgParser ;
-  if ( !isset ( $wgUseCategoryMagic ) || !$wgUseCategoryMagic ) 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 ( " | " , $wgParser->mCategoryLinks ) ;
-  if ( $t != "" ) $s .= " : " ;
-  $s .= $t ;
-  return $s ;
-}
+require_once( "RecentChange.php" );
 
 class RCCacheEntry extends RecentChange
 {
@@ -86,15 +75,52 @@ class Skin {
 
        function initPage( &$out )
        {
-               global $wgStyleSheetPath;
                $fname = "Skin::initPage";
                wfProfileIn( $fname );
                
-               $out->addLink( "shortcut icon", "", "/favicon.ico" );
+               $out->addLink( array( "rel" => "shortcut icon", "href" => "/favicon.ico" ) );
                
+               $this->addMetadataLinks($out);
+           
                wfProfileOut( $fname );
        }
        
+       function addMetadataLinks( &$out ) {
+               global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
+               global $wgRightsPage, $wgRightsUrl;
+
+               if( $out->isArticleRelated() ) {
+                       # note: buggy CC software only reads first "meta" link
+                       if( $wgEnableCreativeCommonsRdf ) {
+                               $out->addMetadataLink( array(
+                                       'title' => 'Creative Commons',
+                                       'type' => 'application/rdf+xml',
+                                       'href' => $wgTitle->getLocalURL( "action=creativecommons") ) );
+                       }
+                       if( $wgEnableDublinCoreRdf ) {
+                               $out->addMetadataLink( array(
+                                       'title' => 'Dublin Core',
+                                       'type' => 'application/rdf+xml',
+                                       'href' => $wgTitle->getLocalURL( "action=dublincore" ) ) );
+                       }
+               }
+               $copyright = "";
+               if( $wgRightsPage ) {
+                       $copy = Title::newFromText( $wgRightsPage );
+                       if( $copy ) {
+                               $copyright = $copy->getLocalURL();
+                       }
+               }
+               if( !$copyright && $wgRightsUrl ) {
+                       $copyright = $wgRightsUrl;
+               }
+               if( $copyright ) {
+                       $out->addLink( array(
+                               "rel" => "copyright",
+                               "href" => $copyright ) );
+               }
+       }
+    
        function outputPage( &$out ) {
                global $wgDebugComments;
                
@@ -114,7 +140,7 @@ class Skin {
                }
                $out->out( $this->beforeContent() );
 
-               $out->out( $out->mBodytext );
+               $out->out( $out->mBodytext . "\n" );
 
                $out->out( $this->afterContent() );
                
@@ -125,25 +151,21 @@ class Skin {
        }
 
        function getHeadScripts() {
-               global $wgStyleSheetPath;
-               $r = "<script type=\"text/javascript\" src=\"{$wgStyleSheetPath}/wikibits.js\"></script>\n";
+               global $wgStylePath;
+               $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/wikibits.js\"></script>\n";
                return $r;
        }
 
        function getUserStyles()
        {
-               global $wgOut, $wgStyleSheetPath;
-               if( $wgOut->isPrintable() ) {
-                       $sheet = "wikiprintable.css";
-               } else {
-                       $sheet = $this->getStylesheet();
-               }
-               $s = "<style type='text/css'><!--\n";
-               $s .= "@import url(\"$wgStyleSheetPath/$sheet\");\n";
+               global $wgOut, $wgStylePath;
+               $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";
                $s .= $this->doGetUserStyles();
                $s .= "/* */\n";
-               $s .= "//--></style>\n";
+               $s .= "</style>\n";
                return $s;
        }
 
@@ -157,7 +179,7 @@ class Skin {
                } else {
                        # CHECK MERGE @@@
                        # Force no underline
-                       $s .= "a.stub, a.new, a.internal, a.external { " .
+                       $s .= "a { " .
                          "text-decoration: none; }\n";
                }
                if ( 1 == $wgUser->getOption( "highlightbroken" ) ) {
@@ -171,21 +193,22 @@ class Skin {
 
        function getBodyOptions()
        {
-               global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $oldid, $redirect, $diff,$action;
+               global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
+               
+               extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
 
                if ( 0 != $wgTitle->getNamespace() ) {
                        $a = array( "bgcolor" => "#ffffec" );
                }
                else $a = array( "bgcolor" => "#FFFFFF" );
-               if($wgOut->isArticle() && $wgUser->getOption("editondblclick")
-                       && 
-                       (!$wgTitle->isProtected() || $wgUser->isSysop())
-                       
-                       ) {
+               if($wgOut->isArticle() && $wgUser->getOption("editondblclick") && 
+                 (!$wgTitle->isProtected() || $wgUser->isSysop()) ) {
                        $t = wfMsg( "editthispage" );
                        $oid = $red = "";
-                       if ( $redirect ) { $red = "&redirect={$redirect}"; }
-                       if ( $oldid && ! isset( $diff ) ) {
+                       if ( !empty($redirect) ) { 
+                               $red = "&redirect={$redirect}"; 
+                       }
+                       if ( !empty($oldid) && ! isset( $diff ) ) {
                                $oid = "&oldid={$oldid}";
                        }
                        $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
@@ -206,8 +229,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}\"";
@@ -223,14 +245,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" ) ) {
@@ -243,14 +263,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" ) ) {
@@ -272,11 +290,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 {
@@ -303,47 +316,60 @@ class Skin {
                        $borderhack = "class='top'";
                }
 
-               $s .= "\n<div id='content'>\n<div id='topbar'>" .
-                 "<table width='98%' border=0 cellspacing=0><tr>";
+               $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
+                 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
 
                $shove = ($qb != 0);
                $left = ($qb == 1 || $qb == 3);
                if($wgLang->isRTL()) $left = !$left;
                
                if ( !$shove ) {
-                       $s .= "<td class='top' align=left valign=top rowspan='{$rows}'>" .
+                       $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
                          $this->logoText() . "</td>";
                } elseif( $left ) {
                        $s .= $this->getQuickbarCompensator( $rows );
                }
                $l = $wgLang->isRTL() ? "right" : "left";
-               $s .= "<td {$borderhack} align='$l' valign='top'>";
+               $s .= "<td {$borderhack} align='$l' valign='top'>\n";
 
                $s .= $this->topLinks() ;
-               $s .= "<p class='subtitle'>" . $this->pageTitleLinks();
+               $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
 
                $r = $wgLang->isRTL() ? "left" : "right";
-               $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap>";
+               $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
                $s .= $this->nameAndLogin();
-               $s .= "\n<br>" . $this->searchForm() . "</td>";
+               $s .= "\n<br />" . $this->searchForm() . "</td>";
 
                if ( $langlinks ) {
-                       $s .= "</tr>\n<tr><td class='top' colspan=\"2\">$langlinks</td>";
+                       $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
                }
 
                if ( $shove && !$left ) { # Right
                        $s .= $this->getQuickbarCompensator( $rows );
                }
-               $s .= "</tr></table>\n</div>\n";
-               $s .= "\n<div id='article'>";
+               $s .= "</tr>\n</table>\n</div>\n";
+               $s .= "\n<div id='article'>\n";
 
                $s .= $this->pageTitle();
                $s .= $this->pageSubtitle() ;
-               $s .= getCategories(); // For some odd reason, zhis can't be a function of the object
-               $s .= "\n<p>";
+               $s .= $this->getCategories();
                wfProfileOut( $fname );
                return $s;
        }
+       
+       function getCategories () {
+               global $wgOut, $wgTitle, $wgUser, $wgParser;
+               global $wgUseCategoryMagic;
+               if( !$wgUseCategoryMagic ) return "" ;
+               if( count( $wgOut->mCategoryLinks ) == 0 ) return "";
+               if( !$wgOut->isArticle() ) return "";
+               
+               $t = implode ( " | " , $wgOut->mCategoryLinks ) ;
+               $s = $this->makeKnownLink( "Special:Categories",
+                       wfMsg( "categories" ), "article=" . urlencode( $wgTitle->getPrefixedDBkey() ) )
+                       . ": " . $t;
+               return "<p class='catlinks'>$s</p>";
+       }
 
        function getQuickbarCompensator( $rows = 1 )
        {
@@ -357,24 +383,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\">\n" . $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;
@@ -382,9 +401,9 @@ class Skin {
                wfProfileIn( $fname );
                wfProfileIn( "$fname-1" );
 
-               $s = "\n</div><br clear=all>\n";
+               $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" );
@@ -403,11 +422,11 @@ class Skin {
                $s .= "<td class='bottom' align='$l' valign='top'>";
 
                $s .= $this->bottomLinks();
-               $s .= "\n<br>" . $this->mainPageLink()
+               $s .= "\n<br />" . $this->mainPageLink()
                  . " | " . $this->aboutLink()
                  . " | " . $this->specialLink( "recentchanges" )
                  . " | " . $this->searchForm()
-                 . "<br>" . $this->pageStats();
+                 . "<br /><span id='pagestats'>" . $this->pageStats() . "</span>";
 
                $s .= "</td>";
                if ( $shove && !$left ) { # Right
@@ -425,7 +444,10 @@ class Skin {
 
        function pageTitleLinks()
        {
-               global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang, $wgUseApproval;
+               global $wgOut, $wgTitle, $wgUser, $wgLang, $wgUseApproval, $wgRequest;
+
+               extract( $wgRequest->getValues( 'oldid', 'diff' ) );
+               $action = $wgRequest->getText( 'action' );
 
                $s = $this->printableLink();
                if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ;
@@ -433,7 +455,7 @@ class Skin {
                if ( $wgOut->isArticleRelated() ) {
                        if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
                                $name = $wgTitle->getDBkey();
-                               $link = wfEscapeHTML( wfImageUrl( $name ) );
+                               $link = wfEscapeHTML( Image::wfImageUrl( $name ) );
                                $style = $this->getInternalLinkAttributes( $link, $name );
                                $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
                        }
@@ -504,24 +526,33 @@ class Skin {
        {
                global $wgOut, $wgTitle, $wgUser;
 
-               $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
+               $s = "<h1 class='pagetitle'>" . htmlspecialchars( $wgOut->getPageTitle() ) . "</h1>";
                if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
                return $s;
        }
 
        function pageSubtitle()
        {
-               global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
+               global $wgOut;
 
                $sub = $wgOut->getSubtitle();
                if ( "" == $sub ) {
                        global $wgExtraSubtitle;
                        $sub = wfMsg( "fromwikipedia" ) . $wgExtraSubtitle;
                }
-               if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
+               $subpages = $this->subPageSubtitle();
+               $sub .= !empty($subpages)?"</p><p class='subpages'>$subpages":'';
+               $s = "<p class='subtitle'>{$sub}</p>\n";
+               return $s;
+       }
+
+       function subPageSubtitle()
+       {
+               global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
+               $subpages = '';
+               if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
                        $ptext=$wgTitle->getPrefixedText();
                        if(preg_match("/\//",$ptext)) {
-                               $sub.="</p><p class='subpages'>";
                                $links=explode("/",$ptext);
                                $c=0;
                                $growinglink="";
@@ -532,19 +563,17 @@ class Skin {
                                                $getlink = $this->makeLink( $growinglink, $link );
                                                if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
                                                if ($c>1) {
-                                                       $sub .= " | ";
+                                                       $subpages .= " | ";
                                                } else  {
-                                                       $sub .="&lt; ";
+                                                       $subpages .="&lt; ";
                                                }
-                                               $sub .= $getlink;
+                                               $subpages .= $getlink;
                                                $growinglink.="/";
                                        }
-                                       
                                }
                        }
                }
-               $s = "<p class='subtitle'>{$sub}\n";
-               return $s;
+               return $subpages;
        }
 
        function nameAndLogin()
@@ -573,7 +602,7 @@ class Skin {
                                $q = "";
                        } else { $q = "returnto={$rt}"; }
                        
-                       $s .= "\n<br>" . $this->makeKnownLink( $li,
+                       $s .= "\n<br />" . $this->makeKnownLink( $li,
                          wfMsg( "login" ), $q );
                } else {
                        $n = $wgUser->getName();
@@ -585,7 +614,7 @@ class Skin {
                        $tl = " ({$tl})"; 
                        
                        $s .= $this->makeKnownLink( $wgLang->getNsText(
-                         Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
+                         Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br />" .
                          $this->makeKnownLink( $lo, wfMsg( "logout" ),
                          "returnto={$rt}" ) . " | " .
                          $this->specialLink( "preferences" );
@@ -595,17 +624,27 @@ class Skin {
 
                return $s;
        }
-
+       
+       function getSearchLink() {
+               $searchPage =& Title::makeTitle( NS_SPECIAL, "Search" );
+               return $searchPage->getLocalURL();
+       }
+       
+       function escapeSearchLink() {
+               return htmlspecialchars( $this->getSearchLink() );
+       }
+       
        function searchForm()
        {
-               global $search;
-
-               $s = "<form name='search' class='inline' method=post action=\""
-                 . wfLocalUrl( "" ) . "\">"
-                 . "<input type=text name=\"search\" size=19 value=\""
-                 . htmlspecialchars(substr($search,0,256)) . "\">\n"
-                 . "<input type=submit name=\"go\" value=\"" . wfMsg ("go") . "\">&nbsp;"
-                 . "<input type=submit name=\"fulltext\" value=\"" . wfMsg ("search") . "\"></form>";
+               global $wgRequest;
+               $search = $wgRequest->getText( 'search' );
+               
+               $s = "<form name='search' class='inline' method='post' action=\""
+                 . $this->escapeSearchLink() . "\">\n"
+                 . "<input type='text' name=\"search\" size='19' value=\""
+                 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
+                 . "<input type='submit' name=\"go\" value=\"" . wfMsg ("go") . "\" />&nbsp;"
+                 . "<input type='submit' name=\"fulltext\" value=\"" . wfMsg ("search") . "\" />\n</form>";
 
                return $s;
        }
@@ -647,7 +686,7 @@ class Skin {
                        if ( $wgTitle->getNamespace() == Namespace::getUser()
                            || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
                            
-                       {       
+                       {
                                $id=User::idFromName($wgTitle->getText());
                                $ip=User::isIP($wgTitle->getText());
                                
@@ -661,41 +700,172 @@ class Skin {
                                }
                        }
                        if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
-                               $s .= "\n<br>" . $this->deleteThisPage() .
+                               $s .= "\n<br />" . $this->deleteThisPage() .
                                $sep . $this->protectThisPage() .
                                $sep . $this->moveThisPage();
                        }
-                       $s .= "<br>\n" . $this->otherLanguages();
+                       $s .= "<br />\n" . $this->otherLanguages();
                }
                return $s;
        }
 
        function pageStats()
        {
-               global $wgOut, $wgLang, $wgArticle;
-               global $oldid, $diff, $wgDisableCounters;
+               global $wgOut, $wgLang, $wgArticle, $wgRequest;
+               global $wgDisableCounters;
 
+               extract( $wgRequest->getValues( 'oldid', 'diff' ) );
                if ( ! $wgOut->isArticle() ) { return ""; }
                if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
                if ( 0 == $wgArticle->getID() ) { return ""; }
 
-               if ( $wgDisableCounters ) {
-                       $s = "";
-               } else {
+               $s = "";
+               if ( !$wgDisableCounters ) {
                        $count = $wgLang->formatNum( $wgArticle->getCount() );
-                       $s = wfMsg( "viewcount", $count );
+                       if ( $count ) {
+                               $s = wfMsg( "viewcount", $count );
+                       }
+               }
+
+               $s .= " " . $this->getCredits();
+           
+               return $s . " " .  $this->getCopyright();
+       }
+
+        function getCredits() {
+              global $wgMaxCredits;
+              
+              $s = '';
+           
+              if (!isset($wgMaxCredits) || $wgMaxCredits == 0) {
+                       $s = $this->lastModified();
+              } else {
+                       $s = $this->getAuthorCredits();
+                       if ($wgMaxCredits > 1) {
+                           $s .= " " . $this->getContributorCredits();
+                       }
+              }
+           
+              return $s;
+       }
+
+        function getAuthorCredits() {
+               global $wgLang, $wgArticle;
+
+               $last_author = $wgArticle->getUser();
+           
+               if ($last_author == 0) {
+                   $author_credit = wfMsg("anonymous");
+               } else {
+                   $real_name = User::whoIsReal($last_author);
+                   if (!empty($real_name)) {
+                       $author_credit = $real_name;
+                   } else {
+                       $author_credit = wfMsg("siteuser", User::whoIs($last_author));
+                   }
                }
-               $s .= $this->lastModified();
-               $s .= " " . wfMsg( "gnunote" );
-               return "<span id='pagestats'>{$s}</span>";
+           
+               $timestamp = $wgArticle->getTimestamp();
+               if ( $timestamp ) {
+                       $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
+               } else {
+                       $d = "";
+               }
+               return wfMsg("lastmodifiedby", $d, $author_credit);
+       }
+
+        function getContributorCredits() {
+           
+               global $wgArticle, $wgMaxCredits, $wgLang;
+
+                # don't count last editor
+
+               $contributors = $wgArticle->getContributors($wgMaxCredits - 1);
+           
+               $real_names = array();
+               $user_names = array();
+
+               # Sift for real versus user names
+               
+               foreach ($contributors as $user_id => $user_parts) {
+                   if ($user_id != 0) {
+                       if (!empty($user_parts[1])) {
+                           $real_names[$user_id] = $user_parts[1];
+                       } else {
+                           $user_names[$user_id] = $user_parts[0];
+                       }
+                   }
+               }
+           
+                $real = $wgLang->listToText(array_values($real_names));
+               $user = $wgLang->listToText(array_values($user_names));
+
+               if (!empty($user)) {
+                   $user = wfMsg("siteusers", $user);
+               }
+           
+               if ($contributors[0] && $contributors[0][0] > 0) {
+                   $anon = wfMsg("anonymous");
+               } else {
+                   $anon = '';
+               }
+           
+               $creds = $wgLang->listToText(array($real, $user, $anon));
+           
+               return wfMsg("othercontribs", $creds);
+       }
+    
+       function getCopyright() {
+               global $wgRightsPage, $wgRightsUrl, $wgRightsText;
+               $out = "";
+               if( $wgRightsPage ) {
+                       $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
+               } elseif( $wgRightsUrl ) {
+                       $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
+               } else {
+                       # Give up now
+                       return $out;
+               }
+               $out .= wfMsg( "copyright", $link );
+               return $out;
+       }
+       
+       function getCopyrightIcon() {
+               global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
+               $out = "";
+               if( $wgRightsIcon ) {
+                       $icon = htmlspecialchars( $wgRightsIcon );
+                       if( $wgRightsUrl ) {
+                               $url = htmlspecialchars( $wgRightsUrl );
+                               $out .= "<a href=\"$url\">";
+                       }
+                       $text = htmlspecialchars( $wgRightsText );
+                       $out .= "<img src=\"$icon\" alt='$text' />";
+                       if( $wgRightsUrl ) {
+                               $out .= "</a>";
+                       }
+               }
+               return $out;
+       }
+       
+       function getPoweredBy() {
+               global $wgStylePath;
+               $url = htmlspecialchars( "$wgStylePath/images/poweredby_mediawiki_88x31.png" );
+               $img = "<a href='http://www.mediawiki.org/'><img src='$url' alt='MediaWiki' /></a>";
+               return $img;
        }
 
        function lastModified()
        {
                global $wgLang, $wgArticle;
-
-               $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
-               $s = " " . wfMsg( "lastmodified", $d );
+               
+               $timestamp = $wgArticle->getTimestamp();
+               if ( $timestamp ) {
+                       $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
+                       $s = " " . wfMsg( "lastmodified", $d );
+               } else {
+                       $s = "";
+               }
                return $s;
        }
 
@@ -707,25 +877,27 @@ class Skin {
                $mp = wfMsg( "mainpage" );
                $titleObj = Title::newFromText( $mp );
                $s = "<a href=\"" . $titleObj->escapeLocalURL()
-                 . "\"><img{$a} border=0 src=\""
-                 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
+                 . "\"><img{$a} src=\""
+                 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\" /></a>";
                return $s;
        }
 
        function quickBar()
        {
-               global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
-               global $wpPreview, $wgDisableUploads, $wgRemoteUploads;
+               global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgLang;
+               global $wgDisableUploads, $wgRemoteUploads;
            
                $fname =  "Skin::quickBar";
                wfProfileIn( $fname );
 
+               $action = $wgRequest->getText( 'action' );
+               $wpPreview = $wgRequest->getBool( 'wpPreview' );
                $tns=$wgTitle->getNamespace();
 
                $s = "\n<div id='quickbar'>";
-               $s .= "\n" . $this->logoText() . "\n<hr class='sep'>";
+               $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
 
-               $sep = "\n<br>";
+               $sep = "\n<br />";
                $s .= $this->mainPageLink()
                  . $sep . $this->specialLink( "recentchanges" )
                  . $sep . $this->specialLink( "randompage" );
@@ -737,7 +909,7 @@ class Skin {
                }
                // only show watchlist link if logged in
                if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
-               $s .= "\n<br><hr class='sep'>";
+               $s .= "\n<br /><hr class='sep' />";
                $articleExists = $wgTitle->getArticleId();
                if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {                            
                        if($wgOut->isArticle()) {
@@ -778,7 +950,7 @@ class Skin {
                                                $link = $nstext . ":" . $link ;
                                        }                       
 
-                                       $s .= $this->makeLink( $link, $text );                  
+                                       $s .= $this->makeLink( $link, $text );
                                } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
                                        # we just throw in a "New page" text to tell the user that he's in edit mode,
                                        # and to avoid messing with the separator that is prepended to the next item
@@ -789,7 +961,7 @@ class Skin {
                        
 
                        if( $tns%2 && $action!="edit" && !$wpPreview) {
-                               $s.="<br>".$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("postcomment"),"action=edit&section=new");
+                               $s.="<br />".$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("postcomment"),"action=edit&section=new");
                        }
 
                        /*
@@ -797,13 +969,13 @@ class Skin {
                        if user edits article, then loads "watch this article" in background and then saves
                        article with "Watch this article" checkbox disabled, the article is transparently
                        unwatched. Therefore we do not show the "Watch this page" link in edit mode
-                       */                      
+                       */
                        if ( 0 != $wgUser->getID() && $articleExists) {
-                               if($action!="edit" && $action != "submit" ) 
+                               if($action!="edit" && $action != "submit" )
                                {
-                                       $s .= $sep . $this->watchThisPage(); 
+                                       $s .= $sep . $this->watchThisPage();
                                }
-                               if ( $wgTitle->userCanEdit() ) 
+                               if ( $wgTitle->userCanEdit() )
                                        $s .= $sep . $this->moveThisPage();
                        }
                        if ( $wgUser->isSysop() and $articleExists ) {
@@ -811,7 +983,7 @@ class Skin {
                                $sep . $this->protectThisPage();
                        }
                        $s .= $sep . $this->talkLink();
-                       if ($articleExists && $action !="history") { 
+                       if ($articleExists && $action !="history") {
                                $s .= $sep . $this->historyLink();
                        }
                        $s.=$sep . $this->whatLinksHere();
@@ -836,7 +1008,7 @@ class Skin {
                                        }
                                }
                        }
-                       $s .= "\n<br><hr class='sep'>";
+                       $s .= "\n<br /><hr class='sep' />";
                } 
                
                if ( 0 != $wgUser->getID() && ( !$wgDisableUploads || $wgRemoteUploads ) ) {
@@ -847,11 +1019,11 @@ class Skin {
                
                global $wgSiteSupportPage;
                if( $wgSiteSupportPage ) {
-                       $s .= "\n<br><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
+                       $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
                          "\" class=\"internal\">" . wfMsg( "sitesupport" ) . "</a>";
                }
        
-               $s .= "\n<br></div>\n";
+               $s .= "\n<br /></div>\n";
                wfProfileOut( $fname );
                return $s;
        }
@@ -890,7 +1062,7 @@ class Skin {
                $spp = $wgLang->specialPage( "Specialpages" );
 
                $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
-                 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
+                 "action=\"" . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
                $s .= "<select name=\"wpDropdown\">\n";
                $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
 
@@ -899,7 +1071,7 @@ class Skin {
                        $s .= "<option value=\"{$p}\">{$desc}</option>\n";
                }
                $s .= "</select>\n";
-               $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
+               $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
                $s .= "</form>\n";
                return $s;
        }
@@ -935,8 +1107,12 @@ class Skin {
 
        function editThisPage()
        {
-               global $wgOut, $wgTitle, $oldid, $redirect, $diff;
-
+               global $wgOut, $wgTitle, $wgRequest;
+               
+               $oldid = $wgRequest->getVal( 'oldid' );
+               $diff = $wgRequest->getVal( 'diff' );
+               $redirect = $wgRequest->getVal( 'redirect' );
+               
                if ( ! $wgOut->isArticleRelated() ) {
                        $s = wfMsg( "protectedpage" );
                } else {
@@ -949,7 +1125,7 @@ class Skin {
                        }
                        $oid = $red = "";
 
-                       if ( $redirect ) { $red = "&redirect={$redirect}"; }
+                       if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
                        if ( $oldid && ! isset( $diff ) ) {
                                $oid = "&oldid={$oldid}";
                        }
@@ -960,8 +1136,9 @@ class Skin {
 
        function deleteThisPage()
        {
-               global $wgUser, $wgOut, $wgTitle, $diff;
+               global $wgUser, $wgOut, $wgTitle, $wgRequest;
 
+               $diff = $wgRequest->getVal( 'diff' );
                if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
                        $n = $wgTitle->getPrefixedText();
                        $t = wfMsg( "deletethispage" );
@@ -975,8 +1152,9 @@ class Skin {
 
        function protectThisPage()
        {
-               global $wgUser, $wgOut, $wgTitle, $diff;
+               global $wgUser, $wgOut, $wgTitle, $wgRequest;
 
+               $diff = $wgRequest->getVal( 'diff' );
                if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
                        $n = $wgTitle->getPrefixedText();
 
@@ -996,7 +1174,7 @@ class Skin {
 
        function watchThisPage()
        {
-               global $wgUser, $wgOut, $wgTitle, $diff;
+               global $wgUser, $wgOut, $wgTitle;
 
                if ( $wgOut->isArticleRelated() ) {
                        $n = $wgTitle->getPrefixedText();
@@ -1081,7 +1259,6 @@ class Skin {
                global $wgOut, $wgLang, $wgTitle, $wgUseNewInterlanguage;
 
                $a = $wgOut->getLanguageLinks();
-               # TEST THIS @@@
                if ( 0 == count( $a ) ) {
                        if ( !$wgUseNewInterlanguage ) return "";
                        $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
@@ -1185,7 +1362,7 @@ class Skin {
                                $text= wfMsg("articlepage");
                        }
                } else {
-                       
+
                        $lns = Namespace::getTalk( $tns );
                        $text=$tp;                      
                }
@@ -1237,21 +1414,21 @@ class Skin {
        function makeLink( $title, $text = "", $query = "", $trail = "" ) {
                wfProfileIn( "Skin::makeLink" );
                $nt = Title::newFromText( $title );
-               if ($nt) {              
+               if ($nt) {
                        $result = $this->makeLinkObj( Title::newFromText( $title ), $text, $query, $trail );
                } else {
                        wfDebug( "Invalid title passed to Skin::makeLink(): \"$title\"\n" );
                        $result = $text == "" ? $title : $text;
-               }       
-               
+               }
+
                wfProfileOut( "Skin::makeLink" );
                return $result;
        }
 
-       function makeKnownLink( $title, $text = "", $query = "", $trail = "" ) {
+       function makeKnownLink( $title, $text = "", $query = "", $trail = "", $prefix = '',$aprops = '') {
                $nt = Title::newFromText( $title );
-               if ($nt) {              
-                       return $this->makeKnownLinkObj( Title::newFromText( $title ), $text, $query, $trail );
+               if ($nt) {
+                       return $this->makeKnownLinkObj( Title::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
                } else {
                        wfDebug( "Invalid title passed to Skin::makeKnownLink(): \"$title\"\n" );
                        return $text == "" ? $title : $text;
@@ -1260,7 +1437,7 @@ class Skin {
 
        function makeBrokenLink( $title, $text = "", $query = "", $trail = "" ) {
                $nt = Title::newFromText( $title );
-               if ($nt) {              
+               if ($nt) {
                        return $this->makeBrokenLinkObj( Title::newFromText( $title ), $text, $query, $trail );
                } else {
                        wfDebug( "Invalid title passed to Skin::makeBrokenLink(): \"$title\"\n" );
@@ -1284,6 +1461,7 @@ class Skin {
                global $wgOut, $wgUser;
                if ( $nt->isExternal() ) {
                        $u = $nt->getFullURL();
+                       $link = $nt->getPrefixedURL();
                        if ( "" == $text ) { $text = $nt->getPrefixedText(); }
                        $style = $this->getExternalLinkAttributes( $link, $text );
 
@@ -1321,7 +1499,7 @@ class Skin {
                                        }
                                } else {
                                        $size = 1 ;
-                               }       
+                               }
                                if ( $size < $threshold ) {
                                        $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
                                } else {
@@ -1333,7 +1511,7 @@ class Skin {
        }
 
        # Pass a title object, not a title string
-       function makeKnownLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" )
+       function makeKnownLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" , $aprops = '')
        {
                global $wgOut, $wgTitle;
 
@@ -1344,14 +1522,18 @@ class Skin {
 
                if ( "" == $link ) {
                        $u = "";
-                       if ( "" == $text ) { $text = $nt->getFragment(); }
+                       if ( "" == $text ) {
+                               $text = htmlspecialchars( $nt->getFragment() );
+                       }
                } else {
                        $u = $nt->escapeLocalURL( $query );
                }
                if ( "" != $nt->getFragment() ) {
-                       $u .= "#" . wfEscapeHTML( $nt->getFragment() );
+                       $u .= "#" . htmlspecialchars( $nt->getFragment() );
+               }
+               if ( "" == $text ) {
+                       $text = htmlspecialchars( $nt->getPrefixedText() );
                }
-               if ( "" == $text ) { $text = $nt->getPrefixedText(); }
                $style = $this->getInternalLinkAttributesObj( $nt, $text );
 
                $inside = "";
@@ -1361,16 +1543,16 @@ class Skin {
                                $trail = $m[2];
                        }
                }
-               $r = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
+               $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
                wfProfileOut( $fname );
                return $r;
        }
-       
+
        # Pass a title object, not a title string
        function makeBrokenLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" )
        {
                global $wgOut, $wgUser;
-               
+
                $fname = "Skin::makeBrokenLinkObj";
                wfProfileIn( $fname );
 
@@ -1381,7 +1563,9 @@ class Skin {
                }
                $u = $nt->escapeLocalURL( $q );
 
-               if ( "" == $text ) { $text = $nt->getPrefixedText(); }
+               if ( "" == $text ) {
+                       $text = htmlspecialchars( $nt->getPrefixedText() );
+               }
                $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
 
                $inside = "";
@@ -1391,8 +1575,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}";
@@ -1411,7 +1594,9 @@ class Skin {
 
                $u = $nt->escapeLocalURL( $query );
 
-               if ( "" == $text ) { $text = $nt->getPrefixedText(); }
+               if ( "" == $text ) {
+                       $text = htmlspecialchars( $nt->getPrefixedText() );
+               }
                $style = $this->getInternalLinkAttributesObj( $nt, $text, "stub" );
 
                $inside = "";
@@ -1421,14 +1606,68 @@ 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}";
                }
                return $s;
        }
+       
+       function makeSelfLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" )
+       {
+               $u = $nt->escapeLocalURL( $query );
+               if ( "" == $text ) {
+                       $text = htmlspecialchars( $nt->getPrefixedText() );
+               }
+               $inside = "";
+               if ( "" != $trail ) {
+                       if ( preg_match( $this->linktrail, $trail, $m ) ) {
+                               $inside = $m[1];
+                               $trail = $m[2];
+                       }
+               }
+               return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
+       }
+
+       /* these are used extensively in SkinPHPTal, but also some other places */
+       /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
+               $title = Title::makeTitle( NS_SPECIAL, $name );
+               $this->checkTitle(&$title, &$name);     
+               return $title->getLocalURL( $urlaction );
+       }
+       /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
+               $title = Title::newFromText( $name );
+               $title = $title->getTalkPage();
+               $this->checkTitle(&$title, &$name);     
+               return $title->getLocalURL( $urlaction );
+       }
+       /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
+               $title = Title::newFromText( $name );
+               $title= $title->getSubjectPage();
+               $this->checkTitle(&$title, &$name);     
+               return $title->getLocalURL( $urlaction );
+       }
+       /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
+               $title = Title::newFromText( wfMsg($name) );
+               $this->checkTitle(&$title, &$name);     
+               return $title->getLocalURL( $urlaction );
+       }
+       /*static*/ function makeUrl ( $name, $urlaction='' ) {
+               $title = Title::newFromText( $name );
+               $this->checkTitle(&$title, &$name);     
+               return $title->getLocalURL( $urlaction ); 
+       }
+
+       # make sure we have some title to operate on, mind the '&'
+       /*static*/ function &checkTitle ( $title, $name ) { 
+               if(!is_object($title)) {
+                       $title = Title::newFromText( $name );
+                       if(!is_object($title)) {
+                               $title = Title::newFromText( '<error: link target missing>' );
+                       }
+               }
+       }
 
        function fnamePart( $url )
        {
@@ -1443,7 +1682,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;
        }
        
@@ -1454,8 +1693,9 @@ class Skin {
 
        function makeImageLinkObj( $nt, $alt = "" ) {
                global $wgLang, $wgUseImageResize;
-               $name  = $nt->getDBKey();
-               $url   = wfImageUrl( $name );
+               $img   = Image::newFromTitle( $nt );
+               $url   = $img->getURL();
+
                $align = "";
                $prefix = $postfix = "";
 
@@ -1467,6 +1707,8 @@ class Skin {
                        #  * right              same, but right aligned
                        #  * none               same, but not aligned
                        #  * ___px              scale to ___ pixels width, no aligning. e.g. use in taxobox
+                       #  * center             center the image
+                       #  * framed             Keep original image size, no magnify-button.
        
                        $part = explode( "|", $alt);
        
@@ -1476,9 +1718,10 @@ class Skin {
                        $mwNone   =& MagicWord::get( MAG_IMG_NONE );
                        $mwWidth  =& MagicWord::get( MAG_IMG_WIDTH );
                        $mwCenter =& MagicWord::get( MAG_IMG_CENTER );
+                       $mwFramed =& MagicWord::get( MAG_IMG_FRAMED );
                        $alt = $part[count($part)-1];
 
-                       $thumb=false;
+                       $framed=$thumb=false;
 
                        foreach( $part as $key => $val ) {
                                if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
@@ -1498,16 +1741,18 @@ class Skin {
                                } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
                                        # $match is the image width in pixels
                                        $width = intval($match);
+                               } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
+                                       $framed=true;
                                }
                        }
                        if ( "center" == $align )
                        {
-                               $prefix  = "<center>";
-                               $postfix = "</center>";
+                               $prefix  = '<span style="text-align: center">';
+                               $postfix = '</span>';
                                $align   = "none";
                        }
        
-                       if ( $thumb ) {
+                       if ( $thumb || $framed ) {
        
                                # Create a thumbnail. Alignment depends on language
                                # writing direction, # right aligned for left-to-right-
@@ -1522,180 +1767,93 @@ class Skin {
                                if ( ! isset($width) ) {
                                        $width = 180;
                                }
-                               return $prefix.$this->makeThumbLinkObj( $nt, $alt, $align, $width ).$postfix;
+                               return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $framed ).$postfix;
        
                        } elseif ( isset($width) ) {
                                
                                # Create a resized image, without the additional thumbnail
                                # features
-                               $url = $this->createThumb( $name, $width );
+                               $url = $img->createThumb( $width );
                        }
                } # endif $wgUseImageResize
                        
                if ( empty( $alt ) ) {
-                       $alt = preg_replace( '/\.(.+?)^/', '', $name );
+                       $alt = preg_replace( '/\.(.+?)^/', '', $img->getName() );
                }
                $alt = htmlspecialchars( $alt );
 
                $u = $nt->escapeLocalURL();
                if ( $url == "" )
                {
-                       $s = str_replace( "$1", $name, wfMsg("missingimage") );
+                       $s = str_replace( "$1", $img->getName(), wfMsg("missingimage") );
+                       $s .= "<br>{$alt}<br>{$url}<br>\n";
                } else {
                        $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
-                               "<img border=\"0\" src=\"{$url}\" alt=\"{$alt}\"></a>";
+                               "<img src=\"{$url}\" alt=\"{$alt}\" /></a>";
                }
                if ( "" != $align ) {
-                       $s = "<div class=\"float{$align}\">{$s}</div>";
+                       $s = "<div class=\"float{$align}\"><span>{$s}</span>\n</div>";
                }
                return $prefix.$s.$postfix;
        }
 
-       function createThumb( $name, $width ) {
-               global $wgUploadDirectory;
-               global $wgImageMagickConvertCommand;
-               global $wgUseImageMagick;
-               global $wgUseSquid, $wgInternalServer;
-               $imgPath   = wfImagePath( $name );
-               $thumbName = $width."px-".$icon.$name;
-               $thumbPath = wfImageThumbDir( $thumbName )."/".$thumbName;
-               $thumbUrl  = wfImageThumbUrl( $thumbName );
-
-               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 ) {
-                               $urlArr = Array(
-                                       $wgInternalServer.$thumbUrl
-                               );
-                               wfPurgeSquidServers($urlArr);
-                       }
-
-                       if ( $wgUseImageMagick ) {
-                               # use ImageMagick
-                               $cmd  =  $wgImageMagickConvertCommand .
-                                       " -quality 85 -geometry {$width} ".
-                                       escapeshellarg($imgPath) . " " .
-                                       escapeshellarg($thumbPath);
-                               $conv = shell_exec( $cmd );
-                       } else {
-                               # Use PHP's builtin GD library functions.
-                               #
-                               # First find out what kind of file this is, and select the correct
-                               # input routine for this.
-                               list($src_width, $src_height, $src_type, $src_attr) = getimagesize( $imgPath );
-                               switch( $src_type ) {
-                                       case 1: # GIF
-                                               $src_image = imagecreatefromgif( $imgPath );
-                                               break;
-                                       case 2: # JPG
-                                               $src_image = imagecreatefromjpeg( $imgPath );
-                                               break;
-                                       case 3: # PNG
-                                               $src_image = imagecreatefrompng( $imgPath );
-                                               break;
-                                       case 15: # WBMP for WML
-                                               $src_image = imagecreatefromwbmp( $imgPath );
-                                               break;
-                                       case 16: # XBM
-                                               $src_image = imagecreatefromxbm( $imgPath );
-                                               break;
-                                       default:
-                                               return "Image type not supported";
-                                               break;
-                               }
-                               $height = floor( $src_height * ( $width/$src_width ) );
-                               $dst_image = imagecreatetruecolor( $width, $height );
-                               imagecopyresampled( $dst_image, $src_image, 
-                                                       0,0,0,0,
-                                                       $width, $height, $src_width, $src_height );
-                               switch( $src_type ) {
-                                       case 1:  # GIF
-                                       case 3:  # PNG
-                                       case 15: # WBMP
-                                       case 16: # XBM
-                                               #$thumbUrl .= ".png";
-                                               #$thumbPath .= ".png";
-                                               imagepng( $dst_image, $thumbPath );
-                                               break;
-                                       case 2:  # JPEG
-                                               #$thumbUrl .= ".jpg";
-                                               #$thumbPath .= ".jpg";
-                                               imageinterlace( $dst_image );
-                                               imagejpeg( $dst_image, $thumbPath, 95 );
-                                               break;
-                                       default:
-                                               break;
-                               }
-                               imagedestroy( $dst_image );
-                               imagedestroy( $src_image );
-
-
-                       }
-                       #
-                       # Check for zero-sized thumbnails. Those can be generated when 
-                       # no disk space is available or some other error occurs
-                       #
-                       $thumbstat = stat( $thumbPath );
-                       $imgstat   = stat( $imgPath );
-                       if( $thumbstat["size"] == 0 )
-                       {
-                               unlink( $thumbPath );
-                       }
 
-               }
-               return $thumbUrl;
-       }
-
-       function makeThumbLinkObj( $nt, $label = "", $align = "right", $boxwidth = 180 ) {
-               global $wgUploadPath, $wgLang;
-               $name = $nt->getDBKey();
-               $image = Title::makeTitle( Namespace::getImage(), $name );
-               $url  = wfImageUrl( $name );
-               $path = wfImagePath( $name );
+       function makeThumbLinkObj( $img, $label = "", $align = "right", $boxwidth = 180, $framed=false ) {
+               global $wgStylePath, $wgLang;
+               # $image = Title::makeTitle( Namespace::getImage(), $name );
+               $url  = $img->getURL();
                
                #$label = htmlspecialchars( $label );
                $alt = preg_replace( "/<[^>]*>/", "", $label);
                $alt = htmlspecialchars( $alt );
                
-               if ( file_exists( $path ) )
+               if ( $img->exists() )
                {
-                       list($width, $height, $type, $attr) = getimagesize( $path );
+                       $width  = $img->getWidth();
+                       $height = $img->getHeight();
                } else {
                        $width = $height = 200;
                }
-               $boxheight  = intval( $height/($width/$boxwidth) );
-               if ( $boxwidth > $width ) {
+               if ( $framed )
+               {
+                       // Use image dimensions, don't scale
                        $boxwidth  = $width;
                        $boxheight = $height;
+                       $thumbUrl  = $url;
+               } else {
+                       $boxheight  = intval( $height/($width/$boxwidth) );
+                       # if ( $boxwidth > $width ) {
+                       #       $boxwidth  = $width;
+                       #       $boxheight = $height;
+                       #}
+                       $thumbUrl = $img->createThumb( $boxwidth );
                }
-               
-               $thumbUrl = $this->createThumb( $name, $boxwidth );
+               $oboxwidth = $boxwidth + 2;
 
-               $u = $nt->escapeLocalURL();
+               $u = $img->getEscapeLocalURL();
 
                $more = htmlspecialchars( wfMsg( "thumbnail-more" ) );
                $magnifyalign = $wgLang->isRTL() ? "left" : "right";
-               $textalign = $wgLang->isRTL() ? " style=\"text-align:right\"" : "";
+               $textalign = $wgLang->isRTL() ? ' style="text-align:right"' : "";
 
-               $s = "<div class=\"thumbnail-{$align}\" style=\"width:{$boxwidth}px;\">";
+               $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
                if ( $thumbUrl == "" ) {
-                       $s .= str_replace( "$1", $name, wfMsg("missingimage") );
+                       $s .= str_replace( "$1", $img->getName(), wfMsg("missingimage") );
+                       $zoomicon = '';
                } else {
-                       $s .= "<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=\"{$magnifyalign}\" alt=\"{$more}\"></a>";
-               }
-               $s .= "<p{$textalign}>{$label}</p></div>";
+                       $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
+                               '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
+                               'width="'.$boxwidth.'" height="'.$boxheight.'" /></a>';
+                       if ( $framed ) {
+                               $zoomicon="";
+                       } else {
+                               $zoomicon =  '<div class="magnify" style="float:'.$magnifyalign.'">'.
+                                       '<a href="'.$u.'" class="internal" title="'.$more.'">'.
+                                       '<img src="'.$wgStylePath.'/images/magnify-clip.png" ' .
+                                       'width="15" height="11" alt="'.$more.'" /></a></div>';
+                       }
+               }
+               $s .= '  <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div>\n</div>";
                return $s;
        }
 
@@ -1707,7 +1865,7 @@ class Skin {
        function makeMediaLinkObj( $nt, $alt = "" )
        {
                $name = $nt->getDBKey();
-               $url = wfImageUrl( $name );
+               $url = Image::wfImageUrl( $name );
                if ( empty( $alt ) ) {
                        $alt = preg_replace( '/\.(.+?)^/', '', $name );
                }
@@ -1726,6 +1884,15 @@ class Skin {
                return $this->makeKnownLink( $wgLang->specialPage( $pn ),
                  wfMsg( $key ) );
        }
+       
+       function makeExternalLink( $url, $text, $escape = true ) {
+               $style = $this->getExternalLinkAttributes( $url, $text );
+               $url = htmlspecialchars( $url );
+               if( $escape ) {
+                       $text = htmlspecialchars( $text );
+               }
+               return "<a href=\"$url\"$style>$text</a>";
+       }
 
        # Called by history lists and recent changes
        #
@@ -1737,13 +1904,14 @@ class Skin {
                $this->rcMoveIndex = 0;
                $this->rcCacheIndex = 0 ;
                $this->lastdate = "";
+               $this->rclistOpen = false;
                return "";
        }
 
        function beginImageHistoryList()
        {
                $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
-                 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
+                 "<p>" . wfMsg( "imghistlegend" ) . "</p>\n<ul class='special'>";
                return $s;
        }
 
@@ -1752,30 +1920,33 @@ class Skin {
        function endRecentChangesList()
        {
                $s = $this->recentChangesBlock() ;
-               $s .= "</ul>\n";
+               if( $this->rclistOpen ) {
+                       $s .= "</ul>\n";
+               }
                return $s;
        }
 
        # Enhanced RC ungrouped line
-       function recentChangesBlockLine ( $rcObj ) 
+       function recentChangesBlockLine ( $rcObj )
        {
-               global $wgUploadPath, $wgLang ;
-               
+               global $wgStylePath, $wgLang ;
+
                # Get rc_xxxx variables
                extract( $rcObj->mAttribs ) ;
                $curIdEq = "curid=$rc_cur_id";
-               
+
                # Spacer image
                $r = "" ;
-               $r .= "<img src='{$wgUploadPath}/Arr_.png' width='12' height='12' border='0'>" ;                $r .= "<tt>" ;
-               
+
+               $r .= "<img src='{$wgStylePath}/images/Arr_.png' width='12' height='12' border='0' />" ;                $r .= "<tt>" ;
+
                if ( $rc_type == RC_MOVE ) {
                        $r .= "&nbsp;&nbsp;";
                } else {
                        # M & N (minor & new)
                        $M = wfMsg( "minoreditletter" );
                        $N = wfMsg( "newpageletter" );
-               
+
                        if ( $rc_type == RC_NEW ) {
                                $r .= $N ;
                        } else {
@@ -1787,7 +1958,7 @@ class Skin {
                                $r .= "&nbsp;" ;
                        }
                }
-               
+
                # Timestamp
                $r .= " ".$rcObj->timestamp." " ;
                $r .= "</tt>" ;
@@ -1801,31 +1972,33 @@ class Skin {
                $r .= " (" ;
                $r .= $rcObj->curlink ;
                $r .= "; " ;
-               
+
                # Hist
                $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" );
 
                # User/talk
                $r .= ") . . ".$rcObj->userlink ;
                $r .= $rcObj->usertalklink ;
-               
+
                # Comment
                if ( $rc_comment != "" && $rc_type != RC_MOVE ) {
-                       $r .= $wgLang->emphasize( " (".wfEscapeHTML($rc_comment).")" );
+                       $rc_comment=$this->formatComment($rc_comment);
+                       $r .= $wgLang->emphasize( " (".$rc_comment.")" );
                }
-               $r .= "<br>\n" ;
+
+               $r .= "<br />\n" ;
                return $r ;
        }
 
        # Enhanced RC group
-       function recentChangesBlockGroup ( $block ) 
+       function recentChangesBlockGroup ( $block )
        {
-               global $wgUploadPath, $wgLang ;
-               
+               global $wgStylePath, $wgLang ;
+
                $r = "" ;
                $M = wfMsg( "minoreditletter" );
                $N = wfMsg( "newpageletter" );
-               
+
                # Collate list of users
                $isnew = false ;
                $userlinks = array () ;
@@ -1836,7 +2009,7 @@ class Skin {
                        if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
                        $userlinks[$u]++ ;
                }
-               
+
                # Sort the list and convert to text
                krsort ( $userlinks ) ;
                asort ( $userlinks ) ;
@@ -1854,8 +2027,8 @@ class Skin {
                $rcm = "RCM{$this->rcCacheIndex}" ;
                $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>" ;
+               $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 ;
 
                # Main line
@@ -1868,7 +2041,7 @@ class Skin {
                # Timestamp
                $r .= " ".$block[0]->timestamp." " ;
                $r .= "</tt>" ;
-               
+
                # Article link
                $link = $block[0]->link ;
                if ( $block[0]->watched ) $link = "<strong>{$link}</strong>" ;
@@ -1889,7 +2062,7 @@ class Skin {
                }
 
                $r .= $users ;
-               $r .= "<br>\n" ;
+               $r .= "<br />\n" ;
 
                # Sub-entries
                $r .= "<div id='{$rci}' style='display:none'>" ;
@@ -1897,7 +2070,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='{$wgStylePath}/images/Arr_.png' width=12 height=12 />";
                        $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
                        if ( $rc_new ) $r .= $N ;
                        else $r .= "&nbsp;" ;
@@ -1924,9 +2097,10 @@ class Skin {
                        $r .= ") . . ".$rcObj->userlink ;
                        $r .= $rcObj->usertalklink ;
                        if ( $rc_comment != "" ) {
-                               $r .= $wgLang->emphasize( " (".wfEscapeHTML($rc_comment).")" ) ;
+                               $rc_comment=$this->formatComment($rc_comment);
+                               $r .= $wgLang->emphasize( " (".$rc_comment.")" ) ;
                        }
-                       $r .= "<br>\n" ;
+                       $r .= "<br />\n" ;
                }
                $r .= "</div>\n" ;
 
@@ -1938,7 +2112,7 @@ class Skin {
        # RC lines, arranges them, and outputs the HTML
        function recentChangesBlock ()
        {
-               global $wgUploadPath ;
+               global $wgStylePath ;
                if ( count ( $this->rc_cache ) == 0 ) return "" ;
                $blockOut = "";
                foreach ( $this->rc_cache AS $secureName => $block ) {
@@ -1964,25 +2138,26 @@ class Skin {
                        $line = $this->recentChangesLineOld ( $rc, $watched ) ;
                return $line ;
        }
-       
+
        function recentChangesLineOld( &$rc, $watched = false )
        {
-               global $wgTitle, $wgLang, $wgUser;
-               
+               global $wgTitle, $wgLang, $wgUser, $wgRCSeconds;
+
                # Extract DB fields into local scope
                extract( $rc->mAttribs );
                $curIdEq = "curid=" . $rc_cur_id;
-               
+
                # Make date header if necessary
                $date = $wgLang->date( $rc_timestamp, true);
                $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;
+                       $this->rclistOpen = true;
                }
                $s .= "<li> ";
-               
+
                if ( $rc_type == RC_MOVE ) {
                        # Diff
                        $s .= "(" . wfMsg( "diff" ) . ") (";
@@ -2001,12 +2176,12 @@ class Skin {
                                $diffLink = wfMsg( "diff" );
                        } else {
                                $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "diff" ),
-                                 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}" );
+                                 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}"  ,'' ,'' , ' tabindex="'.$rc->counter.'"');
                        }
                        $s .= "($diffLink) (";
-                       
+
                        # History link
-                       $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" ); 
+                       $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" );
                        $s .= ") . . ";
 
                        # M and N (minor and new)
@@ -2024,19 +2199,19 @@ class Skin {
                        $s .= " $articleLink";
 
                }
-               
+
                # Timestamp
-               $s .= "; " . $wgLang->time( $rc_timestamp, true ) . " . . ";
-               
+               $s .= "; " . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . " . . ";
+
                # User link (or contributions for unregistered users)
                if ( 0 == $rc_user ) {
                        $userLink = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
-                       $rc_user_text, "target=" . $rc_user_text );                                     
-               } else { 
-                       $userLink = $this->makeLink( $wgLang->getNsText( NS_USER ) . ":{$rc_user_text}", $rc_user_text ); 
+                       $rc_user_text, "target=" . $rc_user_text );
+               } else {
+                       $userLink = $this->makeLink( $wgLang->getNsText( NS_USER ) . ":{$rc_user_text}", $rc_user_text );
                }
                $s .= $userLink;
-               
+
                # User talk link
                $talkname=$wgLang->getNsText(NS_TALK); # use the shorter name
                global $wgDisableAnonTalk;
@@ -2051,9 +2226,9 @@ class Skin {
                if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
                        $blockLink = $this->makeKnownLink( $wgLang->specialPage(
                          "Blockip" ), wfMsg( "blocklink" ), "ip={$rc_user_text}" );
-                       
+
                }
-               if($blockLink) { 
+               if($blockLink) {
                        if($userTalkLink) $userTalkLink .= " | ";
                        $userTalkLink .= $blockLink;
                }
@@ -2061,17 +2236,18 @@ class Skin {
 
                # Add comment
                if ( "" != $rc_comment && "*" != $rc_comment && $rc_type != RC_MOVE ) {
-                       $s .= $wgLang->emphasize(" (" . wfEscapeHTML( $rc_comment ) . ")");
+                       $rc_comment=$this->formatComment($rc_comment);
+                       $s .= $wgLang->emphasize(" (" . $rc_comment . ")");
                }
                $s .= "</li>\n";
 
                return $s;
        }
-       
+
 #      function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
        function recentChangesLineNew( &$baseRC, $watched = false )
        {
-               global $wgTitle, $wgLang, $wgUser;
+               global $wgTitle, $wgLang, $wgUser, $wgRCSeconds;
 
                # Create a specialised object
                $rc = RCCacheEntry::newFromParent( $baseRC ) ;
@@ -2100,7 +2276,7 @@ class Skin {
                        $clink = $this->makeKnownLinkObj( $rc->getTitle(), "" ) ;
                }
                
-               $time = $wgLang->time( $rc_timestamp, true );
+               $time = $wgLang->time( $rc_timestamp, true, $wgRCSeconds );
                $rc->watched = $watched ;
                $rc->link = $clink ;
                $rc->timestamp = $time;
@@ -2110,7 +2286,7 @@ class Skin {
                        $curLink = wfMsg( "cur" );
                } else {
                        $curLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "cur" ),
-                         "{$curIdEq}&diff=0&oldid={$rc_this_oldid}" );
+                         "{$curIdEq}&diff=0&oldid={$rc_this_oldid}" ,'' ,'' , ' tabindex="'.$baseRC->counter.'"' );
                }
 
                # Make "last" link
@@ -2175,6 +2351,56 @@ class Skin {
                return $s;
        }
 
+       /* This function is called by all recent changes variants, by the page history,
+          and by the user contributions list. It is responsible for formatting edit
+          comments. It escapes any HTML in the comment, but adds some CSS to format
+          auto-generated comments (from section editing) and formats [[wikilinks]].
+          Main author: Erik Möller (moeller@scireview.de)
+       */
+       function formatComment($comment)
+       {
+               global $wgLang;
+               $comment=wfEscapeHTML($comment);
+
+               # The pattern for autogen comments is / * foo * /, which makes for
+               # some nasty regex.
+               # We look for all comments, match any text before and after the comment,
+               # add a separator where needed and format the comment itself with CSS
+               while (preg_match("/(.*)\/\*\s*(.*?)\s*\*\/(.*)/", $comment,$match)) {
+                       $pre=$match[1];
+                       $auto=$match[2];
+                       $post=$match[3];
+                       $sep="-";
+                       if($pre) { $auto="$sep ".$auto; }
+                       if($post) { $auto.=" $sep"; }
+                       $auto="<span class=\"autocomment\">".$auto."</span>";
+                       $comment=$pre.$auto.$post;
+               }
+
+               # format regular and media links - all other wiki formatting
+               # is ignored
+               while(preg_match("/\[\[(.*?)(\|(.*?))*\]\]/",$comment,$match)) {
+
+                       $medians = $wgLang->getNsText(Namespace::getMedia());
+                       $func="makeLink";
+                       if(preg_match("/^".$medians."/i",$match[1])) {
+                               $func="makeMediaLink";
+                       }
+                       if(isset($match[3]) ) {
+                               $comment=
+                               preg_replace("/\[\[(.*?)\]\]/",
+                               $this->$func($match[1],$match[3]),$comment,1);
+                       } else {
+                               $comment=
+                               preg_replace("/\[\[(.*?)\]\]/",
+                               $this->$func($match[1],$match[1]),$comment,1);
+                       }
+               }
+
+               return $comment;
+
+       }
+
        function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
        {
                global $wgUser, $wgLang, $wgTitle;
@@ -2184,10 +2410,10 @@ class Skin {
                $cur = wfMsg( "cur" );
 
                if ( $iscur ) {
-                       $url = wfImageUrl( $img );
+                       $url = Image::wfImageUrl( $img );
                        $rlink = $cur;
                        if ( $wgUser->isSysop() ) {
-                               $link = $wgTitle->escapeLocalURL( "image=" . $wgTitle->getPartialURL() . 
+                               $link = $wgTitle->escapeLocalURL( "image=" . $wgTitle->getPartialURL() .
                                  "&action=delete" );
                                $style = $this->getInternalLinkAttributes( $link, $del );
 
@@ -2222,74 +2448,68 @@ class Skin {
                  . " . . {$ul} ({$nb})";
 
                if ( "" != $c && "*" != $c ) {
-                       $s .= $wgLang->emphasize(" (" . wfEscapeHTML( $c ) . ")");
+                       $sk=$wgUser->getSkin();
+                       $s .= $wgLang->emphasize(" (" . $sk->formatComment($c) . ")");
                }
                $s .= "</li>\n";
                return $s;
        }
 
        function tocIndent($level) {
-
-               while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
-               return $rv;
-
+               return str_repeat( "<div class='tocindent'>\n", $level>0 ? $level : 0 );
        }
 
        function tocUnindent($level) {
-               $rv = "";
-               while($level-->0) $rv.="</div>\n";
-               return $rv;
+               return str_repeat( "</div>\n", $level>0 ? $level : 0 );
        }
 
-       // 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".
+               "<table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
                "<b>".wfMsg("toc")."</b>" .
                $hideline .
                "</td></tr><tr id='tocinside'><td>\n".
-               $toc."</td></tr></table><P>\n";
+               $toc."</td></tr></table>\n";
        }
 
        # 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;
+       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>";
+               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";
@@ -2297,7 +2517,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>";
 
        }
 
@@ -2305,76 +2525,102 @@ class Skin {
        // toolbar for common editing functions. It can be disabled in the user preferences.
        // The necsesary JavaScript code can be found in style/wikibits.js.
        function getEditToolbar() {
-
-               global $wgUploadPath,$wgLang;
+               global $wgStylePath, $wgLang, $wgMimeType;
 
                // toolarray an array of arrays which each include the filename of
                // the button image (without path), the opening tag, the closing tag,
                // and optionally a sample text that is inserted between the two when no
                // selection is highlighted.
                // The tip text is shown when the user moves the mouse over the button.
+
+               // Already here are accesskeys (key), which are not used yet until someone
+               // can figure out a way to make them work in IE. However, we should make
+               // sure these keys are not defined on the edit page.
                $toolarray=array(
                        array(  "image"=>"button_bold.png",
                                "open"=>"\'\'\'",
                                "close"=>"\'\'\'",
                                "sample"=>wfMsg("bold_sample"),
-                               "tip"=>wfMsg("bold_tip")),
+                               "tip"=>wfMsg("bold_tip"),
+                               "key"=>"B"
+                               ),
                        array(  "image"=>"button_italic.png",
                                "open"=>"\'\'",
                                "close"=>"\'\'",
                                "sample"=>wfMsg("italic_sample"),
-                               "tip"=>wfMsg("italic_tip")),
+                               "tip"=>wfMsg("italic_tip"),
+                               "key"=>"I"
+                               ),
                        array(  "image"=>"button_link.png",
                                "open"=>"[[",
                                "close"=>"]]",
                                "sample"=>wfMsg("link_sample"),
-                               "tip"=>wfMsg("link_tip")),
+                               "tip"=>wfMsg("link_tip"),
+                               "key"=>"L"
+                               ),
                        array(  "image"=>"button_extlink.png",
                                "open"=>"[",
                                "close"=>"]",
                                "sample"=>wfMsg("extlink_sample"),
-                               "tip"=>wfMsg("extlink_tip")),
+                               "tip"=>wfMsg("extlink_tip"),
+                               "key"=>"X"
+                               ),
                        array(  "image"=>"button_headline.png",
                                "open"=>"\\n== ",
                                "close"=>" ==\\n",
                                "sample"=>wfMsg("headline_sample"),
-                               "tip"=>wfMsg("headline_tip")),
+                               "tip"=>wfMsg("headline_tip"),
+                               "key"=>"H"
+                               ),
                        array(  "image"=>"button_image.png",
                                "open"=>"[[".$wgLang->getNsText(NS_IMAGE).":",
                                "close"=>"]]",
                                "sample"=>wfMsg("image_sample"),
-                               "tip"=>wfMsg("image_tip")),
+                               "tip"=>wfMsg("image_tip"),
+                               "key"=>"D"
+                               ),
                        array(  "image"=>"button_media.png",
                                "open"=>"[[".$wgLang->getNsText(NS_MEDIA).":",
                                "close"=>"]]",
                                "sample"=>wfMsg("media_sample"),
-                               "tip"=>wfMsg("media_tip")),
+                               "tip"=>wfMsg("media_tip"),
+                               "key"=>"M"
+                               ),
                        array(  "image"=>"button_math.png",
                                "open"=>"\\<math\\>",
                                "close"=>"\\</math\\>",
                                "sample"=>wfMsg("math_sample"),
-                               "tip"=>wfMsg("math_tip")),
+                               "tip"=>wfMsg("math_tip"),
+                               "key"=>"C"
+                               ),
                        array(  "image"=>"button_nowiki.png",
                                "open"=>"\\<nowiki\\>",
                                "close"=>"\\</nowiki\\>",
                                "sample"=>wfMsg("nowiki_sample"),
-                               "tip"=>wfMsg("nowiki_tip")),
+                               "tip"=>wfMsg("nowiki_tip"),
+                               "key"=>"N"
+                               ),
                        array(  "image"=>"button_sig.png",
                                "open"=>"--~~~~",
                                "close"=>"",
                                "sample"=>"",
-                               "tip"=>wfMsg("sig_tip")),
+                               "tip"=>wfMsg("sig_tip"),
+                               "key"=>"Y"
+                               ),
                        array(  "image"=>"button_hr.png",
                                "open"=>"\\n----\\n",
                                "close"=>"",
                                "sample"=>"",
-                               "tip"=>wfMsg("hr_tip"))
+                               "tip"=>wfMsg("hr_tip"),
+                               "key"=>"R"
+                               )
                );
-               $toolbar ="<script type='text/javascript'>\n";
+               $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
+               
                $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
                foreach($toolarray as $tool) {
 
-                       $image=$wgUploadPath."/".$tool["image"];
+                       $image=$wgStylePath."/images/".$tool["image"];
                        $open=$tool["open"];
                        $close=$tool["close"];
                        $sample = addslashes( $tool["sample"] );
@@ -2384,21 +2630,27 @@ class Skin {
                        // Ideally these should be different, realistically they
                        // probably don't need to be.
                        $tip = addslashes( $tool["tip"] );
+
+                       #$key = $tool["key"];
+
                        $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
                }
 
-               $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "','" . addslashes(wfMsg("infobox_mozvote"))."');\n";
-               $toolbar.="document.writeln(\"</div>\");\n</script>";
+               $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
+               $toolbar.="document.writeln(\"</div>\");\n";
+               
+               $toolbar.="/*]]>*/\n</script>";
                return $toolbar;
        }
 }
 
-include_once( "SkinStandard.php" );
-include_once( "SkinNostalgia.php" );
-include_once( "SkinCologneBlue.php" );
+require_once( "SkinStandard.php" );
+require_once( "SkinNostalgia.php" );
+require_once( "SkinCologneBlue.php" );
 
-if( $wgUseSmarty ) {
-       include_once( "SkinSmarty.php" );
+if( $wgUsePHPTal ) {
+       require_once( "SkinPHPTal.php" );
 }
 
+
 ?>