Category namespaces
[lhc/web/wiklou.git] / includes / Skin.php
index 7090698..f078b36 100644 (file)
@@ -9,19 +9,16 @@ 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";
-    $wgValidSkinNames['mono'] = "Mono";
+    #$wgValidSkinNames['davinci'] = "DaVinci";
+    #$wgValidSkinNames['mono'] = "Mono";
     $wgValidSkinNames['monobook'] = "MonoBook";
+    #$wgValidSkinNames['monobookminimal'] = "MonoBookMinimal";
 }
 
 include_once( "RecentChange.php" );
@@ -35,12 +32,11 @@ function getCategories ()
   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 .= " : " ;
+  if ( $t != "" ) $s .= ": " ;
   $s .= $t ;
-  return $s ;
+  return "<p class='catlinks'>$s</p>";
 }
 
 class RCCacheEntry extends RecentChange
@@ -94,15 +90,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;
                
@@ -161,7 +194,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" ) ) {
@@ -187,7 +220,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 ) ) {
@@ -306,7 +339,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 );
@@ -418,7 +451,7 @@ class Skin {
                $action = $wgRequest->getText( 'action' );
 
                $s = $this->printableLink();
-               if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ;
+               if ( wfMsg ( "disclaimers" ) != "" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ;
 
                if ( $wgOut->isArticleRelated() ) {
                        if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
@@ -494,7 +527,7 @@ 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;
        }
@@ -508,7 +541,7 @@ class Skin {
                        global $wgExtraSubtitle;
                        $sub = wfMsg( "fromwikipedia" ) . $wgExtraSubtitle;
                }
-               if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
+               if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
                        $ptext=$wgTitle->getPrefixedText();
                        if(preg_match("/\//",$ptext)) {
                                $sub.="</p><p class='subpages'>";
@@ -680,8 +713,47 @@ class Skin {
                        }
                }
                $s .= $this->lastModified();
-               $s .= " " . wfMsg( "gnunote" );
-               return $s;
+               return $s . " " .  $this->getCopyright();
+       }
+       
+       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 $wgUploadPath;
+               $url = htmlspecialchars( "$wgUploadPath/poweredby_mediawiki_88x31.png" );
+               $img = "<a href='http://www.mediawiki.org/'><img src='$url' alt='MediaWiki' /></a>";
+               return $img;
        }
 
        function lastModified()
@@ -706,7 +778,7 @@ class Skin {
                $mp = wfMsg( "mainpage" );
                $titleObj = Title::newFromText( $mp );
                $s = "<a href=\"" . $titleObj->escapeLocalURL()
-                 . "\"><img{$a} border='0' src=\""
+                 . "\"><img{$a} src=\""
                  . $this->getLogo() . "\" alt=\"" . "[{$mp}]\" /></a>";
                return $s;
        }
@@ -737,7 +809,7 @@ class Skin {
                
                }
                // only show watchlist link if logged in
-               if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
+               if ( wfMsg ( "currentevents" ) != "" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
                $s .= "\n<br /><hr class='sep' />";
                $articleExists = $wgTitle->getArticleId();
                if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {                            
@@ -779,7 +851,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
@@ -891,7 +963,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";
 
@@ -900,7 +972,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;
        }
@@ -1243,21 +1315,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;
@@ -1266,7 +1338,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" );
@@ -1290,6 +1362,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 );
 
@@ -1327,7 +1400,7 @@ class Skin {
                                        }
                                } else {
                                        $size = 1 ;
-                               }       
+                               }
                                if ( $size < $threshold ) {
                                        $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
                                } else {
@@ -1339,7 +1412,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;
 
@@ -1350,14 +1423,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 = "";
@@ -1367,16 +1444,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 );
 
@@ -1387,7 +1464,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 = "";
@@ -1416,7 +1495,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 = "";
@@ -1506,8 +1587,8 @@ class Skin {
                        }
                        if ( "center" == $align )
                        {
-                               $prefix  = "<center>";
-                               $postfix = "</center>";
+                               $prefix  = '<span style="text-align: center">';
+                               $postfix = '</span>';
                                $align   = "none";
                        }
        
@@ -1546,11 +1627,11 @@ class Skin {
                {
                        $s = str_replace( "$1", $name, wfMsg("missingimage") );
                } else {
-                       $s = "\n  <a href=\"{$u}\" class='image' title=\"{$alt}\">\n" .
-                               "  <img border=\"0\" src=\"{$url}\" alt=\"{$alt}\" />\n  </a>";
+                       $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
+                               "<img src=\"{$url}\" alt=\"{$alt}\" /></a>";
                }
                if ( "" != $align ) {
-                       $s = "<div class=\"float{$align}\">{$s}\n</div>";
+                       $s = "<div class=\"float{$align}\"><span>{$s}</span>\n</div>";
                }
                return $prefix.$s.$postfix;
        }
