Added categroy feature, turned off by default
[mediawiki.git] / includes / Skin.php
blob862c1ac7141baab005e9f36dc070900ef35e3f2b
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 # For some odd PHP bug, this function can't be part of a class
13 function getCategories ()
15 global $wgOut , $wgTitle , $wgUseCategoryMagic , $wgUser ;
16 if ( !isset ( $wgUseCategoryMagic ) || !$wgUseCategoryMagic ) return "" ;
17 if ( count ( $wgOut->mCategoryLinks ) == 0 ) return "" ;
18 if ( !$wgOut->isArticle() ) return "" ;
19 $sk = $wgUser->getSkin() ;
20 $s = "" ;
21 $s .= "\n<br>\n";
22 $s .= $sk->makeKnownLink ( "Special:Categories" , "Categories" , "article=".$wgTitle->getDBkey() ) ;
23 $t = implode ( " | " , $wgOut->mCategoryLinks ) ;
24 if ( $t != "" ) $s .= " : " ;
25 $s .= $t ;
26 return $s ;
30 class RecentChangesClass {
31 var $secureName , $displayName , $link , $namespace ;
32 var $oldid , $diffid , $timestamp , $curlink , $lastlink , $usertalklink , $versionlink ;
33 var $usercomment , $userlink ;
34 var $isminor , $isnew , $watched , $islog ;
35 } ;
37 class Skin {
39 /* private */ var $lastdate, $lastline;
41 var $rc_cache ; # Cache for Enhanced Recent Changes
42 var $rccc ; # Recent Changes Cache Counter for visibility toggle
45 function Skin()
49 function getSkinNames()
51 global $wgValidSkinNames;
52 return $wgValidSkinNames;
55 function getStylesheet()
57 return "wikistandard.css";
60 function qbSetting()
62 global $wgOut, $wgUser;
64 if ( $wgOut->isQuickbarSupressed() ) { return 0; }
65 $q = $wgUser->getOption( "quickbar" );
66 if ( "" == $q ) { $q = 0; }
67 return $q;
70 function initPage()
72 global $wgOut, $wgStyleSheetPath;
73 wfProfileIn( "Skin::initPage" );
75 $wgOut->addLink( "shortcut icon", "", "/favicon.ico" );
76 if ( $wgOut->isPrintable() ) { $ss = "wikiprintable.css"; }
77 else { $ss = $this->getStylesheet(); }
78 $wgOut->addLink( "stylesheet", "", "{$wgStyleSheetPath}/{$ss}" );
79 wfProfileOut();
82 function getHeadScripts() {
83 global $wgStyleSheetPath;
84 $r = "<script type=\"text/javascript\" src=\"{$wgStyleSheetPath}/wikibits.js\"></script>\n";
85 return $r;
88 function getUserStyles()
90 $s = "<style type='text/css' media='screen'><!--\n";
91 $s .= $this->doGetUserStyles();
92 $s .= "//--></style>\n";
93 return $s;
96 function doGetUserStyles()
98 global $wgUser;
100 $s = "";
101 if ( 1 == $wgUser->getOption( "underline" ) ) {
102 # Don't override browser settings
103 } else {
104 # Force no underline
105 $s .= "a.stub, a.new, a.internal, a.external { " .
106 "text-decoration: none; }\n";
108 if ( 1 == $wgUser->getOption( "highlightbroken" ) ) {
109 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
111 if ( 1 == $wgUser->getOption( "justify" ) ) {
112 $s .= "#article { text-align: justify; }\n";
114 return $s;
117 function getBodyOptions()
119 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $oldid, $redirect, $diff,$action;
121 if ( 0 != $wgTitle->getNamespace() ) {
122 $a = array( "bgcolor" => "#FFFFDD" );
124 else $a = array( "bgcolor" => "#FFFFFF" );
125 if($wgOut->isArticle() && $wgUser->getOption("editondblclick")
127 (!$wgTitle->isProtected() || $wgUser->isSysop())
130 $n = $wgTitle->getPrefixedURL();
131 $t = wfMsg( "editthispage" );
132 $oid = $red = "";
133 if ( $redirect ) { $red = "&redirect={$redirect}"; }
134 if ( $oldid && ! isset( $diff ) ) {
135 $oid = "&oldid={$oldid}";
137 $s = wfLocalUrlE($n,"action=edit{$oid}{$red}");
138 $s = "document.location = \"" .$s ."\";";
139 $a += array ("ondblclick" => $s);
142 if($action=="edit") { # set focus in edit box
143 $a += array("onLoad"=>"document.editform.wpTextbox1.focus()");
145 return $a;
148 function getExternalLinkAttributes( $link, $text )
150 global $wgUser, $wgOut, $wgLang;
152 $link = urldecode( $link );
153 $link = $wgLang->checkTitleEncoding( $link );
154 $link = str_replace( "_", " ", $link );
155 $link = wfEscapeHTML( $link );
157 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
158 else { $r = " class='external'"; }
160 if ( 1 == $wgUser->getOption( "hover" ) ) {
161 $r .= " title=\"{$link}\"";
163 return $r;
166 function getInternalLinkAttributes( $link, $text, $broken = false )
168 global $wgUser, $wgOut;
170 $link = urldecode( $link );
171 $link = str_replace( "_", " ", $link );
172 $link = wfEscapeHTML( $link );
174 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
175 else if ( $broken == "stub" ) { $r = " class='stub'"; }
176 else if ( $broken == "yes" ) { $r = " class='new'"; }
177 else { $r = " class='internal'"; }
179 if ( 1 == $wgUser->getOption( "hover" ) ) {
180 $r .= " title=\"{$link}\"";
182 return $r;
185 function getLogo()
187 global $wgLogo;
188 return $wgLogo;
191 # This will be called immediately after the <body> tag. Split into
192 # two functions to make it easier to subclass.
194 function beforeContent()
196 global $wgUser, $wgOut;
198 if ( $wgOut->isPrintable() ) {
199 $s = $this->pageTitle() . $this->pageSubtitle() . "\n";
200 $s .= "\n<div class='bodytext'>";
201 return $s;
203 return $this->doBeforeContent();
206 function doBeforeContent()
208 global $wgUser, $wgOut, $wgTitle, $wgLang;
209 wfProfileIn( "Skin::doBeforeContent" );
211 $s = "";
212 $qb = $this->qbSetting();
214 if( $langlinks = $this->otherLanguages() ) {
215 $rows = 2;
216 $borderhack = "";
217 } else {
218 $rows = 1;
219 $langlinks = false;
220 $borderhack = "class='top'";
223 $s .= "\n<div id='content'>\n<div id='topbar'>" .
224 "<table width='98%' border=0 cellspacing=0><tr>";
226 $shove = ($qb != 0);
227 $left = ($qb == 1 || $qb == 3);
228 if($wgLang->isRTL()) $left = !$left;
230 if ( !$shove ) {
231 $s .= "<td class='top' align=left valign=top rowspan='{$rows}'>" .
232 $this->logoText() . "</td>";
233 } elseif( $left ) {
234 $s .= $this->getQuickbarCompensator( $rows );
236 $l = $wgLang->isRTL() ? "right" : "left";
237 $s .= "<td {$borderhack} align='$l' valign='top'>";
239 $s .= $this->topLinks() ;
240 $s .= "<p class='subtitle'>" . $this->pageTitleLinks();
242 $r = $wgLang->isRTL() ? "left" : "right";
243 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap>";
244 $s .= $this->nameAndLogin();
245 $s .= "\n<br>" . $this->searchForm() . "</td>";
247 if ( $langlinks ) {
248 $s .= "</tr>\n<tr><td class='top' colspan=\"2\">$langlinks</td>";
251 if ( $shove && !$left ) { # Right
252 $s .= $this->getQuickbarCompensator( $rows );
254 $s .= "</tr></table>\n</div>\n";
255 $s .= "\n<div id='article'>";
257 $s .= $this->pageTitle();
258 $s .= $this->pageSubtitle() ;
259 $s .= getCategories(); // For some odd reason, zhis can't be a function of the object
260 $s .= "\n<p>";
261 wfProfileOut();
262 return $s;
265 function getQuickbarCompensator( $rows = 1 )
267 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
270 # This gets called immediately before the </body> tag.
272 function afterContent()
274 global $wgUser, $wgOut, $wgServer, $HTTP_SERVER_VARS;
276 if ( $wgOut->isPrintable() ) {
277 $s = "\n</div>\n";
279 $u = $wgServer . $HTTP_SERVER_VARS['REQUEST_URI'];
280 $u = preg_replace( "/[?&]printable=yes/", "", $u );
281 $rf = str_replace( "$1", $u, wfMsg( "retrievedfrom" ) );
283 if ( $wgOut->isArticle() ) {
284 $lm = "<br>" . $this->lastModified();
285 } else { $lm = ""; }
287 $s .= "<p><em>{$rf}{$lm}</em>\n";
288 return $s;
290 return $this->doAfterContent();
293 function doAfterContent()
295 global $wgUser, $wgOut, $wgLang;
296 wfProfileIn( "Skin::doAfterContent" );
298 $s = "\n</div><br clear=all>\n";
300 $s .= "\n<div id='footer'>";
301 $s .= "<table width='98%' border=0 cellspacing=0><tr>";
303 $qb = $this->qbSetting();
304 $shove = ($qb != 0);
305 $left = ($qb == 1 || $qb == 3);
306 if($wgLang->isRTL()) $left = !$left;
308 if ( $shove && $left ) { # Left
309 $s .= $this->getQuickbarCompensator();
311 $l = $wgLang->isRTL() ? "right" : "left";
312 $s .= "<td class='bottom' align='$l' valign='top'>";
314 $s .= $this->bottomLinks();
315 $s .= "\n<br>" . $this->mainPageLink()
316 . " | " . $this->aboutLink()
317 . " | " . $this->specialLink( "recentchanges" )
318 . " | " . $this->searchForm()
319 . "<br>" . $this->pageStats();
321 $s .= "</td>";
322 if ( $shove && !$left ) { # Right
323 $s .= $this->getQuickbarCompensator();
325 $s .= "</tr></table>\n</div>\n</div>\n";
327 if ( 0 != $qb ) { $s .= $this->quickBar(); }
328 wfProfileOut();
329 return $s;
332 function pageTitleLinks()
334 global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang;
336 $s = $this->printableLink();
338 if ( $wgOut->isArticle() ) {
339 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
340 $name = $wgTitle->getDBkey();
341 $link = wfEscapeHTML( wfImageUrl( $name ) );
342 $style = $this->getInternalLinkAttributes( $link, $name );
343 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
346 if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
347 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
348 wfMsg( "currentrev" ) );
351 if ( $wgUser->getNewtalk() ) {
352 # do not show "You have new messages" text when we are viewing our
353 # own talk page
355 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
356 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
357 $n =$wgUser->getName();
358 $tl = $this->makeKnownLink( $wgLang->getNsText(
359 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
360 wfMsg("newmessageslink") );
361 $s.=" | <strong>". str_replace( "$1", $tl, wfMsg("newmessages") ) . "</strong>";
364 return $s;
367 function printableLink()
369 global $wgOut, $wgTitle, $oldid, $action;
371 if ( "history" == $action ) { $q = "action=history&"; }
372 else { $q = ""; }
374 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
375 WfMsg( "printableversion" ), "{$q}printable=yes" );
376 return $s;
379 function pageTitle()
381 global $wgOut, $wgTitle;
383 $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
384 return $s;
387 function pageSubtitle()
389 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
391 $sub = $wgOut->getSubtitle();
392 if ( "" == $sub ) { $sub = wfMsg( "fromwikipedia" ); }
393 if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
394 $ptext=$wgTitle->getPrefixedText();
395 if(preg_match("/\//",$ptext)) {
396 $sub.="</p><p class='subpages'>";
397 $links=explode("/",$ptext);
398 $c=0;
399 $growinglink="";
400 foreach($links as $link) {
401 $c++;
402 if ($c<count($links)) {
403 $growinglink.=$link;
404 $getlink=$this->makeLink($growinglink,$link);
405 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
406 if ($c>1) {
407 $sub .= " | ";
408 } else {
409 $sub .="&lt; ";
411 $sub .= $getlink;
412 $growinglink.="/";
418 $s = "<p class='subtitle'>{$sub}\n";
419 return $s;
422 function nameAndLogin()
424 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader;
426 $li = $wgLang->specialPage( "Userlogin" );
427 $lo = $wgLang->specialPage( "Userlogout" );
429 $s = "";
430 if ( 0 == $wgUser->getID() ) {
431 if( $wgShowIPinHeader ) {
432 $n = getenv( "REMOTE_ADDR" );
434 $tl = $this->makeKnownLink( $wgLang->getNsText(
435 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
436 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
438 $s .= $n . " (".$tl.")";
439 } else {
440 $s .= wfMsg("notloggedin");
443 $rt = $wgTitle->getPrefixedURL();
444 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
445 $q = "";
446 } else { $q = "returnto={$rt}"; }
448 $s .= "\n<br>" . $this->makeKnownLink( $li,
449 wfMsg( "login" ), $q );
450 } else {
451 $n = $wgUser->getName();
452 $rt = $wgTitle->getPrefixedURL();
453 $tl = $this->makeKnownLink( $wgLang->getNsText(
454 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
455 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
457 $tl = " ({$tl})";
459 $s .= $this->makeKnownLink( $wgLang->getNsText(
460 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
461 $this->makeKnownLink( $lo, wfMsg( "logout" ),
462 "returnto={$rt}" ) . " | " .
463 $this->specialLink( "preferences" );
465 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
466 wfMsg( "help" ) );
468 return $s;
471 function searchForm()
473 global $search;
475 $s = "<form name='search' class='inline' method=get action=\""
476 . wfLocalUrl( "" ) . "\">"
477 . "<input type=text name=\"search\" size=19 value=\""
478 . htmlspecialchars(substr($search,0,256)) . "\">\n"
479 . "<input type=submit name=\"go\" value=\"" . wfMsg ("go") . "\">&nbsp;"
480 . "<input type=submit value=\"" . wfMsg ("search") . "\"></form>";
482 return $s;
485 function topLinks()
487 global $wgOut;
488 $sep = " |\n";
490 $s = $this->mainPageLink() . $sep
491 . $this->specialLink( "recentchanges" );
493 if ( $wgOut->isArticle() ) {
494 $s .= $sep . $this->editThisPage()
495 . $sep . $this->historyLink();
497 $s .= $sep . $this->specialPagesList();
499 return $s;
502 function bottomLinks()
504 global $wgOut, $wgUser, $wgTitle;
505 $sep = " |\n";
507 $s = "";
508 if ( $wgOut->isArticle() ) {
509 $s .= "<strong>" . $this->editThisPage() . "</strong>";
510 if ( 0 != $wgUser->getID() ) {
511 $s .= $sep . $this->watchThisPage();
513 $s .= $sep . $this->talkLink()
514 . $sep . $this->historyLink()
515 . $sep . $this->whatLinksHere()
516 . $sep . $this->watchPageLinksLink();
518 if ( $wgTitle->getNamespace() == Namespace::getUser()
519 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
522 $id=User::idFromName($wgTitle->getText());
523 $ip=User::isIP($wgTitle->getText());
525 if($id || $ip) { # both anons and non-anons have contri list
526 $s .= $sep . $this->userContribsLink();
528 if ( 0 != $wgUser->getID() ) { # show only to signed in users
529 if($id) { # can only email non-anons
530 $s .= $sep . $this->emailUserLink();
534 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
535 $s .= "\n<br>" . $this->deleteThisPage() .
536 $sep . $this->protectThisPage() .
537 $sep . $this->moveThisPage();
539 $s .= "<br>\n" . $this->otherLanguages();
541 return $s;
544 function pageStats()
546 global $wgOut, $wgLang, $wgArticle;
547 global $oldid, $diff, $wgDisableCounters;
549 if ( ! $wgOut->isArticle() ) { return ""; }
550 if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
551 if ( 0 == $wgArticle->getID() ) { return ""; }
553 if ( $wgDisableCounters ) {
554 $s = "";
555 } else {
556 $count = $wgArticle->getCount();
557 $s = str_replace( "$1", $count, wfMsg( "viewcount" ) );
559 $s .= $this->lastModified();
560 $s .= " " . wfMsg( "gnunote" );
561 return "<span id='pagestats'>{$s}</span>";
564 function lastModified()
566 global $wgLang, $wgArticle;
568 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
569 $s = " " . str_replace( "$1", $d, wfMsg( "lastmodified" ) );
570 return $s;
573 function logoText( $align = "" )
575 if ( "" != $align ) { $a = " align='{$align}'"; }
576 else { $a = ""; }
578 $mp = wfMsg( "mainpage" );
579 $s = "<a href=\"" . wfLocalUrlE( $mp ) . "\"><img{$a} border=0 src=\""
580 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
581 return $s;
584 function quickBar()
586 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
587 global $wpPreview;
588 wfProfileIn( "Skin::quickBar" );
590 $s = "\n<div id='quickbar'>";
591 $s .= "\n" . $this->logoText() . "\n<hr>";
593 $sep = "\n<br>";
594 $s .= $this->mainPageLink()
595 . $sep . $this->specialLink( "recentchanges" )
596 . $sep . $this->specialLink( "randompage" );
597 if ($wgUser->getID()) {
598 $s.= $sep . $this->specialLink( "watchlist" ) ;
599 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
600 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
603 // only show watchlist link if logged in
604 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
605 $s .= "\n<hr>";
606 $articleExists = $wgTitle->getArticleId();
607 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
609 if($wgOut->isArticle()) {
610 $s .= "<strong>" . $this->editThisPage() . "</strong>";
611 } else { # backlink to the article in edit or history mode
613 if($articleExists){ # no backlink if no article
614 $tns=$wgTitle->getNamespace();
615 switch($tns) {
616 case 0:
617 $text = wfMsg("articlepage");
618 break;
619 case 1:
620 $text = wfMsg("viewtalkpage");
621 break;
622 case 2:
623 $text = wfMsg("userpage");
624 break;
625 case 3:
626 $text = wfMsg("viewtalkpage");
627 break;
628 case 4:
629 $text = wfMsg("wikipediapage");
630 break;
631 case 5:
632 $text = wfMsg("viewtalkpage");
633 break;
634 case 6:
635 $text = wfMsg("imagepage");
636 break;
637 case 7:
638 $text = wfMsg("viewtalkpage");
639 break;
640 default:
641 $text= wfMsg("articlepage");
644 $link = $wgTitle->getText();
645 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
646 $link = $nstext . ":" . $link ;
648 $s .= $this->makeLink($link, $text );
649 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
650 # we just throw in a "New page" text to tell the user that he's in edit mode,
651 # and to avoid messing with the separator that is prepended to the next item
652 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
658 watching could cause problems in edit mode:
659 if user edits article, then loads "watch this article" in background and then saves
660 article with "Watch this article" checkbox disabled, the article is transparently
661 unwatched. Therefore we do not show the "Watch this page" link in edit mode
663 if ( 0 != $wgUser->getID() && $articleExists) {
664 if($action!="edit" && $action!="history" &&
665 $action != "submit" )
666 {$s .= $sep . $this->watchThisPage(); }
667 if ( $wgTitle->userCanEdit() ) $s .= $sep . $this->moveThisPage();
669 if ( $wgUser->isSysop() and $articleExists ) {
670 $s .= $sep . $this->deleteThisPage() .
671 $sep . $this->protectThisPage();
673 $s .= $sep . $this->talkLink();
674 if ($articleExists && $action !="history") { $s .= $sep . $this->historyLink();}
675 $s.=$sep . $this->whatLinksHere();
677 if($wgOut->isArticle()) {
678 $s .= $sep . $this->watchPageLinksLink();
681 if ( Namespace::getUser() == $wgTitle->getNamespace()
682 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
685 $id=User::idFromName($wgTitle->getText());
686 $ip=User::isIP($wgTitle->getText());
688 if($id||$ip) {
689 $s .= $sep . $this->userContribsLink();
691 if ( 0 != $wgUser->getID() ) {
692 if($id) { # can only email real users
693 $s .= $sep . $this->emailUserLink();
697 $s .= "\n<hr>";
700 if ( 0 != $wgUser->getID() ) {
701 $s .= $this->specialLink( "upload" ) . $sep;
703 $s .= $this->specialLink( "specialpages" )
704 . $sep . $this->bugReportsLink();
706 $s .= "\n</div>\n";
707 wfProfileOut();
708 return $s;
711 function specialPagesList()
713 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
714 $a = array();
716 $validSP = $wgLang->getValidSpecialPages();
718 foreach ( $validSP as $name => $desc ) {
719 if ( "" == $desc ) { continue; }
720 $a[$name] = $desc;
722 if ( $wgUser->isSysop() )
724 $sysopSP = $wgLang->getSysopSpecialPages();
726 foreach ( $sysopSP as $name => $desc ) {
727 if ( "" == $desc ) { continue; }
728 $a[$name] = $desc ;
731 if ( $wgUser->isDeveloper() )
733 $devSP = $wgLang->getDeveloperSpecialPages();
735 foreach ( $devSP as $name => $desc ) {
736 if ( "" == $desc ) { continue; }
737 $a[$name] = $desc ;
740 $go = wfMsg( "go" );
741 $sp = wfMsg( "specialpages" );
742 $spp = $wgLang->specialPage( "Specialpages" );
744 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
745 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
746 $s .= "<select name=\"wpDropdown\">\n";
747 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
749 foreach ( $a as $name => $desc ) {
750 $p = $wgLang->specialPage( $name );
751 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
753 $s .= "</select>\n";
754 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
755 $s .= "</form>\n";
756 return $s;
759 function mainPageLink()
761 $mp = wfMsg( "mainpage" );
762 $s = $this->makeKnownLink( $mp, $mp );
763 return $s;
766 function copyrightLink()
768 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
769 wfMsg( "copyrightpagename" ) );
770 return $s;
773 function aboutLink()
775 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
776 wfMsg( "aboutwikipedia" ) );
777 return $s;
780 function editThisPage()
782 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
784 if ( ! $wgOut->isArticle() || $diff ) {
785 $s = wfMsg( "protectedpage" );
786 } else if ( $wgTitle->userCanEdit() ) {
787 $n = $wgTitle->getPrefixedText();
788 $t = wfMsg( "editthispage" );
789 $oid = $red = "";
791 if ( $redirect ) { $red = "&redirect={$redirect}"; }
792 if ( $oldid && ! isset( $diff ) ) {
793 $oid = "&oldid={$oldid}";
795 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
796 } else {
797 $s = wfMsg( "protectedpage" );
799 return $s;
802 function deleteThisPage()
804 global $wgUser, $wgOut, $wgTitle, $diff;
806 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
807 $n = $wgTitle->getPrefixedText();
808 $t = wfMsg( "deletethispage" );
810 $s = $this->makeKnownLink( $n, $t, "action=delete" );
811 } else {
812 $s = wfMsg( "error" );
814 return $s;
817 function protectThisPage()
819 global $wgUser, $wgOut, $wgTitle, $diff;
821 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
822 $n = $wgTitle->getPrefixedText();
824 if ( $wgTitle->isProtected() ) {
825 $t = wfMsg( "unprotectthispage" );
826 $q = "action=unprotect";
827 } else {
828 $t = wfMsg( "protectthispage" );
829 $q = "action=protect";
831 $s = $this->makeKnownLink( $n, $t, $q );
832 } else {
833 $s = wfMsg( "error" );
835 return $s;
838 function watchThisPage()
840 global $wgUser, $wgOut, $wgTitle, $diff;
842 if ( $wgOut->isArticle() && ( ! $diff ) ) {
843 $n = $wgTitle->getPrefixedText();
845 if ( $wgTitle->userIsWatching() ) {
846 $t = wfMsg( "unwatchthispage" );
847 $q = "action=unwatch";
848 } else {
849 $t = wfMsg( "watchthispage" );
850 $q = "action=watch";
852 $s = $this->makeKnownLink( $n, $t, $q );
853 } else {
854 $s = wfMsg( "notanarticle" );
856 return $s;
859 function moveThisPage()
861 global $wgTitle, $wgLang;
863 if ( $wgTitle->userCanEdit() ) {
864 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
865 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
866 } // no message if page is protected - would be redundant
867 return $s;
870 function historyLink()
872 global $wgTitle;
874 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
875 wfMsg( "history" ), "action=history" );
876 return $s;
879 function whatLinksHere()
881 global $wgTitle, $wgLang;
883 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
884 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
885 return $s;
888 function userContribsLink()
890 global $wgTitle, $wgLang;
892 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
893 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
894 return $s;
897 function emailUserLink()
899 global $wgTitle, $wgLang;
901 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
902 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
903 return $s;
906 function watchPageLinksLink()
908 global $wgOut, $wgTitle, $wgLang;
910 if ( ! $wgOut->isArticle() ) {
911 $s = "(" . wfMsg( "notanarticle" ) . ")";
912 } else {
913 $s = $this->makeKnownLink( $wgLang->specialPage(
914 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
915 "target=" . $wgTitle->getPrefixedURL() );
917 return $s;
920 function otherLanguages()
922 global $wgOut, $wgLang, $wgTitle , $wgUseNewInterlanguage ;
924 $a = $wgOut->getLanguageLinks();
925 if ( 0 == count( $a ) ) {
926 if ( !$wgUseNewInterlanguage ) return "";
927 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
928 if ( $ns != 0 AND $ns != 1 ) return "" ;
929 $pn = "Intl" ;
930 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
931 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
932 wfMsg( "intl" ) , $x );
935 if ( !$wgUseNewInterlanguage ) {
936 $s = wfMsg( "otherlanguages" ) . ": ";
937 } else {
938 global $wgLanguageCode ;
939 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
940 $x .= "&xl=".$wgLanguageCode ;
941 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
942 wfMsg( "otherlanguages" ) , $x ) . ": " ;
945 $first = true;
946 foreach( $a as $l ) {
947 if ( ! $first ) { $s .= " | "; }
948 $first = false;
950 $nt = Title::newFromText( $l );
951 $url = $nt->getFullURL();
952 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
954 if ( "" == $text ) { $text = $l; }
955 $style = $this->getExternalLinkAttributes( $l, $text );
956 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
958 return $s;
961 function bugReportsLink()
963 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
964 wfMsg( "bugreports" ) );
965 return $s;
968 function dateLink()
970 global $wgLinkCache;
971 $t1 = Title::newFromText( gmdate( "F j" ) );
972 $t2 = Title::newFromText( gmdate( "Y" ) );
974 $wgLinkCache->suspend();
975 $id = $t1->getArticleID();
976 $wgLinkCache->resume();
978 if ( 0 == $id ) {
979 $s = $this->makeBrokenLink( $t1->getText() );
980 } else {
981 $s = $this->makeKnownLink( $t1->getText() );
983 $s .= ", ";
985 $wgLinkCache->suspend();
986 $id = $t2->getArticleID();
987 $wgLinkCache->resume();
989 if ( 0 == $id ) {
990 $s .= $this->makeBrokenLink( $t2->getText() );
991 } else {
992 $s .= $this->makeKnownLink( $t2->getText() );
994 return $s;
997 function talkLink()
999 global $wgLang, $wgTitle, $wgLinkCache;
1001 $tns = $wgTitle->getNamespace();
1002 if ( -1 == $tns ) { return ""; }
1004 $pn = $wgTitle->getText();
1005 $tp = wfMsg( "talkpage" );
1006 if ( Namespace::isTalk( $tns ) ) {
1007 $lns = Namespace::getSubject( $tns );
1008 switch($tns) {
1009 case 1:
1010 $text = wfMsg("articlepage");
1011 break;
1012 case 3:
1013 $text = wfMsg("userpage");
1014 break;
1015 case 5:
1016 $text = wfMsg("wikipediapage");
1017 break;
1018 case 7:
1019 $text = wfMsg("imagepage");
1020 break;
1021 default:
1022 $text= wfMsg("articlepage");
1024 } else {
1026 $lns = Namespace::getTalk( $tns );
1027 $text=$tp;
1029 $n = $wgLang->getNsText( $lns );
1030 if ( "" == $n ) { $link = $pn; }
1031 else { $link = "{$n}:{$pn}"; }
1033 $wgLinkCache->suspend();
1034 $s = $this->makeLink( $link, $text );
1035 $wgLinkCache->resume();
1037 return $s;
1040 # After all the page content is transformed into HTML, it makes
1041 # a final pass through here for things like table backgrounds.
1043 function transformContent( $text )
1045 return $text;
1048 # Note: This function MUST call getArticleID() on the link,
1049 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1051 function makeLink( $title, $text= "", $query = "", $trail = "" )
1053 global $wgOut, $wgUser;
1055 $nt = Title::newFromText( $title );
1057 if ( $nt->isExternal() ) {
1058 $u = $nt->getFullURL();
1059 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1060 $style = $this->getExternalLinkAttributes( $link, $text );
1062 $inside = "";
1063 if ( "" != $trail ) {
1064 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1065 $inside = $m[1];
1066 $trail = $m[2];
1069 return "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1071 if ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1072 return $this->makeKnownLink( $title, $text, $query, $trail );
1074 if ( ( -1 == $nt->getNamespace() ) ||
1075 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1076 return $this->makeKnownLink( $title, $text, $query, $trail );
1078 $aid = $nt->getArticleID() ;
1079 if ( 0 == $aid ) {
1080 return $this->makeBrokenLink( $title, $text, $query, $trail );
1081 } else {
1082 $threshold = $wgUser->getOption("stubthreshold") ;
1083 if ( $threshold > 0 ) {
1084 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'" ) ;
1086 if ( wfNumRows( $res ) > 0 ) {
1087 $s = wfFetchObject( $res );
1088 $size = $s->x;
1089 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
1090 $size = $threshold*2 ; # Really big
1091 wfFreeResult( $res );
1092 } else $size = $threshold*2 ; # Really big
1093 } else $size = 1 ;
1095 if ( $size < $threshold )
1096 return $this->makeStubLink( $title, $text, $query, $trail );
1097 return $this->makeKnownLink( $title, $text, $query, $trail );
1101 function makeKnownLink( $title, $text = "", $query = "", $trail = "" )
1103 global $wgOut, $wgTitle;
1105 $nt = Title::newFromText( $title );
1106 $link = $nt->getPrefixedURL();
1108 if ( "" == $link ) {
1109 $u = "";
1110 if ( "" == $text ) { $text = $nt->getFragment(); }
1111 } else {
1112 $u = wfLocalUrlE( $link, $query );
1114 if ( "" != $nt->getFragment() ) {
1115 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1117 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1118 $style = $this->getInternalLinkAttributes( $link, $text );
1120 $inside = "";
1121 if ( "" != $trail ) {
1122 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1123 $inside = $m[1];
1124 $trail = $m[2];
1127 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1128 return $r;
1131 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" )
1133 global $wgOut, $wgUser;
1135 $nt = Title::newFromText( $title );
1136 $link = $nt->getPrefixedURL();
1138 if ( "" == $query ) { $q = "action=edit"; }
1139 else { $q = "action=edit&{$query}"; }
1140 $u = wfLocalUrlE( $link, $q );
1142 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1143 $style = $this->getInternalLinkAttributes( $link, $text, "yes" );
1145 $inside = "";
1146 if ( "" != $trail ) {
1147 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1148 $inside = $m[1];
1149 $trail = $m[2];
1152 if ( $wgOut->isPrintable() ||
1153 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1154 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1155 } else {
1156 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1158 return $s;
1161 function makeStubLink( $title, $text = "", $query = "", $trail = "" )
1163 global $wgOut, $wgUser;
1165 $nt = Title::newFromText( $title );
1166 $link = $nt->getPrefixedURL();
1168 $u = wfLocalUrlE( $link, $query );
1170 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1171 $style = $this->getInternalLinkAttributes( $link, $text, "stub" );
1173 $inside = "";
1174 if ( "" != $trail ) {
1175 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1176 $inside = $m[1];
1177 $trail = $m[2];
1180 if ( $wgOut->isPrintable() ||
1181 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1182 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1183 } else {
1184 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1186 return $s;
1189 function fnamePart( $url )
1191 $basename = strrchr( $url, "/" );
1192 if ( false === $basename ) { $basename = $url; }
1193 else { $basename = substr( $basename, 1 ); }
1194 return wfEscapeHTML( $basename );
1197 function makeImage( $url, $alt = "" )
1199 global $wgOut;
1201 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1202 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1203 return $s;
1206 function makeImageLink( $name, $url, $alt = "" )
1208 global $wgOut, $wgTitle, $wgLang;
1210 $nt = Title::newFromText( $wgLang->getNsText(
1211 Namespace::getImage() ) . ":{$name}" );
1212 $link = $nt->getPrefixedURL();
1213 if ( "" == $alt ) { $alt = $name; }
1215 $u = wfLocalUrlE( $link );
1216 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1217 "<img border=0 src=\"{$url}\" alt=\"{$alt}\"></a>";
1218 return $s;
1221 function makeMediaLink( $name, $url, $alt = "" )
1223 global $wgOut, $wgTitle;
1225 if ( "" == $alt ) { $alt = $name; }
1226 $u = wfEscapeHTML( $url );
1227 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1228 return $s;
1231 function specialLink( $name, $key = "" )
1233 global $wgLang;
1235 if ( "" == $key ) { $key = strtolower( $name ); }
1236 $pn = $wgLang->ucfirst( $name );
1237 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1238 wfMsg( $key ) );
1241 # Called by history lists and recent changes
1244 function beginRecentChangesList()
1246 $rc_cache = array() ;
1247 $rccc = 0 ;
1248 $this->lastdate = "";
1249 return "";
1252 function beginHistoryList()
1254 $this->lastdate = $this->lastline = "";
1255 $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
1256 return $s;
1259 function beginImageHistoryList()
1261 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1262 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1263 return $s;
1266 function endRecentChangesList()
1268 $s = $this->recentChangesBlock() ;
1269 $s .= "</ul>\n";
1270 return $s;
1273 function endHistoryList()
1275 $last = wfMsg( "last" );
1277 $s = preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
1278 $s .= "</ul>\n";
1279 return $s;
1282 function endImageHistoryList()
1284 $s = "</ul>\n";
1285 return $s;
1288 function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor )
1290 global $wgLang;
1292 $artname = Title::makeName( $ns, $ttl );
1293 $last = wfMsg( "last" );
1294 $cur = wfMsg( "cur" );
1295 $cr = wfMsg( "currentrev" );
1297 if ( $oid && $this->lastline ) {
1298 $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->makeKnownLink(
1299 $artname, $last, "diff=\\1&oldid={$oid}" ), $this->lastline );
1300 } else {
1301 $ret = "";
1303 $dt = $wgLang->timeanddate( $ts, true );
1305 if ( $oid ) { $q = "oldid={$oid}"; }
1306 else { $q = ""; }
1307 $link = $this->makeKnownLink( $artname, $dt, $q );
1309 if ( 0 == $u ) {
1310 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1311 $ut, "target=" . $ut );
1312 } else { $ul = $this->makeLink( $wgLang->getNsText(
1313 Namespace::getUser() ) . ":{$ut}", $ut ); }
1315 $s = "<li>";
1316 if ( $oid ) {
1317 $curlink = $this->makeKnownLink( $artname, $cur,
1318 "diff=0&oldid={$oid}" );
1319 } else {
1320 $curlink = $cur;
1322 $s .= "({$curlink}) (!OLDID!{$oid}!) . .";
1324 $M = wfMsg( "minoreditletter" );
1325 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1326 $s .= " {$link} . . {$ul}";
1328 if ( "" != $c && "*" != $c ) { $s .= " <em>(" . wfEscapeHTML($c) . ")</em>"; }
1329 $s .= "</li>\n";
1331 $this->lastline = $s;
1332 return $ret;
1335 function recentChangesBlockLine ( $y ) {
1336 global $wgUploadPath ;
1338 $M = wfMsg( "minoreditletter" );
1339 $N = wfMsg( "newpageletter" );
1340 $r = "" ;
1341 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;
1342 $r .= "<tt>" ;
1343 if ( $y->isnew ) $r .= $N ;
1344 else $r .= "&nbsp;" ;
1345 if ( $y->isminor ) $r .= $M ;
1346 else $r .= "&nbsp;" ;
1347 $r .= " ".$y->timestamp." " ;
1348 $r .= "</tt>" ;
1349 $link = $y->link ;
1350 if ( $y->watched ) $link = "<strong>{$link}</strong>" ;
1351 $r .= $link ;
1353 $r .= " (" ;
1354 $r .= $y->curlink ;
1355 $r .= "; " ;
1356 $r .= $this->makeKnownLink( $y->secureName, wfMsg( "hist" ), "action=history" );
1358 $r .= ") . . ".$y->userlink ;
1359 $r .= $y->usertalklink ;
1360 if ( $y->usercomment != "" )
1361 $r .= " <em>(".wfEscapeHTML($y->usercomment).")</em>" ;
1362 $r .= "<br>\n" ;
1363 return $r ;
1366 function recentChangesBlockGroup ( $y ) {
1367 global $wgUploadPath ;
1369 $r = "" ;
1370 $M = wfMsg( "minoreditletter" );
1371 $N = wfMsg( "newpageletter" );
1372 $isnew = false ;
1373 $userlinks = array () ;
1374 foreach ( $y AS $x ) {
1375 $oldid = $x->diffid ;
1376 if ( $x->isnew ) $isnew = true ;
1377 $u = $x->userlink ;
1378 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1379 $userlinks[$u]++ ;
1382 krsort ( $userlinks ) ;
1383 asort ( $userlinks ) ;
1384 $users = array () ;
1385 $u = array_keys ( $userlinks ) ;
1386 foreach ( $u as $x ) {
1387 $z = $x ;
1388 if ( $userlinks[$x] > 1 ) $z .= " ({$userlinks[$x]}&times;)" ;
1389 array_push ( $users , $z ) ;
1391 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1393 $e = $y ;
1394 $e = array_shift ( $e ) ;
1396 # Arrow
1397 $rci = "RCI{$this->rccc}" ;
1398 $rcl = "RCL{$this->rccc}" ;
1399 $rcm = "RCM{$this->rccc}" ;
1400 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1401 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1402 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1403 $tl .= "</a>" ;
1404 $r .= $tl ;
1406 # Main line
1407 $r .= "<tt>" ;
1408 if ( $isnew ) $r .= $N ;
1409 else $r .= "&nbsp;" ;
1410 $r .= "&nbsp;" ; # Minor
1411 $r .= " ".$e->timestamp." " ;
1412 $r .= "</tt>" ;
1414 $link = $e->link ;
1415 if ( $e->watched ) $link = "<strong>{$link}</strong>" ;
1416 $r .= $link ;
1418 if ( !$e->islog ) {
1419 $r .= " (".count($y)." " ;
1420 if ( $isnew ) $r .= wfMsg("changes");
1421 else $r .= $this->makeKnownLink( $e->secureName , wfMsg("changes") , "diff=0&oldid=".$oldid ) ;
1422 $r .= "; " ;
1423 $r .= $this->makeKnownLink( $e->secureName, wfMsg( "history" ), "action=history" );
1424 $r .= ")" ;
1427 $r .= $users ;
1428 $r .= "<br>\n" ;
1430 # Sub-entries
1431 $r .= "<div id='{$rci}' style='display:none'>" ;
1432 foreach ( $y AS $x )
1434 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1435 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
1436 if ( $x->isnew ) $r .= $N ;
1437 else $r .= "&nbsp;" ;
1438 if ( $x->isminor ) $r .= $M ;
1439 else $r .= "&nbsp;" ;
1440 $r .= "</tt>" ;
1442 $o = "" ;
1443 if ( $x->oldid != 0 ) $o = "oldid=".$x->oldid ;
1444 if ( $x->islog ) $link = $x->timestamp ;
1445 else $link = $this->makeKnownLink( $x->secureName, $x->timestamp , $o ) ;
1446 $link = "<tt>{$link}</tt>" ;
1449 $r .= $link ;
1450 $r .= " (" ;
1451 $r .= $x->curlink ;
1452 $r .= "; " ;
1453 $r .= $x->lastlink ;
1454 $r .= ") . . ".$x->userlink ;
1455 $r .= $x->usertalklink ;
1456 if ( $x->usercomment != "" )
1457 $r .= " <em>(".wfEscapeHTML($x->usercomment).")</em>" ;
1458 $r .= "<br>\n" ;
1460 $r .= "</div>\n" ;
1462 $this->rccc++ ;
1463 return $r ;
1466 function recentChangesBlock ()
1468 global $wgUploadPath ;
1469 if ( count ( $this->rc_cache ) == 0 ) return "" ;
1470 $k = array_keys ( $this->rc_cache ) ;
1471 foreach ( $k AS $x )
1473 $y = $this->rc_cache[$x] ;
1474 if ( count ( $y ) < 2 ) {
1475 $r .= $this->recentChangesBlockLine ( array_shift ( $y ) ) ;
1476 } else {
1477 $r .= $this->recentChangesBlockGroup ( $y ) ;
1481 return "<div align=left>{$r}</div>" ;
1484 function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1486 global $wgUser ;
1487 $usenew = $wgUser->getOption( "usenewrc" );
1488 if ( $usenew )
1489 $r = $this->recentChangesLineNew ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1490 else
1491 $r = $this->recentChangesLineOld ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1492 return $r ;
1495 function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 )
1497 global $wgTitle, $wgLang, $wgUser;
1499 $d = $wgLang->date( $ts, true);
1500 $s = "";
1501 if ( $d != $this->lastdate ) {
1502 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
1503 $s .= "<h4>{$d}</h4>\n<ul>";
1504 $this->lastdate = $d;
1506 $h = $wgLang->time( $ts, true );
1507 $t = Title::makeName( $ns, $ttl );
1508 $clink = $this->makeKnownLink( $t , "" );
1509 $nt = Title::newFromText( $t );
1511 if ( $watched ) {
1512 $clink = "<strong>{$clink}</strong>";
1514 $hlink = $this->makeKnownLink( $t, wfMsg( "hist" ), "action=history" );
1515 if ( $isnew || $nt->isLog() ) {
1516 $dlink = wfMsg( "diff" );
1517 } else {
1518 $dlink = $this->makeKnownLink( $t, wfMsg( "diff" ),
1519 "diff={$oldid}&oldid={$diffid}" ); # Finagle's law
1521 if ( 0 == $u ) {
1522 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1523 $ut, "target=" . $ut );
1524 } else { $ul = $this->makeLink( $wgLang->getNsText(
1525 Namespace::getUser() ) . ":{$ut}", $ut ); }
1527 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1528 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1529 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1530 $cr = wfMsg( "currentrev" );
1532 $s .= "<li> ({$dlink}) ({$hlink}) . .";
1533 $M = wfMsg( "minoreditletter" );
1534 $N = wfMsg( "newpageletter" );
1535 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1536 if ( $isnew ) { $s .= "<strong>{$N}</strong>"; }
1537 $s .= " {$clink}; {$h} . . {$ul}";
1539 $blink="";
1540 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1541 $blink = $this->makeKnownLink( $wgLang->specialPage(
1542 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1545 if(!$blink) {
1546 $utl = "({$utl})";
1547 } else {
1548 $utl = "({$utl} | {$blink})";
1550 $s.=" {$utl}";
1552 if ( "" != $c && "*" != $c ) {
1553 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1555 $s .= "</li>\n";
1557 return $s;
1560 function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1562 global $wgTitle, $wgLang, $wgUser;
1564 $rc = new RecentChangesClass ;
1566 $d = $wgLang->date( $ts, true);
1567 $s = "";
1568 $ret = "" ;
1569 if ( $d != $this->lastdate ) {
1570 $ret = $this->recentChangesBlock () ;
1571 $this->rc_cache = array() ;
1572 $ret .= "<h4>{$d}</h4>\n";
1573 $this->lastdate = $d;
1575 $h = $wgLang->time( $ts, true );
1576 $t = Title::makeName( $ns, $ttl );
1577 $clink = $this->makeKnownLink( $t, "" ) ;
1578 if ( $oldid == 0 ) $c2link = $clink ;
1579 else $c2link = $this->makeKnownLink( $t, "" , "oldid={$oldid}" );
1580 $nt = Title::newFromText( $t );
1582 $rc->timestamp = $h ;
1583 $rc->oldid = $oldid ;
1584 $rc->diffid = $diffid ;
1585 $rc->watched = $watched ;
1586 $rc->isnew = $isnew ;
1587 $rc->isminor = $isminor ;
1588 $rc->secureName = $t ;
1589 $rc->displayName = $nt ;
1590 $rc->link = $clink ;
1591 $rc->usercomment = $c ;
1592 $rc->islog = $nt->isLog() ;
1594 if ( ( $isnew && $oldid == 0 ) || $nt->isLog() ) {
1595 $dlink = wfMsg( "cur" );
1596 } else {
1597 $dlink = $this->makeKnownLink( $t, wfMsg( "cur" ),
1598 "diff=0&oldid={$oldid}" );
1601 if ( $diffid == 0 || $nt->isLog() ) {
1602 $plink = wfMsg( "last" );
1603 } else {
1604 $plink = $this->makeKnownLink( $t, wfMsg( "last" ),
1605 "diff={$oldid}&oldid={$diffid}" );
1608 if ( 0 == $u ) {
1609 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1610 $ut, "target=" . $ut );
1611 } else { $ul = $this->makeLink( $wgLang->getNsText(
1612 Namespace::getUser() ) . ":{$ut}", $ut ); }
1614 $rc->userlink = $ul ;
1615 $rc->lastlink = $plink ;
1616 $rc->curlink = $dlink ;
1618 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1619 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1620 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1622 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1623 $blink = $this->makeKnownLink( $wgLang->specialPage(
1624 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1625 $rc->usertalklink= " ({$utl} | {$blink})";
1626 } else {
1627 $rc->usertalklink=" ({$utl})";
1630 if ( !isset ( $this->rc_cache[$t] ) ) $this->rc_cache[$t] = array() ;
1631 array_push ( $this->rc_cache[$t] , $rc ) ;
1632 return $ret;
1636 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
1638 global $wgUser, $wgLang, $wgTitle;
1640 $dt = $wgLang->timeanddate( $ts, true );
1641 $del = wfMsg( "deleteimg" );
1642 $cur = wfMsg( "cur" );
1644 if ( $iscur ) {
1645 $url = wfImageUrl( $img );
1646 $rlink = $cur;
1647 if ( $wgUser->isSysop() ) {
1648 $link = wfLocalUrlE( "", "image=" . $wgTitle->getURL() .
1649 "&action=delete" );
1650 $style = $this->getInternalLinkAttributes( $link, $del );
1652 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
1653 } else {
1654 $dlink = $del;
1656 } else {
1657 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
1658 if( $wgUser->getID() != 0 ) {
1659 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1660 wfMsg( "revertimg" ), "action=revert&oldimage=" .
1661 urlencode( $img ) );
1662 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1663 $del, "action=delete&oldimage=" . urlencode( $img ) );
1664 } else {
1665 # Having live active links for non-logged in users
1666 # means that bots and spiders crawling our site can
1667 # inadvertently change content. Baaaad idea.
1668 $rlink = wfMsg( "revertimg" );
1669 $dlink = $del;
1672 if ( 0 == $u ) { $ul = $ut; }
1673 else { $ul = $this->makeLink( $wgLang->getNsText(
1674 Namespace::getUser() ) . ":{$ut}", $ut ); }
1676 $nb = str_replace( "$1", $size, wfMsg( "nbytes" ) );
1677 $style = $this->getInternalLinkAttributes( $url, $dt );
1679 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
1680 . " . . {$ul} ({$nb})";
1682 if ( "" != $c && "*" != $c ) {
1683 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1685 $s .= "</li>\n";
1686 return $s;
1689 function tocIndent($level) {
1691 while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
1692 return $rv;
1696 function tocUnindent($level) {
1697 while($level-->0) $rv.="</div>\n";
1698 return $rv;
1701 // parameter level defines if we are on an indentation level
1702 function tocLine($anchor,$tocline,$level) {
1704 if($level) {
1706 return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
1707 } else {
1709 return "<div style=\"margin-bottom:0px;\">\n".
1710 "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
1711 "</div>\n";
1716 function tocTable($toc) {
1718 /* does not auto-expand, use table for now
1719 return "
1720 <div><div style=\"border-width:1px;background-color:#f3f3ff;border-color:#8888aa;border-style:solid;padding:1em;padding-bottom:1em;\">
1721 <b>".wfMsg("toc")."</b><P>
1722 $toc</div></div>";
1724 return
1725 "<table border=\"0\" bgcolor=\"#8888aa\" cellpadding=\"0\" cellspacing=\"1\"><tr><td>\n" .
1726 "<table border=\"0\" bgcolor=\"#f3f3ff\" CELLPADDING=5><tr><td>\n".
1727 "<b>".wfMsg("toc")."</b>" .
1728 " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>" .
1729 "</td></tr><tr id='tocinside'><td>\n".
1730 $toc."</td></tr></table></td></tr></table><P>\n";
1733 function editSectionLink($section) {
1735 global $wgTitle,$wgUser,$oldid;
1736 if($wgTitle->isProtected() && !$wgUser->isSysop()) return "";
1737 if($oldid) return "";
1738 $editurl="&section={$section}";
1739 $url=$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
1740 return "<div style=\"float:right;margin-left:5px;\"><small>[".$url."]</small></div>";
1745 include_once( "SkinStandard.php" );
1746 include_once( "SkinNostalgia.php" );
1747 include_once( "SkinCologneBlue.php" );