Fix sidebar spacing for right-to-left languages
[mediawiki.git] / includes / Skin.php
blob2360bed567698c5597afc8ad96bba93034fc9a7d
1 <?
2 # See skin.doc
4 # These are the INTERNAL names, which get mapped
5 # directly to class names. For display purposes, the
6 # Language class has internationalized names
8 /* private */ $wgValidSkinNames = array(
9 "Standard", "Nostalgia", "CologneBlue"
12 class RecentChangesClass {
13 var $secureName , $displayName , $link , $namespace ;
14 var $oldid , $diffid , $timestamp , $curlink , $lastlink , $usertalklink , $versionlink ;
15 var $usercomment , $userlink ;
16 var $isminor , $isnew , $watched , $islog ;
17 } ;
19 class Skin {
21 /* private */ var $lastdate, $lastline;
23 var $rc_cache ; # Cache for Enhanced Recent Changes
24 var $rccc ; # Recent Changes Cache Counter for visibility toggle
27 function Skin()
31 function getSkinNames()
33 global $wgValidSkinNames;
34 return $wgValidSkinNames;
37 function getStylesheet()
39 return "wikistandard.css";
42 function qbSetting()
44 global $wgOut, $wgUser;
46 if ( $wgOut->isQuickbarSupressed() ) { return 0; }
47 $q = $wgUser->getOption( "quickbar" );
48 if ( "" == $q ) { $q = 0; }
49 return $q;
52 function initPage()
54 global $wgOut, $wgStyleSheetPath;
55 wfProfileIn( "Skin::initPage" );
57 $wgOut->addLink( "shortcut icon", "", "/favicon.ico" );
58 if ( $wgOut->isPrintable() ) { $ss = "wikiprintable.css"; }
59 else { $ss = $this->getStylesheet(); }
60 $wgOut->addLink( "stylesheet", "", "{$wgStyleSheetPath}/{$ss}" );
61 wfProfileOut();
64 function getHeadScripts() {
65 global $wgStyleSheetPath;
66 $r = "<script type=\"text/javascript\" src=\"{$wgStyleSheetPath}/wikibits.js\"></script>\n";
67 return $r;
70 function getUserStyles()
72 $s = "<style type='text/css' media='screen'><!--\n";
73 $s .= $this->doGetUserStyles();
74 $s .= "//--></style>\n";
75 return $s;
78 function doGetUserStyles()
80 global $wgUser;
82 $s = "";
83 if ( 1 == $wgUser->getOption( "underline" ) ) {
84 # Don't override browser settings
85 } else {
86 # Force no underline
87 $s .= "a.stub, a.new, a.internal, a.external { " .
88 "text-decoration: none; }\n";
90 if ( 1 == $wgUser->getOption( "highlightbroken" ) ) {
91 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
93 if ( 1 == $wgUser->getOption( "justify" ) ) {
94 $s .= "#article { text-align: justify; }\n";
96 return $s;
99 function getBodyOptions()
101 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $oldid, $redirect, $diff,$action;
103 if ( 0 != $wgTitle->getNamespace() ) {
104 $a = array( "bgcolor" => "#FFFFDD" );
106 else $a = array( "bgcolor" => "#FFFFFF" );
107 if($wgOut->isArticle() && $wgUser->getOption("editondblclick")
109 (!$wgTitle->isProtected() || $wgUser->isSysop())
112 $n = $wgTitle->getPrefixedURL();
113 $t = wfMsg( "editthispage" );
114 $oid = $red = "";
115 if ( $redirect ) { $red = "&redirect={$redirect}"; }
116 if ( $oldid && ! isset( $diff ) ) {
117 $oid = "&oldid={$oldid}";
119 $s = wfLocalUrlE($n,"action=edit{$oid}{$red}");
120 $s = "document.location = \"" .$s ."\";";
121 $a += array ("ondblclick" => $s);
124 if($action=="edit") { # set focus in edit box
125 $a += array("onLoad"=>"document.editform.wpTextbox1.focus()");
127 return $a;
130 function getExternalLinkAttributes( $link, $text )
132 global $wgUser, $wgOut, $wgLang;
134 $link = urldecode( $link );
135 $link = $wgLang->checkTitleEncoding( $link );
136 $link = str_replace( "_", " ", $link );
137 $link = wfEscapeHTML( $link );
139 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
140 else { $r = " class='external'"; }
142 if ( 1 == $wgUser->getOption( "hover" ) ) {
143 $r .= " title=\"{$link}\"";
145 return $r;
148 function getInternalLinkAttributes( $link, $text, $broken = false )
150 global $wgUser, $wgOut;
152 $link = urldecode( $link );
153 $link = str_replace( "_", " ", $link );
154 $link = wfEscapeHTML( $link );
156 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
157 else if ( $broken == "stub" ) { $r = " class='stub'"; }
158 else if ( $broken == "yes" ) { $r = " class='new'"; }
159 else { $r = " class='internal'"; }
161 if ( 1 == $wgUser->getOption( "hover" ) ) {
162 $r .= " title=\"{$link}\"";
164 return $r;
167 function getLogo()
169 global $wgLogo;
170 return $wgLogo;
173 # This will be called immediately after the <body> tag. Split into
174 # two functions to make it easier to subclass.
176 function beforeContent()
178 global $wgUser, $wgOut;
180 if ( $wgOut->isPrintable() ) {
181 $s = $this->pageTitle() . $this->pageSubtitle() . "\n";
182 $s .= "\n<div class='bodytext'>";
183 return $s;
185 return $this->doBeforeContent();
188 function doBeforeContent()
190 global $wgUser, $wgOut, $wgTitle, $wgLang;
191 wfProfileIn( "Skin::doBeforeContent" );
193 $s = "";
194 $qb = $this->qbSetting();
196 if( $langlinks = $this->otherLanguages() ) {
197 $rows = 2;
198 $borderhack = "";
199 } else {
200 $rows = 1;
201 $langlinks = false;
202 $borderhack = "class='top'";
205 $s .= "\n<div id='content'>\n<div id='topbar'>" .
206 "<table width='98%' border=0 cellspacing=0><tr>";
208 $shove = ($qb != 0);
209 $left = ($qb == 1 || $qb == 3);
210 if($wgLang->isRTL()) $left = !$left;
212 if ( !$shove ) {
213 $s .= "<td class='top' align=left valign=top rowspan='{$rows}'>" .
214 $this->logoText() . "</td>";
215 } elseif( $left ) {
216 $s .= $this->getQuickbarCompensator( $rows );
218 $s .= "<td {$borderhack} align=left valign=top>";
220 $s .= $this->topLinks() ;
221 $s .= "<p class='subtitle'>" . $this->pageTitleLinks();
223 $s .= "</td>\n<td {$borderhack} valign=top align=right nowrap>";
224 $s .= $this->nameAndLogin();
225 $s .= "\n<br>" . $this->searchForm() . "</td>";
227 if ( $langlinks ) {
228 $s .= "</tr>\n<tr><td class='top' colspan=\"2\">$langlinks</td>";
231 if ( $shove && !$left ) { # Right
232 $s .= $this->getQuickbarCompensator( $rows );
234 $s .= "</tr></table>\n</div>\n";
235 $s .= "\n<div id='article'>";
237 $s .= $this->pageTitle();
238 $s .= $this->pageSubtitle() . "\n<p>";
239 wfProfileOut();
240 return $s;
243 function getQuickbarCompensator( $rows = 1 )
245 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
248 # This gets called immediately before the </body> tag.
250 function afterContent()
252 global $wgUser, $wgOut, $wgServer, $HTTP_SERVER_VARS;
254 if ( $wgOut->isPrintable() ) {
255 $s = "\n</div>\n";
257 $u = $wgServer . $HTTP_SERVER_VARS['REQUEST_URI'];
258 $u = preg_replace( "/[?&]printable=yes/", "", $u );
259 $rf = str_replace( "$1", $u, wfMsg( "retrievedfrom" ) );
261 if ( $wgOut->isArticle() ) {
262 $lm = "<br>" . $this->lastModified();
263 } else { $lm = ""; }
265 $s .= "<p><em>{$rf}{$lm}</em>\n";
266 return $s;
268 return $this->doAfterContent();
271 function doAfterContent()
273 global $wgUser, $wgOut, $wgLang;
274 wfProfileIn( "Skin::doAfterContent" );
276 $s = "\n</div><br clear=all>\n";
278 $s .= "\n<div id='footer'>";
279 $s .= "<table width='98%' border=0 cellspacing=0><tr>";
281 $qb = $this->qbSetting();
282 $shove = ($qb != 0);
283 $left = ($qb == 1 || $qb == 3);
284 if($wgLang->isRTL()) $left = !$left;
286 if ( $shove && $left ) { # Left
287 $s .= $this->getQuickbarCompensator();
289 $s .= "<td class='bottom' align=left valign=top>";
291 $s .= $this->bottomLinks();
292 $s .= "\n<br>" . $this->mainPageLink()
293 . " | " . $this->aboutLink()
294 . " | " . $this->specialLink( "recentchanges" )
295 . " | " . $this->searchForm()
296 . "<br>" . $this->pageStats();
298 $s .= "</td>";
299 if ( $shove && !$left ) { # Right
300 $s .= $this->getQuickbarCompensator();
302 $s .= "</tr></table>\n</div>\n</div>\n";
304 if ( 0 != $qb ) { $s .= $this->quickBar(); }
305 wfProfileOut();
306 return $s;
309 function pageTitleLinks()
311 global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang;
313 $s = $this->printableLink();
315 if ( $wgOut->isArticle() ) {
316 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
317 $name = $wgTitle->getDBkey();
318 $link = wfEscapeHTML( wfImageUrl( $name ) );
319 $style = $this->getInternalLinkAttributes( $link, $name );
320 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
323 if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
324 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
325 wfMsg( "currentrev" ) );
328 if ( $wgUser->getNewtalk() ) {
329 # do not show "You have new messages" text when we are viewing our
330 # own talk page
332 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
333 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
334 $n =$wgUser->getName();
335 $tl = $this->makeKnownLink( $wgLang->getNsText(
336 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
337 wfMsg("newmessageslink") );
338 $s.=" | <strong>". str_replace( "$1", $tl, wfMsg("newmessages") ) . "</strong>";
341 return $s;
344 function printableLink()
346 global $wgOut, $wgTitle, $oldid, $action;
348 if ( "history" == $action ) { $q = "action=history&"; }
349 else { $q = ""; }
351 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
352 WfMsg( "printableversion" ), "{$q}printable=yes" );
353 return $s;
356 function pageTitle()
358 global $wgOut, $wgTitle;
360 $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
361 return $s;
364 function pageSubtitle()
366 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
368 $sub = $wgOut->getSubtitle();
369 if ( "" == $sub ) { $sub = wfMsg( "fromwikipedia" ); }
370 if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
371 $ptext=$wgTitle->getPrefixedText();
372 if(preg_match("/\//",$ptext)) {
373 $sub.="</p><p class='subpages'>";
374 $links=explode("/",$ptext);
375 $c=0;
376 $growinglink="";
377 foreach($links as $link) {
378 $c++;
379 if ($c<count($links)) {
380 $growinglink.=$link;
381 $getlink=$this->makeLink($growinglink,$link);
382 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
383 if ($c>1) {
384 $sub .= " | ";
385 } else {
386 $sub .="&lt; ";
388 $sub .= $getlink;
389 $growinglink.="/";
395 $s = "<p class='subtitle'>{$sub}\n";
396 return $s;
399 function nameAndLogin()
401 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader;
403 $li = $wgLang->specialPage( "Userlogin" );
404 $lo = $wgLang->specialPage( "Userlogout" );
406 $s = "";
407 if ( 0 == $wgUser->getID() ) {
408 if( $wgShowIPinHeader ) {
409 $n = getenv( "REMOTE_ADDR" );
411 $tl = $this->makeKnownLink( $wgLang->getNsText(
412 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
413 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
415 $s .= $n . " (".$tl.")";
416 } else {
417 $s .= wfMsg("notloggedin");
420 $rt = $wgTitle->getPrefixedURL();
421 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
422 $q = "";
423 } else { $q = "returnto={$rt}"; }
425 $s .= "\n<br>" . $this->makeKnownLink( $li,
426 wfMsg( "login" ), $q );
427 } else {
428 $n = $wgUser->getName();
429 $rt = $wgTitle->getPrefixedURL();
430 $tl = $this->makeKnownLink( $wgLang->getNsText(
431 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
432 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
434 $tl = " ({$tl})";
436 $s .= $this->makeKnownLink( $wgLang->getNsText(
437 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
438 $this->makeKnownLink( $lo, wfMsg( "logout" ),
439 "returnto={$rt}" ) . " | " .
440 $this->specialLink( "preferences" );
442 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
443 wfMsg( "help" ) );
445 return $s;
448 function searchForm()
450 global $search;
452 $s = "<form name='search' class='inline' method=get action=\""
453 . wfLocalUrl( "" ) . "\">"
454 . "<input type=text name=\"search\" size=19 value=\""
455 . htmlspecialchars(substr($search,0,256)) . "\">\n"
456 . "<input type=submit name=\"go\" value=\"" . wfMsg ("go") . "\">&nbsp;"
457 . "<input type=submit value=\"" . wfMsg ("search") . "\"></form>";
459 return $s;
462 function topLinks()
464 global $wgOut;
465 $sep = " |\n";
467 $s = $this->mainPageLink() . $sep
468 . $this->specialLink( "recentchanges" );
470 if ( $wgOut->isArticle() ) {
471 $s .= $sep . $this->editThisPage()
472 . $sep . $this->historyLink();
474 $s .= $sep . $this->specialPagesList();
476 return $s;
479 function bottomLinks()
481 global $wgOut, $wgUser, $wgTitle;
482 $sep = " |\n";
484 $s = "";
485 if ( $wgOut->isArticle() ) {
486 $s .= "<strong>" . $this->editThisPage() . "</strong>";
487 if ( 0 != $wgUser->getID() ) {
488 $s .= $sep . $this->watchThisPage();
490 $s .= $sep . $this->talkLink()
491 . $sep . $this->historyLink()
492 . $sep . $this->whatLinksHere()
493 . $sep . $this->watchPageLinksLink();
495 if ( $wgTitle->getNamespace() == Namespace::getUser()
496 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
499 $id=User::idFromName($wgTitle->getText());
500 $ip=User::isIP($wgTitle->getText());
502 if($id || $ip) { # both anons and non-anons have contri list
503 $s .= $sep . $this->userContribsLink();
505 if ( 0 != $wgUser->getID() ) { # show only to signed in users
506 if($id) { # can only email non-anons
507 $s .= $sep . $this->emailUserLink();
511 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
512 $s .= "\n<br>" . $this->deleteThisPage() .
513 $sep . $this->protectThisPage() .
514 $sep . $this->moveThisPage();
516 $s .= "<br>\n" . $this->otherLanguages();
518 return $s;
521 function pageStats()
523 global $wgOut, $wgLang, $wgArticle;
524 global $oldid, $diff, $wgDisableCounters;
526 if ( ! $wgOut->isArticle() ) { return ""; }
527 if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
528 if ( 0 == $wgArticle->getID() ) { return ""; }
530 if ( $wgDisableCounters ) {
531 $s = "";
532 } else {
533 $count = $wgArticle->getCount();
534 $s = str_replace( "$1", $count, wfMsg( "viewcount" ) );
536 $s .= $this->lastModified();
537 $s .= " " . wfMsg( "gnunote" );
538 return "<span id='pagestats'>{$s}</span>";
541 function lastModified()
543 global $wgLang, $wgArticle;
545 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
546 $s = " " . str_replace( "$1", $d, wfMsg( "lastmodified" ) );
547 return $s;
550 function logoText( $align = "" )
552 if ( "" != $align ) { $a = " align='{$align}'"; }
553 else { $a = ""; }
555 $mp = wfMsg( "mainpage" );
556 $s = "<a href=\"" . wfLocalUrlE( $mp ) . "\"><img{$a} border=0 src=\""
557 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
558 return $s;
561 function quickBar()
563 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
564 global $wpPreview;
565 wfProfileIn( "Skin::quickBar" );
567 $s = "\n<div id='quickbar'>";
568 $s .= "\n" . $this->logoText() . "\n<hr>";
570 $sep = "\n<br>";
571 $s .= $this->mainPageLink()
572 . $sep . $this->specialLink( "recentchanges" )
573 . $sep . $this->specialLink( "randompage" );
574 if ($wgUser->getID()) {
575 $s.= $sep . $this->specialLink( "watchlist" ) ;
576 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
577 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
580 // only show watchlist link if logged in
581 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
582 $s .= "\n<hr>";
583 $articleExists = $wgTitle->getArticleId();
584 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
586 if($wgOut->isArticle()) {
587 $s .= "<strong>" . $this->editThisPage() . "</strong>";
588 } else { # backlink to the article in edit or history mode
590 if($articleExists){ # no backlink if no article
591 $tns=$wgTitle->getNamespace();
592 switch($tns) {
593 case 0:
594 $text = wfMsg("articlepage");
595 break;
596 case 1:
597 $text = wfMsg("viewtalkpage");
598 break;
599 case 2:
600 $text = wfMsg("userpage");
601 break;
602 case 3:
603 $text = wfMsg("viewtalkpage");
604 break;
605 case 4:
606 $text = wfMsg("wikipediapage");
607 break;
608 case 5:
609 $text = wfMsg("viewtalkpage");
610 break;
611 case 6:
612 $text = wfMsg("imagepage");
613 break;
614 case 7:
615 $text = wfMsg("viewtalkpage");
616 break;
617 default:
618 $text= wfMsg("articlepage");
621 $link = $wgTitle->getText();
622 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
623 $link = $nstext . ":" . $link ;
625 $s .= $this->makeLink($link, $text );
626 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
627 # we just throw in a "New page" text to tell the user that he's in edit mode,
628 # and to avoid messing with the separator that is prepended to the next item
629 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
635 watching could cause problems in edit mode:
636 if user edits article, then loads "watch this article" in background and then saves
637 article with "Watch this article" checkbox disabled, the article is transparently
638 unwatched. Therefore we do not show the "Watch this page" link in edit mode
640 if ( 0 != $wgUser->getID() && $articleExists) {
641 if($action!="edit" && $action!="history" &&
642 $action != "submit" )
643 {$s .= $sep . $this->watchThisPage(); }
644 if ( $wgTitle->userCanEdit() ) $s .= $sep . $this->moveThisPage();
646 if ( $wgUser->isSysop() and $articleExists ) {
647 $s .= $sep . $this->deleteThisPage() .
648 $sep . $this->protectThisPage();
650 $s .= $sep . $this->talkLink();
651 if ($articleExists && $action !="history") { $s .= $sep . $this->historyLink();}
652 $s.=$sep . $this->whatLinksHere();
654 if($wgOut->isArticle()) {
655 $s .= $sep . $this->watchPageLinksLink();
658 if ( Namespace::getUser() == $wgTitle->getNamespace()
659 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
662 $id=User::idFromName($wgTitle->getText());
663 $ip=User::isIP($wgTitle->getText());
665 if($id||$ip) {
666 $s .= $sep . $this->userContribsLink();
668 if ( 0 != $wgUser->getID() ) {
669 if($id) { # can only email real users
670 $s .= $sep . $this->emailUserLink();
674 $s .= "\n<hr>";
677 if ( 0 != $wgUser->getID() ) {
678 $s .= $this->specialLink( "upload" ) . $sep;
680 $s .= $this->specialLink( "specialpages" )
681 . $sep . $this->bugReportsLink();
683 $s .= "\n</div>\n";
684 wfProfileOut();
685 return $s;
688 function specialPagesList()
690 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
691 $a = array();
693 $validSP = $wgLang->getValidSpecialPages();
695 foreach ( $validSP as $name => $desc ) {
696 if ( "" == $desc ) { continue; }
697 $a[$name] = $desc;
699 if ( $wgUser->isSysop() )
701 $sysopSP = $wgLang->getSysopSpecialPages();
703 foreach ( $sysopSP as $name => $desc ) {
704 if ( "" == $desc ) { continue; }
705 $a[$name] = $desc ;
708 if ( $wgUser->isDeveloper() )
710 $devSP = $wgLang->getDeveloperSpecialPages();
712 foreach ( $devSP as $name => $desc ) {
713 if ( "" == $desc ) { continue; }
714 $a[$name] = $desc ;
717 $go = wfMsg( "go" );
718 $sp = wfMsg( "specialpages" );
719 $spp = $wgLang->specialPage( "Specialpages" );
721 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
722 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
723 $s .= "<select name=\"wpDropdown\">\n";
724 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
726 foreach ( $a as $name => $desc ) {
727 $p = $wgLang->specialPage( $name );
728 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
730 $s .= "</select>\n";
731 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
732 $s .= "</form>\n";
733 return $s;
736 function mainPageLink()
738 $mp = wfMsg( "mainpage" );
739 $s = $this->makeKnownLink( $mp, $mp );
740 return $s;
743 function copyrightLink()
745 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
746 wfMsg( "copyrightpagename" ) );
747 return $s;
750 function aboutLink()
752 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
753 wfMsg( "aboutwikipedia" ) );
754 return $s;
757 function editThisPage()
759 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
761 if ( ! $wgOut->isArticle() || $diff ) {
762 $s = wfMsg( "protectedpage" );
763 } else if ( $wgTitle->userCanEdit() ) {
764 $n = $wgTitle->getPrefixedText();
765 $t = wfMsg( "editthispage" );
766 $oid = $red = "";
768 if ( $redirect ) { $red = "&redirect={$redirect}"; }
769 if ( $oldid && ! isset( $diff ) ) {
770 $oid = "&oldid={$oldid}";
772 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
773 } else {
774 $s = wfMsg( "protectedpage" );
776 return $s;
779 function deleteThisPage()
781 global $wgUser, $wgOut, $wgTitle, $diff;
783 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
784 $n = $wgTitle->getPrefixedText();
785 $t = wfMsg( "deletethispage" );
787 $s = $this->makeKnownLink( $n, $t, "action=delete" );
788 } else {
789 $s = wfMsg( "error" );
791 return $s;
794 function protectThisPage()
796 global $wgUser, $wgOut, $wgTitle, $diff;
798 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
799 $n = $wgTitle->getPrefixedText();
801 if ( $wgTitle->isProtected() ) {
802 $t = wfMsg( "unprotectthispage" );
803 $q = "action=unprotect";
804 } else {
805 $t = wfMsg( "protectthispage" );
806 $q = "action=protect";
808 $s = $this->makeKnownLink( $n, $t, $q );
809 } else {
810 $s = wfMsg( "error" );
812 return $s;
815 function watchThisPage()
817 global $wgUser, $wgOut, $wgTitle, $diff;
819 if ( $wgOut->isArticle() && ( ! $diff ) ) {
820 $n = $wgTitle->getPrefixedText();
822 if ( $wgTitle->userIsWatching() ) {
823 $t = wfMsg( "unwatchthispage" );
824 $q = "action=unwatch";
825 } else {
826 $t = wfMsg( "watchthispage" );
827 $q = "action=watch";
829 $s = $this->makeKnownLink( $n, $t, $q );
830 } else {
831 $s = wfMsg( "notanarticle" );
833 return $s;
836 function moveThisPage()
838 global $wgTitle, $wgLang;
840 if ( $wgTitle->userCanEdit() ) {
841 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
842 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
843 } // no message if page is protected - would be redundant
844 return $s;
847 function historyLink()
849 global $wgTitle;
851 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
852 wfMsg( "history" ), "action=history" );
853 return $s;
856 function whatLinksHere()
858 global $wgTitle, $wgLang;
860 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
861 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
862 return $s;
865 function userContribsLink()
867 global $wgTitle, $wgLang;
869 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
870 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
871 return $s;
874 function emailUserLink()
876 global $wgTitle, $wgLang;
878 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
879 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
880 return $s;
883 function watchPageLinksLink()
885 global $wgOut, $wgTitle, $wgLang;
887 if ( ! $wgOut->isArticle() ) {
888 $s = "(" . wfMsg( "notanarticle" ) . ")";
889 } else {
890 $s = $this->makeKnownLink( $wgLang->specialPage(
891 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
892 "target=" . $wgTitle->getPrefixedURL() );
894 return $s;
897 function otherLanguages()
899 global $wgOut, $wgLang, $wgTitle , $wgUseNewInterlanguage ;
901 $a = $wgOut->getLanguageLinks();
902 if ( 0 == count( $a ) ) {
903 if ( !$wgUseNewInterlanguage ) return "";
904 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
905 if ( $ns != 0 AND $ns != 1 ) return "" ;
906 $pn = "Intl" ;
907 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
908 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
909 wfMsg( "intl" ) , $x );
912 if ( !$wgUseNewInterlanguage ) {
913 $s = wfMsg( "otherlanguages" ) . ": ";
914 } else {
915 global $wgLanguageCode ;
916 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
917 $x .= "&xl=".$wgLanguageCode ;
918 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
919 wfMsg( "otherlanguages" ) , $x ) . ": " ;
922 $first = true;
923 foreach( $a as $l ) {
924 if ( ! $first ) { $s .= " | "; }
925 $first = false;
927 $nt = Title::newFromText( $l );
928 $url = $nt->getFullURL();
929 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
931 if ( "" == $text ) { $text = $l; }
932 $style = $this->getExternalLinkAttributes( $l, $text );
933 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
935 return $s;
938 function bugReportsLink()
940 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
941 wfMsg( "bugreports" ) );
942 return $s;
945 function dateLink()
947 global $wgLinkCache;
948 $t1 = Title::newFromText( gmdate( "F j" ) );
949 $t2 = Title::newFromText( gmdate( "Y" ) );
951 $wgLinkCache->suspend();
952 $id = $t1->getArticleID();
953 $wgLinkCache->resume();
955 if ( 0 == $id ) {
956 $s = $this->makeBrokenLink( $t1->getText() );
957 } else {
958 $s = $this->makeKnownLink( $t1->getText() );
960 $s .= ", ";
962 $wgLinkCache->suspend();
963 $id = $t2->getArticleID();
964 $wgLinkCache->resume();
966 if ( 0 == $id ) {
967 $s .= $this->makeBrokenLink( $t2->getText() );
968 } else {
969 $s .= $this->makeKnownLink( $t2->getText() );
971 return $s;
974 function talkLink()
976 global $wgLang, $wgTitle, $wgLinkCache;
978 $tns = $wgTitle->getNamespace();
979 if ( -1 == $tns ) { return ""; }
981 $pn = $wgTitle->getText();
982 $tp = wfMsg( "talkpage" );
983 if ( Namespace::isTalk( $tns ) ) {
984 $lns = Namespace::getSubject( $tns );
985 switch($tns) {
986 case 1:
987 $text = wfMsg("articlepage");
988 break;
989 case 3:
990 $text = wfMsg("userpage");
991 break;
992 case 5:
993 $text = wfMsg("wikipediapage");
994 break;
995 case 7:
996 $text = wfMsg("imagepage");
997 break;
998 default:
999 $text= wfMsg("articlepage");
1001 } else {
1003 $lns = Namespace::getTalk( $tns );
1004 $text=$tp;
1006 $n = $wgLang->getNsText( $lns );
1007 if ( "" == $n ) { $link = $pn; }
1008 else { $link = "{$n}:{$pn}"; }
1010 $wgLinkCache->suspend();
1011 $s = $this->makeLink( $link, $text );
1012 $wgLinkCache->resume();
1014 return $s;
1017 # After all the page content is transformed into HTML, it makes
1018 # a final pass through here for things like table backgrounds.
1020 function transformContent( $text )
1022 return $text;
1025 # Note: This function MUST call getArticleID() on the link,
1026 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1028 function makeLink( $title, $text= "", $query = "", $trail = "" )
1030 global $wgOut, $wgUser;
1032 $nt = Title::newFromText( $title );
1034 if ( $nt->isExternal() ) {
1035 $u = $nt->getFullURL();
1036 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1037 $style = $this->getExternalLinkAttributes( $link, $text );
1039 $inside = "";
1040 if ( "" != $trail ) {
1041 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1042 $inside = $m[1];
1043 $trail = $m[2];
1046 return "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1048 if ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1049 return $this->makeKnownLink( $title, $text, $query, $trail );
1051 if ( ( -1 == $nt->getNamespace() ) ||
1052 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1053 return $this->makeKnownLink( $title, $text, $query, $trail );
1055 $aid = $nt->getArticleID() ;
1056 if ( 0 == $aid ) {
1057 return $this->makeBrokenLink( $title, $text, $query, $trail );
1058 } else {
1059 $threshold = $wgUser->getOption("stubthreshold") ;
1060 if ( $threshold > 0 ) {
1061 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'" ) ;
1063 if ( wfNumRows( $res ) > 0 ) {
1064 $s = wfFetchObject( $res );
1065 $size = $s->x;
1066 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
1067 $size = $threshold*2 ; # Really big
1068 wfFreeResult( $res );
1069 } else $size = $threshold*2 ; # Really big
1070 } else $size = 1 ;
1072 if ( $size < $threshold )
1073 return $this->makeStubLink( $title, $text, $query, $trail );
1074 return $this->makeKnownLink( $title, $text, $query, $trail );
1078 function makeKnownLink( $title, $text = "", $query = "", $trail = "" )
1080 global $wgOut, $wgTitle;
1082 $nt = Title::newFromText( $title );
1083 $link = $nt->getPrefixedURL();
1085 if ( "" == $link ) {
1086 $u = "";
1087 if ( "" == $text ) { $text = $nt->getFragment(); }
1088 } else {
1089 $u = wfLocalUrlE( $link, $query );
1091 if ( "" != $nt->getFragment() ) {
1092 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1094 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1095 $style = $this->getInternalLinkAttributes( $link, $text );
1097 $inside = "";
1098 if ( "" != $trail ) {
1099 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1100 $inside = $m[1];
1101 $trail = $m[2];
1104 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1105 return $r;
1108 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" )
1110 global $wgOut, $wgUser;
1112 $nt = Title::newFromText( $title );
1113 $link = $nt->getPrefixedURL();
1115 if ( "" == $query ) { $q = "action=edit"; }
1116 else { $q = "action=edit&{$query}"; }
1117 $u = wfLocalUrlE( $link, $q );
1119 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1120 $style = $this->getInternalLinkAttributes( $link, $text, "yes" );
1122 $inside = "";
1123 if ( "" != $trail ) {
1124 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1125 $inside = $m[1];
1126 $trail = $m[2];
1129 if ( $wgOut->isPrintable() ||
1130 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1131 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1132 } else {
1133 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1135 return $s;
1138 function makeStubLink( $title, $text = "", $query = "", $trail = "" )
1140 global $wgOut, $wgUser;
1142 $nt = Title::newFromText( $title );
1143 $link = $nt->getPrefixedURL();
1145 $u = wfLocalUrlE( $link, $query );
1147 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1148 $style = $this->getInternalLinkAttributes( $link, $text, "stub" );
1150 $inside = "";
1151 if ( "" != $trail ) {
1152 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1153 $inside = $m[1];
1154 $trail = $m[2];
1157 if ( $wgOut->isPrintable() ||
1158 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1159 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1160 } else {
1161 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1163 return $s;
1166 function fnamePart( $url )
1168 $basename = strrchr( $url, "/" );
1169 if ( false === $basename ) { $basename = $url; }
1170 else { $basename = substr( $basename, 1 ); }
1171 return wfEscapeHTML( $basename );
1174 function makeImage( $url, $alt = "" )
1176 global $wgOut;
1178 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1179 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1180 return $s;
1183 function makeImageLink( $name, $url, $alt = "" )
1185 global $wgOut, $wgTitle, $wgLang;
1187 $nt = Title::newFromText( $wgLang->getNsText(
1188 Namespace::getImage() ) . ":{$name}" );
1189 $link = $nt->getPrefixedURL();
1190 if ( "" == $alt ) { $alt = $name; }
1192 $u = wfLocalUrlE( $link );
1193 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1194 "<img border=0 src=\"{$url}\" alt=\"{$alt}\"></a>";
1195 return $s;
1198 function makeMediaLink( $name, $url, $alt = "" )
1200 global $wgOut, $wgTitle;
1202 if ( "" == $alt ) { $alt = $name; }
1203 $u = wfEscapeHTML( $url );
1204 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1205 return $s;
1208 function specialLink( $name, $key = "" )
1210 global $wgLang;
1212 if ( "" == $key ) { $key = strtolower( $name ); }
1213 $pn = $wgLang->ucfirst( $name );
1214 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1215 wfMsg( $key ) );
1218 # Called by history lists and recent changes
1221 function beginRecentChangesList()
1223 $rc_cache = array() ;
1224 $rccc = 0 ;
1225 $this->lastdate = "";
1226 return "";
1229 function beginHistoryList()
1231 $this->lastdate = $this->lastline = "";
1232 $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
1233 return $s;
1236 function beginImageHistoryList()
1238 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1239 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1240 return $s;
1243 function endRecentChangesList()
1245 $s = $this->recentChangesBlock() ;
1246 $s .= "</ul>\n";
1247 return $s;
1250 function endHistoryList()
1252 $last = wfMsg( "last" );
1254 $s = preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
1255 $s .= "</ul>\n";
1256 return $s;
1259 function endImageHistoryList()
1261 $s = "</ul>\n";
1262 return $s;
1265 function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor )
1267 global $wgLang;
1269 $artname = Title::makeName( $ns, $ttl );
1270 $last = wfMsg( "last" );
1271 $cur = wfMsg( "cur" );
1272 $cr = wfMsg( "currentrev" );
1274 if ( $oid && $this->lastline ) {
1275 $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->makeKnownLink(
1276 $artname, $last, "diff=\\1&oldid={$oid}" ), $this->lastline );
1277 } else {
1278 $ret = "";
1280 $dt = $wgLang->timeanddate( $ts, true );
1282 if ( $oid ) { $q = "oldid={$oid}"; }
1283 else { $q = ""; }
1284 $link = $this->makeKnownLink( $artname, $dt, $q );
1286 if ( 0 == $u ) {
1287 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1288 $ut, "target=" . $ut );
1289 } else { $ul = $this->makeLink( $wgLang->getNsText(
1290 Namespace::getUser() ) . ":{$ut}", $ut ); }
1292 $s = "<li>";
1293 if ( $oid ) {
1294 $curlink = $this->makeKnownLink( $artname, $cur,
1295 "diff=0&oldid={$oid}" );
1296 } else {
1297 $curlink = $cur;
1299 $s .= "({$curlink}) (!OLDID!{$oid}!) . .";
1301 $M = wfMsg( "minoreditletter" );
1302 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1303 $s .= " {$link} . . {$ul}";
1305 if ( "" != $c && "*" != $c ) { $s .= " <em>(" . wfEscapeHTML($c) . ")</em>"; }
1306 $s .= "</li>\n";
1308 $this->lastline = $s;
1309 return $ret;
1312 function recentChangesBlockLine ( $y ) {
1313 global $wgUploadPath ;
1315 $M = wfMsg( "minoreditletter" );
1316 $N = wfMsg( "newpageletter" );
1317 $r = "" ;
1318 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;
1319 $r .= "<tt>" ;
1320 if ( $y->isnew ) $r .= $N ;
1321 else $r .= "&nbsp;" ;
1322 if ( $y->isminor ) $r .= $M ;
1323 else $r .= "&nbsp;" ;
1324 $r .= " ".$y->timestamp." " ;
1325 $r .= "</tt>" ;
1326 $link = $y->link ;
1327 if ( $y->watched ) $link = "<strong>{$link}</strong>" ;
1328 $r .= $link ;
1330 $r .= " (" ;
1331 $r .= $y->curlink ;
1332 $r .= "; " ;
1333 $r .= $this->makeKnownLink( $y->secureName, wfMsg( "hist" ), "action=history" );
1335 $r .= ") . . ".$y->userlink ;
1336 $r .= $y->usertalklink ;
1337 if ( $y->usercomment != "" )
1338 $r .= " <em>(".wfEscapeHTML($y->usercomment).")</em>" ;
1339 $r .= "<br>\n" ;
1340 return $r ;
1343 function recentChangesBlockGroup ( $y ) {
1344 global $wgUploadPath ;
1346 $r = "" ;
1347 $M = wfMsg( "minoreditletter" );
1348 $N = wfMsg( "newpageletter" );
1349 $isnew = false ;
1350 $userlinks = array () ;
1351 foreach ( $y AS $x ) {
1352 $oldid = $x->diffid ;
1353 if ( $x->isnew ) $isnew = true ;
1354 $u = $x->userlink ;
1355 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1356 $userlinks[$u]++ ;
1359 krsort ( $userlinks ) ;
1360 asort ( $userlinks ) ;
1361 $users = array () ;
1362 $u = array_keys ( $userlinks ) ;
1363 foreach ( $u as $x ) {
1364 $z = $x ;
1365 if ( $userlinks[$x] > 1 ) $z .= " ({$userlinks[$x]}&times;)" ;
1366 array_push ( $users , $z ) ;
1368 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1370 $e = $y ;
1371 $e = array_shift ( $e ) ;
1373 # Arrow
1374 $rci = "RCI{$this->rccc}" ;
1375 $rcl = "RCL{$this->rccc}" ;
1376 $rcm = "RCM{$this->rccc}" ;
1377 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1378 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1379 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1380 $tl .= "</a>" ;
1381 $r .= $tl ;
1383 # Main line
1384 $r .= "<tt>" ;
1385 if ( $isnew ) $r .= $N ;
1386 else $r .= "&nbsp;" ;
1387 $r .= "&nbsp;" ; # Minor
1388 $r .= " ".$e->timestamp." " ;
1389 $r .= "</tt>" ;
1391 $link = $e->link ;
1392 if ( $e->watched ) $link = "<strong>{$link}</strong>" ;
1393 $r .= $link ;
1395 if ( !$e->islog ) {
1396 $r .= " (".count($y)." " ;
1397 if ( $isnew ) $r .= wfMsg("changes");
1398 else $r .= $this->makeKnownLink( $e->secureName , wfMsg("changes") , "diff=0&oldid=".$oldid ) ;
1399 $r .= "; " ;
1400 $r .= $this->makeKnownLink( $e->secureName, wfMsg( "history" ), "action=history" );
1401 $r .= ")" ;
1404 $r .= $users ;
1405 $r .= "<br>\n" ;
1407 # Sub-entries
1408 $r .= "<div id='{$rci}' style='display:none'>" ;
1409 foreach ( $y AS $x )
1411 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1412 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
1413 if ( $x->isnew ) $r .= $N ;
1414 else $r .= "&nbsp;" ;
1415 if ( $x->isminor ) $r .= $M ;
1416 else $r .= "&nbsp;" ;
1417 $r .= "</tt>" ;
1419 $o = "" ;
1420 if ( $x->oldid != 0 ) $o = "oldid=".$x->oldid ;
1421 if ( $x->islog ) $link = $x->timestamp ;
1422 else $link = $this->makeKnownLink( $x->secureName, $x->timestamp , $o ) ;
1423 $link = "<tt>{$link}</tt>" ;
1426 $r .= $link ;
1427 $r .= " (" ;
1428 $r .= $x->curlink ;
1429 $r .= "; " ;
1430 $r .= $x->lastlink ;
1431 $r .= ") . . ".$x->userlink ;
1432 $r .= $x->usertalklink ;
1433 if ( $x->usercomment != "" )
1434 $r .= " <em>(".wfEscapeHTML($x->usercomment).")</em>" ;
1435 $r .= "<br>\n" ;
1437 $r .= "</div>\n" ;
1439 $this->rccc++ ;
1440 return $r ;
1443 function recentChangesBlock ()
1445 global $wgUploadPath ;
1446 if ( count ( $this->rc_cache ) == 0 ) return "" ;
1447 $k = array_keys ( $this->rc_cache ) ;
1448 foreach ( $k AS $x )
1450 $y = $this->rc_cache[$x] ;
1451 if ( count ( $y ) < 2 ) {
1452 $r .= $this->recentChangesBlockLine ( array_shift ( $y ) ) ;
1453 } else {
1454 $r .= $this->recentChangesBlockGroup ( $y ) ;
1458 return "<div align=left>{$r}</div>" ;
1461 function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1463 global $wgUser ;
1464 $usenew = $wgUser->getOption( "usenewrc" );
1465 if ( $usenew )
1466 $r = $this->recentChangesLineNew ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1467 else
1468 $r = $this->recentChangesLineOld ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1469 return $r ;
1472 function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 )
1474 global $wgTitle, $wgLang, $wgUser;
1476 $d = $wgLang->date( $ts, true);
1477 $s = "";
1478 if ( $d != $this->lastdate ) {
1479 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
1480 $s .= "<h4>{$d}</h4>\n<ul>";
1481 $this->lastdate = $d;
1483 $h = $wgLang->time( $ts, true );
1484 $t = Title::makeName( $ns, $ttl );
1485 $clink = $this->makeKnownLink( $t , "" );
1486 $nt = Title::newFromText( $t );
1488 if ( $watched ) {
1489 $clink = "<strong>{$clink}</strong>";
1491 $hlink = $this->makeKnownLink( $t, wfMsg( "hist" ), "action=history" );
1492 if ( $isnew || $nt->isLog() ) {
1493 $dlink = wfMsg( "diff" );
1494 } else {
1495 $dlink = $this->makeKnownLink( $t, wfMsg( "diff" ),
1496 "diff={$oldid}&oldid={$diffid}" ); # Finagle's law
1498 if ( 0 == $u ) {
1499 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1500 $ut, "target=" . $ut );
1501 } else { $ul = $this->makeLink( $wgLang->getNsText(
1502 Namespace::getUser() ) . ":{$ut}", $ut ); }
1504 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1505 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1506 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1507 $cr = wfMsg( "currentrev" );
1509 $s .= "<li> ({$dlink}) ({$hlink}) . .";
1510 $M = wfMsg( "minoreditletter" );
1511 $N = wfMsg( "newpageletter" );
1512 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1513 if ( $isnew ) { $s .= "<strong>{$N}</strong>"; }
1514 $s .= " {$clink}; {$h} . . {$ul}";
1516 $blink="";
1517 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1518 $blink = $this->makeKnownLink( $wgLang->specialPage(
1519 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1522 if(!$blink) {
1523 $utl = "({$utl})";
1524 } else {
1525 $utl = "({$utl} | {$blink})";
1527 $s.=" {$utl}";
1529 if ( "" != $c && "*" != $c ) {
1530 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1532 $s .= "</li>\n";
1534 return $s;
1537 function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1539 global $wgTitle, $wgLang, $wgUser;
1541 $rc = new RecentChangesClass ;
1543 $d = $wgLang->date( $ts, true);
1544 $s = "";
1545 $ret = "" ;
1546 if ( $d != $this->lastdate ) {
1547 $ret = $this->recentChangesBlock () ;
1548 $this->rc_cache = array() ;
1549 $ret .= "<h4>{$d}</h4>\n";
1550 $this->lastdate = $d;
1552 $h = $wgLang->time( $ts, true );
1553 $t = Title::makeName( $ns, $ttl );
1554 $clink = $this->makeKnownLink( $t, "" ) ;
1555 if ( $oldid == 0 ) $c2link = $clink ;
1556 else $c2link = $this->makeKnownLink( $t, "" , "oldid={$oldid}" );
1557 $nt = Title::newFromText( $t );
1559 $rc->timestamp = $h ;
1560 $rc->oldid = $oldid ;
1561 $rc->diffid = $diffid ;
1562 $rc->watched = $watched ;
1563 $rc->isnew = $isnew ;
1564 $rc->isminor = $isminor ;
1565 $rc->secureName = $t ;
1566 $rc->displayName = $nt ;
1567 $rc->link = $clink ;
1568 $rc->usercomment = $c ;
1569 $rc->islog = $nt->isLog() ;
1571 if ( ( $isnew && $oldid == 0 ) || $nt->isLog() ) {
1572 $dlink = wfMsg( "cur" );
1573 } else {
1574 $dlink = $this->makeKnownLink( $t, wfMsg( "cur" ),
1575 "diff=0&oldid={$oldid}" );
1578 if ( $diffid == 0 || $nt->isLog() ) {
1579 $plink = wfMsg( "last" );
1580 } else {
1581 $plink = $this->makeKnownLink( $t, wfMsg( "last" ),
1582 "diff={$oldid}&oldid={$diffid}" );
1585 if ( 0 == $u ) {
1586 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1587 $ut, "target=" . $ut );
1588 } else { $ul = $this->makeLink( $wgLang->getNsText(
1589 Namespace::getUser() ) . ":{$ut}", $ut ); }
1591 $rc->userlink = $ul ;
1592 $rc->lastlink = $plink ;
1593 $rc->curlink = $dlink ;
1595 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1596 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1597 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1599 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1600 $blink = $this->makeKnownLink( $wgLang->specialPage(
1601 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1602 $rc->usertalklink= " ({$utl} | {$blink})";
1603 } else {
1604 $rc->usertalklink=" ({$utl})";
1607 if ( !isset ( $this->rc_cache[$t] ) ) $this->rc_cache[$t] = array() ;
1608 array_push ( $this->rc_cache[$t] , $rc ) ;
1609 return $ret;
1613 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
1615 global $wgUser, $wgLang, $wgTitle;
1617 $dt = $wgLang->timeanddate( $ts, true );
1618 $del = wfMsg( "deleteimg" );
1619 $cur = wfMsg( "cur" );
1621 if ( $iscur ) {
1622 $url = wfImageUrl( $img );
1623 $rlink = $cur;
1624 if ( $wgUser->isSysop() ) {
1625 $link = wfLocalUrlE( "", "image=" . $wgTitle->getURL() .
1626 "&action=delete" );
1627 $style = $this->getInternalLinkAttributes( $link, $del );
1629 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
1630 } else {
1631 $dlink = $del;
1633 } else {
1634 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
1635 if( $wgUser->getID() != 0 ) {
1636 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1637 wfMsg( "revertimg" ), "action=revert&oldimage=" .
1638 urlencode( $img ) );
1639 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1640 $del, "action=delete&oldimage=" . urlencode( $img ) );
1641 } else {
1642 # Having live active links for non-logged in users
1643 # means that bots and spiders crawling our site can
1644 # inadvertently change content. Baaaad idea.
1645 $rlink = wfMsg( "revertimg" );
1646 $dlink = $del;
1649 if ( 0 == $u ) { $ul = $ut; }
1650 else { $ul = $this->makeLink( $wgLang->getNsText(
1651 Namespace::getUser() ) . ":{$ut}", $ut ); }
1653 $nb = str_replace( "$1", $size, wfMsg( "nbytes" ) );
1654 $style = $this->getInternalLinkAttributes( $url, $dt );
1656 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
1657 . " . . {$ul} ({$nb})";
1659 if ( "" != $c && "*" != $c ) {
1660 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1662 $s .= "</li>\n";
1663 return $s;
1666 function tocIndent($level) {
1668 while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
1669 return $rv;
1673 function tocUnindent($level) {
1674 while($level-->0) $rv.="</div>\n";
1675 return $rv;
1678 // parameter level defines if we are on an indentation level
1679 function tocLine($anchor,$tocline,$level) {
1681 if($level) {
1683 return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
1684 } else {
1686 return "<div style=\"margin-bottom:0px;\">\n".
1687 "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
1688 "</div>\n";
1693 function tocTable($toc) {
1695 /* does not auto-expand, use table for now
1696 return "
1697 <div><div style=\"border-width:1px;background-color:#f3f3ff;border-color:#8888aa;border-style:solid;padding:1em;padding-bottom:1em;\">
1698 <b>".wfMsg("toc")."</b><P>
1699 $toc</div></div>";
1701 return
1702 "<table border=\"0\" bgcolor=\"#8888aa\" cellpadding=\"0\" cellspacing=\"1\"><tr><td>\n" .
1703 "<table border=\"0\" bgcolor=\"#f3f3ff\" CELLPADDING=5><tr><td>\n".
1704 "<b>".wfMsg("toc")."</b>" .
1705 " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>" .
1706 "</td></tr><tr id='tocinside'><td>\n".
1707 $toc."</td></tr></table></td></tr></table><P>\n";
1710 function editSectionLink($section) {
1712 global $wgTitle,$wgUser,$oldid;
1713 if($wgTitle->isProtected() && !$wgUser->isSysop()) return "";
1714 if($oldid) return "";
1715 $editurl="&section={$section}";
1716 $url=$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
1717 return "<div style=\"float:right;margin-left:5px;\"><small>[".$url."]</small></div>";
1722 include_once( "SkinStandard.php" );
1723 include_once( "SkinNostalgia.php" );
1724 include_once( "SkinCologneBlue.php" );