Printable mode cleanup. Now done through stylesheets, <link>ed so that the
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 21 Mar 2004 11:28:44 +0000 (11:28 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 21 Mar 2004 11:28:44 +0000 (11:28 +0000)
print command on a regular page will actually use the print stylesheet.
Explicitly following the printable link will also show the printable view
on screen.

CAVEATS: IE/Win may oversimplify the link style in what should be colored
or underlined text. Page title is not shown in Nostalgia skin printable
view. Part of the footer is duplicated in the output and will be visible in a styleless
user agent (lynx, really old Netscape, etc). Some render options aren't
totally handled right for printable, such as ? brokenlinks.

Also, section edit links are now available in diff view if the dest rev is
the current revision.

Some misc code clean-up and formatting as well.

includes/Article.php
includes/OutputPage.php
includes/Parser.php
includes/Skin.php
stylesheets/wikibits.js
stylesheets/wikiprintable.css
stylesheets/wikistandard.css

index 0467539..07ee977 100644 (file)
@@ -300,7 +300,7 @@ class Article {
        function view()
        {
                global $wgUser, $wgOut, $wgLang;
-               global $oldid, $diff, $printable; # From query
+               global $oldid, $diff; # From query
                global $wgLinkCache, $IP, $wgEnableParserCache;
                
                $fname = "Article::view";
@@ -352,10 +352,6 @@ class Article {
 
                $wgLinkCache->preFill( $this->mTitle );
                
-               if ( $printable == "yes" ) {
-                       $wgOut->mParserOptions->setPrintable( true );
-               }
-
                if( $wgEnableParserCache && intval($wgUser->getOption( "stubthreshold" )) == 0 ){
                        $wgOut->addWikiText( $text, true, $this );
                } else {
index e751870..6053370 100644 (file)
@@ -43,7 +43,7 @@ class OutputPage {
        # To add an http-equiv meta tag, precede the name with "http:"
        function addMeta( $name, $val ) { array_push( $this->mMetatags, array( $name, $val ) ); }
        function addKeyword( $text ) { array_push( $this->mKeywords, $text ); }
-       function addLink( $rel, $rev, $target, $type="" ) { array_push( $this->mLinktags, array( $rel, $rev, $target, $type ) ); }
+       function addLink( $rel, $rev, $target, $type="", $media="" ) { array_push( $this->mLinktags, array( $rel, $rev, $target, $type, $media ) ); }
 
        # checkLastModified tells the client to use the client-cached page if
        # possible. If sucessful, the OutputPage is disabled so that
@@ -589,12 +589,22 @@ class OutputPage {
                        if ( "" != $tag[0] ) { $ret .= "rel=\"{$tag[0]}\" "; }
                        if ( "" != $tag[1] ) { $ret .= "rev=\"{$tag[1]}\" "; }
                        if ( !empty( $tag[3] ) ) { $ret .= "type=\"{$tag[3]}\" "; }
+                       if ( !empty( $tag[4] ) ) { $ret .= "media=\"{$tag[4]}\" "; }
                        $ret .= "href=\"{$tag[2]}\">\n";
                }
                if( $this->isSyndicated() ) {
                        $link = $wgRequest->escapeAppendQuery( "feed=rss" );
                        $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS' href='$link'>\n";
                }
+               global $wgStyleSheetPath;
+               if( $this->isPrintable() ) {
+                       $media = "";
+               } else {
+                       $media = "media='print'";
+               }
+               $printsheet = htmlspecialchars( "$wgStyleSheetPath/wikiprintable.css" );
+               $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet'>\n";
+
                $sk = $wgUser->getSkin();
                $ret .= $sk->getHeadScripts();
                $ret .= $sk->getUserStyles();
index 7261dc9..4aabf70 100644 (file)
@@ -531,8 +531,12 @@ class Parser
                                $s .= "[{$protocol}:" . $line;
                                continue;
                        }
-                       if ( $this->mOptions->getPrintable() ) $paren = " (<i>" . htmlspecialchars ( $link ) . "</i>)";
-                       else $paren = "";
+                       if( $link == $text || preg_match( "!$protocol://" . preg_quote( $text, "/" ) . "/?$!", $link ) ) {
+                               $paren = "";
+                       } else {
+                               # Expand the URL for printable version
+                               $paren = "<span class='urlexpansion'> (<i>" . htmlspecialchars ( $link ) . "</i>)</span>";
+                       }
                        $la = $sk->getExternalLinkAttributes( $link, $text );
                        $s .= "<a href='{$link}'{$la}>{$text}</a>{$paren}{$trail}";
 
@@ -1364,44 +1368,46 @@ class Parser
  * string and re-inserts the newly formatted headlines.
  * 
  */
+
        /* private */ function formatHeadings( $text )
        {
-               $nh=$this->mOptions->getNumberHeadings();
-               $st=$this->mOptions->getShowToc();
-               if(!$this->mTitle->userCanEdit()) {
-                       $es=0;
-                       $esr=0;
+               $doNumberHeadings = $this->mOptions->getNumberHeadings();
+               $doShowToc = $this->mOptions->getShowToc();
+               if( !$this->mTitle->userCanEdit() ) {
+                       $showEditLink = 0;
+                       $rightClickHack = 0;
                } else {
-                       $es=$this->mOptions->getEditSection();
-                       $esr=$this->mOptions->getEditSectionOnRightClick();
+                       $showEditLink = $this->mOptions->getEditSection();
+                       $rightClickHack = $this->mOptions->getEditSectionOnRightClick();
                }
 
                # Inhibit editsection links if requested in the page
                $esw =& MagicWord::get( MAG_NOEDITSECTION );
-               if ($esw->matchAndRemove( $text )) {
-                       $es=0;
+               if( $esw->matchAndRemove( $text ) ) {
+                       $showEditLink = 0;
                }
                # if the string __NOTOC__ (not case-sensitive) occurs in the HTML, 
                # do not add TOC
                $mw =& MagicWord::get( MAG_NOTOC );
-               if ($mw->matchAndRemove( $text ))
-               {
-                       $st = 0;
+               if( $mw->matchAndRemove( $text ) ) {
+                       $doShowToc = 0;
                }
 
                # never add the TOC to the Main Page. This is an entry page that should not
                # be more than 1-2 screens large anyway
-               if($this->mTitle->getPrefixedText()==wfMsg("mainpage")) {$st=0;}
+               if( $this->mTitle->getPrefixedText() == wfMsg("mainpage") ) {
+                       $doShowToc = 0;
+               }
 
                # We need this to perform operations on the HTML
                $sk =& $this->mOptions->getSkin();
 
                # Get all headlines for numbering them and adding funky stuff like [edit]
                # links
-               preg_match_all("/<H([1-6])(.*?>)(.*?)<\/H[1-6]>/i",$text,$matches);
+               preg_match_all( "/<H([1-6])(.*?" . ">)(.*?)<\/H[1-6]>/i", $text, $matches );
                
                # headline counter
-               $c=0;
+               $headlineCount = 0;
 
                # Ugh .. the TOC should have neat indentation levels which can be
                # passed to the skin functions. These are determined here
@@ -1409,115 +1415,124 @@ class Parser
                $toc = "";
                $full = "";
                $head = array();
-               foreach($matches[3] as $headline) {
-                       if($level) { $prevlevel=$level;}
-                       $level=$matches[1][$c];
-                       if(($nh||$st) && $prevlevel && $level>$prevlevel) { 
-                                                       
-                               $h[$level]=0; // reset when we enter a new level                                
-                               $toc.=$sk->tocIndent($level-$prevlevel);
-                               $toclevel+=$level-$prevlevel;
-                       
+               $sublevelCount = array();
+               foreach( $matches[3] as $headline ) {
+                       if( $level ) {
+                               $prevlevel = $level;
+                       }
+                       $level = $matches[1][$headlineCount];
+                       if( ( $doNumberHeadings || $doShowToc ) && $prevlevel && $level > $prevlevel ) { 
+                               # reset when we enter a new level
+                               $sublevelCount[$level] = 0;
+                               $toc .= $sk->tocIndent( $level - $prevlevel );
+                               $toclevel += $level - $prevlevel;
                        } 
-                       if(($nh||$st) && $level<$prevlevel) {
-                               $h[$level+1]=0; // reset when we step back a level
-                               $toc.=$sk->tocUnindent($prevlevel-$level);
-                               $toclevel-=$prevlevel-$level;
-
+                       if( ( $doNumberHeadings || $doShowToc ) && $level < $prevlevel ) {
+                               # reset when we step back a level
+                               $sublevelCount[$level+1]=0;
+                               $toc .= $sk->tocUnindent( $prevlevel - $level );
+                               $toclevel -= $prevlevel - $level;
                        }
-                       $h[$level]++; // count number of headlines for each level
+                       # count number of headlines for each level
+                       $sublevelCount[$level]++;
                        
-                       if($nh||$st) {
-                               for($i=1;$i<=$level;$i++) {
-                                       if($h[$i]) {
-                                               if($dot) {$numbering.=".";}
-                                               $numbering.=$h[$i];
-                                               $dot=1;                                 
+                       if( $doNumberHeadings || $doShowToc ) {
+                               for( $i = 1; $i <= $level; $i++ ) {
+                                       if( $sublevelCount[$i] ) {
+                                               if( $dot ) {
+                                                       $numbering .= ".";
+                                               }
+                                               $numbering .= $sublevelCount[$i];
+                                               $dot = 1;                                       
                                        }
                                }
                        }
 
-                       // The canonized header is a version of the header text safe to use for links
-                       // Avoid insertion of weird stuff like <math> by expanding the relevant sections
-                       $canonized_headline=Parser::unstrip( $headline, $this->mStripState );
-                       $canonized_headline=preg_replace("/<.*?>/","",$canonized_headline); // strip out HTML
+                       # The canonized header is a version of the header text safe to use for links
+                       # Avoid insertion of weird stuff like <math> by expanding the relevant sections
+                       $canonized_headline = Parser::unstrip( $headline, $this->mStripState );
+                       
+                       # strip out HTML
+                       $canonized_headline = preg_replace( "/<.*?" . ">/","",$canonized_headline );
+                       
                        $tocline = trim( $canonized_headline );
-                       $canonized_headline=str_replace('"',"",$canonized_headline);
-                       $canonized_headline=str_replace(" ","_",trim($canonized_headline));                     
-                       $refer[$c]=$canonized_headline;
-                       $refers[$canonized_headline]++;  // count how many in assoc. array so we can track dupes in anchors
-                       $refcount[$c]=$refers[$canonized_headline];
+                       $canonized_headline = str_replace( '"', "", $canonized_headline );
+                       $canonized_headline = str_replace( " ", "_", trim( $canonized_headline) );
+                       $refer[$headlineCount] = $canonized_headline;
+                       
+                       # count how many in assoc. array so we can track dupes in anchors
+                       $refers[$canonized_headline]++;
+                       $refcount[$headlineCount]=$refers[$canonized_headline];
 
-            // Prepend the number to the heading text
+                       # Prepend the number to the heading text
                        
-                       if($nh||$st) {
-                               $tocline=$numbering ." ". $tocline;
+                       if( $doNumberHeadings || $doShowToc ) {
+                               $tocline = $numbering . " " . $tocline;
                                
-                               // Don't number the heading if it is the only one (looks silly)
-                               if($nh && count($matches[3]) > 1) {
-                                       $headline=$numbering . " " . $headline; // the two are different if the line contains a link
+                               # Don't number the heading if it is the only one (looks silly)
+                               if( $doNumberHeadings && count( $matches[3] ) > 1) {
+                                       # the two are different if the line contains a link
+                                       $headline=$numbering . " " . $headline;
                                }
                        }
                        
-                       // Create the anchor for linking from the TOC to the section
-                       $anchor=$canonized_headline;
-                       if($refcount[$c]>1) {$anchor.="_".$refcount[$c];}
-                       if($st) {
-                               $toc.=$sk->tocLine($anchor,$tocline,$toclevel);
+                       # Create the anchor for linking from the TOC to the section
+                       $anchor = $canonized_headline;
+                       if($refcount[$headlineCount] > 1 ) {
+                               $anchor .= "_" . $refcount[$headlineCount];
+                       }
+                       if( $doShowToc ) {
+                               $toc .= $sk->tocLine($anchor,$tocline,$toclevel);
                        }
-                       if($es) {
-                               $head[$c].=$sk->editSectionLink($c+1);
+                       if( $showEditLink ) {
+                               $head[$headlineCount] .= $sk->editSectionLink($headlineCount+1);
                        }
                        
                        
-                       // the headline might have a link
-                       if(preg_match("/(.*)<a(.*)/",$headline, $headlinematches))
-                       { 
-                               // if so give an anchor name to the already existent link
+                       # the headline might have a link
+                       if( preg_match( "/(.*)<a(.*)/", $headline, $headlinematches ) ) { 
+                               # if so give an anchor name to the already existent link
                                $headline = $headlinematches[1]
-                                           ."<a name=\"".$anchor."\" ".$headlinematches[2];
+                                           . "<a name=\"$anchor\" " . $headlinematches[2];
                        } else {
-                               // else create an anchor link for the headline
-                               $headline = "<a name=\"".$anchor."\">"
-                                           .$headline
-                                           ."</a>";
+                               # else create an anchor link for the headline
+                               $headline = "<a name=\"$anchor.\">$headline</a>";
                        }
                                
-                       // give headline the correct <h#> tag
-                       $head[$c].="<h".$level.$matches[2][$c] .$headline."</h".$level.">";
-                       
-                       // Add the edit section link
+                       # give headline the correct <h#> tag
+                       $head[$headlineCount] .= "<h".$level.$matches[2][$headlineCount] .$headline."</h".$level.">";
                        
-                       if($esr) {
-                               $head[$c]=$sk->editSectionScript($c+1,$head[$c]);       
+                       # Add the edit section link
+                       if( $rightClickHack ) {
+                               $head[$headlineCount] = $sk->editSectionScript($headlineCount+1,$head[$headlineCount]); 
                        }
                        
-                       $numbering="";
-                       $c++;
-                       $dot=0;
+                       $numbering = "";
+                       $headlineCount++;
+                       $dot = 0;
                }               
 
-               if($st) {
-                       $toclines=$c;
-                       $toc.=$sk->tocUnindent($toclevel);
-                       $toc=$sk->tocTable($toc);
+               if( $doShowToc ) {
+                       $toclines = $headlineCount;
+                       $toc .= $sk->tocUnindent( $toclevel );
+                       $toc = $sk->tocTable( $toc );
                }
 
-               // split up and insert constructed headlines
+               # split up and insert constructed headlines
                
-               $blocks=preg_split("/<H[1-6].*?>.*?<\/H[1-6]>/i",$text);
-               $i=0;
+               $blocks = preg_split( "/<H[1-6].*?" . ">.*?<\/H[1-6]>/i", $text );
+               $i = 0;
 
-               foreach($blocks as $block) {
-                       if(($es) && $c>0 && $i==0) {
+               foreach( $blocks as $block ) {
+                       if( $showEditLink && $headlineCount > 0 && $i == 0 ) {
                            # This is the [edit] link that appears for the top block of text when 
                                # section editing is enabled
-                               $full.=$sk->editSectionLink(0);
+                               $full .= $sk->editSectionLink(0);
                        }
-                       $full.=$block;
-                       if($st && $toclines>3 && !$i) {
+                       $full .= $block;
+                       if( $doShowToc && $toclines>3 && !$i) {
                                # Let's add a top anchor just in case we want to link to the top of the page
-                               $full="<a name=\"top\"></a>".$full.$toc;
+                               $full = "<a name=\"top\"></a>".$full.$toc;
                        }
 
                        if( !empty( $head[$i] ) ) {
@@ -1752,7 +1767,6 @@ class ParserOptions
        var $mDateFormat;                # Date format index
        var $mEditSection;               # Create "edit section" links
        var $mEditSectionOnRightClick;   # Generate JavaScript to edit section on right click
-       var $mPrintable;                 # Generate printable output
        var $mNumberHeadings;            # Automatically number headings
        var $mShowToc;                   # Show table of contents
 
@@ -1765,7 +1779,6 @@ class ParserOptions
        function getDateFormat() { return $this->mDateFormat; }
        function getEditSection() { return $this->mEditSection; }
        function getEditSectionOnRightClick() { return $this->mEditSectionOnRightClick; }
-       function getPrintable() { return $this->mPrintable; }
        function getNumberHeadings() { return $this->mNumberHeadings; }
        function getShowToc() { return $this->mShowToc; }
 
@@ -1778,7 +1791,6 @@ class ParserOptions
        function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat, $x ); }
        function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); }
        function setEditSectionOnRightClick( $x ) { return wfSetVar( $this->mEditSectionOnRightClick, $x ); }
-       function setPrintable( $x ) { return wfSetVar( $this->mPrintable, $x ); }
        function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); }
        function setShowToc( $x ) { return wfSetVar( $this->mShowToc, $x ); }
 
@@ -1808,7 +1820,6 @@ class ParserOptions
                $this->mDateFormat = $user->getOption( "date" );
                $this->mEditSection = $user->getOption( "editsection" );
                $this->mEditSectionOnRightClick = $user->getOption( "editsectiononrightclick" );
-               $this->mPrintable = false;
                $this->mNumberHeadings = $user->getOption( "numberheadings" );
                $this->mShowToc = $user->getOption( "showtoc" );
        }
index 0b677fa..c87fdbe 100644 (file)
@@ -133,14 +133,10 @@ class Skin {
        function getUserStyles()
        {
                global $wgOut, $wgStyleSheetPath;
-               if( $wgOut->isPrintable() ) {
-                       $sheet = "wikiprintable.css";
-               } else {
-                       $sheet = $this->getStylesheet();
-               }
+               $sheet = $this->getStylesheet();
                $s = "<style type='text/css'><!--\n";
-               $s .= "@import url(\"$wgStyleSheetPath/$sheet\");\n";
                $s .= "/*/*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
+               $s .= "@import url(\"$wgStyleSheetPath/$sheet\");\n";
                $s .= $this->doGetUserStyles();
                $s .= "/* */\n";
                $s .= "//--></style>\n";
@@ -206,8 +202,7 @@ class Skin {
                $link = str_replace( "_", " ", $link );
                $link = wfEscapeHTML( $link );
 
-               if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
-               else { $r = " class='external'"; }
+               $r = " class='external'";
 
                if ( 1 == $wgUser->getOption( "hover" ) ) {
                        $r .= " title=\"{$link}\"";
@@ -223,14 +218,12 @@ class Skin {
                $link = str_replace( "_", " ", $link );
                $link = wfEscapeHTML( $link );
 
-               if ( $wgOut->isPrintable() ) { 
-                       $r = " class='printable'"; 
-               } else if ( $broken == "stub" ) { 
+               if ( $broken == "stub" ) { 
                        $r = " class='stub'"; 
                } else if ( $broken == "yes" ) { 
                        $r = " class='new'"; 
                } else { 
-                       $r = " class='internal'"; 
+                       $r = ""; 
                }
 
                if ( 1 == $wgUser->getOption( "hover" ) ) {
@@ -243,14 +236,12 @@ class Skin {
        {
                global $wgUser, $wgOut;
 
-               if ( $wgOut->isPrintable() ) { 
-                       $r = " class='printable'"; 
-               } else if ( $broken == "stub" ) { 
+               if ( $broken == "stub" ) { 
                        $r = " class='stub'"; 
                } else if ( $broken == "yes" ) { 
                        $r = " class='new'"; 
                } else { 
-                       $r = " class='internal'"; 
+                       $r = ""; 
                }
 
                if ( 1 == $wgUser->getOption( "hover" ) ) {
@@ -272,11 +263,6 @@ class Skin {
        {
                global $wgUser, $wgOut, $wgSiteNotice;
 
-               if ( $wgOut->isPrintable() ) {
-                       $s = $this->pageTitle() . $this->pageSubtitle() . "\n";
-                       $s .= "\n<div class='bodytext'>";
-                       return $s;
-               }
                if( $wgSiteNotice ) {
                        $note = "\n<div id='notice' style='font-weight: bold; color: red; text-align: center'>$wgSiteNotice</div>\n";
                } else {
@@ -357,24 +343,17 @@ class Skin {
                global $wgUser, $wgOut, $wgServer;
                global $wgTitle, $wgLang;
                
-               if ( $wgOut->isPrintable() ) {
-                       $s = "\n</div>\n";
-
-                       $u = htmlspecialchars( $wgServer . $wgTitle->getFullURL() );
-                       $u = "<a href=\"$u\">$u</a>";
-                       $rf = wfMsg( "retrievedfrom", $u );
-
-                       if ( $wgOut->isArticle() ) {
-                               $lm = "<br>" . $this->lastModified();
-                       } else { $lm = ""; }
-
-                       $cr = wfMsg( "gnunote" );
-                       $s .= "<p>" . $wgLang->emphasize("{$rf}{$lm} {$cr}\n");
-                       return $s;
-               }
-               return $this->doAfterContent();
+               $printfooter = "<div class=\"printfooter\">" . $this->printFooter() . "</div>\n";
+               return $printfooter . $this->doAfterContent();
        }
-
+       
+       function printFooter() {
+               global $wgTitle;
+               $url = htmlspecialchars( $wgTitle->getFullURL() );
+               return "<p>" . wfMsg( "retrievedfrom", "<a href=\"$url\">$url</a>" ) .
+                       "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
+       }
+       
        function doAfterContent()
        {
                global $wgUser, $wgOut, $wgLang;
@@ -407,7 +386,7 @@ class Skin {
                  . " | " . $this->aboutLink()
                  . " | " . $this->specialLink( "recentchanges" )
                  . " | " . $this->searchForm()
-                 . "<br>" . $this->pageStats();
+                 . "<br><span id='pagestats'>" . $this->pageStats() . "</span>";
 
                $s .= "</td>";
                if ( $shove && !$left ) { # Right
@@ -687,7 +666,7 @@ class Skin {
                }
                $s .= $this->lastModified();
                $s .= " " . wfMsg( "gnunote" );
-               return "<span id='pagestats'>{$s}</span>";
+               return $s;
        }
 
        function lastModified()
@@ -1391,8 +1370,7 @@ class Skin {
                                $trail = $m[2];
                        }
                }
-               if ( $wgOut->isPrintable() ||
-                 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
+               if ( $wgUser->getOption( "highlightbroken" ) ) {
                        $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
                } else {
                        $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
@@ -1421,8 +1399,7 @@ class Skin {
                                $trail = $m[2];
                        }
                }
-               if ( $wgOut->isPrintable() ||
-                               ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
+               if ( $wgUser->getOption( "highlightbroken" ) ) {
                        $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
                } else {
                        $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
@@ -2229,40 +2206,28 @@ class Skin {
        }
 
        function tocIndent($level) {
-
-               while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
-               return $rv;
-
+               return str_repeat( "<div class='tocindent'>\n", $level );
        }
 
        function tocUnindent($level) {
-               $rv = "";
-               while($level-->0) $rv.="</div>\n";
-               return $rv;
+               return str_repeat( "</div>\n", $level );
        }
 
-       // parameter level defines if we are on an indentation level
-       function tocLine($anchor,$tocline,$level) {
-               
-               if($level) { 
-               
-                       return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
+       # parameter level defines if we are on an indentation level
+       function tocLine( $anchor, $tocline, $level ) {
+               $link = "<a href=\"#$anchor\">$tocline</a><br />";
+               if($level) {
+                       return "$link\n";
                } else { 
-
-                       return "<div style=\"margin-bottom:0px;\">\n".
-                       "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
-                       "</div>\n";
+                       return "<div class='tocline'>$link</div>\n";
                }
 
        }
 
        function tocTable($toc) {
-               // note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
-               global $printable;
-               
-               if (!$printable) {
-                       $hideline = " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>";
-               }
+               # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
+               # try min-width & co when somebody gets a chance
+               $hideline = " <script type='text/javascript'>showTocToggle(\"" . addslashes( wfMsg("showtoc") ) . "\",\"" . addslashes( wfMsg("hidetoc") ) . "\")</script>";
                return
                "<p><table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
                "<b>".wfMsg("toc")."</b>" .
@@ -2272,20 +2237,25 @@ class Skin {
        }
 
        # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
-       function editSectionScript($section,$head) {
-
-               global $wgTitle,$wgUser,$oldid;
-               if($oldid) return $head;
+       function editSectionScript( $section, $head ) {
+               global $wgTitle, $wgRequest;
+               if( $wgRequest->getInt( "oldid" ) ) {
+                       return $head;
+               }
                $url = $wgTitle->escapeLocalURL( "action=edit&section=$section" );
-               return "<span onContextMenu='document.location=\"".$url."\";return false;'>{$head}</span>";
+               return "<span oncontextmenu='document.location=\"$url\";return false;'>{$head}</span>";
        }
 
-       function editSectionLink($section) {
-               global $printable,$oldid;
+       function editSectionLink( $section ) {
+               global $wgRequest;
                global $wgTitle, $wgUser, $wgLang;
                
-               if( isset( $oldid ) ) return "";
-               if( isset( $printable ) ) return "";
+               if( $wgRequest->getInt( "oldid" ) && ( $wgRequest->getVal( "diff" ) != "0" ) ) {
+                       # Section edit links would be out of sync on an old page.
+                       # But, if we're diffing to the current page, they'll be
+                       # correct.
+                       return "";
+               }
                
                $editurl = "&section={$section}";
                $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
@@ -2297,7 +2267,7 @@ class Skin {
                        $farside = "right";
                        $nearside = "left";
                }
-               return "<div style=\"float:$farside;margin-$nearside:5px;\"><small>[".$url."]</small></div>";
+               return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
 
        }
 
index 8bf119e..bfe1d8c 100644 (file)
@@ -57,10 +57,10 @@ function guessTimezone(box) {
 
 function showTocToggle(show,hide) {
        if(document.getElementById) {
-               document.writeln('<small>[<a href="javascript:toggleToc()" class="internal">' +
+               document.writeln('<span class=\'toctoggle\'>[<a href="javascript:toggleToc()" class="internal">' +
                '<span id="showlink" style="display:none;">' + show + '</span>' +
                '<span id="hidelink">' + hide + '</span>'
-               + '</a>]</small>');
+               + '</a>]</span>');
        }
 }
 
index 101cf91..686850a 100644 (file)
@@ -1,7 +1,52 @@
+/* MediaWiki print stylesheet */
+
+body {
+       color: #000000; background: #ffffff;
+}
+
+
+/* MSIE/Win doesn't understand 'inherit' */
+a, a.external, a.new, a.stub {
+       color: black ! important;
+       text-decoration: none ! important;
+}
+#article {
+       margin: 0 ! important;
+}
+
+/* Continue ... */
+a, a.external, a.new, a.stub {
+       color: inherit ! important;
+       text-decoration: inherit ! important;
+}
+
+/* Hide ugly UI stuff */
+#quickbar, #topbar, #footer,
+.editsection, .toctoggle {
+       display: none;
+}
+
+/* */
+#article {
+       position: relative;
+       margin: inherit ! important;
+}
+
+/* Show some stuff */
+.urlexpansion {
+       display: inline ! important;
+}
+
+.printfooter {
+       border-top: solid 1px black;
+       display: block ! important;
+}
+
+/* Old stuff, fixme:
 .bodytext { }
 a.CBlink { color: #0000AA; text-decoration: none; font-size: 12pt; }
 a.interwiki, a.external { color: #3333BB; text-decoration: none; }
-body { color: #000000; background: #ffffff; }
 h1.pagetitle { padding-bottom: 0; margin-bottom: 0; }
 i.link, u.link { color: #000066; }
 p.subtitle { padding-top: 0; margin-top: 0; }
+*/
index 3bb71da..9610c75 100644 (file)
@@ -7,7 +7,25 @@
 }
 #quickbar { width: 140px; padding: 4px; visibility: visible; z-index:99;font-size:95%;}
 #topbar { padding: 4px;font-size:95%; }
-#toc { border:1px solid #8888aa; background-color:#f7f8ff;padding:5px;font-size:95%; }
+
+/* Table of contents */
+#toc {
+       border: 1px solid #8888aa;
+       background-color: #f7f8ff;
+       padding: 5px;
+       font-size: 95%;
+}
+.tocindent {
+       margin-left: 2em;
+}
+.tocline {
+       margin-bottom: 0px;
+}
+.toctoggle, .editsection {
+       font-size: smaller;
+}
+
+/* ... */
 #toolbar { padding:0px; }
 #infobox { background:#eeeeff;color:black;;}
 #editform { margin-top:1px; }
@@ -18,11 +36,6 @@ a.stub { color:#772233; text-decoration:none; }
 body { margin: 0px; padding: 4px; color: black; }
 form.inline { display: inline; }
 
-/* CHECK MERGE @@@
- * h1.pagetitle { padding-top: 0; margin-top: 0; padding-bottom: 0; margin-bottom: 0;
- * font-size:130%; }
- * h2 { font-size: 112.5%; }
- */
 
 h1.pagetitle { padding-top: 0; margin-top: 0; padding-bottom: 0; margin-bottom: 0;
 font-size:150%; }
@@ -78,3 +91,9 @@ table.rimage {
        text-align:center;
        font-size:smaller;
        }
+
+
+/* Print-specific things to hide */
+.urlexpansion, .printfooter {
+       display: none;
+}