external link icons removed, personal toolbar cleanup, relative paths
[lhc/web/wiklou.git] / includes / Skin.php
index ffb671f..2836a24 100644 (file)
@@ -15,6 +15,10 @@ if( $wgUseSmarty ) {
        $wgValidSkinNames[] = "Smarty";
        $wgValidSkinNames[] = "Montparnasse";
 }
+if( $wgUsePHPTal ) {
+    #$wgValidSkinNames[] = "PHPTal";
+    $wgValidSkinNames[] = "DaVinci";
+}
 
 include_once( "RecentChange.php" );
 
@@ -133,14 +137,10 @@ class Skin {
        function getUserStyles()
        {
                global $wgOut, $wgStyleSheetPath;
-               if( $wgOut->isPrintable() ) {
-                       $sheet = "wikiprintable.css";
-               } else {
-                       $sheet = $this->getStylesheet();
-               }
+               $sheet = $this->getStylesheet();
                $s = "<style type='text/css'><!--\n";
-               $s .= "@import url(\"$wgStyleSheetPath/$sheet\");\n";
                $s .= "/*/*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
+               $s .= "@import url(\"$wgStyleSheetPath/$sheet\");\n";
                $s .= $this->doGetUserStyles();
                $s .= "/* */\n";
                $s .= "//--></style>\n";
@@ -206,8 +206,7 @@ class Skin {
                $link = str_replace( "_", " ", $link );
                $link = wfEscapeHTML( $link );
 
-               if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
-               else { $r = " class='external'"; }
+               $r = " class='external'";
 
                if ( 1 == $wgUser->getOption( "hover" ) ) {
                        $r .= " title=\"{$link}\"";
@@ -223,14 +222,12 @@ class Skin {
                $link = str_replace( "_", " ", $link );
                $link = wfEscapeHTML( $link );
 
-               if ( $wgOut->isPrintable() ) { 
-                       $r = " class='printable'"; 
-               } else if ( $broken == "stub" ) { 
+               if ( $broken == "stub" ) { 
                        $r = " class='stub'"; 
                } else if ( $broken == "yes" ) { 
                        $r = " class='new'"; 
                } else { 
-                       $r = " class='internal'"; 
+                       $r = ""; 
                }
 
                if ( 1 == $wgUser->getOption( "hover" ) ) {
@@ -243,14 +240,12 @@ class Skin {
        {
                global $wgUser, $wgOut;
 
-               if ( $wgOut->isPrintable() ) { 
-                       $r = " class='printable'"; 
-               } else if ( $broken == "stub" ) { 
+               if ( $broken == "stub" ) { 
                        $r = " class='stub'"; 
                } else if ( $broken == "yes" ) { 
                        $r = " class='new'"; 
                } else { 
-                       $r = " class='internal'"; 
+                       $r = ""; 
                }
 
                if ( 1 == $wgUser->getOption( "hover" ) ) {
@@ -272,11 +267,6 @@ class Skin {
        {
                global $wgUser, $wgOut, $wgSiteNotice;
 
-               if ( $wgOut->isPrintable() ) {
-                       $s = $this->pageTitle() . $this->pageSubtitle() . "\n";
-                       $s .= "\n<div class='bodytext'>";
-                       return $s;
-               }
                if( $wgSiteNotice ) {
                        $note = "\n<div id='notice' style='font-weight: bold; color: red; text-align: center'>$wgSiteNotice</div>\n";
                } else {
@@ -304,7 +294,7 @@ class Skin {
                }
 
                $s .= "\n<div id='content'>\n<div id='topbar'>" .
-                 "<table width='98%' border=0 cellspacing=0><tr>";
+                 "<table border=0 cellspacing=0><tr>";
 
                $shove = ($qb != 0);
                $left = ($qb == 1 || $qb == 3);
@@ -357,24 +347,17 @@ class Skin {
                global $wgUser, $wgOut, $wgServer;
                global $wgTitle, $wgLang;
                
-               if ( $wgOut->isPrintable() ) {
-                       $s = "\n</div>\n";
-
-                       $u = htmlspecialchars( $wgServer . $wgTitle->getFullURL() );
-                       $u = "<a href=\"$u\">$u</a>";
-                       $rf = wfMsg( "retrievedfrom", $u );
-
-                       if ( $wgOut->isArticle() ) {
-                               $lm = "<br>" . $this->lastModified();
-                       } else { $lm = ""; }
-
-                       $cr = wfMsg( "gnunote" );
-                       $s .= "<p>" . $wgLang->emphasize("{$rf}{$lm} {$cr}\n");
-                       return $s;
-               }
-               return $this->doAfterContent();
+               $printfooter = "<div class=\"printfooter\">" . $this->printFooter() . "</div>\n";
+               return $printfooter . $this->doAfterContent();
        }
-
+       
+       function printFooter() {
+               global $wgTitle;
+               $url = htmlspecialchars( $wgTitle->getFullURL() );
+               return "<p>" . wfMsg( "retrievedfrom", "<a href=\"$url\">$url</a>" ) .
+                       "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
+       }
+       
        function doAfterContent()
        {
                global $wgUser, $wgOut, $wgLang;
@@ -384,7 +367,7 @@ class Skin {
 
                $s = "\n</div><br clear=all>\n";
                $s .= "\n<div id='footer'>";
-               $s .= "<table width='98%' border=0 cellspacing=0><tr>";
+               $s .= "<table border=0 cellspacing=0><tr>";
                
                wfProfileOut( "$fname-1" );
                wfProfileIn( "$fname-2" );
@@ -407,7 +390,7 @@ class Skin {
                  . " | " . $this->aboutLink()
                  . " | " . $this->specialLink( "recentchanges" )
                  . " | " . $this->searchForm()
-                 . "<br>" . $this->pageStats();
+                 . "<br><span id='pagestats'>" . $this->pageStats() . "</span>";
 
                $s .= "</td>";
                if ( $shove && !$left ) { # Right
@@ -479,7 +462,7 @@ class Skin {
 
        function printableLink()
        {
-               global $wgOut, $wgFeedClasses;
+               global $wgOut, $wgFeedClasses, $wgRequest;
 
                $baseurl = $_SERVER['REQUEST_URI'];
                if( strpos( "?", $baseurl ) == false ) {
@@ -488,11 +471,13 @@ class Skin {
                        $baseurl .= "&";
                }
                $baseurl = htmlspecialchars( $baseurl );
+               $printurl = $wgRequest->escapeAppendQuery( "printable=yes" );
                
-               $s = "<a href=\"{$baseurl}printable=yes\">" . wfMsg( "printableversion" ) . "</a>";
+               $s = "<a href=\"$printurl\">" . wfMsg( "printableversion" ) . "</a>";
                if( $wgOut->isSyndicated() ) {
                        foreach( $wgFeedClasses as $format => $class ) {
-                               $s .= " | <a href=\"{$baseurl}feed={$format}\">{$format}</a>";
+                               $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
+                               $s .= " | <a href=\"$feedurl\">{$format}</a>";
                        }
                }
                return $s;
@@ -685,7 +670,7 @@ class Skin {
                }
                $s .= $this->lastModified();
                $s .= " " . wfMsg( "gnunote" );
-               return "<span id='pagestats'>{$s}</span>";
+               return $s;
        }
 
        function lastModified()
@@ -706,7 +691,7 @@ class Skin {
                $titleObj = Title::newFromText( $mp );
                $s = "<a href=\"" . $titleObj->escapeLocalURL()
                  . "\"><img{$a} border=0 src=\""
-                 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
+                 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\" /></a>";
                return $s;
        }
 
@@ -1389,8 +1374,7 @@ class Skin {
                                $trail = $m[2];
                        }
                }
-               if ( $wgOut->isPrintable() ||
-                 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
+               if ( $wgUser->getOption( "highlightbroken" ) ) {
                        $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
                } else {
                        $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
@@ -1419,8 +1403,7 @@ class Skin {
                                $trail = $m[2];
                        }
                }
-               if ( $wgOut->isPrintable() ||
-                               ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
+               if ( $wgUser->getOption( "highlightbroken" ) ) {
                        $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
                } else {
                        $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
@@ -1441,7 +1424,7 @@ class Skin {
                global $wgOut;
 
                if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
-               $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
+               $s = "<img src=\"{$url}\" alt=\"{$alt}\" />";
                return $s;
        }
        
@@ -1540,11 +1523,11 @@ class Skin {
                {
                        $s = str_replace( "$1", $name, wfMsg("missingimage") );
                } else {
-                       $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
-                               "<img border=\"0\" src=\"{$url}\" alt=\"{$alt}\"></a>";
+                       $s = "\n  <a href=\"{$u}\" class='image' title=\"{$alt}\">\n" .
+                               "  <img border=\"0\" src=\"{$url}\" alt=\"{$alt}\" />\n  </a>";
                }
                if ( "" != $align ) {
-                       $s = "<div class=\"float{$align}\">{$s}</div>";
+                       $s = "<div class=\"float{$align}\">{$s}\n</div>";
                }
                return $prefix.$s.$postfix;
        }
@@ -1686,14 +1669,14 @@ class Skin {
                if ( $thumbUrl == "" ) {
                        $s .= str_replace( "$1", $name, wfMsg("missingimage") );
                } else {
-                       $s .= "<a href=\"{$u}\" class=\"internal\" title=\"{$alt}\">" .
-                               "<img border=\"0\" src=\"{$thumbUrl}\" alt=\"{$alt}\" " .
-                               "  width=\"{$boxwidth}\" height=\"{$boxheight}\"></a>" .
-                               "<a href=\"{$u}\" class=\"internal\" title=\"{$more}\">" .
-                               "<img border=\"0\" src=\"{$wgUploadPath}/magnify-clip.png\" " .
-                               "  width=\"26\" height=\"24\" align=\"{$magnifyalign}\" alt=\"{$more}\"></a>";
-               }
-               $s .= "<p{$textalign}>{$label}</p></div>";
+                       $s .= "\n".'  <a href="'.$u.'" class="internal" title="'.$alt.'">'."\n".
+                               '  <img border="0" src="'.$thumbUrl.'" alt="'.$alt.'" ' .
+                               '  width="'.$boxwidth.'" height="'.$boxheight.'" /></a>' ."\n".
+                               '  <a href="'.$u.'" class="internal" title="'.$more.'"> ' ."\n".
+                               '  <img border="0" src="'.$wgUploadPath.'/magnify-clip.png" ' .
+                               'width="26" height="24" align="'.$magnifyalign.'" alt="'.$more.'" /> </a>'."\n";
+               }
+               $s .= '  <p'.$textalign.'>'.$label."</p>\n</div>";
                return $s;
        }
 
@@ -1741,7 +1724,7 @@ class Skin {
        function beginImageHistoryList()
        {
                $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
-                 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
+                 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul class='special'>";
                return $s;
        }
 
@@ -1765,7 +1748,7 @@ class Skin {
                
                # Spacer image
                $r = "" ;
-               $r .= "<img src='{$wgUploadPath}/Arr_.png' width='12' height='12' border='0'>" ;                $r .= "<tt>" ;
+               $r .= "<img src='{$wgUploadPath}/Arr_.png' width='12' height='12' border='0' />" ;              $r .= "<tt>" ;
                
                if ( $rc_type == RC_MOVE ) {
                        $r .= "&nbsp;&nbsp;";
@@ -1895,7 +1878,7 @@ class Skin {
                        # Get rc_xxxx variables
                        extract( $rcObj->mAttribs );
                        
-                       $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
+                       $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0 />";
                        $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
                        if ( $rc_new ) $r .= $N ;
                        else $r .= "&nbsp;" ;
@@ -1976,7 +1959,7 @@ class Skin {
                $s = "";
                if ( $date != $this->lastdate ) {
                        if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
-                       $s .= "<h4>{$date}</h4>\n<ul>";
+                       $s .= "<h4>{$date}</h4>\n<ul class='special'>";
                        $this->lastdate = $date;
                }
                $s .= "<li> ";
@@ -2227,40 +2210,28 @@ class Skin {
        }
 
        function tocIndent($level) {
-
-               while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
-               return $rv;
-
+               return str_repeat( "<div class='tocindent'>\n", $level );
        }
 
        function tocUnindent($level) {
-               $rv = "";
-               while($level-->0) $rv.="</div>\n";
-               return $rv;
+               return str_repeat( "</div>\n", $level );
        }
 
-       // parameter level defines if we are on an indentation level
-       function tocLine($anchor,$tocline,$level) {
-               
-               if($level) { 
-               
-                       return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
-               } else { 
-
-                       return "<div style=\"margin-bottom:0px;\">\n".
-                       "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
-                       "</div>\n";
+       # parameter level defines if we are on an indentation level
+       function tocLine( $anchor, $tocline, $level ) {
+               $link = "<a href=\"#$anchor\">$tocline</a><br />";
+               if($level) {
+                       return "$link\n";
+               } else {
+                       return "<div class='tocline'>$link</div>\n";
                }
 
        }
 
        function tocTable($toc) {
-               // note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
-               global $printable;
-               
-               if (!$printable) {
-                       $hideline = " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>";
-               }
+               # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
+               # try min-width & co when somebody gets a chance
+               $hideline = " <script type='text/javascript'>showTocToggle(\"" . addslashes( wfMsg("showtoc") ) . "\",\"" . addslashes( wfMsg("hidetoc") ) . "\")</script>";
                return
                "<p><table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
                "<b>".wfMsg("toc")."</b>" .
@@ -2270,24 +2241,29 @@ class Skin {
        }
 
        # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
-       function editSectionScript($section,$head) {
-
-               global $wgTitle,$wgUser,$oldid;
-               if($oldid) return $head;
+       function editSectionScript( $section, $head ) {
+               global $wgTitle, $wgRequest;
+               if( $wgRequest->getInt( "oldid" ) && ( $wgRequest->getVal( "diff" ) != "0" ) ) {
+                       return $head;
+               }
                $url = $wgTitle->escapeLocalURL( "action=edit&section=$section" );
-               return "<span onContextMenu='document.location=\"".$url."\";return false;'>{$head}</span>";
+               return "<span oncontextmenu='document.location=\"$url\";return false;'>{$head}</span>";
        }
 
-       function editSectionLink($section) {
-               global $printable,$oldid;
+       function editSectionLink( $section ) {
+               global $wgRequest;
                global $wgTitle, $wgUser, $wgLang;
-               
-               if( isset( $oldid ) ) return "";
-               if( isset( $printable ) ) return "";
-               
+
+               if( $wgRequest->getInt( "oldid" ) && ( $wgRequest->getVal( "diff" ) != "0" ) ) {
+                       # Section edit links would be out of sync on an old page.
+                       # But, if we're diffing to the current page, they'll be
+                       # correct.
+                       return "";
+               }
+
                $editurl = "&section={$section}";
                $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
-               
+
                if( $wgLang->isRTL() ) {
                        $farside = "left";
                        $nearside = "right";
@@ -2295,7 +2271,7 @@ class Skin {
                        $farside = "right";
                        $nearside = "left";
                }
-               return "<div style=\"float:$farside;margin-$nearside:5px;\"><small>[".$url."]</small></div>";
+               return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
 
        }
 
@@ -2398,5 +2374,9 @@ include_once( "SkinCologneBlue.php" );
 if( $wgUseSmarty ) {
        include_once( "SkinSmarty.php" );
 }
+if( $wgUsePHPTal ) {
+       include_once( "SkinPHPTal.php" );
+}
+
 
 ?>