pipe for stderr was troublesome on pages with many errors (buffer filled up), generic...
[lhc/web/wiklou.git] / includes / Skin.php
index 6a416c8..c4686d1 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 include_once( "Feed.php" );
+include_once( "Image.php" );
 
 # See skin.doc
 
@@ -9,14 +10,10 @@ include_once( "Feed.php" );
 # Language class has internationalized names
 #
 /* private */ $wgValidSkinNames = array(
-       'standard' => "Standard", 
+       'standard' => "Standard",
        'nostalgia' => "Nostalgia",
        'cologneblue' => "CologneBlue"
 );
-if( $wgUseSmarty ) {
-       $wgValidSkinNames['smarty'] = "Smarty";
-       $wgValidSkinNames['montparnasse'] = "Montparnasse";
-}
 if( $wgUsePHPTal ) {
     #$wgValidSkinNames[] = "PHPTal";
     #$wgValidSkinNames['davinci'] = "DaVinci";
@@ -27,23 +24,6 @@ if( $wgUsePHPTal ) {
 
 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 ( $wgOut->mCategoryLinks ) == 0 ) return "" ;
-  if ( !$wgOut->isArticle() ) return "" ;
-  $sk = $wgUser->getSkin() ;
-  $s = "" ;
-  $s .=  "\n<br />\n";
-  $s .= $sk->makeKnownLink ( "Special:Categories" , "Categories" , "article=".$wgTitle->getDBkey() ) ;
-  $t = implode ( " | " , $wgOut->mCategoryLinks ) ;
-  if ( $t != "" ) $s .= " : " ;
-  $s .= $t ;
-  return $s ;
-}
-
 class RCCacheEntry extends RecentChange
 {
        var $secureName, $link;
@@ -95,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;
                
@@ -134,18 +151,18 @@ 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;
+               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(\"$wgStyleSheetPath/$sheet\");\n";
+               $s .= "@import url(\"$wgStylePath/$sheet\");\n";
                $s .= $this->doGetUserStyles();
                $s .= "/* */\n";
                $s .= "</style>\n";
@@ -162,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" ) ) {
@@ -188,7 +205,7 @@ class Skin {
                  (!$wgTitle->isProtected() || $wgUser->isSysop()) ) {
                        $t = wfMsg( "editthispage" );
                        $oid = $red = "";
-                       if ( $redirect ) { 
+                       if ( !empty($redirect) ) { 
                                $red = "&redirect={$redirect}"; 
                        }
                        if ( !empty($oldid) && ! isset( $diff ) ) {
@@ -307,7 +324,7 @@ class Skin {
                if($wgLang->isRTL()) $left = !$left;
                
                if ( !$shove ) {
-                       $s .= "<td class='top' align=left valign=top rowspan='{$rows}'>\n" .
+                       $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
                          $this->logoText() . "</td>";
                } elseif( $left ) {
                        $s .= $this->getQuickbarCompensator( $rows );
@@ -335,10 +352,24 @@ class Skin {
 
                $s .= $this->pageTitle();
                $s .= $this->pageSubtitle() ;
-               $s .= getCategories(); // For some odd reason, zhis can't be a function of the object
+               $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 )
        {
@@ -424,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>";
                        }
@@ -495,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="";
@@ -523,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}</p>\n";
-               return $s;
+               return $subpages;
        }
 
        function nameAndLogin()
@@ -586,15 +624,23 @@ class Skin {
 
                return $s;
        }
-
+       
+       function getSearchLink() {
+               $searchPage =& Title::makeTitle( NS_SPECIAL, "Search" );
+               return $searchPage->getLocalURL();
+       }
+       
+       function escapeSearchLink() {
+               return htmlspecialchars( $this->getSearchLink() );
+       }
+       
        function searchForm()
        {
                global $wgRequest;
-
-               $search = $wgRequest->getText( 'search' );;
-
+               $search = $wgRequest->getText( 'search' );
+               
                $s = "<form name='search' class='inline' method='post' action=\""
-                 . wfLocalUrl( "" ) . "\">\n"
+                 . $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;"
@@ -667,7 +713,7 @@ class Skin {
        {
                global $wgOut, $wgLang, $wgArticle, $wgRequest;
                global $wgDisableCounters;
-               
+
                extract( $wgRequest->getValues( 'oldid', 'diff' ) );
                if ( ! $wgOut->isArticle() ) { return ""; }
                if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
@@ -680,9 +726,133 @@ class Skin {
                                $s = wfMsg( "viewcount", $count );
                        }
                }
-               $s .= $this->lastModified();
-               $s .= " " . wfMsg( "gnunote" );
-               return $s;
+
+               $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));
+                   }
+               }
+           
+               $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()
@@ -780,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
@@ -892,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";
 
@@ -901,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;
        }
@@ -1244,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;
@@ -1267,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" );
@@ -1291,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 );
 
@@ -1328,7 +1499,7 @@ class Skin {
                                        }
                                } else {
                                        $size = 1 ;
-                               }       
+                               }
                                if ( $size < $threshold ) {
                                        $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
                                } else {
@@ -1340,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;
 
@@ -1351,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 = "";
@@ -1368,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 );
 
