Added label tag for confirm checkbox
[mediawiki.git] / includes / Skin.php
blob30b114a5ab5ce7ce5ed9e990a7301483ba9f2ad6
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'><!--\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" => "#ffffec" );
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;
280 global $wgTitle;
282 if ( $wgOut->isPrintable() ) {
283 $s = "\n</div>\n";
285 $u = $wgServer . $wgTitle->getFullURL();
286 $rf = wfMsg( "retrievedfrom", $u );
288 if ( $wgOut->isArticle() ) {
289 $lm = "<br>" . $this->lastModified();
290 } else { $lm = ""; }
292 $cr = wfMsg( "gnunote" );
293 $s .= "<p><em>{$rf}{$lm} {$cr}</em>\n";
294 return $s;
296 return $this->doAfterContent();
299 function doAfterContent()
301 global $wgUser, $wgOut, $wgLang;
302 wfProfileIn( "Skin::doAfterContent" );
304 $s = "\n</div><br clear=all>\n";
306 $s .= "\n<div id='footer'>";
307 $s .= "<table width='98%' border=0 cellspacing=0><tr>";
309 $qb = $this->qbSetting();
310 $shove = ($qb != 0);
311 $left = ($qb == 1 || $qb == 3);
312 if($wgLang->isRTL()) $left = !$left;
314 if ( $shove && $left ) { # Left
315 $s .= $this->getQuickbarCompensator();
317 $l = $wgLang->isRTL() ? "right" : "left";
318 $s .= "<td class='bottom' align='$l' valign='top'>";
320 $s .= $this->bottomLinks();
321 $s .= "\n<br>" . $this->mainPageLink()
322 . " | " . $this->aboutLink()
323 . " | " . $this->specialLink( "recentchanges" )
324 . " | " . $this->searchForm()
325 . "<br>" . $this->pageStats();
327 $s .= "</td>";
328 if ( $shove && !$left ) { # Right
329 $s .= $this->getQuickbarCompensator();
331 $s .= "</tr></table>\n</div>\n</div>\n";
333 if ( 0 != $qb ) { $s .= $this->quickBar(); }
334 wfProfileOut();
335 return $s;
338 function pageTitleLinks()
340 global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang;
342 $s = $this->printableLink();
344 if ( $wgOut->isArticle() ) {
345 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
346 $name = $wgTitle->getDBkey();
347 $link = wfEscapeHTML( wfImageUrl( $name ) );
348 $style = $this->getInternalLinkAttributes( $link, $name );
349 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
352 if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
353 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
354 wfMsg( "currentrev" ) );
357 if ( $wgUser->getNewtalk() ) {
358 # do not show "You have new messages" text when we are viewing our
359 # own talk page
361 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
362 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
363 $n =$wgUser->getName();
364 $tl = $this->makeKnownLink( $wgLang->getNsText(
365 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
366 wfMsg("newmessageslink") );
367 $s.=" | <strong>". str_replace( "$1", $tl, wfMsg("newmessages") ) . "</strong>";
370 return $s;
373 function printableLink()
375 global $wgOut, $wgTitle, $oldid, $action;
377 if ( "history" == $action ) { $q = "action=history&"; }
378 else { $q = ""; }
380 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
381 WfMsg( "printableversion" ), "{$q}printable=yes" );
382 return $s;
385 function pageTitle()
387 global $wgOut, $wgTitle, $wgUser;
389 $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
390 if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
391 return $s;
394 function pageSubtitle()
396 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
398 $sub = $wgOut->getSubtitle();
399 if ( "" == $sub ) { $sub = wfMsg( "fromwikipedia" ); }
400 if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
401 $ptext=$wgTitle->getPrefixedText();
402 if(preg_match("/\//",$ptext)) {
403 $sub.="</p><p class='subpages'>";
404 $links=explode("/",$ptext);
405 $c=0;
406 $growinglink="";
407 foreach($links as $link) {
408 $c++;
409 if ($c<count($links)) {
410 $growinglink.=$link;
411 $getlink=$this->makeLink($growinglink,$link);
412 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
413 if ($c>1) {
414 $sub .= " | ";
415 } else {
416 $sub .="&lt; ";
418 $sub .= $getlink;
419 $growinglink.="/";
425 $s = "<p class='subtitle'>{$sub}\n";
426 return $s;
429 function nameAndLogin()
431 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader;
433 $li = $wgLang->specialPage( "Userlogin" );
434 $lo = $wgLang->specialPage( "Userlogout" );
436 $s = "";
437 if ( 0 == $wgUser->getID() ) {
438 if( $wgShowIPinHeader ) {
439 $n = getenv( "REMOTE_ADDR" );
441 $tl = $this->makeKnownLink( $wgLang->getNsText(
442 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
443 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
445 $s .= $n . " (".$tl.")";
446 } else {
447 $s .= wfMsg("notloggedin");
450 $rt = $wgTitle->getPrefixedURL();
451 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
452 $q = "";
453 } else { $q = "returnto={$rt}"; }
455 $s .= "\n<br>" . $this->makeKnownLink( $li,
456 wfMsg( "login" ), $q );
457 } else {
458 $n = $wgUser->getName();
459 $rt = $wgTitle->getPrefixedURL();
460 $tl = $this->makeKnownLink( $wgLang->getNsText(
461 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
462 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
464 $tl = " ({$tl})";
466 $s .= $this->makeKnownLink( $wgLang->getNsText(
467 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
468 $this->makeKnownLink( $lo, wfMsg( "logout" ),
469 "returnto={$rt}" ) . " | " .
470 $this->specialLink( "preferences" );
472 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
473 wfMsg( "help" ) );
475 return $s;
478 function searchForm()
480 global $search;
482 $s = "<form name='search' class='inline' method=get action=\""
483 . wfLocalUrl( "" ) . "\">"
484 . "<input type=text name=\"search\" size=19 value=\""
485 . htmlspecialchars(substr($search,0,256)) . "\">\n"
486 . "<input type=submit name=\"go\" value=\"" . wfMsg ("go") . "\">&nbsp;"
487 . "<input type=submit value=\"" . wfMsg ("search") . "\"></form>";
489 return $s;
492 function topLinks()
494 global $wgOut;
495 $sep = " |\n";
497 $s = $this->mainPageLink() . $sep
498 . $this->specialLink( "recentchanges" );
500 if ( $wgOut->isArticle() ) {
501 $s .= $sep . $this->editThisPage()
502 . $sep . $this->historyLink();
504 # Many people don't like this dropdown box
505 #$s .= $sep . $this->specialPagesList();
507 return $s;
510 function bottomLinks()
512 global $wgOut, $wgUser, $wgTitle;
513 $sep = " |\n";
515 $s = "";
516 if ( $wgOut->isArticle() ) {
517 $s .= "<strong>" . $this->editThisPage() . "</strong>";
518 if ( 0 != $wgUser->getID() ) {
519 $s .= $sep . $this->watchThisPage();
521 $s .= $sep . $this->talkLink()
522 . $sep . $this->historyLink()
523 . $sep . $this->whatLinksHere()
524 . $sep . $this->watchPageLinksLink();
526 if ( $wgTitle->getNamespace() == Namespace::getUser()
527 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
530 $id=User::idFromName($wgTitle->getText());
531 $ip=User::isIP($wgTitle->getText());
533 if($id || $ip) { # both anons and non-anons have contri list
534 $s .= $sep . $this->userContribsLink();
536 if ( 0 != $wgUser->getID() ) { # show only to signed in users
537 if($id) { # can only email non-anons
538 $s .= $sep . $this->emailUserLink();
542 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
543 $s .= "\n<br>" . $this->deleteThisPage() .
544 $sep . $this->protectThisPage() .
545 $sep . $this->moveThisPage();
547 $s .= "<br>\n" . $this->otherLanguages();
549 return $s;
552 function pageStats()
554 global $wgOut, $wgLang, $wgArticle;
555 global $oldid, $diff, $wgDisableCounters;
557 if ( ! $wgOut->isArticle() ) { return ""; }
558 if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
559 if ( 0 == $wgArticle->getID() ) { return ""; }
561 if ( $wgDisableCounters ) {
562 $s = "";
563 } else {
564 $count = $wgArticle->getCount();
565 $s = str_replace( "$1", $count, wfMsg( "viewcount" ) );
567 $s .= $this->lastModified();
568 $s .= " " . wfMsg( "gnunote" );
569 return "<span id='pagestats'>{$s}</span>";
572 function lastModified()
574 global $wgLang, $wgArticle;
576 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
577 $s = " " . str_replace( "$1", $d, wfMsg( "lastmodified" ) );
578 return $s;
581 function logoText( $align = "" )
583 if ( "" != $align ) { $a = " align='{$align}'"; }
584 else { $a = ""; }
586 $mp = wfMsg( "mainpage" );
587 $s = "<a href=\"" . wfLocalUrlE( $mp ) . "\"><img{$a} border=0 src=\""
588 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
589 return $s;
592 function quickBar()
594 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
595 global $wpPreview;
596 wfProfileIn( "Skin::quickBar" );
597 $tns=$wgTitle->getNamespace();
599 $s = "\n<div id='quickbar'>";
600 $s .= "\n" . $this->logoText() . "\n<hr class='sep'>";
602 $sep = "\n<br>";
603 $s .= $this->mainPageLink()
604 . $sep . $this->specialLink( "recentchanges" )
605 . $sep . $this->specialLink( "randompage" );
606 if ($wgUser->getID()) {
607 $s.= $sep . $this->specialLink( "watchlist" ) ;
608 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
609 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
612 // only show watchlist link if logged in
613 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
614 $s .= "\n<br><hr class='sep'>";
615 $articleExists = $wgTitle->getArticleId();
616 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
618 if($wgOut->isArticle()) {
619 $s .= "<strong>" . $this->editThisPage() . "</strong>";
620 } else { # backlink to the article in edit or history mode
621 if($articleExists){ # no backlink if no article
622 switch($tns) {
623 case 0:
624 $text = wfMsg("articlepage");
625 break;
626 case 1:
627 $text = wfMsg("viewtalkpage");
628 break;
629 case 2:
630 $text = wfMsg("userpage");
631 break;
632 case 3:
633 $text = wfMsg("viewtalkpage");
634 break;
635 case 4:
636 $text = wfMsg("wikipediapage");
637 break;
638 case 5:
639 $text = wfMsg("viewtalkpage");
640 break;
641 case 6:
642 $text = wfMsg("imagepage");
643 break;
644 case 7:
645 $text = wfMsg("viewtalkpage");
646 break;
647 default:
648 $text= wfMsg("articlepage");
651 $link = $wgTitle->getText();
652 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
653 $link = $nstext . ":" . $link ;
655 $s .= $this->makeLink($link, $text );
656 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
657 # we just throw in a "New page" text to tell the user that he's in edit mode,
658 # and to avoid messing with the separator that is prepended to the next item
659 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
665 if( $tns%2 && $action!="edit" && !$wpPreview) {
666 $s.="<br>".$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("postcomment"),"action=edit&section=new");
670 watching could cause problems in edit mode:
671 if user edits article, then loads "watch this article" in background and then saves
672 article with "Watch this article" checkbox disabled, the article is transparently
673 unwatched. Therefore we do not show the "Watch this page" link in edit mode
675 if ( 0 != $wgUser->getID() && $articleExists) {
676 if($action!="edit" && $action!="history" &&
677 $action != "submit" )
678 {$s .= $sep . $this->watchThisPage(); }
679 if ( $wgTitle->userCanEdit() ) $s .= $sep . $this->moveThisPage();
681 if ( $wgUser->isSysop() and $articleExists ) {
682 $s .= $sep . $this->deleteThisPage() .
683 $sep . $this->protectThisPage();
685 $s .= $sep . $this->talkLink();
686 if ($articleExists && $action !="history") { $s .= $sep . $this->historyLink();}
687 $s.=$sep . $this->whatLinksHere();
689 if($wgOut->isArticle()) {
690 $s .= $sep . $this->watchPageLinksLink();
693 if ( Namespace::getUser() == $wgTitle->getNamespace()
694 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
697 $id=User::idFromName($wgTitle->getText());
698 $ip=User::isIP($wgTitle->getText());
700 if($id||$ip) {
701 $s .= $sep . $this->userContribsLink();
703 if ( 0 != $wgUser->getID() ) {
704 if($id) { # can only email real users
705 $s .= $sep . $this->emailUserLink();
709 $s .= "\n<br><hr class='sep'>";
712 if ( 0 != $wgUser->getID() ) {
713 $s .= $this->specialLink( "upload" ) . $sep;
715 $s .= $this->specialLink( "specialpages" )
716 . $sep . $this->bugReportsLink();
718 $s .= "\n<br></div>\n";
719 wfProfileOut();
720 return $s;
723 function specialPagesList()
725 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
726 $a = array();
728 $validSP = $wgLang->getValidSpecialPages();
730 foreach ( $validSP as $name => $desc ) {
731 if ( "" == $desc ) { continue; }
732 $a[$name] = $desc;
734 if ( $wgUser->isSysop() )
736 $sysopSP = $wgLang->getSysopSpecialPages();
738 foreach ( $sysopSP as $name => $desc ) {
739 if ( "" == $desc ) { continue; }
740 $a[$name] = $desc ;
743 if ( $wgUser->isDeveloper() )
745 $devSP = $wgLang->getDeveloperSpecialPages();
747 foreach ( $devSP as $name => $desc ) {
748 if ( "" == $desc ) { continue; }
749 $a[$name] = $desc ;
752 $go = wfMsg( "go" );
753 $sp = wfMsg( "specialpages" );
754 $spp = $wgLang->specialPage( "Specialpages" );
756 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
757 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
758 $s .= "<select name=\"wpDropdown\">\n";
759 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
761 foreach ( $a as $name => $desc ) {
762 $p = $wgLang->specialPage( $name );
763 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
765 $s .= "</select>\n";
766 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
767 $s .= "</form>\n";
768 return $s;
771 function mainPageLink()
773 $mp = wfMsg( "mainpage" );
774 $s = $this->makeKnownLink( $mp, $mp );
775 return $s;
778 function copyrightLink()
780 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
781 wfMsg( "copyrightpagename" ) );
782 return $s;
785 function aboutLink()
787 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
788 wfMsg( "aboutwikipedia" ) );
789 return $s;
792 function editThisPage()
794 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
796 if ( ! $wgOut->isArticle() || $diff ) {
797 $s = wfMsg( "protectedpage" );
798 } else if ( $wgTitle->userCanEdit() ) {
799 $n = $wgTitle->getPrefixedText();
800 $t = wfMsg( "editthispage" );
801 $oid = $red = "";
803 if ( $redirect ) { $red = "&redirect={$redirect}"; }
804 if ( $oldid && ! isset( $diff ) ) {
805 $oid = "&oldid={$oldid}";
807 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
808 } else {
809 $s = wfMsg( "protectedpage" );
811 return $s;
814 function deleteThisPage()
816 global $wgUser, $wgOut, $wgTitle, $diff;
818 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
819 $n = $wgTitle->getPrefixedText();
820 $t = wfMsg( "deletethispage" );
822 $s = $this->makeKnownLink( $n, $t, "action=delete" );
823 } else {
824 $s = wfMsg( "error" );
826 return $s;
829 function protectThisPage()
831 global $wgUser, $wgOut, $wgTitle, $diff;
833 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
834 $n = $wgTitle->getPrefixedText();
836 if ( $wgTitle->isProtected() ) {
837 $t = wfMsg( "unprotectthispage" );
838 $q = "action=unprotect";
839 } else {
840 $t = wfMsg( "protectthispage" );
841 $q = "action=protect";
843 $s = $this->makeKnownLink( $n, $t, $q );
844 } else {
845 $s = wfMsg( "error" );
847 return $s;
850 function watchThisPage()
852 global $wgUser, $wgOut, $wgTitle, $diff;
854 if ( $wgOut->isArticle() && ( ! $diff ) ) {
855 $n = $wgTitle->getPrefixedText();
857 if ( $wgTitle->userIsWatching() ) {
858 $t = wfMsg( "unwatchthispage" );
859 $q = "action=unwatch";
860 } else {
861 $t = wfMsg( "watchthispage" );
862 $q = "action=watch";
864 $s = $this->makeKnownLink( $n, $t, $q );
865 } else {
866 $s = wfMsg( "notanarticle" );
868 return $s;
871 function moveThisPage()
873 global $wgTitle, $wgLang;
875 if ( $wgTitle->userCanEdit() ) {
876 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
877 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
878 } // no message if page is protected - would be redundant
879 return $s;
882 function historyLink()
884 global $wgTitle;
886 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
887 wfMsg( "history" ), "action=history" );
888 return $s;
891 function whatLinksHere()
893 global $wgTitle, $wgLang;
895 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
896 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
897 return $s;
900 function userContribsLink()
902 global $wgTitle, $wgLang;
904 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
905 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
906 return $s;
909 function emailUserLink()
911 global $wgTitle, $wgLang;
913 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
914 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
915 return $s;
918 function watchPageLinksLink()
920 global $wgOut, $wgTitle, $wgLang;
922 if ( ! $wgOut->isArticle() ) {
923 $s = "(" . wfMsg( "notanarticle" ) . ")";
924 } else {
925 $s = $this->makeKnownLink( $wgLang->specialPage(
926 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
927 "target=" . $wgTitle->getPrefixedURL() );
929 return $s;
932 function otherLanguages()
934 global $wgOut, $wgLang, $wgTitle , $wgUseNewInterlanguage ;
936 $a = $wgOut->getLanguageLinks();
937 if ( 0 == count( $a ) ) {
938 if ( !$wgUseNewInterlanguage ) return "";
939 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
940 if ( $ns != 0 AND $ns != 1 ) return "" ;
941 $pn = "Intl" ;
942 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
943 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
944 wfMsg( "intl" ) , $x );
947 if ( !$wgUseNewInterlanguage ) {
948 $s = wfMsg( "otherlanguages" ) . ": ";
949 } else {
950 global $wgLanguageCode ;
951 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
952 $x .= "&xl=".$wgLanguageCode ;
953 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
954 wfMsg( "otherlanguages" ) , $x ) . ": " ;
957 $first = true;
958 if($wgLang->isRTL()) $s .= "<span dir='LTR'>";
959 foreach( $a as $l ) {
960 if ( ! $first ) { $s .= " | "; }
961 $first = false;
963 $nt = Title::newFromText( $l );
964 $url = $nt->getFullURL();
965 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
967 if ( "" == $text ) { $text = $l; }
968 $style = $this->getExternalLinkAttributes( $l, $text );
969 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
971 if($wgLang->isRTL()) $s .= "</span>";
972 return $s;
975 function bugReportsLink()
977 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
978 wfMsg( "bugreports" ) );
979 return $s;
982 function dateLink()
984 global $wgLinkCache;
985 $t1 = Title::newFromText( gmdate( "F j" ) );
986 $t2 = Title::newFromText( gmdate( "Y" ) );
988 $wgLinkCache->suspend();
989 $id = $t1->getArticleID();
990 $wgLinkCache->resume();
992 if ( 0 == $id ) {
993 $s = $this->makeBrokenLink( $t1->getText() );
994 } else {
995 $s = $this->makeKnownLink( $t1->getText() );
997 $s .= ", ";
999 $wgLinkCache->suspend();
1000 $id = $t2->getArticleID();
1001 $wgLinkCache->resume();
1003 if ( 0 == $id ) {
1004 $s .= $this->makeBrokenLink( $t2->getText() );
1005 } else {
1006 $s .= $this->makeKnownLink( $t2->getText() );
1008 return $s;
1011 function talkLink()
1013 global $wgLang, $wgTitle, $wgLinkCache;
1015 $tns = $wgTitle->getNamespace();
1016 if ( -1 == $tns ) { return ""; }
1018 $pn = $wgTitle->getText();
1019 $tp = wfMsg( "talkpage" );
1020 if ( Namespace::isTalk( $tns ) ) {
1021 $lns = Namespace::getSubject( $tns );
1022 switch($tns) {
1023 case 1:
1024 $text = wfMsg("articlepage");
1025 break;
1026 case 3:
1027 $text = wfMsg("userpage");
1028 break;
1029 case 5:
1030 $text = wfMsg("wikipediapage");
1031 break;
1032 case 7:
1033 $text = wfMsg("imagepage");
1034 break;
1035 default:
1036 $text= wfMsg("articlepage");
1038 } else {
1040 $lns = Namespace::getTalk( $tns );
1041 $text=$tp;
1043 $n = $wgLang->getNsText( $lns );
1044 if ( "" == $n ) { $link = $pn; }
1045 else { $link = "{$n}:{$pn}"; }
1047 $wgLinkCache->suspend();
1048 $s = $this->makeLink( $link, $text );
1049 $wgLinkCache->resume();
1051 return $s;
1054 # After all the page content is transformed into HTML, it makes
1055 # a final pass through here for things like table backgrounds.
1057 function transformContent( $text )
1059 return $text;
1062 # Note: This function MUST call getArticleID() on the link,
1063 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1065 function makeLink( $title, $text= "", $query = "", $trail = "" )
1067 global $wgOut, $wgUser;
1069 $nt = Title::newFromText( $title );
1071 if ( $nt->isExternal() ) {
1072 $u = $nt->getFullURL();
1073 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1074 $style = $this->getExternalLinkAttributes( $link, $text );
1076 $inside = "";
1077 if ( "" != $trail ) {
1078 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1079 $inside = $m[1];
1080 $trail = $m[2];
1083 return "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1085 if ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1086 return $this->makeKnownLink( $title, $text, $query, $trail );
1088 if ( ( -1 == $nt->getNamespace() ) ||
1089 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1090 return $this->makeKnownLink( $title, $text, $query, $trail );
1092 $aid = $nt->getArticleID() ;
1093 if ( 0 == $aid ) {
1094 return $this->makeBrokenLink( $title, $text, $query, $trail );
1095 } else {
1096 $threshold = $wgUser->getOption("stubthreshold") ;
1097 if ( $threshold > 0 ) {
1098 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'" ) ;
1100 if ( wfNumRows( $res ) > 0 ) {
1101 $s = wfFetchObject( $res );
1102 $size = $s->x;
1103 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
1104 $size = $threshold*2 ; # Really big
1105 wfFreeResult( $res );
1106 } else $size = $threshold*2 ; # Really big
1107 } else $size = 1 ;
1109 if ( $size < $threshold )
1110 return $this->makeStubLink( $title, $text, $query, $trail );
1111 return $this->makeKnownLink( $title, $text, $query, $trail );
1115 function makeKnownLink( $title, $text = "", $query = "", $trail = "" )
1117 global $wgOut, $wgTitle;
1119 $nt = Title::newFromText( $title );
1120 $link = $nt->getPrefixedURL();
1122 if ( "" == $link ) {
1123 $u = "";
1124 if ( "" == $text ) { $text = $nt->getFragment(); }
1125 } else {
1126 $u = wfLocalUrlE( $link, $query );
1128 if ( "" != $nt->getFragment() ) {
1129 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1131 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1132 $style = $this->getInternalLinkAttributes( $link, $text );
1134 $inside = "";
1135 if ( "" != $trail ) {
1136 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1137 $inside = $m[1];
1138 $trail = $m[2];
1141 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1142 return $r;
1145 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" )
1147 global $wgOut, $wgUser;
1149 $nt = Title::newFromText( $title );
1150 $link = $nt->getPrefixedURL();
1152 if ( "" == $query ) { $q = "action=edit"; }
1153 else { $q = "action=edit&{$query}"; }
1154 $u = wfLocalUrlE( $link, $q );
1156 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1157 $style = $this->getInternalLinkAttributes( $link, $text, "yes" );
1159 $inside = "";
1160 if ( "" != $trail ) {
1161 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1162 $inside = $m[1];
1163 $trail = $m[2];
1166 if ( $wgOut->isPrintable() ||
1167 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1168 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1169 } else {
1170 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1172 return $s;
1175 function makeStubLink( $title, $text = "", $query = "", $trail = "" )
1177 global $wgOut, $wgUser;
1179 $nt = Title::newFromText( $title );
1180 $link = $nt->getPrefixedURL();
1182 $u = wfLocalUrlE( $link, $query );
1184 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1185 $style = $this->getInternalLinkAttributes( $link, $text, "stub" );
1187 $inside = "";
1188 if ( "" != $trail ) {
1189 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1190 $inside = $m[1];
1191 $trail = $m[2];
1194 if ( $wgOut->isPrintable() ||
1195 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1196 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1197 } else {
1198 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1200 return $s;
1203 function fnamePart( $url )
1205 $basename = strrchr( $url, "/" );
1206 if ( false === $basename ) { $basename = $url; }
1207 else { $basename = substr( $basename, 1 ); }
1208 return wfEscapeHTML( $basename );
1211 function makeImage( $url, $alt = "" )
1213 global $wgOut;
1215 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1216 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1217 return $s;
1220 function makeImageLink( $name, $url, $alt = "" )
1222 global $wgOut, $wgTitle, $wgLang;
1224 $nt = Title::newFromText( $wgLang->getNsText(
1225 Namespace::getImage() ) . ":{$name}" );
1226 $link = $nt->getPrefixedURL();
1227 if ( "" == $alt ) { $alt = $name; }
1229 $u = wfLocalUrlE( $link );
1230 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1231 "<img border=0 src=\"{$url}\" alt=\"{$alt}\"></a>";
1232 return $s;
1235 function makeMediaLink( $name, $url, $alt = "" )
1237 global $wgOut, $wgTitle;
1239 if ( "" == $alt ) { $alt = $name; }
1240 $u = wfEscapeHTML( $url );
1241 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1242 return $s;
1245 function specialLink( $name, $key = "" )
1247 global $wgLang;
1249 if ( "" == $key ) { $key = strtolower( $name ); }
1250 $pn = $wgLang->ucfirst( $name );
1251 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1252 wfMsg( $key ) );
1255 # Called by history lists and recent changes
1258 function beginRecentChangesList()
1260 $rc_cache = array() ;
1261 $rccc = 0 ;
1262 $this->lastdate = "";
1263 return "";
1266 function beginHistoryList()
1268 $this->lastdate = $this->lastline = "";
1269 $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
1270 return $s;
1273 function beginImageHistoryList()
1275 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1276 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1277 return $s;
1280 function endRecentChangesList()
1282 $s = $this->recentChangesBlock() ;
1283 $s .= "</ul>\n";
1284 return $s;
1287 function endHistoryList()
1289 $last = wfMsg( "last" );
1291 $s = preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
1292 $s .= "</ul>\n";
1293 return $s;
1296 function endImageHistoryList()
1298 $s = "</ul>\n";
1299 return $s;
1302 function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor )
1304 global $wgLang;
1306 $artname = Title::makeName( $ns, $ttl );
1307 $last = wfMsg( "last" );
1308 $cur = wfMsg( "cur" );
1309 $cr = wfMsg( "currentrev" );
1311 if ( $oid && $this->lastline ) {
1312 $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->makeKnownLink(
1313 $artname, $last, "diff=\\1&oldid={$oid}" ), $this->lastline );
1314 } else {
1315 $ret = "";
1317 $dt = $wgLang->timeanddate( $ts, true );
1319 if ( $oid ) { $q = "oldid={$oid}"; }
1320 else { $q = ""; }
1321 $link = $this->makeKnownLink( $artname, $dt, $q );
1323 if ( 0 == $u ) {
1324 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1325 $ut, "target=" . $ut );
1326 } else { $ul = $this->makeLink( $wgLang->getNsText(
1327 Namespace::getUser() ) . ":{$ut}", $ut ); }
1329 $s = "<li>";
1330 if ( $oid ) {
1331 $curlink = $this->makeKnownLink( $artname, $cur,
1332 "diff=0&oldid={$oid}" );
1333 } else {
1334 $curlink = $cur;
1336 $s .= "({$curlink}) (!OLDID!{$oid}!) . .";
1338 $M = wfMsg( "minoreditletter" );
1339 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1340 $s .= " {$link} . . {$ul}";
1342 if ( "" != $c && "*" != $c ) { $s .= " <em>(" . wfEscapeHTML($c) . ")</em>"; }
1343 $s .= "</li>\n";
1345 $this->lastline = $s;
1346 return $ret;
1349 function recentChangesBlockLine ( $y ) {
1350 global $wgUploadPath ;
1352 $M = wfMsg( "minoreditletter" );
1353 $N = wfMsg( "newpageletter" );
1354 $r = "" ;
1355 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;
1356 $r .= "<tt>" ;
1357 if ( $y->isnew ) $r .= $N ;
1358 else $r .= "&nbsp;" ;
1359 if ( $y->isminor ) $r .= $M ;
1360 else $r .= "&nbsp;" ;
1361 $r .= " ".$y->timestamp." " ;
1362 $r .= "</tt>" ;
1363 $link = $y->link ;
1364 if ( $y->watched ) $link = "<strong>{$link}</strong>" ;
1365 $r .= $link ;
1367 $r .= " (" ;
1368 $r .= $y->curlink ;
1369 $r .= "; " ;
1370 $r .= $this->makeKnownLink( $y->secureName, wfMsg( "hist" ), "action=history" );
1372 $r .= ") . . ".$y->userlink ;
1373 $r .= $y->usertalklink ;
1374 if ( $y->usercomment != "" )
1375 $r .= " <em>(".wfEscapeHTML($y->usercomment).")</em>" ;
1376 $r .= "<br>\n" ;
1377 return $r ;
1380 function recentChangesBlockGroup ( $y ) {
1381 global $wgUploadPath ;
1383 $r = "" ;
1384 $M = wfMsg( "minoreditletter" );
1385 $N = wfMsg( "newpageletter" );
1386 $isnew = false ;
1387 $userlinks = array () ;
1388 foreach ( $y AS $x ) {
1389 $oldid = $x->diffid ;
1390 if ( $x->isnew ) $isnew = true ;
1391 $u = $x->userlink ;
1392 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1393 $userlinks[$u]++ ;
1396 krsort ( $userlinks ) ;
1397 asort ( $userlinks ) ;
1398 $users = array () ;
1399 $u = array_keys ( $userlinks ) ;
1400 foreach ( $u as $x ) {
1401 $z = $x ;
1402 if ( $userlinks[$x] > 1 ) $z .= " ({$userlinks[$x]}&times;)" ;
1403 array_push ( $users , $z ) ;
1405 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1407 $e = $y ;
1408 $e = array_shift ( $e ) ;
1410 # Arrow
1411 $rci = "RCI{$this->rccc}" ;
1412 $rcl = "RCL{$this->rccc}" ;
1413 $rcm = "RCM{$this->rccc}" ;
1414 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1415 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1416 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1417 $tl .= "</a>" ;
1418 $r .= $tl ;
1420 # Main line
1421 $r .= "<tt>" ;
1422 if ( $isnew ) $r .= $N ;
1423 else $r .= "&nbsp;" ;
1424 $r .= "&nbsp;" ; # Minor
1425 $r .= " ".$e->timestamp." " ;
1426 $r .= "</tt>" ;
1428 $link = $e->link ;
1429 if ( $e->watched ) $link = "<strong>{$link}</strong>" ;
1430 $r .= $link ;
1432 if ( !$e->islog ) {
1433 $r .= " (".count($y)." " ;
1434 if ( $isnew ) $r .= wfMsg("changes");
1435 else $r .= $this->makeKnownLink( $e->secureName , wfMsg("changes") , "diff=0&oldid=".$oldid ) ;
1436 $r .= "; " ;
1437 $r .= $this->makeKnownLink( $e->secureName, wfMsg( "history" ), "action=history" );
1438 $r .= ")" ;
1441 $r .= $users ;
1442 $r .= "<br>\n" ;
1444 # Sub-entries
1445 $r .= "<div id='{$rci}' style='display:none'>" ;
1446 foreach ( $y AS $x )
1448 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1449 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
1450 if ( $x->isnew ) $r .= $N ;
1451 else $r .= "&nbsp;" ;
1452 if ( $x->isminor ) $r .= $M ;
1453 else $r .= "&nbsp;" ;
1454 $r .= "</tt>" ;
1456 $o = "" ;
1457 if ( $x->oldid != 0 ) $o = "oldid=".$x->oldid ;
1458 if ( $x->islog ) $link = $x->timestamp ;
1459 else $link = $this->makeKnownLink( $x->secureName, $x->timestamp , $o ) ;
1460 $link = "<tt>{$link}</tt>" ;
1463 $r .= $link ;
1464 $r .= " (" ;
1465 $r .= $x->curlink ;
1466 $r .= "; " ;
1467 $r .= $x->lastlink ;
1468 $r .= ") . . ".$x->userlink ;
1469 $r .= $x->usertalklink ;
1470 if ( $x->usercomment != "" )
1471 $r .= " <em>(".wfEscapeHTML($x->usercomment).")</em>" ;
1472 $r .= "<br>\n" ;
1474 $r .= "</div>\n" ;
1476 $this->rccc++ ;
1477 return $r ;
1480 function recentChangesBlock ()
1482 global $wgUploadPath ;
1483 if ( count ( $this->rc_cache ) == 0 ) return "" ;
1484 $k = array_keys ( $this->rc_cache ) ;
1485 foreach ( $k AS $x )
1487 $y = $this->rc_cache[$x] ;
1488 if ( count ( $y ) < 2 ) {
1489 $r .= $this->recentChangesBlockLine ( array_shift ( $y ) ) ;
1490 } else {
1491 $r .= $this->recentChangesBlockGroup ( $y ) ;
1495 return "<div align=left>{$r}</div>" ;
1498 function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1500 global $wgUser ;
1501 $usenew = $wgUser->getOption( "usenewrc" );
1502 if ( $usenew )
1503 $r = $this->recentChangesLineNew ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1504 else
1505 $r = $this->recentChangesLineOld ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1506 return $r ;
1509 function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 )
1511 global $wgTitle, $wgLang, $wgUser;
1513 $d = $wgLang->date( $ts, true);
1514 $s = "";
1515 if ( $d != $this->lastdate ) {
1516 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
1517 $s .= "<h4>{$d}</h4>\n<ul>";
1518 $this->lastdate = $d;
1520 $h = $wgLang->time( $ts, true );
1521 $t = Title::makeName( $ns, $ttl );
1522 $clink = $this->makeKnownLink( $t , "" );
1523 $nt = Title::newFromText( $t );
1525 if ( $watched ) {
1526 $clink = "<strong>{$clink}</strong>";
1528 $hlink = $this->makeKnownLink( $t, wfMsg( "hist" ), "action=history" );
1529 if ( $isnew || $nt->isLog() ) {
1530 $dlink = wfMsg( "diff" );
1531 } else {
1532 $dlink = $this->makeKnownLink( $t, wfMsg( "diff" ),
1533 "diff={$oldid}&oldid={$diffid}" ); # Finagle's law
1535 if ( 0 == $u ) {
1536 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1537 $ut, "target=" . $ut );
1538 } else { $ul = $this->makeLink( $wgLang->getNsText(
1539 Namespace::getUser() ) . ":{$ut}", $ut ); }
1541 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1542 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1543 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1544 $cr = wfMsg( "currentrev" );
1546 $s .= "<li> ({$dlink}) ({$hlink}) . .";
1547 $M = wfMsg( "minoreditletter" );
1548 $N = wfMsg( "newpageletter" );
1549 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1550 if ( $isnew ) { $s .= "<strong>{$N}</strong>"; }
1551 $s .= " {$clink}; {$h} . . {$ul}";
1553 $blink="";
1554 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1555 $blink = $this->makeKnownLink( $wgLang->specialPage(
1556 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1559 if(!$blink) {
1560 $utl = "({$utl})";
1561 } else {
1562 $utl = "({$utl} | {$blink})";
1564 $s.=" {$utl}";
1566 if ( "" != $c && "*" != $c ) {
1567 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1569 $s .= "</li>\n";
1571 return $s;
1574 function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1576 global $wgTitle, $wgLang, $wgUser;
1578 $rc = new RecentChangesClass ;
1580 $d = $wgLang->date( $ts, true);
1581 $s = "";
1582 $ret = "" ;
1583 if ( $d != $this->lastdate ) {
1584 $ret = $this->recentChangesBlock () ;
1585 $this->rc_cache = array() ;
1586 $ret .= "<h4>{$d}</h4>\n";
1587 $this->lastdate = $d;
1589 $h = $wgLang->time( $ts, true );
1590 $t = Title::makeName( $ns, $ttl );
1591 $clink = $this->makeKnownLink( $t, "" ) ;
1592 if ( $oldid == 0 ) $c2link = $clink ;
1593 else $c2link = $this->makeKnownLink( $t, "" , "oldid={$oldid}" );
1594 $nt = Title::newFromText( $t );
1596 $rc->timestamp = $h ;
1597 $rc->oldid = $oldid ;
1598 $rc->diffid = $diffid ;
1599 $rc->watched = $watched ;
1600 $rc->isnew = $isnew ;
1601 $rc->isminor = $isminor ;
1602 $rc->secureName = $t ;
1603 $rc->displayName = $nt ;
1604 $rc->link = $clink ;
1605 $rc->usercomment = $c ;
1606 $rc->islog = $nt->isLog() ;
1608 if ( ( $isnew && $oldid == 0 ) || $nt->isLog() ) {
1609 $dlink = wfMsg( "cur" );
1610 } else {
1611 $dlink = $this->makeKnownLink( $t, wfMsg( "cur" ),
1612 "diff=0&oldid={$oldid}" );
1615 if ( $diffid == 0 || $nt->isLog() ) {
1616 $plink = wfMsg( "last" );
1617 } else {
1618 $plink = $this->makeKnownLink( $t, wfMsg( "last" ),
1619 "diff={$oldid}&oldid={$diffid}" );
1622 if ( 0 == $u ) {
1623 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1624 $ut, "target=" . $ut );
1625 } else { $ul = $this->makeLink( $wgLang->getNsText(
1626 Namespace::getUser() ) . ":{$ut}", $ut ); }
1628 $rc->userlink = $ul ;
1629 $rc->lastlink = $plink ;
1630 $rc->curlink = $dlink ;
1632 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1633 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1634 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1636 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1637 $blink = $this->makeKnownLink( $wgLang->specialPage(
1638 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1639 $rc->usertalklink= " ({$utl} | {$blink})";
1640 } else {
1641 $rc->usertalklink=" ({$utl})";
1644 if ( !isset ( $this->rc_cache[$t] ) ) $this->rc_cache[$t] = array() ;
1645 array_push ( $this->rc_cache[$t] , $rc ) ;
1646 return $ret;
1650 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
1652 global $wgUser, $wgLang, $wgTitle;
1654 $dt = $wgLang->timeanddate( $ts, true );
1655 $del = wfMsg( "deleteimg" );
1656 $cur = wfMsg( "cur" );
1658 if ( $iscur ) {
1659 $url = wfImageUrl( $img );
1660 $rlink = $cur;
1661 if ( $wgUser->isSysop() ) {
1662 $link = wfLocalUrlE( "", "image=" . $wgTitle->getURL() .
1663 "&action=delete" );
1664 $style = $this->getInternalLinkAttributes( $link, $del );
1666 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
1667 } else {
1668 $dlink = $del;
1670 } else {
1671 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
1672 if( $wgUser->getID() != 0 ) {
1673 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1674 wfMsg( "revertimg" ), "action=revert&oldimage=" .
1675 urlencode( $img ) );
1676 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1677 $del, "action=delete&oldimage=" . urlencode( $img ) );
1678 } else {
1679 # Having live active links for non-logged in users
1680 # means that bots and spiders crawling our site can
1681 # inadvertently change content. Baaaad idea.
1682 $rlink = wfMsg( "revertimg" );
1683 $dlink = $del;
1686 if ( 0 == $u ) { $ul = $ut; }
1687 else { $ul = $this->makeLink( $wgLang->getNsText(
1688 Namespace::getUser() ) . ":{$ut}", $ut ); }
1690 $nb = str_replace( "$1", $size, wfMsg( "nbytes" ) );
1691 $style = $this->getInternalLinkAttributes( $url, $dt );
1693 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
1694 . " . . {$ul} ({$nb})";
1696 if ( "" != $c && "*" != $c ) {
1697 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1699 $s .= "</li>\n";
1700 return $s;
1703 function tocIndent($level) {
1705 while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
1706 return $rv;
1710 function tocUnindent($level) {
1711 while($level-->0) $rv.="</div>\n";
1712 return $rv;
1715 // parameter level defines if we are on an indentation level
1716 function tocLine($anchor,$tocline,$level) {
1718 if($level) {
1720 return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
1721 } else {
1723 return "<div style=\"margin-bottom:0px;\">\n".
1724 "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
1725 "</div>\n";
1730 function tocTable($toc) {
1731 // note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
1732 global $printable;
1734 if (!$printable) {
1735 $hideline = " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>";
1737 return
1738 "<p><table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
1739 "<b>".wfMsg("toc")."</b>" .
1740 $hideline .
1741 "</td></tr><tr id='tocinside'><td align=\"left\">\n".
1742 $toc."</td></tr></table><P>\n";
1745 # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
1746 function editSectionScript($section,$head) {
1748 global $wgTitle,$wgUser,$oldid;
1749 if($oldid) return $head;
1750 $url = wfLocalUrlE(urlencode($wgTitle->getPrefixedText()),"action=edit&section=$section");
1751 return "<span onContextMenu='document.location=\"".$url."\";return false;'>{$head}</span>";
1754 function editSectionLink($section) {
1756 global $printable;
1757 global $wgTitle,$wgUser,$oldid;
1758 if($oldid) return "";
1759 if ($printable) return "";
1760 $editurl="&section={$section}";
1761 $url=$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
1762 return "<div style=\"float:right;margin-left:5px;\"><small>[".$url."]</small></div>";
1767 include_once( "SkinStandard.php" );
1768 include_once( "SkinNostalgia.php" );
1769 include_once( "SkinCologneBlue.php" );