update he, hu urls
[mediawiki.git] / includes / Skin.php
blob7f68821632665ddbd5f97024ad0c6b99e56e8894
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;
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 if ( 0 == $qb ) {
209 $s .= "<td class='top' align=left valign=top rowspan='{$rows}'>" .
210 $this->logoText() . "</td>";
211 } else if ( 1 == $qb || 3 == $qb ) { # Left
212 $s .= $this->getQuickbarCompensator( $rows );
214 $s .= "<td {$borderhack} align=left valign=top>";
216 $s .= $this->topLinks() ;
217 $s .= "<p class='subtitle'>" . $this->pageTitleLinks();
219 $s .= "</td>\n<td {$borderhack} valign=top align=right nowrap>";
220 $s .= $this->nameAndLogin();
221 $s .= "\n<br>" . $this->searchForm() . "</td>";
223 if ( $langlinks ) {
224 $s .= "</tr>\n<tr><td class='top' colspan=\"2\">$langlinks</td>";
227 if ( 2 == $qb ) { # Right
228 $s .= $this->getQuickbarCompensator( $rows );
230 $s .= "</tr></table>\n</div>\n";
231 $s .= "\n<div id='article'>";
233 $s .= $this->pageTitle();
234 $s .= $this->pageSubtitle() . "\n<p>";
235 wfProfileOut();
236 return $s;
239 function getQuickbarCompensator( $rows = 1 )
241 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
244 # This gets called immediately before the </body> tag.
246 function afterContent()
248 global $wgUser, $wgOut, $wgServer, $HTTP_SERVER_VARS;
250 if ( $wgOut->isPrintable() ) {
251 $s = "\n</div>\n";
253 $u = $wgServer . $HTTP_SERVER_VARS['REQUEST_URI'];
254 $u = preg_replace( "/[?&]printable=yes/", "", $u );
255 $rf = str_replace( "$1", $u, wfMsg( "retrievedfrom" ) );
257 if ( $wgOut->isArticle() ) {
258 $lm = "<br>" . $this->lastModified();
259 } else { $lm = ""; }
261 $s .= "<p><em>{$rf}{$lm}</em>\n";
262 return $s;
264 return $this->doAfterContent();
267 function doAfterContent()
269 global $wgUser, $wgOut;
270 wfProfileIn( "Skin::doAfterContent" );
272 $s = "\n</div><br clear=all>\n";
274 $s .= "\n<div id='footer'>";
275 $s .= "<table width='98%' border=0 cellspacing=0><tr>";
277 $qb = $this->qbSetting();
278 if ( 1 == $qb || 3 == $qb ) { # Left
279 $s .= $this->getQuickbarCompensator();
281 $s .= "<td class='bottom' align=left valign=top>";
283 $s .= $this->bottomLinks();
284 $s .= "\n<br>" . $this->mainPageLink()
285 . " | " . $this->aboutLink()
286 . " | " . $this->specialLink( "recentchanges" )
287 . " | " . $this->searchForm()
288 . "<br>" . $this->pageStats();
290 $s .= "</td>";
291 if ( 2 == $qb ) { # Right
292 $s .= $this->getQuickbarCompensator();
294 $s .= "</tr></table>\n</div>\n</div>\n";
296 if ( 0 != $qb ) { $s .= $this->quickBar(); }
297 wfProfileOut();
298 return $s;
301 function pageTitleLinks()
303 global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang;
305 $s = $this->printableLink();
307 if ( $wgOut->isArticle() ) {
308 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
309 $name = $wgTitle->getDBkey();
310 $link = wfEscapeHTML( wfImageUrl( $name ) );
311 $style = $this->getInternalLinkAttributes( $link, $name );
312 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
315 if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
316 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
317 wfMsg( "currentrev" ) );
320 if ( $wgUser->getNewtalk() ) {
321 # do not show "You have new messages" text when we are viewing our
322 # own talk page
324 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
325 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
326 $n =$wgUser->getName();
327 $tl = $this->makeKnownLink( $wgLang->getNsText(
328 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
329 wfMsg("newmessageslink") );
330 $s.=" | <strong>". str_replace( "$1", $tl, wfMsg("newmessages") ) . "</strong>";
333 return $s;
336 function printableLink()
338 global $wgOut, $wgTitle, $oldid, $action;
340 if ( "history" == $action ) { $q = "action=history&"; }
341 else { $q = ""; }
343 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
344 WfMsg( "printableversion" ), "{$q}printable=yes" );
345 return $s;
348 function pageTitle()
350 global $wgOut, $wgTitle;
352 $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
353 return $s;
356 function pageSubtitle()
358 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
360 $sub = $wgOut->getSubtitle();
361 if ( "" == $sub ) { $sub = wfMsg( "fromwikipedia" ); }
362 if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
363 $ptext=$wgTitle->getPrefixedText();
364 if(preg_match("/\//",$ptext)) {
365 $sub.="</p><p class='subpages'>";
366 $links=explode("/",$ptext);
367 $c=0;
368 $growinglink="";
369 foreach($links as $link) {
370 $c++;
371 if ($c<count($links)) {
372 $growinglink.=$link;
373 $getlink=$this->makeLink($growinglink,$link);
374 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
375 if ($c>1) {
376 $sub .= " | ";
377 } else {
378 $sub .="&lt; ";
380 $sub .= $getlink;
381 $growinglink.="/";
387 $s = "<p class='subtitle'>{$sub}\n";
388 return $s;
391 function nameAndLogin()
393 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader;
395 $li = $wgLang->specialPage( "Userlogin" );
396 $lo = $wgLang->specialPage( "Userlogout" );
398 $s = "";
399 if ( 0 == $wgUser->getID() ) {
400 if( $wgShowIPinHeader ) {
401 $n = getenv( "REMOTE_ADDR" );
403 $tl = $this->makeKnownLink( $wgLang->getNsText(
404 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
405 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
407 $s .= $n . " (".$tl.")";
408 } else {
409 $s .= wfMsg("notloggedin");
412 $rt = $wgTitle->getPrefixedURL();
413 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
414 $q = "";
415 } else { $q = "returnto={$rt}"; }
417 $s .= "\n<br>" . $this->makeKnownLink( $li,
418 wfMsg( "login" ), $q );
419 } else {
420 $n = $wgUser->getName();
421 $rt = $wgTitle->getPrefixedURL();
422 $tl = $this->makeKnownLink( $wgLang->getNsText(
423 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
424 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
426 $tl = " ({$tl})";
428 $s .= $this->makeKnownLink( $wgLang->getNsText(
429 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
430 $this->makeKnownLink( $lo, wfMsg( "logout" ),
431 "returnto={$rt}" ) . " | " .
432 $this->specialLink( "preferences" );
434 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
435 wfMsg( "help" ) );
437 return $s;
440 function searchForm()
442 global $search;
444 $s = "<form name='search' class='inline' method=get action=\""
445 . wfLocalUrl( "" ) . "\">"
446 . "<input type=text name=\"search\" size=19 value=\""
447 . htmlspecialchars(substr($search,0,256)) . "\">\n"
448 . "<input type=submit name=\"go\" value=\"" . wfMsg ("go") . "\">&nbsp;"
449 . "<input type=submit value=\"" . wfMsg ("search") . "\"></form>";
451 return $s;
454 function topLinks()
456 global $wgOut;
457 $sep = " |\n";
459 $s = $this->mainPageLink() . $sep
460 . $this->specialLink( "recentchanges" );
462 if ( $wgOut->isArticle() ) {
463 $s .= $sep . $this->editThisPage()
464 . $sep . $this->historyLink();
466 $s .= $sep . $this->specialPagesList();
468 return $s;
471 function bottomLinks()
473 global $wgOut, $wgUser, $wgTitle;
474 $sep = " |\n";
476 $s = "";
477 if ( $wgOut->isArticle() ) {
478 $s .= "<strong>" . $this->editThisPage() . "</strong>";
479 if ( 0 != $wgUser->getID() ) {
480 $s .= $sep . $this->watchThisPage();
482 $s .= $sep . $this->talkLink()
483 . $sep . $this->historyLink()
484 . $sep . $this->whatLinksHere()
485 . $sep . $this->watchPageLinksLink();
487 if ( $wgTitle->getNamespace() == Namespace::getUser()
488 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
491 $id=User::idFromName($wgTitle->getText());
492 $ip=User::isIP($wgTitle->getText());
494 if($id || $ip) { # both anons and non-anons have contri list
495 $s .= $sep . $this->userContribsLink();
497 if ( 0 != $wgUser->getID() ) { # show only to signed in users
498 if($id) { # can only email non-anons
499 $s .= $sep . $this->emailUserLink();
503 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
504 $s .= "\n<br>" . $this->deleteThisPage() .
505 $sep . $this->protectThisPage() .
506 $sep . $this->moveThisPage();
508 $s .= "<br>\n" . $this->otherLanguages();
510 return $s;
513 function pageStats()
515 global $wgOut, $wgLang, $wgArticle;
516 global $oldid, $diff, $wgDisableCounters;
518 if ( ! $wgOut->isArticle() ) { return ""; }
519 if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
520 if ( 0 == $wgArticle->getID() ) { return ""; }
522 if ( $wgDisableCounters ) {
523 $s = "";
524 } else {
525 $count = $wgArticle->getCount();
526 $s = str_replace( "$1", $count, wfMsg( "viewcount" ) );
528 $s .= $this->lastModified();
529 $s .= " " . wfMsg( "gnunote" );
530 return "<span id='pagestats'>{$s}</span>";
533 function lastModified()
535 global $wgLang, $wgArticle;
537 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
538 $s = " " . str_replace( "$1", $d, wfMsg( "lastmodified" ) );
539 return $s;
542 function logoText( $align = "" )
544 if ( "" != $align ) { $a = " align='{$align}'"; }
545 else { $a = ""; }
547 $mp = wfMsg( "mainpage" );
548 $s = "<a href=\"" . wfLocalUrlE( $mp ) . "\"><img{$a} border=0 src=\""
549 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
550 return $s;
553 function quickBar()
555 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
556 global $wpPreview;
557 wfProfileIn( "Skin::quickBar" );
559 $s = "\n<div id='quickbar'>";
560 $s .= "\n" . $this->logoText() . "\n<hr>";
562 $sep = "\n<br>";
563 $s .= $this->mainPageLink()
564 . $sep . $this->specialLink( "recentchanges" )
565 . $sep . $this->specialLink( "randompage" );
566 if ($wgUser->getID()) {
567 $s.= $sep . $this->specialLink( "watchlist" ) ;
568 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
569 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
572 // only show watchlist link if logged in
573 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
574 $s .= "\n<hr>";
575 $articleExists = $wgTitle->getArticleId();
576 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
578 if($wgOut->isArticle()) {
579 $s .= "<strong>" . $this->editThisPage() . "</strong>";
580 } else { # backlink to the article in edit or history mode
582 if($articleExists){ # no backlink if no article
583 $tns=$wgTitle->getNamespace();
584 switch($tns) {
585 case 0:
586 $text = wfMsg("articlepage");
587 break;
588 case 1:
589 $text = wfMsg("viewtalkpage");
590 break;
591 case 2:
592 $text = wfMsg("userpage");
593 break;
594 case 3:
595 $text = wfMsg("viewtalkpage");
596 break;
597 case 4:
598 $text = wfMsg("wikipediapage");
599 break;
600 case 5:
601 $text = wfMsg("viewtalkpage");
602 break;
603 case 6:
604 $text = wfMsg("imagepage");
605 break;
606 case 7:
607 $text = wfMsg("viewtalkpage");
608 break;
609 default:
610 $text= wfMsg("articlepage");
613 $link = $wgTitle->getText();
614 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
615 $link = $nstext . ":" . $link ;
617 $s .= $this->makeLink($link, $text );
618 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
619 # we just throw in a "New page" text to tell the user that he's in edit mode,
620 # and to avoid messing with the separator that is prepended to the next item
621 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
627 watching could cause problems in edit mode:
628 if user edits article, then loads "watch this article" in background and then saves
629 article with "Watch this article" checkbox disabled, the article is transparently
630 unwatched. Therefore we do not show the "Watch this page" link in edit mode
632 if ( 0 != $wgUser->getID() && $articleExists) {
633 if($action!="edit" && $action!="history" &&
634 $action != "submit" )
635 {$s .= $sep . $this->watchThisPage(); }
636 if ( $wgTitle->userCanEdit() ) $s .= $sep . $this->moveThisPage();
638 if ( $wgUser->isSysop() and $articleExists ) {
639 $s .= $sep . $this->deleteThisPage() .
640 $sep . $this->protectThisPage();
642 $s .= $sep . $this->talkLink();
643 if ($articleExists && $action !="history") { $s .= $sep . $this->historyLink();}
644 $s.=$sep . $this->whatLinksHere();
646 if($wgOut->isArticle()) {
647 $s .= $sep . $this->watchPageLinksLink();
650 if ( Namespace::getUser() == $wgTitle->getNamespace()
651 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
654 $id=User::idFromName($wgTitle->getText());
655 $ip=User::isIP($wgTitle->getText());
657 if($id||$ip) {
658 $s .= $sep . $this->userContribsLink();
660 if ( 0 != $wgUser->getID() ) {
661 if($id) { # can only email real users
662 $s .= $sep . $this->emailUserLink();
666 $s .= "\n<hr>";
669 if ( 0 != $wgUser->getID() ) {
670 $s .= $this->specialLink( "upload" ) . $sep;
672 $s .= $this->specialLink( "specialpages" )
673 . $sep . $this->bugReportsLink();
675 $s .= "\n</div>\n";
676 wfProfileOut();
677 return $s;
680 function specialPagesList()
682 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
683 $a = array();
685 $validSP = $wgLang->getValidSpecialPages();
687 foreach ( $validSP as $name => $desc ) {
688 if ( "" == $desc ) { continue; }
689 $a[$name] = $desc;
691 if ( $wgUser->isSysop() )
693 $sysopSP = $wgLang->getSysopSpecialPages();
695 foreach ( $sysopSP as $name => $desc ) {
696 if ( "" == $desc ) { continue; }
697 $a[$name] = $desc ;
700 if ( $wgUser->isDeveloper() )
702 $devSP = $wgLang->getDeveloperSpecialPages();
704 foreach ( $devSP as $name => $desc ) {
705 if ( "" == $desc ) { continue; }
706 $a[$name] = $desc ;
709 $go = wfMsg( "go" );
710 $sp = wfMsg( "specialpages" );
711 $spp = $wgLang->specialPage( "Specialpages" );
713 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
714 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
715 $s .= "<select name=\"wpDropdown\">\n";
716 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
718 foreach ( $a as $name => $desc ) {
719 $p = $wgLang->specialPage( $name );
720 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
722 $s .= "</select>\n";
723 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
724 $s .= "</form>\n";
725 return $s;
728 function mainPageLink()
730 $mp = wfMsg( "mainpage" );
731 $s = $this->makeKnownLink( $mp, $mp );
732 return $s;
735 function copyrightLink()
737 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
738 wfMsg( "copyrightpagename" ) );
739 return $s;
742 function aboutLink()
744 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
745 wfMsg( "aboutwikipedia" ) );
746 return $s;
749 function editThisPage()
751 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
753 if ( ! $wgOut->isArticle() || $diff ) {
754 $s = wfMsg( "protectedpage" );
755 } else if ( $wgTitle->userCanEdit() ) {
756 $n = $wgTitle->getPrefixedText();
757 $t = wfMsg( "editthispage" );
758 $oid = $red = "";
760 if ( $redirect ) { $red = "&redirect={$redirect}"; }
761 if ( $oldid && ! isset( $diff ) ) {
762 $oid = "&oldid={$oldid}";
764 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
765 } else {
766 $s = wfMsg( "protectedpage" );
768 return $s;
771 function deleteThisPage()
773 global $wgUser, $wgOut, $wgTitle, $diff;
775 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
776 $n = $wgTitle->getPrefixedText();
777 $t = wfMsg( "deletethispage" );
779 $s = $this->makeKnownLink( $n, $t, "action=delete" );
780 } else {
781 $s = wfMsg( "error" );
783 return $s;
786 function protectThisPage()
788 global $wgUser, $wgOut, $wgTitle, $diff;
790 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
791 $n = $wgTitle->getPrefixedText();
793 if ( $wgTitle->isProtected() ) {
794 $t = wfMsg( "unprotectthispage" );
795 $q = "action=unprotect";
796 } else {
797 $t = wfMsg( "protectthispage" );
798 $q = "action=protect";
800 $s = $this->makeKnownLink( $n, $t, $q );
801 } else {
802 $s = wfMsg( "error" );
804 return $s;
807 function watchThisPage()
809 global $wgUser, $wgOut, $wgTitle, $diff;
811 if ( $wgOut->isArticle() && ( ! $diff ) ) {
812 $n = $wgTitle->getPrefixedText();
814 if ( $wgTitle->userIsWatching() ) {
815 $t = wfMsg( "unwatchthispage" );
816 $q = "action=unwatch";
817 } else {
818 $t = wfMsg( "watchthispage" );
819 $q = "action=watch";
821 $s = $this->makeKnownLink( $n, $t, $q );
822 } else {
823 $s = wfMsg( "notanarticle" );
825 return $s;
828 function moveThisPage()
830 global $wgTitle, $wgLang;
832 if ( $wgTitle->userCanEdit() ) {
833 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
834 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
835 } // no message if page is protected - would be redundant
836 return $s;
839 function historyLink()
841 global $wgTitle;
843 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
844 wfMsg( "history" ), "action=history" );
845 return $s;
848 function whatLinksHere()
850 global $wgTitle, $wgLang;
852 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
853 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
854 return $s;
857 function userContribsLink()
859 global $wgTitle, $wgLang;
861 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
862 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
863 return $s;
866 function emailUserLink()
868 global $wgTitle, $wgLang;
870 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
871 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
872 return $s;
875 function watchPageLinksLink()
877 global $wgOut, $wgTitle, $wgLang;
879 if ( ! $wgOut->isArticle() ) {
880 $s = "(" . wfMsg( "notanarticle" ) . ")";
881 } else {
882 $s = $this->makeKnownLink( $wgLang->specialPage(
883 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
884 "target=" . $wgTitle->getPrefixedURL() );
886 return $s;
889 function otherLanguages()
891 global $wgOut, $wgLang, $wgTitle , $wgUseNewInterlanguage ;
893 $a = $wgOut->getLanguageLinks();
894 if ( 0 == count( $a ) ) {
895 if ( !$wgUseNewInterlanguage ) return "";
896 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
897 if ( $ns != 0 AND $ns != 1 ) return "" ;
898 $pn = "Intl" ;
899 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
900 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
901 wfMsg( "intl" ) , $x );
904 if ( !$wgUseNewInterlanguage ) {
905 $s = wfMsg( "otherlanguages" ) . ": ";
906 } else {
907 global $wgLanguageCode ;
908 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
909 $x .= "&xl=".$wgLanguageCode ;
910 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
911 wfMsg( "otherlanguages" ) , $x ) . ": " ;
914 $first = true;
915 foreach( $a as $l ) {
916 if ( ! $first ) { $s .= " | "; }
917 $first = false;
919 $nt = Title::newFromText( $l );
920 $url = $nt->getFullURL();
921 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
923 if ( "" == $text ) { $text = $l; }
924 $style = $this->getExternalLinkAttributes( $l, $text );
925 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
927 return $s;
930 function bugReportsLink()
932 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
933 wfMsg( "bugreports" ) );
934 return $s;
937 function dateLink()
939 global $wgLinkCache;
940 $t1 = Title::newFromText( gmdate( "F j" ) );
941 $t2 = Title::newFromText( gmdate( "Y" ) );
943 $wgLinkCache->suspend();
944 $id = $t1->getArticleID();
945 $wgLinkCache->resume();
947 if ( 0 == $id ) {
948 $s = $this->makeBrokenLink( $t1->getText() );
949 } else {
950 $s = $this->makeKnownLink( $t1->getText() );
952 $s .= ", ";
954 $wgLinkCache->suspend();
955 $id = $t2->getArticleID();
956 $wgLinkCache->resume();
958 if ( 0 == $id ) {
959 $s .= $this->makeBrokenLink( $t2->getText() );
960 } else {
961 $s .= $this->makeKnownLink( $t2->getText() );
963 return $s;
966 function talkLink()
968 global $wgLang, $wgTitle, $wgLinkCache;
970 $tns = $wgTitle->getNamespace();
971 if ( -1 == $tns ) { return ""; }
973 $pn = $wgTitle->getText();
974 $tp = wfMsg( "talkpage" );
975 if ( Namespace::isTalk( $tns ) ) {
976 $lns = Namespace::getSubject( $tns );
977 switch($tns) {
978 case 1:
979 $text = wfMsg("articlepage");
980 break;
981 case 3:
982 $text = wfMsg("userpage");
983 break;
984 case 5:
985 $text = wfMsg("wikipediapage");
986 break;
987 case 7:
988 $text = wfMsg("imagepage");
989 break;
990 default:
991 $text= wfMsg("articlepage");
993 } else {
995 $lns = Namespace::getTalk( $tns );
996 $text=$tp;
998 $n = $wgLang->getNsText( $lns );
999 if ( "" == $n ) { $link = $pn; }
1000 else { $link = "{$n}:{$pn}"; }
1002 $wgLinkCache->suspend();
1003 $s = $this->makeLink( $link, $text );
1004 $wgLinkCache->resume();
1006 return $s;
1009 # After all the page content is transformed into HTML, it makes
1010 # a final pass through here for things like table backgrounds.
1012 function transformContent( $text )
1014 return $text;
1017 # Note: This function MUST call getArticleID() on the link,
1018 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1020 function makeLink( $title, $text= "", $query = "", $trail = "" )
1022 global $wgOut, $wgUser;
1024 $nt = Title::newFromText( $title );
1026 if ( $nt->isExternal() ) {
1027 $u = $nt->getFullURL();
1028 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1029 $style = $this->getExternalLinkAttributes( $link, $text );
1031 $inside = "";
1032 if ( "" != $trail ) {
1033 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1034 $inside = $m[1];
1035 $trail = $m[2];
1038 return "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1040 if ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1041 return $this->makeKnownLink( $title, $text, $query, $trail );
1043 if ( ( -1 == $nt->getNamespace() ) ||
1044 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1045 return $this->makeKnownLink( $title, $text, $query, $trail );
1047 $aid = $nt->getArticleID() ;
1048 if ( 0 == $aid ) {
1049 return $this->makeBrokenLink( $title, $text, $query, $trail );
1050 } else {
1051 $threshold = $wgUser->getOption("stubthreshold") ;
1052 if ( $threshold > 0 ) {
1053 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'" ) ;
1055 if ( wfNumRows( $res ) > 0 ) {
1056 $s = wfFetchObject( $res );
1057 $size = $s->x;
1058 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
1059 $size = $threshold*2 ; # Really big
1060 wfFreeResult( $res );
1061 } else $size = $threshold*2 ; # Really big
1062 } else $size = 1 ;
1064 if ( $size < $threshold )
1065 return $this->makeStubLink( $title, $text, $query, $trail );
1066 return $this->makeKnownLink( $title, $text, $query, $trail );
1070 function makeKnownLink( $title, $text = "", $query = "", $trail = "" )
1072 global $wgOut, $wgTitle;
1074 $nt = Title::newFromText( $title );
1075 $link = $nt->getPrefixedURL();
1077 if ( "" == $link ) {
1078 $u = "";
1079 if ( "" == $text ) { $text = $nt->getFragment(); }
1080 } else {
1081 $u = wfLocalUrlE( $link, $query );
1083 if ( "" != $nt->getFragment() ) {
1084 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1086 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1087 $style = $this->getInternalLinkAttributes( $link, $text );
1089 $inside = "";
1090 if ( "" != $trail ) {
1091 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1092 $inside = $m[1];
1093 $trail = $m[2];
1096 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1097 return $r;
1100 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" )
1102 global $wgOut, $wgUser;
1104 $nt = Title::newFromText( $title );
1105 $link = $nt->getPrefixedURL();
1107 if ( "" == $query ) { $q = "action=edit"; }
1108 else { $q = "action=edit&{$query}"; }
1109 $u = wfLocalUrlE( $link, $q );
1111 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1112 $style = $this->getInternalLinkAttributes( $link, $text, "yes" );
1114 $inside = "";
1115 if ( "" != $trail ) {
1116 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1117 $inside = $m[1];
1118 $trail = $m[2];
1121 if ( $wgOut->isPrintable() ||
1122 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1123 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1124 } else {
1125 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1127 return $s;
1130 function makeStubLink( $title, $text = "", $query = "", $trail = "" )
1132 global $wgOut, $wgUser;
1134 $nt = Title::newFromText( $title );
1135 $link = $nt->getPrefixedURL();
1137 $u = wfLocalUrlE( $link, $query );
1139 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1140 $style = $this->getInternalLinkAttributes( $link, $text, "stub" );
1142 $inside = "";
1143 if ( "" != $trail ) {
1144 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1145 $inside = $m[1];
1146 $trail = $m[2];
1149 if ( $wgOut->isPrintable() ||
1150 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1151 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1152 } else {
1153 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1155 return $s;
1158 function fnamePart( $url )
1160 $basename = strrchr( $url, "/" );
1161 if ( false === $basename ) { $basename = $url; }
1162 else { $basename = substr( $basename, 1 ); }
1163 return wfEscapeHTML( $basename );
1166 function makeImage( $url, $alt = "" )
1168 global $wgOut;
1170 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1171 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1172 return $s;
1175 function makeImageLink( $name, $url, $alt = "" )
1177 global $wgOut, $wgTitle, $wgLang;
1179 $nt = Title::newFromText( $wgLang->getNsText(
1180 Namespace::getImage() ) . ":{$name}" );
1181 $link = $nt->getPrefixedURL();
1182 if ( "" == $alt ) { $alt = $name; }
1184 $u = wfLocalUrlE( $link );
1185 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1186 "<img border=0 src=\"{$url}\" alt=\"{$alt}\"></a>";
1187 return $s;
1190 function makeMediaLink( $name, $url, $alt = "" )
1192 global $wgOut, $wgTitle;
1194 if ( "" == $alt ) { $alt = $name; }
1195 $u = wfEscapeHTML( $url );
1196 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1197 return $s;
1200 function specialLink( $name, $key = "" )
1202 global $wgLang;
1204 if ( "" == $key ) { $key = strtolower( $name ); }
1205 $pn = $wgLang->ucfirst( $name );
1206 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1207 wfMsg( $key ) );
1210 # Called by history lists and recent changes
1213 function beginRecentChangesList()
1215 $rc_cache = array() ;
1216 $rccc = 0 ;
1217 $this->lastdate = "";
1218 return "";
1221 function beginHistoryList()
1223 $this->lastdate = $this->lastline = "";
1224 $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
1225 return $s;
1228 function beginImageHistoryList()
1230 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1231 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1232 return $s;
1235 function endRecentChangesList()
1237 $s = $this->recentChangesBlock() ;
1238 $s .= "</ul>\n";
1239 return $s;
1242 function endHistoryList()
1244 $last = wfMsg( "last" );
1246 $s = preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
1247 $s .= "</ul>\n";
1248 return $s;
1251 function endImageHistoryList()
1253 $s = "</ul>\n";
1254 return $s;
1257 function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor )
1259 global $wgLang;
1261 $artname = Title::makeName( $ns, $ttl );
1262 $last = wfMsg( "last" );
1263 $cur = wfMsg( "cur" );
1264 $cr = wfMsg( "currentrev" );
1266 if ( $oid && $this->lastline ) {
1267 $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->makeKnownLink(
1268 $artname, $last, "diff=\\1&oldid={$oid}" ), $this->lastline );
1269 } else {
1270 $ret = "";
1272 $dt = $wgLang->timeanddate( $ts, true );
1274 if ( $oid ) { $q = "oldid={$oid}"; }
1275 else { $q = ""; }
1276 $link = $this->makeKnownLink( $artname, $dt, $q );
1278 if ( 0 == $u ) {
1279 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1280 $ut, "target=" . $ut );
1281 } else { $ul = $this->makeLink( $wgLang->getNsText(
1282 Namespace::getUser() ) . ":{$ut}", $ut ); }
1284 $s = "<li>";
1285 if ( $oid ) {
1286 $curlink = $this->makeKnownLink( $artname, $cur,
1287 "diff=0&oldid={$oid}" );
1288 } else {
1289 $curlink = $cur;
1291 $s .= "({$curlink}) (!OLDID!{$oid}!) . .";
1293 $M = wfMsg( "minoreditletter" );
1294 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1295 $s .= " {$link} . . {$ul}";
1297 if ( "" != $c && "*" != $c ) { $s .= " <em>(" . wfEscapeHTML($c) . ")</em>"; }
1298 $s .= "</li>\n";
1300 $this->lastline = $s;
1301 return $ret;
1304 function recentChangesBlockLine ( $y ) {
1305 global $wgUploadPath ;
1307 $M = wfMsg( "minoreditletter" );
1308 $N = wfMsg( "newpageletter" );
1309 $r = "" ;
1310 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;
1311 $r .= "<tt>" ;
1312 if ( $y->isnew ) $r .= $N ;
1313 else $r .= "&nbsp;" ;
1314 if ( $y->isminor ) $r .= $M ;
1315 else $r .= "&nbsp;" ;
1316 $r .= " ".$y->timestamp." " ;
1317 $r .= "</tt>" ;
1318 $link = $y->link ;
1319 if ( $y->watched ) $link = "<strong>{$link}</strong>" ;
1320 $r .= $link ;
1322 $r .= " (" ;
1323 $r .= $y->curlink ;
1324 $r .= "; " ;
1325 $r .= $this->makeKnownLink( $y->secureName, wfMsg( "hist" ), "action=history" );
1327 $r .= ") . . ".$y->userlink ;
1328 $r .= $y->usertalklink ;
1329 if ( $y->usercomment != "" )
1330 $r .= " <em>(".wfEscapeHTML($y->usercomment).")</em>" ;
1331 $r .= "<br>\n" ;
1332 return $r ;
1335 function recentChangesBlockGroup ( $y ) {
1336 global $wgUploadPath ;
1338 $r = "" ;
1339 $M = wfMsg( "minoreditletter" );
1340 $N = wfMsg( "newpageletter" );
1341 $isnew = false ;
1342 $userlinks = array () ;
1343 foreach ( $y AS $x ) {
1344 $oldid = $x->diffid ;
1345 if ( $x->isnew ) $isnew = true ;
1346 $u = $x->userlink ;
1347 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1348 $userlinks[$u]++ ;
1351 krsort ( $userlinks ) ;
1352 asort ( $userlinks ) ;
1353 $users = array () ;
1354 $u = array_keys ( $userlinks ) ;
1355 foreach ( $u as $x ) {
1356 $z = $x ;
1357 if ( $userlinks[$x] > 1 ) $z .= " ({$userlinks[$x]}&times;)" ;
1358 array_push ( $users , $z ) ;
1360 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1362 $e = $y ;
1363 $e = array_shift ( $e ) ;
1365 # Arrow
1366 $rci = "RCI{$this->rccc}" ;
1367 $rcl = "RCL{$this->rccc}" ;
1368 $rcm = "RCM{$this->rccc}" ;
1369 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1370 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1371 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1372 $tl .= "</a>" ;
1373 $r .= $tl ;
1375 # Main line
1376 $r .= "<tt>" ;
1377 if ( $isnew ) $r .= $N ;
1378 else $r .= "&nbsp;" ;
1379 $r .= "&nbsp;" ; # Minor
1380 $r .= " ".$e->timestamp." " ;
1381 $r .= "</tt>" ;
1383 $link = $e->link ;
1384 if ( $e->watched ) $link = "<strong>{$link}</strong>" ;
1385 $r .= $link ;
1387 if ( !$e->islog ) {
1388 $r .= " (".count($y)." " ;
1389 if ( $isnew ) $r .= wfMsg("changes");
1390 else $r .= $this->makeKnownLink( $e->secureName , wfMsg("changes") , "diff=0&oldid=".$oldid ) ;
1391 $r .= "; " ;
1392 $r .= $this->makeKnownLink( $e->secureName, wfMsg( "history" ), "action=history" );
1393 $r .= ")" ;
1396 $r .= $users ;
1397 $r .= "<br>\n" ;
1399 # Sub-entries
1400 $r .= "<div id='{$rci}' style='display:none'>" ;
1401 foreach ( $y AS $x )
1403 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1404 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
1405 if ( $x->isnew ) $r .= $N ;
1406 else $r .= "&nbsp;" ;
1407 if ( $x->isminor ) $r .= $M ;
1408 else $r .= "&nbsp;" ;
1409 $r .= "</tt>" ;
1411 $o = "" ;
1412 if ( $x->oldid != 0 ) $o = "oldid=".$x->oldid ;
1413 if ( $x->islog ) $link = $x->timestamp ;
1414 else $link = $this->makeKnownLink( $x->secureName, $x->timestamp , $o ) ;
1415 $link = "<tt>{$link}</tt>" ;
1418 $r .= $link ;
1419 $r .= " (" ;
1420 $r .= $x->curlink ;
1421 $r .= "; " ;
1422 $r .= $x->lastlink ;
1423 $r .= ") . . ".$x->userlink ;
1424 $r .= $x->usertalklink ;
1425 if ( $x->usercomment != "" )
1426 $r .= " <em>(".wfEscapeHTML($x->usercomment).")</em>" ;
1427 $r .= "<br>\n" ;
1429 $r .= "</div>\n" ;
1431 $this->rccc++ ;
1432 return $r ;
1435 function recentChangesBlock ()
1437 global $wgUploadPath ;
1438 if ( count ( $this->rc_cache ) == 0 ) return "" ;
1439 $k = array_keys ( $this->rc_cache ) ;
1440 foreach ( $k AS $x )
1442 $y = $this->rc_cache[$x] ;
1443 if ( count ( $y ) < 2 ) {
1444 $r .= $this->recentChangesBlockLine ( array_shift ( $y ) ) ;
1445 } else {
1446 $r .= $this->recentChangesBlockGroup ( $y ) ;
1450 return "<div align=left>{$r}</div>" ;
1453 function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1455 global $wgUser ;
1456 $usenew = $wgUser->getOption( "usenewrc" );
1457 if ( $usenew )
1458 $r = $this->recentChangesLineNew ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1459 else
1460 $r = $this->recentChangesLineOld ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1461 return $r ;
1464 function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 )
1466 global $wgTitle, $wgLang, $wgUser;
1468 $d = $wgLang->date( $ts, true);
1469 $s = "";
1470 if ( $d != $this->lastdate ) {
1471 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
1472 $s .= "<h4>{$d}</h4>\n<ul>";
1473 $this->lastdate = $d;
1475 $h = $wgLang->time( $ts, true );
1476 $t = Title::makeName( $ns, $ttl );
1477 $clink = $this->makeKnownLink( $t , "" );
1478 $nt = Title::newFromText( $t );
1480 if ( $watched ) {
1481 $clink = "<strong>{$clink}</strong>";
1483 $hlink = $this->makeKnownLink( $t, wfMsg( "hist" ), "action=history" );
1484 if ( $isnew || $nt->isLog() ) {
1485 $dlink = wfMsg( "diff" );
1486 } else {
1487 $dlink = $this->makeKnownLink( $t, wfMsg( "diff" ),
1488 "diff={$oldid}&oldid={$diffid}" ); # Finagle's law
1490 if ( 0 == $u ) {
1491 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1492 $ut, "target=" . $ut );
1493 } else { $ul = $this->makeLink( $wgLang->getNsText(
1494 Namespace::getUser() ) . ":{$ut}", $ut ); }
1496 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1497 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1498 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1499 $cr = wfMsg( "currentrev" );
1501 $s .= "<li> ({$dlink}) ({$hlink}) . .";
1502 $M = wfMsg( "minoreditletter" );
1503 $N = wfMsg( "newpageletter" );
1504 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1505 if ( $isnew ) { $s .= "<strong>{$N}</strong>"; }
1506 $s .= " {$clink}; {$h} . . {$ul}";
1508 $blink="";
1509 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1510 $blink = $this->makeKnownLink( $wgLang->specialPage(
1511 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1514 if(!$blink) {
1515 $utl = "({$utl})";
1516 } else {
1517 $utl = "({$utl} | {$blink})";
1519 $s.=" {$utl}";
1521 if ( "" != $c && "*" != $c ) {
1522 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1524 $s .= "</li>\n";
1526 return $s;
1529 function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1531 global $wgTitle, $wgLang, $wgUser;
1533 $rc = new RecentChangesClass ;
1535 $d = $wgLang->date( $ts, true);
1536 $s = "";
1537 $ret = "" ;
1538 if ( $d != $this->lastdate ) {
1539 $ret = $this->recentChangesBlock () ;
1540 $this->rc_cache = array() ;
1541 $ret .= "<h4>{$d}</h4>\n";
1542 $this->lastdate = $d;
1544 $h = $wgLang->time( $ts, true );
1545 $t = Title::makeName( $ns, $ttl );
1546 $clink = $this->makeKnownLink( $t, "" ) ;
1547 if ( $oldid == 0 ) $c2link = $clink ;
1548 else $c2link = $this->makeKnownLink( $t, "" , "oldid={$oldid}" );
1549 $nt = Title::newFromText( $t );
1551 $rc->timestamp = $h ;
1552 $rc->oldid = $oldid ;
1553 $rc->diffid = $diffid ;
1554 $rc->watched = $watched ;
1555 $rc->isnew = $isnew ;
1556 $rc->isminor = $isminor ;
1557 $rc->secureName = $t ;
1558 $rc->displayName = $nt ;
1559 $rc->link = $clink ;
1560 $rc->usercomment = $c ;
1561 $rc->islog = $nt->isLog() ;
1563 if ( ( $isnew && $oldid == 0 ) || $nt->isLog() ) {
1564 $dlink = wfMsg( "cur" );
1565 } else {
1566 $dlink = $this->makeKnownLink( $t, wfMsg( "cur" ),
1567 "diff=0&oldid={$oldid}" );
1570 if ( $diffid == 0 || $nt->isLog() ) {
1571 $plink = wfMsg( "last" );
1572 } else {
1573 $plink = $this->makeKnownLink( $t, wfMsg( "last" ),
1574 "diff={$oldid}&oldid={$diffid}" );
1577 if ( 0 == $u ) {
1578 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1579 $ut, "target=" . $ut );
1580 } else { $ul = $this->makeLink( $wgLang->getNsText(
1581 Namespace::getUser() ) . ":{$ut}", $ut ); }
1583 $rc->userlink = $ul ;
1584 $rc->lastlink = $plink ;
1585 $rc->curlink = $dlink ;
1587 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1588 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1589 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1591 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1592 $blink = $this->makeKnownLink( $wgLang->specialPage(
1593 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1594 $rc->usertalklink= " ({$utl} | {$blink})";
1595 } else {
1596 $rc->usertalklink=" ({$utl})";
1599 if ( !isset ( $this->rc_cache[$t] ) ) $this->rc_cache[$t] = array() ;
1600 array_push ( $this->rc_cache[$t] , $rc ) ;
1601 return $ret;
1605 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
1607 global $wgUser, $wgLang, $wgTitle;
1609 $dt = $wgLang->timeanddate( $ts, true );
1610 $del = wfMsg( "deleteimg" );
1611 $cur = wfMsg( "cur" );
1613 if ( $iscur ) {
1614 $url = wfImageUrl( $img );
1615 $rlink = $cur;
1616 if ( $wgUser->isSysop() ) {
1617 $link = wfLocalUrlE( "", "image=" . $wgTitle->getURL() .
1618 "&action=delete" );
1619 $style = $this->getInternalLinkAttributes( $link, $del );
1621 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
1622 } else {
1623 $dlink = $del;
1625 } else {
1626 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
1627 if( $wgUser->getID() != 0 ) {
1628 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1629 wfMsg( "revertimg" ), "action=revert&oldimage=" .
1630 urlencode( $img ) );
1631 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1632 $del, "action=delete&oldimage=" . urlencode( $img ) );
1633 } else {
1634 # Having live active links for non-logged in users
1635 # means that bots and spiders crawling our site can
1636 # inadvertently change content. Baaaad idea.
1637 $rlink = wfMsg( "revertimg" );
1638 $dlink = $del;
1641 if ( 0 == $u ) { $ul = $ut; }
1642 else { $ul = $this->makeLink( $wgLang->getNsText(
1643 Namespace::getUser() ) . ":{$ut}", $ut ); }
1645 $nb = str_replace( "$1", $size, wfMsg( "nbytes" ) );
1646 $style = $this->getInternalLinkAttributes( $url, $dt );
1648 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
1649 . " . . {$ul} ({$nb})";
1651 if ( "" != $c && "*" != $c ) {
1652 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1654 $s .= "</li>\n";
1655 return $s;
1658 function tocIndent($level) {
1660 while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
1661 return $rv;
1665 function tocUnindent($level) {
1666 while($level-->0) $rv.="</div>\n";
1667 return $rv;
1670 // parameter level defines if we are on an indentation level
1671 function tocLine($anchor,$tocline,$level) {
1673 if($level) {
1675 return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
1676 } else {
1678 return "<div style=\"margin-bottom:0px;\">\n".
1679 "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
1680 "</div>\n";
1685 function tocTable($toc) {
1687 /* does not auto-expand, use table for now
1688 return "
1689 <div><div style=\"border-width:1px;background-color:#f3f3ff;border-color:#8888aa;border-style:solid;padding:1em;padding-bottom:1em;\">
1690 <b>".wfMsg("toc")."</b><P>
1691 $toc</div></div>";
1693 return
1694 "<table border=\"0\" bgcolor=\"#8888aa\" cellpadding=\"0\" cellspacing=\"1\"><tr><td>\n" .
1695 "<table border=\"0\" bgcolor=\"#f3f3ff\" CELLPADDING=5><tr><td>\n".
1696 "<b>".wfMsg("toc")."</b>" .
1697 " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>" .
1698 "</td></tr><tr id='tocinside'><td>\n".
1699 $toc."</td></tr></table></td></tr></table><P>\n";
1702 function editSectionLink($section) {
1704 global $wgTitle,$wgUser,$oldid;
1705 if($wgTitle->isProtected() && !$wgUser->isSysop()) return "";
1706 if($oldid) return "";
1707 $editurl="&section={$section}";
1708 $url=$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
1709 return "<div style=\"float:right;margin-left:5px;\"><small>[".$url."]</small></div>";
1714 include_once( "SkinStandard.php" );
1715 include_once( "SkinNostalgia.php" );
1716 include_once( "SkinCologneBlue.php" );