@@ -1388,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 = "";
@@ -1417,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 = "";
@@ -1434,6 +1613,61 @@ class Skin {
                }
                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 )
        {
@@ -1459,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 = "";
 
@@ -1472,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);
        
@@ -1481,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) ) ) {
@@ -1503,6 +1741,8 @@ 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 )
@@ -1512,7 +1752,7 @@ class Skin {
                                $align   = "none";
                        }
        
-                       if ( $thumb ) {
+                       if ( $thumb || $framed ) {
        
                                # Create a thumbnail. Alignment depends on language
                                # writing direction, # right aligned for left-to-right-
@@ -1527,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 = "\n  <a href=\"{$u}\" class='image' title=\"{$alt}\">\n" .
-                               "  <img src=\"{$url}\" alt=\"{$alt}\" />\n  </a>";
+                       $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
+                               "<img src=\"{$url}\" alt=\"{$alt}\" /></a>";
                }
                if ( "" != $align ) {
-                       $s = "<div class=\"float{$align}\"><span>{$s}\n</span></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;\"><div>";
+               $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 .= "\n".'  <a href="'.$u.'" class="internal" title="'.$alt.'">'."\n".
-                               '  <img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
-                               '  width="'.$boxwidth.'" height="'.$boxheight.'" /></a>' ."\n".
-                               '  <a href="'.$u.'" class="internal" title="'.$more.'"> ' ."\n".
-                               '  <img src="'.$wgUploadPath.'/magnify-clip.png" ' .
-                               'width="26" height="24" align="'.$magnifyalign.'" alt="'.$more.'" /> </a>'."\n";
-               }
-               $s .= '  <p'.$textalign.'>'.$label."</p>\n</div></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;
        }
 
@@ -1712,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 );
                }
@@ -1731,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
        #
@@ -1742,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 class='special'>";
+                 "<p>" . wfMsg( "imghistlegend" ) . "</p>\n<ul class='special'>";
                return $s;
        }
 
@@ -1757,14 +1920,16 @@ 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 )
        {
-               global $wgUploadPath, $wgLang ;
+               global $wgStylePath, $wgLang ;
 
                # Get rc_xxxx variables
                extract( $rcObj->mAttribs ) ;
@@ -1773,7 +1938,7 @@ class Skin {
                # 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;";
@@ -1828,7 +1993,7 @@ class Skin {
        # Enhanced RC group
        function recentChangesBlockGroup ( $block )
        {
-               global $wgUploadPath, $wgLang ;
+               global $wgStylePath, $wgLang ;
 
                $r = "" ;
                $M = wfMsg( "minoreditletter" );
@@ -1844,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 ) ;
@@ -1862,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' /></a></span>" ;
-               $tl .= "<span id='{$rcl}' style='display:none'><a href='$toggleLink'><img src='{$wgUploadPath}/Arr_d.png' width='12' height='12' /></a></span>" ;
+               $tl  = "<span id='{$rcm}'><a href='$toggleLink'><img src='{$wgStylePath}/images/Arr_{$arrowdir}.png' width='12' height='12' /></a></span>" ;
+               $tl .= "<span id='{$rcl}' style='display:none'><a href='$toggleLink'><img src='{$wgStylePath}/images/Arr_d.png' width='12' height='12' /></a></span>" ;
                $r .= $tl ;
 
                # Main line
@@ -1905,7 +2070,7 @@ class Skin {
                        # Get rc_xxxx variables
                        extract( $rcObj->mAttribs );
                        
-                       $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 />";
+                       $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;" ;
@@ -1947,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 ) {
@@ -1989,6 +2154,7 @@ class Skin {
                        if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
                        $s .= "<h4>{$date}</h4>\n<ul class='special'>";
                        $this->lastdate = $date;
+                       $this->rclistOpen = true;
                }
                $s .= "<li> ";
 
@@ -2010,7 +2176,7 @@ 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) (";
 
@@ -2120,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
@@ -2188,16 +2354,51 @@ class Skin {
        /* 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).
+          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);
-               
-               # format text between /* .. */ with autocomment CSS class
-               $comment=preg_replace("/\/\*\s*(.*?)\s*\*\//i",
-               "<span class=\"autocomment\">$1</span>",$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 )
@@ -2209,7 +2410,7 @@ 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() .
@@ -2247,7 +2448,8 @@ 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;
@@ -2323,81 +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, $wgMimeType;
+               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";
-               
-               $xml = ($wgMimeType == "text/xml");
-               if( $xml ) {
-                       $toolbar .= "<![CDATA[";
-               }
+               $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"] );
@@ -2407,16 +2630,16 @@ 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")) . "');\n";
                $toolbar.="document.writeln(\"</div>\");\n";
                
-               if( $xml ) {
-                       $toolbar .= "]]>";
-               }
-               $toolbar.="</script>";
+               $toolbar.="/*]]>*/\n</script>";
                return $toolbar;
        }
 }
@@ -2425,9 +2648,6 @@ include_once( "SkinStandard.php" );
 include_once( "SkinNostalgia.php" );
 include_once( "SkinCologneBlue.php" );
 
-if( $wgUseSmarty ) {
-       include_once( "SkinSmarty.php" );
-}
 if( $wgUsePHPTal ) {
        include_once( "SkinPHPTal.php" );
 }