updates from the French Wikipedia's copy
[mediawiki.git] / includes / Skin.php
blobd00a1920c95cc1a4b2bdd5625ebccc80404d1fec
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 $s .= "a.stub, a.new, a.internal, a.external { " .
85 "text-decoration: underline; }\n";
86 } else {
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 { color: #CC2200; }\n" .
92 "#quickbar a.new { color: CC2200; }\n";
94 if ( 1 == $wgUser->getOption( "justify" ) ) {
95 $s .= "#article { text-align: justify; }\n";
97 return $s;
100 function getBodyOptions()
102 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $oldid, $redirect, $diff,$action;
104 if ( 0 != $wgTitle->getNamespace() ) {
105 $a = array( "bgcolor" => "#FFFFDD" );
107 else $a = array( "bgcolor" => "#FFFFFF" );
108 if($wgOut->isArticle() && $wgUser->getOption("editondblclick")
110 (!$wgTitle->isProtected() || $wgUser->isSysop())
113 $n = $wgTitle->getPrefixedURL();
114 $t = wfMsg( "editthispage" );
115 $oid = $red = "";
116 if ( $redirect ) { $red = "&redirect={$redirect}"; }
117 if ( $oldid && ! isset( $diff ) ) {
118 $oid = "&oldid={$oldid}";
120 $s = wfLocalUrlE($n,"action=edit{$oid}{$red}");
121 $s = "document.location = \"" .$s ."\";";
122 $a += array ("ondblclick" => $s);
125 if($action=="edit") { # set focus in edit box
126 $a += array("onLoad"=>"document.editform.wpTextbox1.focus()");
128 return $a;
131 function getExternalLinkAttributes( $link, $text )
133 global $wgUser, $wgOut, $wgLang;
135 $link = urldecode( $link );
136 $link = $wgLang->checkTitleEncoding( $link );
137 $link = str_replace( "_", " ", $link );
138 $link = wfEscapeHTML( $link );
140 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
141 else { $r = " class='external'"; }
143 if ( 1 == $wgUser->getOption( "hover" ) ) {
144 $r .= " title=\"{$link}\"";
146 return $r;
149 function getInternalLinkAttributes( $link, $text, $broken = false )
151 global $wgUser, $wgOut;
153 $link = urldecode( $link );
154 $link = str_replace( "_", " ", $link );
155 $link = wfEscapeHTML( $link );
157 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
158 else if ( $broken == "stub" ) { $r = " class='stub'"; }
159 else if ( $broken == "yes" ) { $r = " class='new'"; }
160 else { $r = " class='internal'"; }
162 if ( 1 == $wgUser->getOption( "hover" ) ) {
163 $r .= " title=\"{$link}\"";
165 return $r;
168 function getLogo()
170 global $wgLogo;
171 return $wgLogo;
174 # This will be called immediately after the <body> tag. Split into
175 # two functions to make it easier to subclass.
177 function beforeContent()
179 global $wgUser, $wgOut;
181 if ( $wgOut->isPrintable() ) {
182 $s = $this->pageTitle() . $this->pageSubtitle() . "\n";
183 $s .= "\n<div class='bodytext'>";
184 return $s;
186 return $this->doBeforeContent();
189 function doBeforeContent()
191 global $wgUser, $wgOut, $wgTitle;
192 wfProfileIn( "Skin::doBeforeContent" );
194 $s = "";
195 $qb = $this->qbSetting();
197 if( $langlinks = $this->otherLanguages() ) {
198 $rows = 2;
199 $borderhack = "";
200 } else {
201 $rows = 1;
202 $langlinks = false;
203 $borderhack = "class='top'";
206 $s .= "\n<div id='content'>\n<div id='topbar'>" .
207 "<table width='98%' border=0 cellspacing=0><tr>";
209 if ( 0 == $qb ) {
210 $s .= "<td class='top' align=left valign=top rowspan='{$rows}'>" .
211 $this->logoText() . "</td>";
212 } else if ( 1 == $qb || 3 == $qb ) { # Left
213 $s .= $this->getQuickbarCompensator( $rows );
215 $s .= "<td {$borderhack} align=left valign=top>";
217 $s .= $this->topLinks() ;
218 $s .= "<p class='subtitle'>" . $this->pageTitleLinks();
220 $s .= "</td>\n<td {$borderhack} valign=top align=right nowrap>";
221 $s .= $this->nameAndLogin();
222 $s .= "\n<br>" . $this->searchForm() . "</td>";
224 if ( $langlinks ) {
225 $s .= "</tr>\n<tr><td class='top' colspan=\"2\">$langlinks</td>";
228 if ( 2 == $qb ) { # Right
229 $s .= $this->getQuickbarCompensator( $rows );
231 $s .= "</tr></table>\n</div>\n";
232 $s .= "\n<div id='article'>";
234 $s .= $this->pageTitle();
235 $s .= $this->pageSubtitle() . "\n<p>";
236 wfProfileOut();
237 return $s;
240 function getQuickbarCompensator( $rows = 1 )
242 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
245 # This gets called immediately before the </body> tag.
247 function afterContent()
249 global $wgUser, $wgOut, $wgServer, $HTTP_SERVER_VARS;
251 if ( $wgOut->isPrintable() ) {
252 $s = "\n</div>\n";
254 $u = $wgServer . $HTTP_SERVER_VARS['REQUEST_URI'];
255 $u = preg_replace( "/[?&]printable=yes/", "", $u );
256 $rf = str_replace( "$1", $u, wfMsg( "retrievedfrom" ) );
258 if ( $wgOut->isArticle() ) {
259 $lm = "<br>" . $this->lastModified();
260 } else { $lm = ""; }
262 $s .= "<p><em>{$rf}{$lm}</em>\n";
263 return $s;
265 return $this->doAfterContent();
268 function doAfterContent()
270 global $wgUser, $wgOut;
271 wfProfileIn( "Skin::doAfterContent" );
273 $s = "\n</div><br clear=all>\n";
275 $s .= "\n<div id='footer'>";
276 $s .= "<table width='98%' border=0 cellspacing=0><tr>";
278 $qb = $this->qbSetting();
279 if ( 1 == $qb || 3 == $qb ) { # Left
280 $s .= $this->getQuickbarCompensator();
282 $s .= "<td class='bottom' align=left valign=top>";
284 $s .= $this->bottomLinks();
285 $s .= "\n<br>" . $this->mainPageLink()
286 . " | " . $this->aboutLink()
287 . " | " . $this->specialLink( "recentchanges" )
288 . " | " . $this->searchForm()
289 . "<br>" . $this->pageStats();
291 $s .= "</td>";
292 if ( 2 == $qb ) { # Right
293 $s .= $this->getQuickbarCompensator();
295 $s .= "</tr></table>\n</div>\n</div>\n";
297 if ( 0 != $qb ) { $s .= $this->quickBar(); }
298 wfProfileOut();
299 return $s;
302 function pageTitleLinks()
304 global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang;
306 $s = $this->printableLink();
308 if ( $wgOut->isArticle() ) {
309 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
310 $name = $wgTitle->getDBkey();
311 $link = wfEscapeHTML( wfImageUrl( $name ) );
312 $style = $this->getInternalLinkAttributes( $link, $name );
313 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
316 if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
317 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
318 wfMsg( "currentrev" ) );
321 if ( $wgUser->getNewtalk() ) {
322 # do not show "You have new messages" text when we are viewing our
323 # own talk page
325 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
326 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
327 $n =$wgUser->getName();
328 $tl = $this->makeKnownLink( $wgLang->getNsText(
329 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
330 wfMsg("newmessageslink") );
331 $s.=" | <strong>". str_replace( "$1", $tl, wfMsg("newmessages") ) . "</strong>";
334 return $s;
337 function printableLink()
339 global $wgOut, $wgTitle, $oldid, $action;
341 if ( "history" == $action ) { $q = "action=history&"; }
342 else { $q = ""; }
344 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
345 WfMsg( "printableversion" ), "{$q}printable=yes" );
346 return $s;
349 function pageTitle()
351 global $wgOut, $wgTitle;
353 $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
354 return $s;
357 function pageSubtitle()
359 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
361 $sub = $wgOut->getSubtitle();
362 if ( "" == $sub ) { $sub = wfMsg( "fromwikipedia" ); }
363 if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
364 $ptext=$wgTitle->getPrefixedText();
365 if(preg_match("/\//",$ptext)) {
366 $sub.="</p><p class='subpages'>";
367 $links=explode("/",$ptext);
368 $c=0;
369 $growinglink="";
370 foreach($links as $link) {
371 $c++;
372 if ($c<count($links)) {
373 $growinglink.=$link;
374 $getlink=$this->makeLink($growinglink,$link);
375 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
376 if ($c>1) {
377 $sub .= " | ";
378 } else {
379 $sub .="&lt; ";
381 $sub .= $getlink;
382 $growinglink.="/";
388 $s = "<p class='subtitle'>{$sub}\n";
389 return $s;
392 function nameAndLogin()
394 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader;
396 $li = $wgLang->specialPage( "Userlogin" );
397 $lo = $wgLang->specialPage( "Userlogout" );
399 $s = "";
400 if ( 0 == $wgUser->getID() ) {
401 if( $wgShowIPinHeader ) {
402 $n = getenv( "REMOTE_ADDR" );
404 $tl = $this->makeKnownLink( $wgLang->getNsText(
405 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
406 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
408 $s .= $n . " (".$tl.")";
409 } else {
410 $s .= wfMsg("notloggedin");
413 $rt = $wgTitle->getPrefixedURL();
414 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
415 $q = "";
416 } else { $q = "returnto={$rt}"; }
418 $s .= "\n<br>" . $this->makeKnownLink( $li,
419 wfMsg( "login" ), $q );
420 } else {
421 $n = $wgUser->getName();
422 $rt = $wgTitle->getPrefixedURL();
423 $tl = $this->makeKnownLink( $wgLang->getNsText(
424 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
425 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
427 $tl = " ({$tl})";
429 $s .= $this->makeKnownLink( $wgLang->getNsText(
430 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
431 $this->makeKnownLink( $lo, wfMsg( "logout" ),
432 "returnto={$rt}" ) . " | " .
433 $this->specialLink( "preferences" );
435 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
436 wfMsg( "help" ) );
438 return $s;
441 function searchForm()
443 global $search;
445 $s = "<form name='search' class='inline' method=get action=\""
446 . wfLocalUrl( "" ) . "\">"
447 . "<input type=text name=\"search\" size=19 value=\""
448 . htmlspecialchars(substr($search,0,256)) . "\">\n"
449 . "<input type=submit name=\"go\" value=\"" . wfMsg ("go") . "\">&nbsp;"
450 . "<input type=submit value=\"" . wfMsg ("search") . "\"></form>";
452 return $s;
455 function topLinks()
457 global $wgOut;
458 $sep = " |\n";
460 $s = $this->mainPageLink() . $sep
461 . $this->specialLink( "recentchanges" );
463 if ( $wgOut->isArticle() ) {
464 $s .= $sep . $this->editThisPage()
465 . $sep . $this->historyLink();
467 $s .= $sep . $this->specialPagesList();
469 return $s;
472 function bottomLinks()
474 global $wgOut, $wgUser, $wgTitle;
475 $sep = " |\n";
477 $s = "";
478 if ( $wgOut->isArticle() ) {
479 $s .= "<strong>" . $this->editThisPage() . "</strong>";
480 if ( 0 != $wgUser->getID() ) {
481 $s .= $sep . $this->watchThisPage();
483 $s .= $sep . $this->talkLink()
484 . $sep . $this->historyLink()
485 . $sep . $this->whatLinksHere()
486 . $sep . $this->watchPageLinksLink();
488 if ( $wgTitle->getNamespace() == Namespace::getUser()
489 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
492 $id=User::idFromName($wgTitle->getText());
493 $ip=User::isIP($wgTitle->getText());
495 if($id || $ip) { # both anons and non-anons have contri list
496 $s .= $sep . $this->userContribsLink();
498 if ( 0 != $wgUser->getID() ) { # show only to signed in users
499 if($id) { # can only email non-anons
500 $s .= $sep . $this->emailUserLink();
504 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
505 $s .= "\n<br>" . $this->deleteThisPage() .
506 $sep . $this->protectThisPage() .
507 $sep . $this->moveThisPage();
509 $s .= "<br>\n" . $this->otherLanguages();
511 return $s;
514 function pageStats()
516 global $wgOut, $wgLang, $wgArticle;
517 global $oldid, $diff, $wgDisableCounters;
519 if ( ! $wgOut->isArticle() ) { return ""; }
520 if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
521 if ( 0 == $wgArticle->getID() ) { return ""; }
523 if ( $wgDisableCounters ) {
524 $s = "";
525 } else {
526 $count = $wgArticle->getCount();
527 $s = str_replace( "$1", $count, wfMsg( "viewcount" ) );
529 $s .= $this->lastModified();
530 $s .= " " . wfMsg( "gnunote" );
531 return "<span id='pagestats'>{$s}</span>";
534 function lastModified()
536 global $wgLang, $wgArticle;
538 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
539 $s = " " . str_replace( "$1", $d, wfMsg( "lastmodified" ) );
540 return $s;
543 function logoText( $align = "" )
545 if ( "" != $align ) { $a = " align='{$align}'"; }
546 else { $a = ""; }
548 $mp = wfMsg( "mainpage" );
549 $s = "<a href=\"" . wfLocalUrlE( $mp ) . "\"><img{$a} border=0 src=\""
550 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
551 return $s;
554 function quickBar()
556 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
557 global $wpPreview;
558 wfProfileIn( "Skin::quickBar" );
560 $s = "\n<div id='quickbar'>";
561 $s .= "\n" . $this->logoText() . "\n<hr>";
563 $sep = "\n<br>";
564 $s .= $this->mainPageLink()
565 . $sep . $this->specialLink( "recentchanges" )
566 . $sep . $this->specialLink( "randompage" );
567 if ($wgUser->getID()) {
568 $s.= $sep . $this->specialLink( "watchlist" ) ;
569 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
570 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
573 // only show watchlist link if logged in
574 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
575 $s .= "\n<hr>";
576 $articleExists = $wgTitle->getArticleId();
577 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
579 if($wgOut->isArticle()) {
580 $s .= "<strong>" . $this->editThisPage() . "</strong>";
581 } else { # backlink to the article in edit or history mode
583 if($articleExists){ # no backlink if no article
584 $tns=$wgTitle->getNamespace();
585 switch($tns) {
586 case 0:
587 $text = wfMsg("articlepage");
588 break;
589 case 1:
590 $text = wfMsg("viewtalkpage");
591 break;
592 case 2:
593 $text = wfMsg("userpage");
594 break;
595 case 3:
596 $text = wfMsg("viewtalkpage");
597 break;
598 case 4:
599 $text = wfMsg("wikipediapage");
600 break;
601 case 5:
602 $text = wfMsg("viewtalkpage");
603 break;
604 case 6:
605 $text = wfMsg("imagepage");
606 break;
607 case 7:
608 $text = wfMsg("viewtalkpage");
609 break;
610 default:
611 $text= wfMsg("articlepage");
614 $link = $wgTitle->getText();
615 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
616 $link = $nstext . ":" . $link ;
618 $s .= $this->makeLink($link, $text );
619 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
620 # we just throw in a "New page" text to tell the user that he's in edit mode,
621 # and to avoid messing with the separator that is prepended to the next item
622 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
628 watching could cause problems in edit mode:
629 if user edits article, then loads "watch this article" in background and then saves
630 article with "Watch this article" checkbox disabled, the article is transparently
631 unwatched. Therefore we do not show the "Watch this page" link in edit mode
633 if ( 0 != $wgUser->getID() && $articleExists) {
634 if($action!="edit" && $action!="history" &&
635 $action != "submit" )
636 {$s .= $sep . $this->watchThisPage(); }
637 if ( $wgTitle->userCanEdit() ) $s .= $sep . $this->moveThisPage();
639 if ( $wgUser->isSysop() and $articleExists ) {
640 $s .= $sep . $this->deleteThisPage() .
641 $sep . $this->protectThisPage();
643 $s .= $sep . $this->talkLink();
644 if ($articleExists && $action !="history") { $s .= $sep . $this->historyLink();}
645 $s.=$sep . $this->whatLinksHere();
647 if($wgOut->isArticle()) {
648 $s .= $sep . $this->watchPageLinksLink();
651 if ( Namespace::getUser() == $wgTitle->getNamespace()
652 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
655 $id=User::idFromName($wgTitle->getText());
656 $ip=User::isIP($wgTitle->getText());
658 if($id||$ip) {
659 $s .= $sep . $this->userContribsLink();
661 if ( 0 != $wgUser->getID() ) {
662 if($id) { # can only email real users
663 $s .= $sep . $this->emailUserLink();
667 $s .= "\n<hr>";
670 if ( 0 != $wgUser->getID() ) {
671 $s .= $this->specialLink( "upload" ) . $sep;
673 $s .= $this->specialLink( "specialpages" )
674 . $sep . $this->bugReportsLink();
676 $s .= "\n</div>\n";
677 wfProfileOut();
678 return $s;
681 function specialPagesList()
683 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
684 $a = array();
686 $validSP = $wgLang->getValidSpecialPages();
688 foreach ( $validSP as $name => $desc ) {
689 if ( "" == $desc ) { continue; }
690 $a[$name] = $desc;
692 if ( $wgUser->isSysop() )
694 $sysopSP = $wgLang->getSysopSpecialPages();
696 foreach ( $sysopSP as $name => $desc ) {
697 if ( "" == $desc ) { continue; }
698 $a[$name] = $desc ;
701 if ( $wgUser->isDeveloper() )
703 $devSP = $wgLang->getDeveloperSpecialPages();
705 foreach ( $devSP as $name => $desc ) {
706 if ( "" == $desc ) { continue; }
707 $a[$name] = $desc ;
710 $go = wfMsg( "go" );
711 $sp = wfMsg( "specialpages" );
712 $spp = $wgLang->specialPage( "Specialpages" );
714 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
715 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
716 $s .= "<select name=\"wpDropdown\">\n";
717 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
719 foreach ( $a as $name => $desc ) {
720 $p = $wgLang->specialPage( $name );
721 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
723 $s .= "</select>\n";
724 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
725 $s .= "</form>\n";
726 return $s;
729 function mainPageLink()
731 $mp = wfMsg( "mainpage" );
732 $s = $this->makeKnownLink( $mp, $mp );
733 return $s;
736 function copyrightLink()
738 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
739 wfMsg( "copyrightpagename" ) );
740 return $s;
743 function aboutLink()
745 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
746 wfMsg( "aboutwikipedia" ) );
747 return $s;
750 function editThisPage()
752 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
754 if ( ! $wgOut->isArticle() || $diff ) {
755 $s = wfMsg( "protectedpage" );
756 } else if ( $wgTitle->userCanEdit() ) {
757 $n = $wgTitle->getPrefixedText();
758 $t = wfMsg( "editthispage" );
759 $oid = $red = "";
761 if ( $redirect ) { $red = "&redirect={$redirect}"; }
762 if ( $oldid && ! isset( $diff ) ) {
763 $oid = "&oldid={$oldid}";
765 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
766 } else {
767 $s = wfMsg( "protectedpage" );
769 return $s;
772 function deleteThisPage()
774 global $wgUser, $wgOut, $wgTitle, $diff;
776 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
777 $n = $wgTitle->getPrefixedText();
778 $t = wfMsg( "deletethispage" );
780 $s = $this->makeKnownLink( $n, $t, "action=delete" );
781 } else {
782 $s = wfMsg( "error" );
784 return $s;
787 function protectThisPage()
789 global $wgUser, $wgOut, $wgTitle, $diff;
791 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
792 $n = $wgTitle->getPrefixedText();
794 if ( $wgTitle->isProtected() ) {
795 $t = wfMsg( "unprotectthispage" );
796 $q = "action=unprotect";
797 } else {
798 $t = wfMsg( "protectthispage" );
799 $q = "action=protect";
801 $s = $this->makeKnownLink( $n, $t, $q );
802 } else {
803 $s = wfMsg( "error" );
805 return $s;
808 function watchThisPage()
810 global $wgUser, $wgOut, $wgTitle, $diff;
812 if ( $wgOut->isArticle() && ( ! $diff ) ) {
813 $n = $wgTitle->getPrefixedText();
815 if ( $wgTitle->userIsWatching() ) {
816 $t = wfMsg( "unwatchthispage" );
817 $q = "action=unwatch";
818 } else {
819 $t = wfMsg( "watchthispage" );
820 $q = "action=watch";
822 $s = $this->makeKnownLink( $n, $t, $q );
823 } else {
824 $s = wfMsg( "notanarticle" );
826 return $s;
829 function moveThisPage()
831 global $wgTitle, $wgLang;
833 if ( $wgTitle->userCanEdit() ) {
834 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
835 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
836 } // no message if page is protected - would be redundant
837 return $s;
840 function historyLink()
842 global $wgTitle;
844 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
845 wfMsg( "history" ), "action=history" );
846 return $s;
849 function whatLinksHere()
851 global $wgTitle, $wgLang;
853 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
854 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
855 return $s;
858 function userContribsLink()
860 global $wgTitle, $wgLang;
862 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
863 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
864 return $s;
867 function emailUserLink()
869 global $wgTitle, $wgLang;
871 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
872 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
873 return $s;
876 function watchPageLinksLink()
878 global $wgOut, $wgTitle, $wgLang;
880 if ( ! $wgOut->isArticle() ) {
881 $s = "(" . wfMsg( "notanarticle" ) . ")";
882 } else {
883 $s = $this->makeKnownLink( $wgLang->specialPage(
884 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
885 "target=" . $wgTitle->getPrefixedURL() );
887 return $s;
890 function otherLanguages()
892 global $wgOut, $wgLang, $wgTitle , $wgUseNewInterlanguage ;
894 $a = $wgOut->getLanguageLinks();
895 if ( 0 == count( $a ) ) {
896 if ( !$wgUseNewInterlanguage ) return "";
897 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
898 if ( $ns != 0 AND $ns != 1 ) return "" ;
899 $pn = "Intl" ;
900 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
901 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
902 wfMsg( "intl" ) , $x );
905 if ( !$wgUseNewInterlanguage ) {
906 $s = wfMsg( "otherlanguages" ) . ": ";
907 } else {
908 global $wgLanguageCode ;
909 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
910 $x .= "&xl=".$wgLanguageCode ;
911 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
912 wfMsg( "otherlanguages" ) , $x ) . ": " ;
915 $first = true;
916 foreach( $a as $l ) {
917 if ( ! $first ) { $s .= " | "; }
918 $first = false;
920 $nt = Title::newFromText( $l );
921 $url = $nt->getFullURL();
922 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
924 if ( "" == $text ) { $text = $l; }
925 $style = $this->getExternalLinkAttributes( $l, $text );
926 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
928 return $s;
931 function bugReportsLink()
933 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
934 wfMsg( "bugreports" ) );
935 return $s;
938 function dateLink()
940 global $wgLinkCache;
941 $t1 = Title::newFromText( date( "F j" ) );
942 $t2 = Title::newFromText( date( "Y" ) );
944 $wgLinkCache->suspend();
945 $id = $t1->getArticleID();
946 $wgLinkCache->resume();
948 if ( 0 == $id ) {
949 $s = $this->makeBrokenLink( $t1->getText() );
950 } else {
951 $s = $this->makeKnownLink( $t1->getText() );
953 $s .= ", ";
955 $wgLinkCache->suspend();
956 $id = $t2->getArticleID();
957 $wgLinkCache->resume();
959 if ( 0 == $id ) {
960 $s .= $this->makeBrokenLink( $t2->getText() );
961 } else {
962 $s .= $this->makeKnownLink( $t2->getText() );
964 return $s;
967 function talkLink()
969 global $wgLang, $wgTitle, $wgLinkCache;
971 $tns = $wgTitle->getNamespace();
972 if ( -1 == $tns ) { return ""; }
974 $pn = $wgTitle->getText();
975 $tp = wfMsg( "talkpage" );
976 if ( Namespace::isTalk( $tns ) ) {
977 $lns = Namespace::getSubject( $tns );
978 switch($tns) {
979 case 1:
980 $text = wfMsg("articlepage");
981 break;
982 case 3:
983 $text = wfMsg("userpage");
984 break;
985 case 5:
986 $text = wfMsg("wikipediapage");
987 break;
988 case 7:
989 $text = wfMsg("imagepage");
990 break;
991 default:
992 $text= wfMsg("articlepage");
994 } else {
996 $lns = Namespace::getTalk( $tns );
997 $text=$tp;
999 $n = $wgLang->getNsText( $lns );
1000 if ( "" == $n ) { $link = $pn; }
1001 else { $link = "{$n}:{$pn}"; }
1003 $wgLinkCache->suspend();
1004 $s = $this->makeLink( $link, $text );
1005 $wgLinkCache->resume();
1007 return $s;
1010 # After all the page content is transformed into HTML, it makes
1011 # a final pass through here for things like table backgrounds.
1013 function transformContent( $text )
1015 return $text;
1018 # Note: This function MUST call getArticleID() on the link,
1019 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1021 function makeLink( $title, $text= "", $query = "", $trail = "" )
1023 global $wgOut, $wgUser;
1025 $nt = Title::newFromText( $title );
1027 if ( $nt->isExternal() ) {
1028 $u = $nt->getFullURL();
1029 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1030 $style = $this->getExternalLinkAttributes( $link, $text );
1032 $inside = "";
1033 if ( "" != $trail ) {
1034 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1035 $inside = $m[1];
1036 $trail = $m[2];
1039 return "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1041 if ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1042 return $this->makeKnownLink( $title, $text, $query, $trail );
1044 if ( ( -1 == $nt->getNamespace() ) ||
1045 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1046 return $this->makeKnownLink( $title, $text, $query, $trail );
1048 $aid = $nt->getArticleID() ;
1049 if ( 0 == $aid ) {
1050 return $this->makeBrokenLink( $title, $text, $query, $trail );
1051 } else {
1052 $threshold = $wgUser->getOption("stubthreshold") ;
1053 if ( $threshold > 0 ) {
1054 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'" ) ;
1056 if ( wfNumRows( $res ) > 0 ) {
1057 $s = wfFetchObject( $res );
1058 $size = $s->x;
1059 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
1060 $size = $threshold*2 ; # Really big
1061 wfFreeResult( $res );
1062 } else $size = $threshold*2 ; # Really big
1063 } else $size = 1 ;
1065 if ( $size < $threshold )
1066 return $this->makeStubLink( $title, $text, $query, $trail );
1067 return $this->makeKnownLink( $title, $text, $query, $trail );
1071 function makeKnownLink( $title, $text = "", $query = "", $trail = "" )
1073 global $wgOut, $wgTitle;
1075 $nt = Title::newFromText( $title );
1076 $link = $nt->getPrefixedURL();
1078 if ( "" == $link ) {
1079 $u = "";
1080 if ( "" == $text ) { $text = $nt->getFragment(); }
1081 } else {
1082 $u = wfLocalUrlE( $link, $query );
1084 if ( "" != $nt->getFragment() ) {
1085 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1087 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1088 $style = $this->getInternalLinkAttributes( $link, $text );
1090 $inside = "";
1091 if ( "" != $trail ) {
1092 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1093 $inside = $m[1];
1094 $trail = $m[2];
1097 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1098 return $r;
1101 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" )
1103 global $wgOut, $wgUser;
1105 $nt = Title::newFromText( $title );
1106 $link = $nt->getPrefixedURL();
1108 if ( "" == $query ) { $q = "action=edit"; }
1109 else { $q = "action=edit&{$query}"; }
1110 $u = wfLocalUrlE( $link, $q );
1112 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1113 $style = $this->getInternalLinkAttributes( $link, $text, "yes" );
1115 $inside = "";
1116 if ( "" != $trail ) {
1117 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1118 $inside = $m[1];
1119 $trail = $m[2];
1122 if ( $wgOut->isPrintable() ||
1123 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1124 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1125 } else {
1126 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1128 return $s;
1131 function makeStubLink( $title, $text = "", $query = "", $trail = "" )
1133 global $wgOut, $wgUser;
1135 $nt = Title::newFromText( $title );
1136 $link = $nt->getPrefixedURL();
1138 $u = wfLocalUrlE( $link, $query );
1140 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1141 $style = $this->getInternalLinkAttributes( $link, $text, "stub" );
1143 $inside = "";
1144 if ( "" != $trail ) {
1145 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1146 $inside = $m[1];
1147 $trail = $m[2];
1150 if ( $wgOut->isPrintable() ||
1151 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1152 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1153 } else {
1154 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1156 return $s;
1159 function fnamePart( $url )
1161 $basename = strrchr( $url, "/" );
1162 if ( false === $basename ) { $basename = $url; }
1163 else { $basename = substr( $basename, 1 ); }
1164 return wfEscapeHTML( $basename );
1167 function makeImage( $url, $alt = "" )
1169 global $wgOut;
1171 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1172 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1173 return $s;
1176 function makeImageLink( $name, $url, $alt = "" )
1178 global $wgOut, $wgTitle, $wgLang;
1180 $nt = Title::newFromText( $wgLang->getNsText(
1181 Namespace::getImage() ) . ":{$name}" );
1182 $link = $nt->getPrefixedURL();
1183 if ( "" == $alt ) { $alt = $name; }
1185 $u = wfLocalUrlE( $link );
1186 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1187 "<img border=0 src=\"{$url}\" alt=\"{$alt}\"></a>";
1188 return $s;
1191 function makeMediaLink( $name, $url, $alt = "" )
1193 global $wgOut, $wgTitle;
1195 if ( "" == $alt ) { $alt = $name; }
1196 $u = wfEscapeHTML( $url );
1197 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1198 return $s;
1201 function specialLink( $name, $key = "" )
1203 global $wgLang;
1205 if ( "" == $key ) { $key = strtolower( $name ); }
1206 $pn = $wgLang->ucfirst( $name );
1207 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1208 wfMsg( $key ) );
1211 # Called by history lists and recent changes
1214 function beginRecentChangesList()
1216 $rc_cache = array() ;
1217 $rccc = 0 ;
1218 $this->lastdate = "";
1219 return "";
1222 function beginHistoryList()
1224 $this->lastdate = $this->lastline = "";
1225 $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
1226 return $s;
1229 function beginImageHistoryList()
1231 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1232 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1233 return $s;
1236 function endRecentChangesList()
1238 $s = $this->recentChangesBlock() ;
1239 $s .= "</ul>\n";
1240 return $s;
1243 function endHistoryList()
1245 $last = wfMsg( "last" );
1247 $s = preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
1248 $s .= "</ul>\n";
1249 return $s;
1252 function endImageHistoryList()
1254 $s = "</ul>\n";
1255 return $s;
1258 function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor )
1260 global $wgLang;
1262 $artname = Title::makeName( $ns, $ttl );
1263 $last = wfMsg( "last" );
1264 $cur = wfMsg( "cur" );
1265 $cr = wfMsg( "currentrev" );
1267 if ( $oid && $this->lastline ) {
1268 $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->makeKnownLink(
1269 $artname, $last, "diff=\\1&oldid={$oid}" ), $this->lastline );
1270 } else {
1271 $ret = "";
1273 $dt = $wgLang->timeanddate( $ts, true );
1275 if ( $oid ) { $q = "oldid={$oid}"; }
1276 else { $q = ""; }
1277 $link = $this->makeKnownLink( $artname, $dt, $q );
1279 if ( 0 == $u ) {
1280 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1281 $ut, "target=" . $ut );
1282 } else { $ul = $this->makeLink( $wgLang->getNsText(
1283 Namespace::getUser() ) . ":{$ut}", $ut ); }
1285 $s = "<li>";
1286 if ( $oid ) {
1287 $curlink = $this->makeKnownLink( $artname, $cur,
1288 "diff=0&oldid={$oid}" );
1289 } else {
1290 $curlink = $cur;
1292 $s .= "({$curlink}) (!OLDID!{$oid}!) . .";
1294 $M = wfMsg( "minoreditletter" );
1295 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1296 $s .= " {$link} . . {$ul}";
1298 if ( "" != $c && "*" != $c ) { $s .= " <em>(" . wfEscapeHTML($c) . ")</em>"; }
1299 $s .= "</li>\n";
1301 $this->lastline = $s;
1302 return $ret;
1305 function recentChangesBlockLine ( $y ) {
1306 global $wgUploadPath ;
1308 $M = wfMsg( "minoreditletter" );
1309 $N = wfMsg( "newpageletter" );
1310 $r = "" ;
1311 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;
1312 $r .= "<tt>" ;
1313 if ( $y->isnew ) $r .= $N ;
1314 else $r .= "&nbsp;" ;
1315 if ( $y->isminor ) $r .= $M ;
1316 else $r .= "&nbsp;" ;
1317 $r .= " ".$y->timestamp." " ;
1318 $r .= "</tt>" ;
1319 $link = $y->link ;
1320 if ( $y->watched ) $link = "<strong>{$link}</strong>" ;
1321 $r .= $link ;
1323 $r .= " (" ;
1324 $r .= $y->curlink ;
1325 $r .= "; " ;
1326 $r .= $this->makeKnownLink( $y->secureName, wfMsg( "hist" ), "action=history" );
1328 $r .= ") . . ".$y->userlink ;
1329 $r .= $y->usertalklink ;
1330 if ( $y->usercomment != "" )
1331 $r .= " <em>(".wfEscapeHTML($y->usercomment).")</em>" ;
1332 $r .= "<br>\n" ;
1333 return $r ;
1336 function recentChangesBlockGroup ( $y ) {
1337 global $wgUploadPath ;
1339 $r = "" ;
1340 $M = wfMsg( "minoreditletter" );
1341 $N = wfMsg( "newpageletter" );
1342 $isnew = false ;
1343 $userlinks = array () ;
1344 foreach ( $y AS $x ) {
1345 $oldid = $x->diffid ;
1346 if ( $x->isnew ) $isnew = true ;
1347 $u = $x->userlink ;
1348 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1349 $userlinks[$u]++ ;
1352 krsort ( $userlinks ) ;
1353 asort ( $userlinks ) ;
1354 $users = array () ;
1355 $u = array_keys ( $userlinks ) ;
1356 foreach ( $u as $x ) {
1357 $z = $x ;
1358 if ( $userlinks[$x] > 1 ) $z .= " ({$userlinks[$x]}&times;)" ;
1359 array_push ( $users , $z ) ;
1361 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1363 $e = $y ;
1364 $e = array_shift ( $e ) ;
1366 # Arrow
1367 $rci = "RCI{$this->rccc}" ;
1368 $rcl = "RCL{$this->rccc}" ;
1369 $rcm = "RCM{$this->rccc}" ;
1370 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1371 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1372 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1373 $tl .= "</a>" ;
1374 $r .= $tl ;
1376 # Main line
1377 $r .= "<tt>" ;
1378 if ( $isnew ) $r .= $N ;
1379 else $r .= "&nbsp;" ;
1380 $r .= "&nbsp;" ; # Minor
1381 $r .= " ".$e->timestamp." " ;
1382 $r .= "</tt>" ;
1384 $link = $e->link ;
1385 if ( $e->watched ) $link = "<strong>{$link}</strong>" ;
1386 $r .= $link ;
1388 if ( !$e->islog ) {
1389 $r .= " (".count($y)." " ;
1390 if ( $isnew ) $r .= wfMsg("changes");
1391 else $r .= $this->makeKnownLink( $e->secureName , wfMsg("changes") , "diff=0&oldid=".$oldid ) ;
1392 $r .= "; " ;
1393 $r .= $this->makeKnownLink( $e->secureName, wfMsg( "history" ), "action=history" );
1394 $r .= ")" ;
1397 $r .= $users ;
1398 $r .= "<br>\n" ;
1400 # Sub-entries
1401 $r .= "<div id='{$rci}' style='display:none'>" ;
1402 foreach ( $y AS $x )
1404 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1405 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
1406 if ( $x->isnew ) $r .= $N ;
1407 else $r .= "&nbsp;" ;
1408 if ( $x->isminor ) $r .= $M ;
1409 else $r .= "&nbsp;" ;
1410 $r .= "</tt>" ;
1412 $o = "" ;
1413 if ( $x->oldid != 0 ) $o = "oldid=".$x->oldid ;
1414 if ( $x->islog ) $link = $x->timestamp ;
1415 else $link = $this->makeKnownLink( $x->secureName, $x->timestamp , $o ) ;
1416 $link = "<tt>{$link}</tt>" ;
1419 $r .= $link ;
1420 $r .= " (" ;
1421 $r .= $x->curlink ;
1422 $r .= "; " ;
1423 $r .= $x->lastlink ;
1424 $r .= ") . . ".$x->userlink ;
1425 $r .= $x->usertalklink ;
1426 if ( $x->usercomment != "" )
1427 $r .= " <em>(".wfEscapeHTML($x->usercomment).")</em>" ;
1428 $r .= "<br>\n" ;
1430 $r .= "</div>\n" ;
1432 $this->rccc++ ;
1433 return $r ;
1436 function recentChangesBlock ()
1438 global $wgUploadPath ;
1439 if ( count ( $this->rc_cache ) == 0 ) return "" ;
1440 $k = array_keys ( $this->rc_cache ) ;
1441 foreach ( $k AS $x )
1443 $y = $this->rc_cache[$x] ;
1444 if ( count ( $y ) < 2 ) {
1445 $r .= $this->recentChangesBlockLine ( array_shift ( $y ) ) ;
1446 } else {
1447 $r .= $this->recentChangesBlockGroup ( $y ) ;
1451 return "<div align=left>{$r}</div>" ;
1454 function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1456 global $wgUser ;
1457 $usenew = $wgUser->getOption( "usenewrc" );
1458 if ( $usenew )
1459 $r = $this->recentChangesLineNew ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1460 else
1461 $r = $this->recentChangesLineOld ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1462 return $r ;
1465 function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 )
1467 global $wgTitle, $wgLang, $wgUser;
1469 $d = $wgLang->date( $ts, true);
1470 $s = "";
1471 if ( $d != $this->lastdate ) {
1472 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
1473 $s .= "<h4>{$d}</h4>\n<ul>";
1474 $this->lastdate = $d;
1476 $h = $wgLang->time( $ts, true );
1477 $t = Title::makeName( $ns, $ttl );
1478 $clink = $this->makeKnownLink( $t , "" );
1479 $nt = Title::newFromText( $t );
1481 if ( $watched ) {
1482 $clink = "<strong>{$clink}</strong>";
1484 $hlink = $this->makeKnownLink( $t, wfMsg( "hist" ), "action=history" );
1485 if ( $isnew || $nt->isLog() ) {
1486 $dlink = wfMsg( "diff" );
1487 } else {
1488 $dlink = $this->makeKnownLink( $t, wfMsg( "diff" ),
1489 "diff={$oldid}&oldid={$diffid}" ); # Finagle's law
1491 if ( 0 == $u ) {
1492 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1493 $ut, "target=" . $ut );
1494 } else { $ul = $this->makeLink( $wgLang->getNsText(
1495 Namespace::getUser() ) . ":{$ut}", $ut ); }
1497 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1498 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1499 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1500 $cr = wfMsg( "currentrev" );
1502 $s .= "<li> ({$dlink}) ({$hlink}) . .";
1503 $M = wfMsg( "minoreditletter" );
1504 $N = wfMsg( "newpageletter" );
1505 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1506 if ( $isnew ) { $s .= "<strong>{$N}</strong>"; }
1507 $s .= " {$clink}; {$h} . . {$ul}";
1509 $blink="";
1510 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1511 $blink = $this->makeKnownLink( $wgLang->specialPage(
1512 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1515 if(!$blink) {
1516 $utl = "({$utl})";
1517 } else {
1518 $utl = "({$utl} | {$blink})";
1520 $s.=" {$utl}";
1522 if ( "" != $c && "*" != $c ) {
1523 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1525 $s .= "</li>\n";
1527 return $s;
1530 function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1532 global $wgTitle, $wgLang, $wgUser;
1534 $rc = new RecentChangesClass ;
1536 $d = $wgLang->date( $ts, true);
1537 $s = "";
1538 $ret = "" ;
1539 if ( $d != $this->lastdate ) {
1540 $ret = $this->recentChangesBlock () ;
1541 $this->rc_cache = array() ;
1542 $ret .= "<h4>{$d}</h4>\n";
1543 $this->lastdate = $d;
1545 $h = $wgLang->time( $ts, true );
1546 $t = Title::makeName( $ns, $ttl );
1547 $clink = $this->makeKnownLink( $t, "" ) ;
1548 if ( $oldid == 0 ) $c2link = $clink ;
1549 else $c2link = $this->makeKnownLink( $t, "" , "oldid={$oldid}" );
1550 $nt = Title::newFromText( $t );
1552 $rc->timestamp = $h ;
1553 $rc->oldid = $oldid ;
1554 $rc->diffid = $diffid ;
1555 $rc->watched = $watched ;
1556 $rc->isnew = $isnew ;
1557 $rc->isminor = $isminor ;
1558 $rc->secureName = $t ;
1559 $rc->displayName = $nt ;
1560 $rc->link = $clink ;
1561 $rc->usercomment = $c ;
1562 $rc->islog = $nt->isLog() ;
1564 if ( ( $isnew && $oldid == 0 ) || $nt->isLog() ) {
1565 $dlink = wfMsg( "cur" );
1566 } else {
1567 $dlink = $this->makeKnownLink( $t, wfMsg( "cur" ),
1568 "diff=0&oldid={$oldid}" );
1571 if ( $diffid == 0 || $nt->isLog() ) {
1572 $plink = wfMsg( "last" );
1573 } else {
1574 $plink = $this->makeKnownLink( $t, wfMsg( "last" ),
1575 "diff={$oldid}&oldid={$diffid}" );
1578 if ( 0 == $u ) {
1579 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1580 $ut, "target=" . $ut );
1581 } else { $ul = $this->makeLink( $wgLang->getNsText(
1582 Namespace::getUser() ) . ":{$ut}", $ut ); }
1584 $rc->userlink = $ul ;
1585 $rc->lastlink = $plink ;
1586 $rc->curlink = $dlink ;
1588 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1589 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1590 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1592 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1593 $blink = $this->makeKnownLink( $wgLang->specialPage(
1594 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1595 $rc->usertalklink= " ({$utl} | {$blink})";
1596 } else {
1597 $rc->usertalklink=" ({$utl})";
1600 if ( !isset ( $this->rc_cache[$t] ) ) $this->rc_cache[$t] = array() ;
1601 array_push ( $this->rc_cache[$t] , $rc ) ;
1602 return $ret;
1606 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
1608 global $wgUser, $wgLang, $wgTitle;
1610 $dt = $wgLang->timeanddate( $ts, true );
1611 $del = wfMsg( "deleteimg" );
1612 $cur = wfMsg( "cur" );
1614 if ( $iscur ) {
1615 $url = wfImageUrl( $img );
1616 $rlink = $cur;
1617 if ( $wgUser->isSysop() ) {
1618 $link = wfLocalUrlE( "", "image=" . $wgTitle->getURL() .
1619 "&action=delete" );
1620 $style = $this->getInternalLinkAttributes( $link, $del );
1622 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
1623 } else {
1624 $dlink = $del;
1626 } else {
1627 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
1628 if( $wgUser->getID() != 0 ) {
1629 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1630 wfMsg( "revertimg" ), "action=revert&oldimage=" .
1631 urlencode( $img ) );
1632 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1633 $del, "action=delete&oldimage=" . urlencode( $img ) );
1634 } else {
1635 # Having live active links for non-logged in users
1636 # means that bots and spiders crawling our site can
1637 # inadvertently change content. Baaaad idea.
1638 $rlink = wfMsg( "revertimg" );
1639 $dlink = $del;
1642 if ( 0 == $u ) { $ul = $ut; }
1643 else { $ul = $this->makeLink( $wgLang->getNsText(
1644 Namespace::getUser() ) . ":{$ut}", $ut ); }
1646 $nb = str_replace( "$1", $size, wfMsg( "nbytes" ) );
1647 $style = $this->getInternalLinkAttributes( $url, $dt );
1649 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
1650 . " . . {$ul} ({$nb})";
1652 if ( "" != $c && "*" != $c ) {
1653 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1655 $s .= "</li>\n";
1656 return $s;
1660 include_once( "SkinStandard.php" );
1661 include_once( "SkinNostalgia.php" );
1662 include_once( "SkinCologneBlue.php" );