@@ -1561,7 +1642,7 @@ class Skin {
                global $wgUseImageMagick;
                global $wgUseSquid, $wgInternalServer;
                $imgPath   = wfImagePath( $name );
-               $thumbName = $width."px-".$icon.$name;
+               $thumbName = $width."px-".$name;
                $thumbPath = wfImageThumbDir( $thumbName )."/".$thumbName;
                $thumbUrl  = wfImageThumbUrl( $thumbName );
 
@@ -1688,18 +1769,18 @@ class Skin {
                $magnifyalign = $wgLang->isRTL() ? "left" : "right";
                $textalign = $wgLang->isRTL() ? " style=\"text-align:right\"" : "";
 
-               $s = "<div class=\"thumbnail-{$align}\" style=\"width:{$boxwidth}px;\">";
+               $s = "<div class=\"thumbnail-{$align}\" style=\"width:{$boxwidth}px;\"><div>";
                if ( $thumbUrl == "" ) {
                        $s .= str_replace( "$1", $name, wfMsg("missingimage") );
                } else {
-                       $s .= "\n".'  <a href="'.$u.'" class="internal" title="'.$alt.'">'."\n".
-                               '  <img border="0" src="'.$thumbUrl.'" alt="'.$alt.'" ' .
-                               '  width="'.$boxwidth.'" height="'.$boxheight.'" /></a>' ."\n".
-                               '  <a href="'.$u.'" class="internal" title="'.$more.'"> ' ."\n".
-                               '  <img border="0" src="'.$wgUploadPath.'/magnify-clip.png" ' .
-                               'width="26" height="24" align="'.$magnifyalign.'" alt="'.$more.'" /> </a>'."\n";
-               }
-               $s .= '  <p'.$textalign.'>'.$label."</p>\n</div>";
+                       $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
+                               '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
+                               'width="'.$boxwidth.'" height="'.$boxheight.'" /></a>'.
+                               '<a href="'.$u.'" class="internal" title="'.$more.'"> '.
+                               '<img src="'.$wgUploadPath.'/magnify-clip.png" ' .
+                               'width="26" height="24" align="'.$magnifyalign.'" alt="'.$more.'" /> </a>';
+               }
+               $s .= '  <div'.$textalign.'>'.$label."</div></div>\n</div>";
                return $s;
        }
 
@@ -1730,6 +1811,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
        #
@@ -1741,13 +1831,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;
        }
 
@@ -1756,7 +1847,9 @@ class Skin {
        function endRecentChangesList()
        {
                $s = $this->recentChangesBlock() ;
-               $s .= "</ul>\n";
+               if( $this->rclistOpen ) {
+                       $s .= "</ul>\n";
+               }
                return $s;
        }
 
@@ -1843,7 +1936,7 @@ class Skin {
                        if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
                        $userlinks[$u]++ ;
                }
-               
+
                # Sort the list and convert to text
                krsort ( $userlinks ) ;
                asort ( $userlinks ) ;
@@ -1861,8 +1954,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='{$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>" ;
                $r .= $tl ;
 
                # Main line
@@ -1904,7 +1997,7 @@ class Skin {
                        # Get rc_xxxx variables
                        extract( $rcObj->mAttribs );
                        
-                       $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0 />";
+                       $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 />";
                        $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
                        if ( $rc_new ) $r .= $N ;
                        else $r .= "&nbsp;" ;
@@ -1988,6 +2081,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> ";
 
@@ -2009,7 +2103,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) (";
 
@@ -2119,7 +2213,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
@@ -2187,16 +2281,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 id=\"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 )
@@ -2246,7 +2375,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;
@@ -2276,11 +2406,11 @@ class Skin {
                # try min-width & co when somebody gets a chance
                $hideline = " <script type='text/javascript'>showTocToggle(\"" . addslashes( wfMsg("showtoc") ) . "\",\"" . addslashes( wfMsg("hidetoc") ) . "\")</script>";
                return
-               "<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
@@ -2329,69 +2459,90 @@ class Skin {
                // 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) {
@@ -2406,16 +2557,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;
        }
 }
@@ -2424,9 +2575,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" );
 }