Some partial code updates to eo
[mediawiki.git] / includes / Skin.php
blob7938a57542fbcb1e948f77bb8eb40891c8b3a55d
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 $foc = "document.editform.wpTextbox1.focus()";
144 if($a['onload']) {
145 $a['onload'] .= ";$foc";
146 } else {
147 $a['onload'] = $foc;
150 return $a;
153 function getExternalLinkAttributes( $link, $text )
155 global $wgUser, $wgOut, $wgLang;
157 $link = urldecode( $link );
158 $link = $wgLang->checkTitleEncoding( $link );
159 $link = str_replace( "_", " ", $link );
160 $link = wfEscapeHTML( $link );
162 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
163 else { $r = " class='external'"; }
165 if ( 1 == $wgUser->getOption( "hover" ) ) {
166 $r .= " title=\"{$link}\"";
168 return $r;
171 function getInternalLinkAttributes( $link, $text, $broken = false )
173 global $wgUser, $wgOut;
175 $link = urldecode( $link );
176 $link = str_replace( "_", " ", $link );
177 $link = wfEscapeHTML( $link );
179 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
180 else if ( $broken == "stub" ) { $r = " class='stub'"; }
181 else if ( $broken == "yes" ) { $r = " class='new'"; }
182 else { $r = " class='internal'"; }
184 if ( 1 == $wgUser->getOption( "hover" ) ) {
185 $r .= " title=\"{$link}\"";
187 return $r;
190 function getLogo()
192 global $wgLogo;
193 return $wgLogo;
196 # This will be called immediately after the <body> tag. Split into
197 # two functions to make it easier to subclass.
199 function beforeContent()
201 global $wgUser, $wgOut;
203 if ( $wgOut->isPrintable() ) {
204 $s = $this->pageTitle() . $this->pageSubtitle() . "\n";
205 $s .= "\n<div class='bodytext'>";
206 return $s;
208 return $this->doBeforeContent();
211 function doBeforeContent()
213 global $wgUser, $wgOut, $wgTitle, $wgLang;
214 wfProfileIn( "Skin::doBeforeContent" );
216 $s = "";
217 $qb = $this->qbSetting();
219 if( $langlinks = $this->otherLanguages() ) {
220 $rows = 2;
221 $borderhack = "";
222 } else {
223 $rows = 1;
224 $langlinks = false;
225 $borderhack = "class='top'";
228 $s .= "\n<div id='content'>\n<div id='topbar'>" .
229 "<table width='98%' border=0 cellspacing=0><tr>";
231 $shove = ($qb != 0);
232 $left = ($qb == 1 || $qb == 3);
233 if($wgLang->isRTL()) $left = !$left;
235 if ( !$shove ) {
236 $s .= "<td class='top' align=left valign=top rowspan='{$rows}'>" .
237 $this->logoText() . "</td>";
238 } elseif( $left ) {
239 $s .= $this->getQuickbarCompensator( $rows );
241 $l = $wgLang->isRTL() ? "right" : "left";
242 $s .= "<td {$borderhack} align='$l' valign='top'>";
244 $s .= $this->topLinks() ;
245 $s .= "<p class='subtitle'>" . $this->pageTitleLinks();
247 $r = $wgLang->isRTL() ? "left" : "right";
248 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap>";
249 $s .= $this->nameAndLogin();
250 $s .= "\n<br>" . $this->searchForm() . "</td>";
252 if ( $langlinks ) {
253 $s .= "</tr>\n<tr><td class='top' colspan=\"2\">$langlinks</td>";
256 if ( $shove && !$left ) { # Right
257 $s .= $this->getQuickbarCompensator( $rows );
259 $s .= "</tr></table>\n</div>\n";
260 $s .= "\n<div id='article'>";
262 $s .= $this->pageTitle();
263 $s .= $this->pageSubtitle() ;
264 $s .= getCategories(); // For some odd reason, zhis can't be a function of the object
265 $s .= "\n<p>";
266 wfProfileOut();
267 return $s;
270 function getQuickbarCompensator( $rows = 1 )
272 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
275 # This gets called immediately before the </body> tag.
277 function afterContent()
279 global $wgUser, $wgOut, $wgServer, $HTTP_SERVER_VARS;
281 if ( $wgOut->isPrintable() ) {
282 $s = "\n</div>\n";
284 $u = $wgServer . $HTTP_SERVER_VARS['REQUEST_URI'];
285 $u = preg_replace( "/[?&]printable=yes/", "", $u );
286 $rf = str_replace( "$1", $u, wfMsg( "retrievedfrom" ) );
288 if ( $wgOut->isArticle() ) {
289 $lm = "<br>" . $this->lastModified();
290 } else { $lm = ""; }
292 $s .= "<p><em>{$rf}{$lm}</em>\n";
293 return $s;
295 return $this->doAfterContent();
298 function doAfterContent()
300 global $wgUser, $wgOut, $wgLang;
301 wfProfileIn( "Skin::doAfterContent" );
303 $s = "\n</div><br clear=all>\n";
305 $s .= "\n<div id='footer'>";
306 $s .= "<table width='98%' border=0 cellspacing=0><tr>";
308 $qb = $this->qbSetting();
309 $shove = ($qb != 0);
310 $left = ($qb == 1 || $qb == 3);
311 if($wgLang->isRTL()) $left = !$left;
313 if ( $shove && $left ) { # Left
314 $s .= $this->getQuickbarCompensator();
316 $l = $wgLang->isRTL() ? "right" : "left";
317 $s .= "<td class='bottom' align='$l' valign='top'>";
319 $s .= $this->bottomLinks();
320 $s .= "\n<br>" . $this->mainPageLink()
321 . " | " . $this->aboutLink()
322 . " | " . $this->specialLink( "recentchanges" )
323 . " | " . $this->searchForm()
324 . "<br>" . $this->pageStats();
326 $s .= "</td>";
327 if ( $shove && !$left ) { # Right
328 $s .= $this->getQuickbarCompensator();
330 $s .= "</tr></table>\n</div>\n</div>\n";
332 if ( 0 != $qb ) { $s .= $this->quickBar(); }
333 wfProfileOut();
334 return $s;
337 function pageTitleLinks()
339 global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang;
341 $s = $this->printableLink();
343 if ( $wgOut->isArticle() ) {
344 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
345 $name = $wgTitle->getDBkey();
346 $link = wfEscapeHTML( wfImageUrl( $name ) );
347 $style = $this->getInternalLinkAttributes( $link, $name );
348 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
351 if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
352 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
353 wfMsg( "currentrev" ) );
356 if ( $wgUser->getNewtalk() ) {
357 # do not show "You have new messages" text when we are viewing our
358 # own talk page
360 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
361 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
362 $n =$wgUser->getName();
363 $tl = $this->makeKnownLink( $wgLang->getNsText(
364 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
365 wfMsg("newmessageslink") );
366 $s.=" | <strong>". str_replace( "$1", $tl, wfMsg("newmessages") ) . "</strong>";
369 return $s;
372 function printableLink()
374 global $wgOut, $wgTitle, $oldid, $action;
376 if ( "history" == $action ) { $q = "action=history&"; }
377 else { $q = ""; }
379 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
380 WfMsg( "printableversion" ), "{$q}printable=yes" );
381 return $s;
384 function pageTitle()
386 global $wgOut, $wgTitle;
388 $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
389 return $s;
392 function pageSubtitle()
394 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
396 $sub = $wgOut->getSubtitle();
397 if ( "" == $sub ) { $sub = wfMsg( "fromwikipedia" ); }
398 if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
399 $ptext=$wgTitle->getPrefixedText();
400 if(preg_match("/\//",$ptext)) {
401 $sub.="</p><p class='subpages'>";
402 $links=explode("/",$ptext);
403 $c=0;
404 $growinglink="";
405 foreach($links as $link) {
406 $c++;
407 if ($c<count($links)) {
408 $growinglink.=$link;
409 $getlink=$this->makeLink($growinglink,$link);
410 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
411 if ($c>1) {
412 $sub .= " | ";
413 } else {
414 $sub .="&lt; ";
416 $sub .= $getlink;
417 $growinglink.="/";
423 $s = "<p class='subtitle'>{$sub}\n";
424 return $s;
427 function nameAndLogin()
429 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader;
431 $li = $wgLang->specialPage( "Userlogin" );
432 $lo = $wgLang->specialPage( "Userlogout" );
434 $s = "";
435 if ( 0 == $wgUser->getID() ) {
436 if( $wgShowIPinHeader ) {
437 $n = getenv( "REMOTE_ADDR" );
439 $tl = $this->makeKnownLink( $wgLang->getNsText(
440 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
441 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
443 $s .= $n . " (".$tl.")";
444 } else {
445 $s .= wfMsg("notloggedin");
448 $rt = $wgTitle->getPrefixedURL();
449 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
450 $q = "";
451 } else { $q = "returnto={$rt}"; }
453 $s .= "\n<br>" . $this->makeKnownLink( $li,
454 wfMsg( "login" ), $q );
455 } else {
456 $n = $wgUser->getName();
457 $rt = $wgTitle->getPrefixedURL();
458 $tl = $this->makeKnownLink( $wgLang->getNsText(
459 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
460 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
462 $tl = " ({$tl})";
464 $s .= $this->makeKnownLink( $wgLang->getNsText(
465 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
466 $this->makeKnownLink( $lo, wfMsg( "logout" ),
467 "returnto={$rt}" ) . " | " .
468 $this->specialLink( "preferences" );
470 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
471 wfMsg( "help" ) );
473 return $s;
476 function searchForm()
478 global $search;
480 $s = "<form name='search' class='inline' method=get action=\""
481 . wfLocalUrl( "" ) . "\">"
482 . "<input type=text name=\"search\" size=19 value=\""
483 . htmlspecialchars(substr($search,0,256)) . "\">\n"
484 . "<input type=submit name=\"go\" value=\"" . wfMsg ("go") . "\">&nbsp;"
485 . "<input type=submit value=\"" . wfMsg ("search") . "\"></form>";
487 return $s;
490 function topLinks()
492 global $wgOut;
493 $sep = " |\n";
495 $s = $this->mainPageLink() . $sep
496 . $this->specialLink( "recentchanges" );
498 if ( $wgOut->isArticle() ) {
499 $s .= $sep . $this->editThisPage()
500 . $sep . $this->historyLink();
502 $s .= $sep . $this->specialPagesList();
504 return $s;
507 function bottomLinks()
509 global $wgOut, $wgUser, $wgTitle;
510 $sep = " |\n";
512 $s = "";
513 if ( $wgOut->isArticle() ) {
514 $s .= "<strong>" . $this->editThisPage() . "</strong>";
515 if ( 0 != $wgUser->getID() ) {
516 $s .= $sep . $this->watchThisPage();
518 $s .= $sep . $this->talkLink()
519 . $sep . $this->historyLink()
520 . $sep . $this->whatLinksHere()
521 . $sep . $this->watchPageLinksLink();
523 if ( $wgTitle->getNamespace() == Namespace::getUser()
524 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
527 $id=User::idFromName($wgTitle->getText());
528 $ip=User::isIP($wgTitle->getText());
530 if($id || $ip) { # both anons and non-anons have contri list
531 $s .= $sep . $this->userContribsLink();
533 if ( 0 != $wgUser->getID() ) { # show only to signed in users
534 if($id) { # can only email non-anons
535 $s .= $sep . $this->emailUserLink();
539 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
540 $s .= "\n<br>" . $this->deleteThisPage() .
541 $sep . $this->protectThisPage() .
542 $sep . $this->moveThisPage();
544 $s .= "<br>\n" . $this->otherLanguages();
546 return $s;
549 function pageStats()
551 global $wgOut, $wgLang, $wgArticle;
552 global $oldid, $diff, $wgDisableCounters;
554 if ( ! $wgOut->isArticle() ) { return ""; }
555 if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
556 if ( 0 == $wgArticle->getID() ) { return ""; }
558 if ( $wgDisableCounters ) {
559 $s = "";
560 } else {
561 $count = $wgArticle->getCount();
562 $s = str_replace( "$1", $count, wfMsg( "viewcount" ) );
564 $s .= $this->lastModified();
565 $s .= " " . wfMsg( "gnunote" );
566 return "<span id='pagestats'>{$s}</span>";
569 function lastModified()
571 global $wgLang, $wgArticle;
573 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
574 $s = " " . str_replace( "$1", $d, wfMsg( "lastmodified" ) );
575 return $s;
578 function logoText( $align = "" )
580 if ( "" != $align ) { $a = " align='{$align}'"; }
581 else { $a = ""; }
583 $mp = wfMsg( "mainpage" );
584 $s = "<a href=\"" . wfLocalUrlE( $mp ) . "\"><img{$a} border=0 src=\""
585 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
586 return $s;
589 function quickBar()
591 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
592 global $wpPreview;
593 wfProfileIn( "Skin::quickBar" );
595 $s = "\n<div id='quickbar'>";
596 $s .= "\n" . $this->logoText() . "\n<hr>";
598 $sep = "\n<br>";
599 $s .= $this->mainPageLink()
600 . $sep . $this->specialLink( "recentchanges" )
601 . $sep . $this->specialLink( "randompage" );
602 if ($wgUser->getID()) {
603 $s.= $sep . $this->specialLink( "watchlist" ) ;
604 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
605 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
608 // only show watchlist link if logged in
609 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
610 $s .= "\n<hr>";
611 $articleExists = $wgTitle->getArticleId();
612 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
614 if($wgOut->isArticle()) {
615 $s .= "<strong>" . $this->editThisPage() . "</strong>";
616 } else { # backlink to the article in edit or history mode
618 if($articleExists){ # no backlink if no article
619 $tns=$wgTitle->getNamespace();
620 switch($tns) {
621 case 0:
622 $text = wfMsg("articlepage");
623 break;
624 case 1:
625 $text = wfMsg("viewtalkpage");
626 break;
627 case 2:
628 $text = wfMsg("userpage");
629 break;
630 case 3:
631 $text = wfMsg("viewtalkpage");
632 break;
633 case 4:
634 $text = wfMsg("wikipediapage");
635 break;
636 case 5:
637 $text = wfMsg("viewtalkpage");
638 break;
639 case 6:
640 $text = wfMsg("imagepage");
641 break;
642 case 7:
643 $text = wfMsg("viewtalkpage");
644 break;
645 default:
646 $text= wfMsg("articlepage");
649 $link = $wgTitle->getText();
650 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
651 $link = $nstext . ":" . $link ;
653 $s .= $this->makeLink($link, $text );
654 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
655 # we just throw in a "New page" text to tell the user that he's in edit mode,
656 # and to avoid messing with the separator that is prepended to the next item
657 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
663 watching could cause problems in edit mode:
664 if user edits article, then loads "watch this article" in background and then saves
665 article with "Watch this article" checkbox disabled, the article is transparently
666 unwatched. Therefore we do not show the "Watch this page" link in edit mode
668 if ( 0 != $wgUser->getID() && $articleExists) {
669 if($action!="edit" && $action!="history" &&
670 $action != "submit" )
671 {$s .= $sep . $this->watchThisPage(); }
672 if ( $wgTitle->userCanEdit() ) $s .= $sep . $this->moveThisPage();
674 if ( $wgUser->isSysop() and $articleExists ) {
675 $s .= $sep . $this->deleteThisPage() .
676 $sep . $this->protectThisPage();
678 $s .= $sep . $this->talkLink();
679 if ($articleExists && $action !="history") { $s .= $sep . $this->historyLink();}
680 $s.=$sep . $this->whatLinksHere();
682 if($wgOut->isArticle()) {
683 $s .= $sep . $this->watchPageLinksLink();
686 if ( Namespace::getUser() == $wgTitle->getNamespace()
687 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
690 $id=User::idFromName($wgTitle->getText());
691 $ip=User::isIP($wgTitle->getText());
693 if($id||$ip) {
694 $s .= $sep . $this->userContribsLink();
696 if ( 0 != $wgUser->getID() ) {
697 if($id) { # can only email real users
698 $s .= $sep . $this->emailUserLink();
702 $s .= "\n<hr>";
705 if ( 0 != $wgUser->getID() ) {
706 $s .= $this->specialLink( "upload" ) . $sep;
708 $s .= $this->specialLink( "specialpages" )
709 . $sep . $this->bugReportsLink();
711 $s .= "\n</div>\n";
712 wfProfileOut();
713 return $s;
716 function specialPagesList()
718 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
719 $a = array();
721 $validSP = $wgLang->getValidSpecialPages();
723 foreach ( $validSP as $name => $desc ) {
724 if ( "" == $desc ) { continue; }
725 $a[$name] = $desc;
727 if ( $wgUser->isSysop() )
729 $sysopSP = $wgLang->getSysopSpecialPages();
731 foreach ( $sysopSP as $name => $desc ) {
732 if ( "" == $desc ) { continue; }
733 $a[$name] = $desc ;
736 if ( $wgUser->isDeveloper() )
738 $devSP = $wgLang->getDeveloperSpecialPages();
740 foreach ( $devSP as $name => $desc ) {
741 if ( "" == $desc ) { continue; }
742 $a[$name] = $desc ;
745 $go = wfMsg( "go" );
746 $sp = wfMsg( "specialpages" );
747 $spp = $wgLang->specialPage( "Specialpages" );
749 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
750 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
751 $s .= "<select name=\"wpDropdown\">\n";
752 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
754 foreach ( $a as $name => $desc ) {
755 $p = $wgLang->specialPage( $name );
756 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
758 $s .= "</select>\n";
759 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
760 $s .= "</form>\n";
761 return $s;
764 function mainPageLink()
766 $mp = wfMsg( "mainpage" );
767 $s = $this->makeKnownLink( $mp, $mp );
768 return $s;
771 function copyrightLink()
773 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
774 wfMsg( "copyrightpagename" ) );
775 return $s;
778 function aboutLink()
780 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
781 wfMsg( "aboutwikipedia" ) );
782 return $s;
785 function editThisPage()
787 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
789 if ( ! $wgOut->isArticle() || $diff ) {
790 $s = wfMsg( "protectedpage" );
791 } else if ( $wgTitle->userCanEdit() ) {
792 $n = $wgTitle->getPrefixedText();
793 $t = wfMsg( "editthispage" );
794 $oid = $red = "";
796 if ( $redirect ) { $red = "&redirect={$redirect}"; }
797 if ( $oldid && ! isset( $diff ) ) {
798 $oid = "&oldid={$oldid}";
800 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
801 } else {
802 $s = wfMsg( "protectedpage" );
804 return $s;
807 function deleteThisPage()
809 global $wgUser, $wgOut, $wgTitle, $diff;
811 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
812 $n = $wgTitle->getPrefixedText();
813 $t = wfMsg( "deletethispage" );
815 $s = $this->makeKnownLink( $n, $t, "action=delete" );
816 } else {
817 $s = wfMsg( "error" );
819 return $s;
822 function protectThisPage()
824 global $wgUser, $wgOut, $wgTitle, $diff;
826 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
827 $n = $wgTitle->getPrefixedText();
829 if ( $wgTitle->isProtected() ) {
830 $t = wfMsg( "unprotectthispage" );
831 $q = "action=unprotect";
832 } else {
833 $t = wfMsg( "protectthispage" );
834 $q = "action=protect";
836 $s = $this->makeKnownLink( $n, $t, $q );
837 } else {
838 $s = wfMsg( "error" );
840 return $s;
843 function watchThisPage()
845 global $wgUser, $wgOut, $wgTitle, $diff;
847 if ( $wgOut->isArticle() && ( ! $diff ) ) {
848 $n = $wgTitle->getPrefixedText();
850 if ( $wgTitle->userIsWatching() ) {
851 $t = wfMsg( "unwatchthispage" );
852 $q = "action=unwatch";
853 } else {
854 $t = wfMsg( "watchthispage" );
855 $q = "action=watch";
857 $s = $this->makeKnownLink( $n, $t, $q );
858 } else {
859 $s = wfMsg( "notanarticle" );
861 return $s;
864 function moveThisPage()
866 global $wgTitle, $wgLang;
868 if ( $wgTitle->userCanEdit() ) {
869 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
870 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
871 } // no message if page is protected - would be redundant
872 return $s;
875 function historyLink()
877 global $wgTitle;
879 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
880 wfMsg( "history" ), "action=history" );
881 return $s;
884 function whatLinksHere()
886 global $wgTitle, $wgLang;
888 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
889 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
890 return $s;
893 function userContribsLink()
895 global $wgTitle, $wgLang;
897 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
898 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
899 return $s;
902 function emailUserLink()
904 global $wgTitle, $wgLang;
906 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
907 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
908 return $s;
911 function watchPageLinksLink()
913 global $wgOut, $wgTitle, $wgLang;
915 if ( ! $wgOut->isArticle() ) {
916 $s = "(" . wfMsg( "notanarticle" ) . ")";
917 } else {
918 $s = $this->makeKnownLink( $wgLang->specialPage(
919 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
920 "target=" . $wgTitle->getPrefixedURL() );
922 return $s;
925 function otherLanguages()
927 global $wgOut, $wgLang, $wgTitle , $wgUseNewInterlanguage ;
929 $a = $wgOut->getLanguageLinks();
930 if ( 0 == count( $a ) ) {
931 if ( !$wgUseNewInterlanguage ) return "";
932 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
933 if ( $ns != 0 AND $ns != 1 ) return "" ;
934 $pn = "Intl" ;
935 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
936 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
937 wfMsg( "intl" ) , $x );
940 if ( !$wgUseNewInterlanguage ) {
941 $s = wfMsg( "otherlanguages" ) . ": ";
942 } else {
943 global $wgLanguageCode ;
944 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
945 $x .= "&xl=".$wgLanguageCode ;
946 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
947 wfMsg( "otherlanguages" ) , $x ) . ": " ;
950 $first = true;
951 foreach( $a as $l ) {
952 if ( ! $first ) { $s .= " | "; }
953 $first = false;
955 $nt = Title::newFromText( $l );
956 $url = $nt->getFullURL();
957 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
959 if ( "" == $text ) { $text = $l; }
960 $style = $this->getExternalLinkAttributes( $l, $text );
961 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
963 return $s;
966 function bugReportsLink()
968 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
969 wfMsg( "bugreports" ) );
970 return $s;
973 function dateLink()
975 global $wgLinkCache;
976 $t1 = Title::newFromText( gmdate( "F j" ) );
977 $t2 = Title::newFromText( gmdate( "Y" ) );
979 $wgLinkCache->suspend();
980 $id = $t1->getArticleID();
981 $wgLinkCache->resume();
983 if ( 0 == $id ) {
984 $s = $this->makeBrokenLink( $t1->getText() );
985 } else {
986 $s = $this->makeKnownLink( $t1->getText() );
988 $s .= ", ";
990 $wgLinkCache->suspend();
991 $id = $t2->getArticleID();
992 $wgLinkCache->resume();
994 if ( 0 == $id ) {
995 $s .= $this->makeBrokenLink( $t2->getText() );
996 } else {
997 $s .= $this->makeKnownLink( $t2->getText() );
999 return $s;
1002 function talkLink()
1004 global $wgLang, $wgTitle, $wgLinkCache;
1006 $tns = $wgTitle->getNamespace();
1007 if ( -1 == $tns ) { return ""; }
1009 $pn = $wgTitle->getText();
1010 $tp = wfMsg( "talkpage" );
1011 if ( Namespace::isTalk( $tns ) ) {
1012 $lns = Namespace::getSubject( $tns );
1013 switch($tns) {
1014 case 1:
1015 $text = wfMsg("articlepage");
1016 break;
1017 case 3:
1018 $text = wfMsg("userpage");
1019 break;
1020 case 5:
1021 $text = wfMsg("wikipediapage");
1022 break;
1023 case 7:
1024 $text = wfMsg("imagepage");
1025 break;
1026 default:
1027 $text= wfMsg("articlepage");
1029 } else {
1031 $lns = Namespace::getTalk( $tns );
1032 $text=$tp;
1034 $n = $wgLang->getNsText( $lns );
1035 if ( "" == $n ) { $link = $pn; }
1036 else { $link = "{$n}:{$pn}"; }
1038 $wgLinkCache->suspend();
1039 $s = $this->makeLink( $link, $text );
1040 $wgLinkCache->resume();
1042 return $s;
1045 # After all the page content is transformed into HTML, it makes
1046 # a final pass through here for things like table backgrounds.
1048 function transformContent( $text )
1050 return $text;
1053 # Note: This function MUST call getArticleID() on the link,
1054 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1056 function makeLink( $title, $text= "", $query = "", $trail = "" )
1058 global $wgOut, $wgUser;
1060 $nt = Title::newFromText( $title );
1062 if ( $nt->isExternal() ) {
1063 $u = $nt->getFullURL();
1064 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1065 $style = $this->getExternalLinkAttributes( $link, $text );
1067 $inside = "";
1068 if ( "" != $trail ) {
1069 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1070 $inside = $m[1];
1071 $trail = $m[2];
1074 return "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1076 if ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1077 return $this->makeKnownLink( $title, $text, $query, $trail );
1079 if ( ( -1 == $nt->getNamespace() ) ||
1080 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1081 return $this->makeKnownLink( $title, $text, $query, $trail );
1083 $aid = $nt->getArticleID() ;
1084 if ( 0 == $aid ) {
1085 return $this->makeBrokenLink( $title, $text, $query, $trail );
1086 } else {
1087 $threshold = $wgUser->getOption("stubthreshold") ;
1088 if ( $threshold > 0 ) {
1089 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'" ) ;
1091 if ( wfNumRows( $res ) > 0 ) {
1092 $s = wfFetchObject( $res );
1093 $size = $s->x;
1094 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
1095 $size = $threshold*2 ; # Really big
1096 wfFreeResult( $res );
1097 } else $size = $threshold*2 ; # Really big
1098 } else $size = 1 ;
1100 if ( $size < $threshold )
1101 return $this->makeStubLink( $title, $text, $query, $trail );
1102 return $this->makeKnownLink( $title, $text, $query, $trail );
1106 function makeKnownLink( $title, $text = "", $query = "", $trail = "" )
1108 global $wgOut, $wgTitle;
1110 $nt = Title::newFromText( $title );
1111 $link = $nt->getPrefixedURL();
1113 if ( "" == $link ) {
1114 $u = "";
1115 if ( "" == $text ) { $text = $nt->getFragment(); }
1116 } else {
1117 $u = wfLocalUrlE( $link, $query );
1119 if ( "" != $nt->getFragment() ) {
1120 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1122 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1123 $style = $this->getInternalLinkAttributes( $link, $text );
1125 $inside = "";
1126 if ( "" != $trail ) {
1127 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1128 $inside = $m[1];
1129 $trail = $m[2];
1132 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1133 return $r;
1136 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" )
1138 global $wgOut, $wgUser;
1140 $nt = Title::newFromText( $title );
1141 $link = $nt->getPrefixedURL();
1143 if ( "" == $query ) { $q = "action=edit"; }
1144 else { $q = "action=edit&{$query}"; }
1145 $u = wfLocalUrlE( $link, $q );
1147 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1148 $style = $this->getInternalLinkAttributes( $link, $text, "yes" );
1150 $inside = "";
1151 if ( "" != $trail ) {
1152 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1153 $inside = $m[1];
1154 $trail = $m[2];
1157 if ( $wgOut->isPrintable() ||
1158 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1159 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1160 } else {
1161 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1163 return $s;
1166 function makeStubLink( $title, $text = "", $query = "", $trail = "" )
1168 global $wgOut, $wgUser;
1170 $nt = Title::newFromText( $title );
1171 $link = $nt->getPrefixedURL();
1173 $u = wfLocalUrlE( $link, $query );
1175 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1176 $style = $this->getInternalLinkAttributes( $link, $text, "stub" );
1178 $inside = "";
1179 if ( "" != $trail ) {
1180 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1181 $inside = $m[1];
1182 $trail = $m[2];
1185 if ( $wgOut->isPrintable() ||
1186 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1187 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1188 } else {
1189 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1191 return $s;
1194 function fnamePart( $url )
1196 $basename = strrchr( $url, "/" );
1197 if ( false === $basename ) { $basename = $url; }
1198 else { $basename = substr( $basename, 1 ); }
1199 return wfEscapeHTML( $basename );
1202 function makeImage( $url, $alt = "" )
1204 global $wgOut;
1206 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1207 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1208 return $s;
1211 function makeImageLink( $name, $url, $alt = "" )
1213 global $wgOut, $wgTitle, $wgLang;
1215 $nt = Title::newFromText( $wgLang->getNsText(
1216 Namespace::getImage() ) . ":{$name}" );
1217 $link = $nt->getPrefixedURL();
1218 if ( "" == $alt ) { $alt = $name; }
1220 $u = wfLocalUrlE( $link );
1221 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1222 "<img border=0 src=\"{$url}\" alt=\"{$alt}\"></a>";
1223 return $s;
1226 function makeMediaLink( $name, $url, $alt = "" )
1228 global $wgOut, $wgTitle;
1230 if ( "" == $alt ) { $alt = $name; }
1231 $u = wfEscapeHTML( $url );
1232 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1233 return $s;
1236 function specialLink( $name, $key = "" )
1238 global $wgLang;
1240 if ( "" == $key ) { $key = strtolower( $name ); }
1241 $pn = $wgLang->ucfirst( $name );
1242 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1243 wfMsg( $key ) );
1246 # Called by history lists and recent changes
1249 function beginRecentChangesList()
1251 $rc_cache = array() ;
1252 $rccc = 0 ;
1253 $this->lastdate = "";
1254 return "";
1257 function beginHistoryList()
1259 $this->lastdate = $this->lastline = "";
1260 $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
1261 return $s;
1264 function beginImageHistoryList()
1266 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1267 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1268 return $s;
1271 function endRecentChangesList()
1273 $s = $this->recentChangesBlock() ;
1274 $s .= "</ul>\n";
1275 return $s;
1278 function endHistoryList()
1280 $last = wfMsg( "last" );
1282 $s = preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
1283 $s .= "</ul>\n";
1284 return $s;
1287 function endImageHistoryList()
1289 $s = "</ul>\n";
1290 return $s;
1293 function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor )
1295 global $wgLang;
1297 $artname = Title::makeName( $ns, $ttl );
1298 $last = wfMsg( "last" );
1299 $cur = wfMsg( "cur" );
1300 $cr = wfMsg( "currentrev" );
1302 if ( $oid && $this->lastline ) {
1303 $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->makeKnownLink(
1304 $artname, $last, "diff=\\1&oldid={$oid}" ), $this->lastline );
1305 } else {
1306 $ret = "";
1308 $dt = $wgLang->timeanddate( $ts, true );
1310 if ( $oid ) { $q = "oldid={$oid}"; }
1311 else { $q = ""; }
1312 $link = $this->makeKnownLink( $artname, $dt, $q );
1314 if ( 0 == $u ) {
1315 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1316 $ut, "target=" . $ut );
1317 } else { $ul = $this->makeLink( $wgLang->getNsText(
1318 Namespace::getUser() ) . ":{$ut}", $ut ); }
1320 $s = "<li>";
1321 if ( $oid ) {
1322 $curlink = $this->makeKnownLink( $artname, $cur,
1323 "diff=0&oldid={$oid}" );
1324 } else {
1325 $curlink = $cur;
1327 $s .= "({$curlink}) (!OLDID!{$oid}!) . .";
1329 $M = wfMsg( "minoreditletter" );
1330 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1331 $s .= " {$link} . . {$ul}";
1333 if ( "" != $c && "*" != $c ) { $s .= " <em>(" . wfEscapeHTML($c) . ")</em>"; }
1334 $s .= "</li>\n";
1336 $this->lastline = $s;
1337 return $ret;
1340 function recentChangesBlockLine ( $y ) {
1341 global $wgUploadPath ;
1343 $M = wfMsg( "minoreditletter" );
1344 $N = wfMsg( "newpageletter" );
1345 $r = "" ;
1346 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;
1347 $r .= "<tt>" ;
1348 if ( $y->isnew ) $r .= $N ;
1349 else $r .= "&nbsp;" ;
1350 if ( $y->isminor ) $r .= $M ;
1351 else $r .= "&nbsp;" ;
1352 $r .= " ".$y->timestamp." " ;
1353 $r .= "</tt>" ;
1354 $link = $y->link ;
1355 if ( $y->watched ) $link = "<strong>{$link}</strong>" ;
1356 $r .= $link ;
1358 $r .= " (" ;
1359 $r .= $y->curlink ;
1360 $r .= "; " ;
1361 $r .= $this->makeKnownLink( $y->secureName, wfMsg( "hist" ), "action=history" );
1363 $r .= ") . . ".$y->userlink ;
1364 $r .= $y->usertalklink ;
1365 if ( $y->usercomment != "" )
1366 $r .= " <em>(".wfEscapeHTML($y->usercomment).")</em>" ;
1367 $r .= "<br>\n" ;
1368 return $r ;
1371 function recentChangesBlockGroup ( $y ) {
1372 global $wgUploadPath ;
1374 $r = "" ;
1375 $M = wfMsg( "minoreditletter" );
1376 $N = wfMsg( "newpageletter" );
1377 $isnew = false ;
1378 $userlinks = array () ;
1379 foreach ( $y AS $x ) {
1380 $oldid = $x->diffid ;
1381 if ( $x->isnew ) $isnew = true ;
1382 $u = $x->userlink ;
1383 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1384 $userlinks[$u]++ ;
1387 krsort ( $userlinks ) ;
1388 asort ( $userlinks ) ;
1389 $users = array () ;
1390 $u = array_keys ( $userlinks ) ;
1391 foreach ( $u as $x ) {
1392 $z = $x ;
1393 if ( $userlinks[$x] > 1 ) $z .= " ({$userlinks[$x]}&times;)" ;
1394 array_push ( $users , $z ) ;
1396 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1398 $e = $y ;
1399 $e = array_shift ( $e ) ;
1401 # Arrow
1402 $rci = "RCI{$this->rccc}" ;
1403 $rcl = "RCL{$this->rccc}" ;
1404 $rcm = "RCM{$this->rccc}" ;
1405 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1406 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1407 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1408 $tl .= "</a>" ;
1409 $r .= $tl ;
1411 # Main line
1412 $r .= "<tt>" ;
1413 if ( $isnew ) $r .= $N ;
1414 else $r .= "&nbsp;" ;
1415 $r .= "&nbsp;" ; # Minor
1416 $r .= " ".$e->timestamp." " ;
1417 $r .= "</tt>" ;
1419 $link = $e->link ;
1420 if ( $e->watched ) $link = "<strong>{$link}</strong>" ;
1421 $r .= $link ;
1423 if ( !$e->islog ) {
1424 $r .= " (".count($y)." " ;
1425 if ( $isnew ) $r .= wfMsg("changes");
1426 else $r .= $this->makeKnownLink( $e->secureName , wfMsg("changes") , "diff=0&oldid=".$oldid ) ;
1427 $r .= "; " ;
1428 $r .= $this->makeKnownLink( $e->secureName, wfMsg( "history" ), "action=history" );
1429 $r .= ")" ;
1432 $r .= $users ;
1433 $r .= "<br>\n" ;
1435 # Sub-entries
1436 $r .= "<div id='{$rci}' style='display:none'>" ;
1437 foreach ( $y AS $x )
1439 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1440 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
1441 if ( $x->isnew ) $r .= $N ;
1442 else $r .= "&nbsp;" ;
1443 if ( $x->isminor ) $r .= $M ;
1444 else $r .= "&nbsp;" ;
1445 $r .= "</tt>" ;
1447 $o = "" ;
1448 if ( $x->oldid != 0 ) $o = "oldid=".$x->oldid ;
1449 if ( $x->islog ) $link = $x->timestamp ;
1450 else $link = $this->makeKnownLink( $x->secureName, $x->timestamp , $o ) ;
1451 $link = "<tt>{$link}</tt>" ;
1454 $r .= $link ;
1455 $r .= " (" ;
1456 $r .= $x->curlink ;
1457 $r .= "; " ;
1458 $r .= $x->lastlink ;
1459 $r .= ") . . ".$x->userlink ;
1460 $r .= $x->usertalklink ;
1461 if ( $x->usercomment != "" )
1462 $r .= " <em>(".wfEscapeHTML($x->usercomment).")</em>" ;
1463 $r .= "<br>\n" ;
1465 $r .= "</div>\n" ;
1467 $this->rccc++ ;
1468 return $r ;
1471 function recentChangesBlock ()
1473 global $wgUploadPath ;
1474 if ( count ( $this->rc_cache ) == 0 ) return "" ;
1475 $k = array_keys ( $this->rc_cache ) ;
1476 foreach ( $k AS $x )
1478 $y = $this->rc_cache[$x] ;
1479 if ( count ( $y ) < 2 ) {
1480 $r .= $this->recentChangesBlockLine ( array_shift ( $y ) ) ;
1481 } else {
1482 $r .= $this->recentChangesBlockGroup ( $y ) ;
1486 return "<div align=left>{$r}</div>" ;
1489 function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1491 global $wgUser ;
1492 $usenew = $wgUser->getOption( "usenewrc" );
1493 if ( $usenew )
1494 $r = $this->recentChangesLineNew ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1495 else
1496 $r = $this->recentChangesLineOld ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1497 return $r ;
1500 function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 )
1502 global $wgTitle, $wgLang, $wgUser;
1504 $d = $wgLang->date( $ts, true);
1505 $s = "";
1506 if ( $d != $this->lastdate ) {
1507 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
1508 $s .= "<h4>{$d}</h4>\n<ul>";
1509 $this->lastdate = $d;
1511 $h = $wgLang->time( $ts, true );
1512 $t = Title::makeName( $ns, $ttl );
1513 $clink = $this->makeKnownLink( $t , "" );
1514 $nt = Title::newFromText( $t );
1516 if ( $watched ) {
1517 $clink = "<strong>{$clink}</strong>";
1519 $hlink = $this->makeKnownLink( $t, wfMsg( "hist" ), "action=history" );
1520 if ( $isnew || $nt->isLog() ) {
1521 $dlink = wfMsg( "diff" );
1522 } else {
1523 $dlink = $this->makeKnownLink( $t, wfMsg( "diff" ),
1524 "diff={$oldid}&oldid={$diffid}" ); # Finagle's law
1526 if ( 0 == $u ) {
1527 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1528 $ut, "target=" . $ut );
1529 } else { $ul = $this->makeLink( $wgLang->getNsText(
1530 Namespace::getUser() ) . ":{$ut}", $ut ); }
1532 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1533 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1534 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1535 $cr = wfMsg( "currentrev" );
1537 $s .= "<li> ({$dlink}) ({$hlink}) . .";
1538 $M = wfMsg( "minoreditletter" );
1539 $N = wfMsg( "newpageletter" );
1540 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1541 if ( $isnew ) { $s .= "<strong>{$N}</strong>"; }
1542 $s .= " {$clink}; {$h} . . {$ul}";
1544 $blink="";
1545 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1546 $blink = $this->makeKnownLink( $wgLang->specialPage(
1547 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1550 if(!$blink) {
1551 $utl = "({$utl})";
1552 } else {
1553 $utl = "({$utl} | {$blink})";
1555 $s.=" {$utl}";
1557 if ( "" != $c && "*" != $c ) {
1558 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1560 $s .= "</li>\n";
1562 return $s;
1565 function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1567 global $wgTitle, $wgLang, $wgUser;
1569 $rc = new RecentChangesClass ;
1571 $d = $wgLang->date( $ts, true);
1572 $s = "";
1573 $ret = "" ;
1574 if ( $d != $this->lastdate ) {
1575 $ret = $this->recentChangesBlock () ;
1576 $this->rc_cache = array() ;
1577 $ret .= "<h4>{$d}</h4>\n";
1578 $this->lastdate = $d;
1580 $h = $wgLang->time( $ts, true );
1581 $t = Title::makeName( $ns, $ttl );
1582 $clink = $this->makeKnownLink( $t, "" ) ;
1583 if ( $oldid == 0 ) $c2link = $clink ;
1584 else $c2link = $this->makeKnownLink( $t, "" , "oldid={$oldid}" );
1585 $nt = Title::newFromText( $t );
1587 $rc->timestamp = $h ;
1588 $rc->oldid = $oldid ;
1589 $rc->diffid = $diffid ;
1590 $rc->watched = $watched ;
1591 $rc->isnew = $isnew ;
1592 $rc->isminor = $isminor ;
1593 $rc->secureName = $t ;
1594 $rc->displayName = $nt ;
1595 $rc->link = $clink ;
1596 $rc->usercomment = $c ;
1597 $rc->islog = $nt->isLog() ;
1599 if ( ( $isnew && $oldid == 0 ) || $nt->isLog() ) {
1600 $dlink = wfMsg( "cur" );
1601 } else {
1602 $dlink = $this->makeKnownLink( $t, wfMsg( "cur" ),
1603 "diff=0&oldid={$oldid}" );
1606 if ( $diffid == 0 || $nt->isLog() ) {
1607 $plink = wfMsg( "last" );
1608 } else {
1609 $plink = $this->makeKnownLink( $t, wfMsg( "last" ),
1610 "diff={$oldid}&oldid={$diffid}" );
1613 if ( 0 == $u ) {
1614 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1615 $ut, "target=" . $ut );
1616 } else { $ul = $this->makeLink( $wgLang->getNsText(
1617 Namespace::getUser() ) . ":{$ut}", $ut ); }
1619 $rc->userlink = $ul ;
1620 $rc->lastlink = $plink ;
1621 $rc->curlink = $dlink ;
1623 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1624 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1625 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1627 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1628 $blink = $this->makeKnownLink( $wgLang->specialPage(
1629 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1630 $rc->usertalklink= " ({$utl} | {$blink})";
1631 } else {
1632 $rc->usertalklink=" ({$utl})";
1635 if ( !isset ( $this->rc_cache[$t] ) ) $this->rc_cache[$t] = array() ;
1636 array_push ( $this->rc_cache[$t] , $rc ) ;
1637 return $ret;
1641 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
1643 global $wgUser, $wgLang, $wgTitle;
1645 $dt = $wgLang->timeanddate( $ts, true );
1646 $del = wfMsg( "deleteimg" );
1647 $cur = wfMsg( "cur" );
1649 if ( $iscur ) {
1650 $url = wfImageUrl( $img );
1651 $rlink = $cur;
1652 if ( $wgUser->isSysop() ) {
1653 $link = wfLocalUrlE( "", "image=" . $wgTitle->getURL() .
1654 "&action=delete" );
1655 $style = $this->getInternalLinkAttributes( $link, $del );
1657 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
1658 } else {
1659 $dlink = $del;
1661 } else {
1662 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
1663 if( $wgUser->getID() != 0 ) {
1664 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1665 wfMsg( "revertimg" ), "action=revert&oldimage=" .
1666 urlencode( $img ) );
1667 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1668 $del, "action=delete&oldimage=" . urlencode( $img ) );
1669 } else {
1670 # Having live active links for non-logged in users
1671 # means that bots and spiders crawling our site can
1672 # inadvertently change content. Baaaad idea.
1673 $rlink = wfMsg( "revertimg" );
1674 $dlink = $del;
1677 if ( 0 == $u ) { $ul = $ut; }
1678 else { $ul = $this->makeLink( $wgLang->getNsText(
1679 Namespace::getUser() ) . ":{$ut}", $ut ); }
1681 $nb = str_replace( "$1", $size, wfMsg( "nbytes" ) );
1682 $style = $this->getInternalLinkAttributes( $url, $dt );
1684 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
1685 . " . . {$ul} ({$nb})";
1687 if ( "" != $c && "*" != $c ) {
1688 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1690 $s .= "</li>\n";
1691 return $s;
1694 function tocIndent($level) {
1696 while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
1697 return $rv;
1701 function tocUnindent($level) {
1702 while($level-->0) $rv.="</div>\n";
1703 return $rv;
1706 // parameter level defines if we are on an indentation level
1707 function tocLine($anchor,$tocline,$level) {
1709 if($level) {
1711 return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
1712 } else {
1714 return "<div style=\"margin-bottom:0px;\">\n".
1715 "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
1716 "</div>\n";
1721 function tocTable($toc) {
1723 /* does not auto-expand, use table for now
1724 return "
1725 <div><div style=\"border-width:1px;background-color:#f3f3ff;border-color:#8888aa;border-style:solid;padding:1em;padding-bottom:1em;\">
1726 <b>".wfMsg("toc")."</b><P>
1727 $toc</div></div>";
1729 return
1730 "<table border=\"0\" bgcolor=\"#8888aa\" cellpadding=\"0\" cellspacing=\"1\"><tr><td>\n" .
1731 "<table border=\"0\" bgcolor=\"#f3f3ff\" CELLPADDING=5><tr><td>\n".
1732 "<b>".wfMsg("toc")."</b>" .
1733 " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>" .
1734 "</td></tr><tr id='tocinside'><td>\n".
1735 $toc."</td></tr></table></td></tr></table><P>\n";
1738 function editSectionLink($section) {
1740 global $wgTitle,$wgUser,$oldid;
1741 if($wgTitle->isProtected() && !$wgUser->isSysop()) return "";
1742 if($oldid) return "";
1743 $editurl="&section={$section}";
1744 $url=$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
1745 return "<div style=\"float:right;margin-left:5px;\"><small>[".$url."]</small></div>";
1750 include_once( "SkinStandard.php" );
1751 include_once( "SkinNostalgia.php" );
1752 include_once( "SkinCologneBlue.php" );