Added label tag for "remember me" checkbox
[mediawiki.git] / includes / Skin.php
blobb9a6aa83c9362ab52ef5effecab66e4c007252ff
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;
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, $wgUser;
388 $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
389 if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
390 return $s;
393 function pageSubtitle()
395 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
397 $sub = $wgOut->getSubtitle();
398 if ( "" == $sub ) { $sub = wfMsg( "fromwikipedia" ); }
399 if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
400 $ptext=$wgTitle->getPrefixedText();
401 if(preg_match("/\//",$ptext)) {
402 $sub.="</p><p class='subpages'>";
403 $links=explode("/",$ptext);
404 $c=0;
405 $growinglink="";
406 foreach($links as $link) {
407 $c++;
408 if ($c<count($links)) {
409 $growinglink.=$link;
410 $getlink=$this->makeLink($growinglink,$link);
411 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
412 if ($c>1) {
413 $sub .= " | ";
414 } else {
415 $sub .="&lt; ";
417 $sub .= $getlink;
418 $growinglink.="/";
424 $s = "<p class='subtitle'>{$sub}\n";
425 return $s;
428 function nameAndLogin()
430 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader;
432 $li = $wgLang->specialPage( "Userlogin" );
433 $lo = $wgLang->specialPage( "Userlogout" );
435 $s = "";
436 if ( 0 == $wgUser->getID() ) {
437 if( $wgShowIPinHeader ) {
438 $n = getenv( "REMOTE_ADDR" );
440 $tl = $this->makeKnownLink( $wgLang->getNsText(
441 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
442 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
444 $s .= $n . " (".$tl.")";
445 } else {
446 $s .= wfMsg("notloggedin");
449 $rt = $wgTitle->getPrefixedURL();
450 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
451 $q = "";
452 } else { $q = "returnto={$rt}"; }
454 $s .= "\n<br>" . $this->makeKnownLink( $li,
455 wfMsg( "login" ), $q );
456 } else {
457 $n = $wgUser->getName();
458 $rt = $wgTitle->getPrefixedURL();
459 $tl = $this->makeKnownLink( $wgLang->getNsText(
460 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
461 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
463 $tl = " ({$tl})";
465 $s .= $this->makeKnownLink( $wgLang->getNsText(
466 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
467 $this->makeKnownLink( $lo, wfMsg( "logout" ),
468 "returnto={$rt}" ) . " | " .
469 $this->specialLink( "preferences" );
471 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
472 wfMsg( "help" ) );
474 return $s;
477 function searchForm()
479 global $search;
481 $s = "<form name='search' class='inline' method=get action=\""
482 . wfLocalUrl( "" ) . "\">"
483 . "<input type=text name=\"search\" size=19 value=\""
484 . htmlspecialchars(substr($search,0,256)) . "\">\n"
485 . "<input type=submit name=\"go\" value=\"" . wfMsg ("go") . "\">&nbsp;"
486 . "<input type=submit value=\"" . wfMsg ("search") . "\"></form>";
488 return $s;
491 function topLinks()
493 global $wgOut;
494 $sep = " |\n";
496 $s = $this->mainPageLink() . $sep
497 . $this->specialLink( "recentchanges" );
499 if ( $wgOut->isArticle() ) {
500 $s .= $sep . $this->editThisPage()
501 . $sep . $this->historyLink();
503 # Many people don't like this dropdown box
504 #$s .= $sep . $this->specialPagesList();
506 return $s;
509 function bottomLinks()
511 global $wgOut, $wgUser, $wgTitle;
512 $sep = " |\n";
514 $s = "";
515 if ( $wgOut->isArticle() ) {
516 $s .= "<strong>" . $this->editThisPage() . "</strong>";
517 if ( 0 != $wgUser->getID() ) {
518 $s .= $sep . $this->watchThisPage();
520 $s .= $sep . $this->talkLink()
521 . $sep . $this->historyLink()
522 . $sep . $this->whatLinksHere()
523 . $sep . $this->watchPageLinksLink();
525 if ( $wgTitle->getNamespace() == Namespace::getUser()
526 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
529 $id=User::idFromName($wgTitle->getText());
530 $ip=User::isIP($wgTitle->getText());
532 if($id || $ip) { # both anons and non-anons have contri list
533 $s .= $sep . $this->userContribsLink();
535 if ( 0 != $wgUser->getID() ) { # show only to signed in users
536 if($id) { # can only email non-anons
537 $s .= $sep . $this->emailUserLink();
541 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
542 $s .= "\n<br>" . $this->deleteThisPage() .
543 $sep . $this->protectThisPage() .
544 $sep . $this->moveThisPage();
546 $s .= "<br>\n" . $this->otherLanguages();
548 return $s;
551 function pageStats()
553 global $wgOut, $wgLang, $wgArticle;
554 global $oldid, $diff, $wgDisableCounters;
556 if ( ! $wgOut->isArticle() ) { return ""; }
557 if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
558 if ( 0 == $wgArticle->getID() ) { return ""; }
560 if ( $wgDisableCounters ) {
561 $s = "";
562 } else {
563 $count = $wgArticle->getCount();
564 $s = str_replace( "$1", $count, wfMsg( "viewcount" ) );
566 $s .= $this->lastModified();
567 $s .= " " . wfMsg( "gnunote" );
568 return "<span id='pagestats'>{$s}</span>";
571 function lastModified()
573 global $wgLang, $wgArticle;
575 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
576 $s = " " . str_replace( "$1", $d, wfMsg( "lastmodified" ) );
577 return $s;
580 function logoText( $align = "" )
582 if ( "" != $align ) { $a = " align='{$align}'"; }
583 else { $a = ""; }
585 $mp = wfMsg( "mainpage" );
586 $s = "<a href=\"" . wfLocalUrlE( $mp ) . "\"><img{$a} border=0 src=\""
587 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
588 return $s;
591 function quickBar()
593 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
594 global $wpPreview;
595 wfProfileIn( "Skin::quickBar" );
596 $tns=$wgTitle->getNamespace();
598 $s = "\n<div id='quickbar'>";
599 $s .= "\n" . $this->logoText() . "\n<hr class='sep'>";
601 $sep = "\n<br>";
602 $s .= $this->mainPageLink()
603 . $sep . $this->specialLink( "recentchanges" )
604 . $sep . $this->specialLink( "randompage" );
605 if ($wgUser->getID()) {
606 $s.= $sep . $this->specialLink( "watchlist" ) ;
607 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
608 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
611 // only show watchlist link if logged in
612 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
613 $s .= "\n<br><hr class='sep'>";
614 $articleExists = $wgTitle->getArticleId();
615 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
617 if($wgOut->isArticle()) {
618 $s .= "<strong>" . $this->editThisPage() . "</strong>";
619 } else { # backlink to the article in edit or history mode
620 if($articleExists){ # no backlink if no article
621 switch($tns) {
622 case 0:
623 $text = wfMsg("articlepage");
624 break;
625 case 1:
626 $text = wfMsg("viewtalkpage");
627 break;
628 case 2:
629 $text = wfMsg("userpage");
630 break;
631 case 3:
632 $text = wfMsg("viewtalkpage");
633 break;
634 case 4:
635 $text = wfMsg("wikipediapage");
636 break;
637 case 5:
638 $text = wfMsg("viewtalkpage");
639 break;
640 case 6:
641 $text = wfMsg("imagepage");
642 break;
643 case 7:
644 $text = wfMsg("viewtalkpage");
645 break;
646 default:
647 $text= wfMsg("articlepage");
650 $link = $wgTitle->getText();
651 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
652 $link = $nstext . ":" . $link ;
654 $s .= $this->makeLink($link, $text );
655 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
656 # we just throw in a "New page" text to tell the user that he's in edit mode,
657 # and to avoid messing with the separator that is prepended to the next item
658 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
664 if( $tns%2 && $action!="edit" && !$wpPreview) {
665 $s.="<br>".$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("postcomment"),"action=edit&section=new");
669 watching could cause problems in edit mode:
670 if user edits article, then loads "watch this article" in background and then saves
671 article with "Watch this article" checkbox disabled, the article is transparently
672 unwatched. Therefore we do not show the "Watch this page" link in edit mode
674 if ( 0 != $wgUser->getID() && $articleExists) {
675 if($action!="edit" && $action!="history" &&
676 $action != "submit" )
677 {$s .= $sep . $this->watchThisPage(); }
678 if ( $wgTitle->userCanEdit() ) $s .= $sep . $this->moveThisPage();
680 if ( $wgUser->isSysop() and $articleExists ) {
681 $s .= $sep . $this->deleteThisPage() .
682 $sep . $this->protectThisPage();
684 $s .= $sep . $this->talkLink();
685 if ($articleExists && $action !="history") { $s .= $sep . $this->historyLink();}
686 $s.=$sep . $this->whatLinksHere();
688 if($wgOut->isArticle()) {
689 $s .= $sep . $this->watchPageLinksLink();
692 if ( Namespace::getUser() == $wgTitle->getNamespace()
693 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
696 $id=User::idFromName($wgTitle->getText());
697 $ip=User::isIP($wgTitle->getText());
699 if($id||$ip) {
700 $s .= $sep . $this->userContribsLink();
702 if ( 0 != $wgUser->getID() ) {
703 if($id) { # can only email real users
704 $s .= $sep . $this->emailUserLink();
708 $s .= "\n<br><hr class='sep'>";
711 if ( 0 != $wgUser->getID() ) {
712 $s .= $this->specialLink( "upload" ) . $sep;
714 $s .= $this->specialLink( "specialpages" )
715 . $sep . $this->bugReportsLink();
717 $s .= "\n<br></div>\n";
718 wfProfileOut();
719 return $s;
722 function specialPagesList()
724 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
725 $a = array();
727 $validSP = $wgLang->getValidSpecialPages();
729 foreach ( $validSP as $name => $desc ) {
730 if ( "" == $desc ) { continue; }
731 $a[$name] = $desc;
733 if ( $wgUser->isSysop() )
735 $sysopSP = $wgLang->getSysopSpecialPages();
737 foreach ( $sysopSP as $name => $desc ) {
738 if ( "" == $desc ) { continue; }
739 $a[$name] = $desc ;
742 if ( $wgUser->isDeveloper() )
744 $devSP = $wgLang->getDeveloperSpecialPages();
746 foreach ( $devSP as $name => $desc ) {
747 if ( "" == $desc ) { continue; }
748 $a[$name] = $desc ;
751 $go = wfMsg( "go" );
752 $sp = wfMsg( "specialpages" );
753 $spp = $wgLang->specialPage( "Specialpages" );
755 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
756 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
757 $s .= "<select name=\"wpDropdown\">\n";
758 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
760 foreach ( $a as $name => $desc ) {
761 $p = $wgLang->specialPage( $name );
762 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
764 $s .= "</select>\n";
765 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
766 $s .= "</form>\n";
767 return $s;
770 function mainPageLink()
772 $mp = wfMsg( "mainpage" );
773 $s = $this->makeKnownLink( $mp, $mp );
774 return $s;
777 function copyrightLink()
779 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
780 wfMsg( "copyrightpagename" ) );
781 return $s;
784 function aboutLink()
786 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
787 wfMsg( "aboutwikipedia" ) );
788 return $s;
791 function editThisPage()
793 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
795 if ( ! $wgOut->isArticle() || $diff ) {
796 $s = wfMsg( "protectedpage" );
797 } else if ( $wgTitle->userCanEdit() ) {
798 $n = $wgTitle->getPrefixedText();
799 $t = wfMsg( "editthispage" );
800 $oid = $red = "";
802 if ( $redirect ) { $red = "&redirect={$redirect}"; }
803 if ( $oldid && ! isset( $diff ) ) {
804 $oid = "&oldid={$oldid}";
806 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
807 } else {
808 $s = wfMsg( "protectedpage" );
810 return $s;
813 function deleteThisPage()
815 global $wgUser, $wgOut, $wgTitle, $diff;
817 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
818 $n = $wgTitle->getPrefixedText();
819 $t = wfMsg( "deletethispage" );
821 $s = $this->makeKnownLink( $n, $t, "action=delete" );
822 } else {
823 $s = wfMsg( "error" );
825 return $s;
828 function protectThisPage()
830 global $wgUser, $wgOut, $wgTitle, $diff;
832 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
833 $n = $wgTitle->getPrefixedText();
835 if ( $wgTitle->isProtected() ) {
836 $t = wfMsg( "unprotectthispage" );
837 $q = "action=unprotect";
838 } else {
839 $t = wfMsg( "protectthispage" );
840 $q = "action=protect";
842 $s = $this->makeKnownLink( $n, $t, $q );
843 } else {
844 $s = wfMsg( "error" );
846 return $s;
849 function watchThisPage()
851 global $wgUser, $wgOut, $wgTitle, $diff;
853 if ( $wgOut->isArticle() && ( ! $diff ) ) {
854 $n = $wgTitle->getPrefixedText();
856 if ( $wgTitle->userIsWatching() ) {
857 $t = wfMsg( "unwatchthispage" );
858 $q = "action=unwatch";
859 } else {
860 $t = wfMsg( "watchthispage" );
861 $q = "action=watch";
863 $s = $this->makeKnownLink( $n, $t, $q );
864 } else {
865 $s = wfMsg( "notanarticle" );
867 return $s;
870 function moveThisPage()
872 global $wgTitle, $wgLang;
874 if ( $wgTitle->userCanEdit() ) {
875 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
876 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
877 } // no message if page is protected - would be redundant
878 return $s;
881 function historyLink()
883 global $wgTitle;
885 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
886 wfMsg( "history" ), "action=history" );
887 return $s;
890 function whatLinksHere()
892 global $wgTitle, $wgLang;
894 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
895 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
896 return $s;
899 function userContribsLink()
901 global $wgTitle, $wgLang;
903 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
904 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
905 return $s;
908 function emailUserLink()
910 global $wgTitle, $wgLang;
912 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
913 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
914 return $s;
917 function watchPageLinksLink()
919 global $wgOut, $wgTitle, $wgLang;
921 if ( ! $wgOut->isArticle() ) {
922 $s = "(" . wfMsg( "notanarticle" ) . ")";
923 } else {
924 $s = $this->makeKnownLink( $wgLang->specialPage(
925 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
926 "target=" . $wgTitle->getPrefixedURL() );
928 return $s;
931 function otherLanguages()
933 global $wgOut, $wgLang, $wgTitle , $wgUseNewInterlanguage ;
935 $a = $wgOut->getLanguageLinks();
936 if ( 0 == count( $a ) ) {
937 if ( !$wgUseNewInterlanguage ) return "";
938 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
939 if ( $ns != 0 AND $ns != 1 ) return "" ;
940 $pn = "Intl" ;
941 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
942 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
943 wfMsg( "intl" ) , $x );
946 if ( !$wgUseNewInterlanguage ) {
947 $s = wfMsg( "otherlanguages" ) . ": ";
948 } else {
949 global $wgLanguageCode ;
950 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
951 $x .= "&xl=".$wgLanguageCode ;
952 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
953 wfMsg( "otherlanguages" ) , $x ) . ": " ;
956 $first = true;
957 if($wgLang->isRTL()) $s .= "<span dir='LTR'>";
958 foreach( $a as $l ) {
959 if ( ! $first ) { $s .= " | "; }
960 $first = false;
962 $nt = Title::newFromText( $l );
963 $url = $nt->getFullURL();
964 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
966 if ( "" == $text ) { $text = $l; }
967 $style = $this->getExternalLinkAttributes( $l, $text );
968 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
970 if($wgLang->isRTL()) $s .= "</span>";
971 return $s;
974 function bugReportsLink()
976 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
977 wfMsg( "bugreports" ) );
978 return $s;
981 function dateLink()
983 global $wgLinkCache;
984 $t1 = Title::newFromText( gmdate( "F j" ) );
985 $t2 = Title::newFromText( gmdate( "Y" ) );
987 $wgLinkCache->suspend();
988 $id = $t1->getArticleID();
989 $wgLinkCache->resume();
991 if ( 0 == $id ) {
992 $s = $this->makeBrokenLink( $t1->getText() );
993 } else {
994 $s = $this->makeKnownLink( $t1->getText() );
996 $s .= ", ";
998 $wgLinkCache->suspend();
999 $id = $t2->getArticleID();
1000 $wgLinkCache->resume();
1002 if ( 0 == $id ) {
1003 $s .= $this->makeBrokenLink( $t2->getText() );
1004 } else {
1005 $s .= $this->makeKnownLink( $t2->getText() );
1007 return $s;
1010 function talkLink()
1012 global $wgLang, $wgTitle, $wgLinkCache;
1014 $tns = $wgTitle->getNamespace();
1015 if ( -1 == $tns ) { return ""; }
1017 $pn = $wgTitle->getText();
1018 $tp = wfMsg( "talkpage" );
1019 if ( Namespace::isTalk( $tns ) ) {
1020 $lns = Namespace::getSubject( $tns );
1021 switch($tns) {
1022 case 1:
1023 $text = wfMsg("articlepage");
1024 break;
1025 case 3:
1026 $text = wfMsg("userpage");
1027 break;
1028 case 5:
1029 $text = wfMsg("wikipediapage");
1030 break;
1031 case 7:
1032 $text = wfMsg("imagepage");
1033 break;
1034 default:
1035 $text= wfMsg("articlepage");
1037 } else {
1039 $lns = Namespace::getTalk( $tns );
1040 $text=$tp;
1042 $n = $wgLang->getNsText( $lns );
1043 if ( "" == $n ) { $link = $pn; }
1044 else { $link = "{$n}:{$pn}"; }
1046 $wgLinkCache->suspend();
1047 $s = $this->makeLink( $link, $text );
1048 $wgLinkCache->resume();
1050 return $s;
1053 # After all the page content is transformed into HTML, it makes
1054 # a final pass through here for things like table backgrounds.
1056 function transformContent( $text )
1058 return $text;
1061 # Note: This function MUST call getArticleID() on the link,
1062 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1064 function makeLink( $title, $text= "", $query = "", $trail = "" )
1066 global $wgOut, $wgUser;
1068 $nt = Title::newFromText( $title );
1070 if ( $nt->isExternal() ) {
1071 $u = $nt->getFullURL();
1072 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1073 $style = $this->getExternalLinkAttributes( $link, $text );
1075 $inside = "";
1076 if ( "" != $trail ) {
1077 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1078 $inside = $m[1];
1079 $trail = $m[2];
1082 return "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1084 if ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1085 return $this->makeKnownLink( $title, $text, $query, $trail );
1087 if ( ( -1 == $nt->getNamespace() ) ||
1088 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1089 return $this->makeKnownLink( $title, $text, $query, $trail );
1091 $aid = $nt->getArticleID() ;
1092 if ( 0 == $aid ) {
1093 return $this->makeBrokenLink( $title, $text, $query, $trail );
1094 } else {
1095 $threshold = $wgUser->getOption("stubthreshold") ;
1096 if ( $threshold > 0 ) {
1097 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'" ) ;
1099 if ( wfNumRows( $res ) > 0 ) {
1100 $s = wfFetchObject( $res );
1101 $size = $s->x;
1102 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
1103 $size = $threshold*2 ; # Really big
1104 wfFreeResult( $res );
1105 } else $size = $threshold*2 ; # Really big
1106 } else $size = 1 ;
1108 if ( $size < $threshold )
1109 return $this->makeStubLink( $title, $text, $query, $trail );
1110 return $this->makeKnownLink( $title, $text, $query, $trail );
1114 function makeKnownLink( $title, $text = "", $query = "", $trail = "" )
1116 global $wgOut, $wgTitle;
1118 $nt = Title::newFromText( $title );
1119 $link = $nt->getPrefixedURL();
1121 if ( "" == $link ) {
1122 $u = "";
1123 if ( "" == $text ) { $text = $nt->getFragment(); }
1124 } else {
1125 $u = wfLocalUrlE( $link, $query );
1127 if ( "" != $nt->getFragment() ) {
1128 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1130 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1131 $style = $this->getInternalLinkAttributes( $link, $text );
1133 $inside = "";
1134 if ( "" != $trail ) {
1135 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1136 $inside = $m[1];
1137 $trail = $m[2];
1140 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1141 return $r;
1144 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" )
1146 global $wgOut, $wgUser;
1148 $nt = Title::newFromText( $title );
1149 $link = $nt->getPrefixedURL();
1151 if ( "" == $query ) { $q = "action=edit"; }
1152 else { $q = "action=edit&{$query}"; }
1153 $u = wfLocalUrlE( $link, $q );
1155 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1156 $style = $this->getInternalLinkAttributes( $link, $text, "yes" );
1158 $inside = "";
1159 if ( "" != $trail ) {
1160 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1161 $inside = $m[1];
1162 $trail = $m[2];
1165 if ( $wgOut->isPrintable() ||
1166 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1167 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1168 } else {
1169 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1171 return $s;
1174 function makeStubLink( $title, $text = "", $query = "", $trail = "" )
1176 global $wgOut, $wgUser;
1178 $nt = Title::newFromText( $title );
1179 $link = $nt->getPrefixedURL();
1181 $u = wfLocalUrlE( $link, $query );
1183 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1184 $style = $this->getInternalLinkAttributes( $link, $text, "stub" );
1186 $inside = "";
1187 if ( "" != $trail ) {
1188 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1189 $inside = $m[1];
1190 $trail = $m[2];
1193 if ( $wgOut->isPrintable() ||
1194 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1195 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1196 } else {
1197 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1199 return $s;
1202 function fnamePart( $url )
1204 $basename = strrchr( $url, "/" );
1205 if ( false === $basename ) { $basename = $url; }
1206 else { $basename = substr( $basename, 1 ); }
1207 return wfEscapeHTML( $basename );
1210 function makeImage( $url, $alt = "" )
1212 global $wgOut;
1214 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1215 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1216 return $s;
1219 function makeImageLink( $name, $url, $alt = "" )
1221 global $wgOut, $wgTitle, $wgLang;
1223 $nt = Title::newFromText( $wgLang->getNsText(
1224 Namespace::getImage() ) . ":{$name}" );
1225 $link = $nt->getPrefixedURL();
1226 if ( "" == $alt ) { $alt = $name; }
1228 $u = wfLocalUrlE( $link );
1229 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1230 "<img border=0 src=\"{$url}\" alt=\"{$alt}\"></a>";
1231 return $s;
1234 function makeMediaLink( $name, $url, $alt = "" )
1236 global $wgOut, $wgTitle;
1238 if ( "" == $alt ) { $alt = $name; }
1239 $u = wfEscapeHTML( $url );
1240 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1241 return $s;
1244 function specialLink( $name, $key = "" )
1246 global $wgLang;
1248 if ( "" == $key ) { $key = strtolower( $name ); }
1249 $pn = $wgLang->ucfirst( $name );
1250 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1251 wfMsg( $key ) );
1254 # Called by history lists and recent changes
1257 function beginRecentChangesList()
1259 $rc_cache = array() ;
1260 $rccc = 0 ;
1261 $this->lastdate = "";
1262 return "";
1265 function beginHistoryList()
1267 $this->lastdate = $this->lastline = "";
1268 $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
1269 return $s;
1272 function beginImageHistoryList()
1274 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1275 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1276 return $s;
1279 function endRecentChangesList()
1281 $s = $this->recentChangesBlock() ;
1282 $s .= "</ul>\n";
1283 return $s;
1286 function endHistoryList()
1288 $last = wfMsg( "last" );
1290 $s = preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
1291 $s .= "</ul>\n";
1292 return $s;
1295 function endImageHistoryList()
1297 $s = "</ul>\n";
1298 return $s;
1301 function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor )
1303 global $wgLang;
1305 $artname = Title::makeName( $ns, $ttl );
1306 $last = wfMsg( "last" );
1307 $cur = wfMsg( "cur" );
1308 $cr = wfMsg( "currentrev" );
1310 if ( $oid && $this->lastline ) {
1311 $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->makeKnownLink(
1312 $artname, $last, "diff=\\1&oldid={$oid}" ), $this->lastline );
1313 } else {
1314 $ret = "";
1316 $dt = $wgLang->timeanddate( $ts, true );
1318 if ( $oid ) { $q = "oldid={$oid}"; }
1319 else { $q = ""; }
1320 $link = $this->makeKnownLink( $artname, $dt, $q );
1322 if ( 0 == $u ) {
1323 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1324 $ut, "target=" . $ut );
1325 } else { $ul = $this->makeLink( $wgLang->getNsText(
1326 Namespace::getUser() ) . ":{$ut}", $ut ); }
1328 $s = "<li>";
1329 if ( $oid ) {
1330 $curlink = $this->makeKnownLink( $artname, $cur,
1331 "diff=0&oldid={$oid}" );
1332 } else {
1333 $curlink = $cur;
1335 $s .= "({$curlink}) (!OLDID!{$oid}!) . .";
1337 $M = wfMsg( "minoreditletter" );
1338 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1339 $s .= " {$link} . . {$ul}";
1341 if ( "" != $c && "*" != $c ) { $s .= " <em>(" . wfEscapeHTML($c) . ")</em>"; }
1342 $s .= "</li>\n";
1344 $this->lastline = $s;
1345 return $ret;
1348 function recentChangesBlockLine ( $y ) {
1349 global $wgUploadPath ;
1351 $M = wfMsg( "minoreditletter" );
1352 $N = wfMsg( "newpageletter" );
1353 $r = "" ;
1354 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;
1355 $r .= "<tt>" ;
1356 if ( $y->isnew ) $r .= $N ;
1357 else $r .= "&nbsp;" ;
1358 if ( $y->isminor ) $r .= $M ;
1359 else $r .= "&nbsp;" ;
1360 $r .= " ".$y->timestamp." " ;
1361 $r .= "</tt>" ;
1362 $link = $y->link ;
1363 if ( $y->watched ) $link = "<strong>{$link}</strong>" ;
1364 $r .= $link ;
1366 $r .= " (" ;
1367 $r .= $y->curlink ;
1368 $r .= "; " ;
1369 $r .= $this->makeKnownLink( $y->secureName, wfMsg( "hist" ), "action=history" );
1371 $r .= ") . . ".$y->userlink ;
1372 $r .= $y->usertalklink ;
1373 if ( $y->usercomment != "" )
1374 $r .= " <em>(".wfEscapeHTML($y->usercomment).")</em>" ;
1375 $r .= "<br>\n" ;
1376 return $r ;
1379 function recentChangesBlockGroup ( $y ) {
1380 global $wgUploadPath ;
1382 $r = "" ;
1383 $M = wfMsg( "minoreditletter" );
1384 $N = wfMsg( "newpageletter" );
1385 $isnew = false ;
1386 $userlinks = array () ;
1387 foreach ( $y AS $x ) {
1388 $oldid = $x->diffid ;
1389 if ( $x->isnew ) $isnew = true ;
1390 $u = $x->userlink ;
1391 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1392 $userlinks[$u]++ ;
1395 krsort ( $userlinks ) ;
1396 asort ( $userlinks ) ;
1397 $users = array () ;
1398 $u = array_keys ( $userlinks ) ;
1399 foreach ( $u as $x ) {
1400 $z = $x ;
1401 if ( $userlinks[$x] > 1 ) $z .= " ({$userlinks[$x]}&times;)" ;
1402 array_push ( $users , $z ) ;
1404 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1406 $e = $y ;
1407 $e = array_shift ( $e ) ;
1409 # Arrow
1410 $rci = "RCI{$this->rccc}" ;
1411 $rcl = "RCL{$this->rccc}" ;
1412 $rcm = "RCM{$this->rccc}" ;
1413 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1414 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1415 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1416 $tl .= "</a>" ;
1417 $r .= $tl ;
1419 # Main line
1420 $r .= "<tt>" ;
1421 if ( $isnew ) $r .= $N ;
1422 else $r .= "&nbsp;" ;
1423 $r .= "&nbsp;" ; # Minor
1424 $r .= " ".$e->timestamp." " ;
1425 $r .= "</tt>" ;
1427 $link = $e->link ;
1428 if ( $e->watched ) $link = "<strong>{$link}</strong>" ;
1429 $r .= $link ;
1431 if ( !$e->islog ) {
1432 $r .= " (".count($y)." " ;
1433 if ( $isnew ) $r .= wfMsg("changes");
1434 else $r .= $this->makeKnownLink( $e->secureName , wfMsg("changes") , "diff=0&oldid=".$oldid ) ;
1435 $r .= "; " ;
1436 $r .= $this->makeKnownLink( $e->secureName, wfMsg( "history" ), "action=history" );
1437 $r .= ")" ;
1440 $r .= $users ;
1441 $r .= "<br>\n" ;
1443 # Sub-entries
1444 $r .= "<div id='{$rci}' style='display:none'>" ;
1445 foreach ( $y AS $x )
1447 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1448 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
1449 if ( $x->isnew ) $r .= $N ;
1450 else $r .= "&nbsp;" ;
1451 if ( $x->isminor ) $r .= $M ;
1452 else $r .= "&nbsp;" ;
1453 $r .= "</tt>" ;
1455 $o = "" ;
1456 if ( $x->oldid != 0 ) $o = "oldid=".$x->oldid ;
1457 if ( $x->islog ) $link = $x->timestamp ;
1458 else $link = $this->makeKnownLink( $x->secureName, $x->timestamp , $o ) ;
1459 $link = "<tt>{$link}</tt>" ;
1462 $r .= $link ;
1463 $r .= " (" ;
1464 $r .= $x->curlink ;
1465 $r .= "; " ;
1466 $r .= $x->lastlink ;
1467 $r .= ") . . ".$x->userlink ;
1468 $r .= $x->usertalklink ;
1469 if ( $x->usercomment != "" )
1470 $r .= " <em>(".wfEscapeHTML($x->usercomment).")</em>" ;
1471 $r .= "<br>\n" ;
1473 $r .= "</div>\n" ;
1475 $this->rccc++ ;
1476 return $r ;
1479 function recentChangesBlock ()
1481 global $wgUploadPath ;
1482 if ( count ( $this->rc_cache ) == 0 ) return "" ;
1483 $k = array_keys ( $this->rc_cache ) ;
1484 foreach ( $k AS $x )
1486 $y = $this->rc_cache[$x] ;
1487 if ( count ( $y ) < 2 ) {
1488 $r .= $this->recentChangesBlockLine ( array_shift ( $y ) ) ;
1489 } else {
1490 $r .= $this->recentChangesBlockGroup ( $y ) ;
1494 return "<div align=left>{$r}</div>" ;
1497 function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1499 global $wgUser ;
1500 $usenew = $wgUser->getOption( "usenewrc" );
1501 if ( $usenew )
1502 $r = $this->recentChangesLineNew ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1503 else
1504 $r = $this->recentChangesLineOld ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1505 return $r ;
1508 function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 )
1510 global $wgTitle, $wgLang, $wgUser;
1512 $d = $wgLang->date( $ts, true);
1513 $s = "";
1514 if ( $d != $this->lastdate ) {
1515 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
1516 $s .= "<h4>{$d}</h4>\n<ul>";
1517 $this->lastdate = $d;
1519 $h = $wgLang->time( $ts, true );
1520 $t = Title::makeName( $ns, $ttl );
1521 $clink = $this->makeKnownLink( $t , "" );
1522 $nt = Title::newFromText( $t );
1524 if ( $watched ) {
1525 $clink = "<strong>{$clink}</strong>";
1527 $hlink = $this->makeKnownLink( $t, wfMsg( "hist" ), "action=history" );
1528 if ( $isnew || $nt->isLog() ) {
1529 $dlink = wfMsg( "diff" );
1530 } else {
1531 $dlink = $this->makeKnownLink( $t, wfMsg( "diff" ),
1532 "diff={$oldid}&oldid={$diffid}" ); # Finagle's law
1534 if ( 0 == $u ) {
1535 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1536 $ut, "target=" . $ut );
1537 } else { $ul = $this->makeLink( $wgLang->getNsText(
1538 Namespace::getUser() ) . ":{$ut}", $ut ); }
1540 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1541 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1542 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1543 $cr = wfMsg( "currentrev" );
1545 $s .= "<li> ({$dlink}) ({$hlink}) . .";
1546 $M = wfMsg( "minoreditletter" );
1547 $N = wfMsg( "newpageletter" );
1548 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1549 if ( $isnew ) { $s .= "<strong>{$N}</strong>"; }
1550 $s .= " {$clink}; {$h} . . {$ul}";
1552 $blink="";
1553 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1554 $blink = $this->makeKnownLink( $wgLang->specialPage(
1555 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1558 if(!$blink) {
1559 $utl = "({$utl})";
1560 } else {
1561 $utl = "({$utl} | {$blink})";
1563 $s.=" {$utl}";
1565 if ( "" != $c && "*" != $c ) {
1566 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1568 $s .= "</li>\n";
1570 return $s;
1573 function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1575 global $wgTitle, $wgLang, $wgUser;
1577 $rc = new RecentChangesClass ;
1579 $d = $wgLang->date( $ts, true);
1580 $s = "";
1581 $ret = "" ;
1582 if ( $d != $this->lastdate ) {
1583 $ret = $this->recentChangesBlock () ;
1584 $this->rc_cache = array() ;
1585 $ret .= "<h4>{$d}</h4>\n";
1586 $this->lastdate = $d;
1588 $h = $wgLang->time( $ts, true );
1589 $t = Title::makeName( $ns, $ttl );
1590 $clink = $this->makeKnownLink( $t, "" ) ;
1591 if ( $oldid == 0 ) $c2link = $clink ;
1592 else $c2link = $this->makeKnownLink( $t, "" , "oldid={$oldid}" );
1593 $nt = Title::newFromText( $t );
1595 $rc->timestamp = $h ;
1596 $rc->oldid = $oldid ;
1597 $rc->diffid = $diffid ;
1598 $rc->watched = $watched ;
1599 $rc->isnew = $isnew ;
1600 $rc->isminor = $isminor ;
1601 $rc->secureName = $t ;
1602 $rc->displayName = $nt ;
1603 $rc->link = $clink ;
1604 $rc->usercomment = $c ;
1605 $rc->islog = $nt->isLog() ;
1607 if ( ( $isnew && $oldid == 0 ) || $nt->isLog() ) {
1608 $dlink = wfMsg( "cur" );
1609 } else {
1610 $dlink = $this->makeKnownLink( $t, wfMsg( "cur" ),
1611 "diff=0&oldid={$oldid}" );
1614 if ( $diffid == 0 || $nt->isLog() ) {
1615 $plink = wfMsg( "last" );
1616 } else {
1617 $plink = $this->makeKnownLink( $t, wfMsg( "last" ),
1618 "diff={$oldid}&oldid={$diffid}" );
1621 if ( 0 == $u ) {
1622 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1623 $ut, "target=" . $ut );
1624 } else { $ul = $this->makeLink( $wgLang->getNsText(
1625 Namespace::getUser() ) . ":{$ut}", $ut ); }
1627 $rc->userlink = $ul ;
1628 $rc->lastlink = $plink ;
1629 $rc->curlink = $dlink ;
1631 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1632 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1633 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1635 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1636 $blink = $this->makeKnownLink( $wgLang->specialPage(
1637 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1638 $rc->usertalklink= " ({$utl} | {$blink})";
1639 } else {
1640 $rc->usertalklink=" ({$utl})";
1643 if ( !isset ( $this->rc_cache[$t] ) ) $this->rc_cache[$t] = array() ;
1644 array_push ( $this->rc_cache[$t] , $rc ) ;
1645 return $ret;
1649 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
1651 global $wgUser, $wgLang, $wgTitle;
1653 $dt = $wgLang->timeanddate( $ts, true );
1654 $del = wfMsg( "deleteimg" );
1655 $cur = wfMsg( "cur" );
1657 if ( $iscur ) {
1658 $url = wfImageUrl( $img );
1659 $rlink = $cur;
1660 if ( $wgUser->isSysop() ) {
1661 $link = wfLocalUrlE( "", "image=" . $wgTitle->getURL() .
1662 "&action=delete" );
1663 $style = $this->getInternalLinkAttributes( $link, $del );
1665 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
1666 } else {
1667 $dlink = $del;
1669 } else {
1670 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
1671 if( $wgUser->getID() != 0 ) {
1672 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1673 wfMsg( "revertimg" ), "action=revert&oldimage=" .
1674 urlencode( $img ) );
1675 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1676 $del, "action=delete&oldimage=" . urlencode( $img ) );
1677 } else {
1678 # Having live active links for non-logged in users
1679 # means that bots and spiders crawling our site can
1680 # inadvertently change content. Baaaad idea.
1681 $rlink = wfMsg( "revertimg" );
1682 $dlink = $del;
1685 if ( 0 == $u ) { $ul = $ut; }
1686 else { $ul = $this->makeLink( $wgLang->getNsText(
1687 Namespace::getUser() ) . ":{$ut}", $ut ); }
1689 $nb = str_replace( "$1", $size, wfMsg( "nbytes" ) );
1690 $style = $this->getInternalLinkAttributes( $url, $dt );
1692 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
1693 . " . . {$ul} ({$nb})";
1695 if ( "" != $c && "*" != $c ) {
1696 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1698 $s .= "</li>\n";
1699 return $s;
1702 function tocIndent($level) {
1704 while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
1705 return $rv;
1709 function tocUnindent($level) {
1710 while($level-->0) $rv.="</div>\n";
1711 return $rv;
1714 // parameter level defines if we are on an indentation level
1715 function tocLine($anchor,$tocline,$level) {
1717 if($level) {
1719 return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
1720 } else {
1722 return "<div style=\"margin-bottom:0px;\">\n".
1723 "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
1724 "</div>\n";
1729 function tocTable($toc) {
1730 // note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
1731 global $printable;
1733 if (!$printable) {
1734 $hideline = " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>";
1736 return
1737 "<p><table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
1738 "<b>".wfMsg("toc")."</b>" .
1739 $hideline .
1740 "</td></tr><tr id='tocinside'><td align=\"left\">\n".
1741 $toc."</td></tr></table><P>\n";
1744 # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
1745 function editSectionScript($section,$head) {
1747 global $wgTitle,$wgUser,$oldid;
1748 if($oldid) return $head;
1749 $url = wfLocalUrlE(urlencode($wgTitle->getPrefixedText()),"action=edit&section=$section");
1750 return "<span onContextMenu='document.location=\"".$url."\";return false;'>{$head}</span>";
1753 function editSectionLink($section) {
1755 global $printable;
1756 global $wgTitle,$wgUser,$oldid;
1757 if($oldid) return "";
1758 if ($printable) return "";
1759 $editurl="&section={$section}";
1760 $url=$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
1761 return "<div style=\"float:right;margin-left:5px;\"><small>[".$url."]</small></div>";
1766 include_once( "SkinStandard.php" );
1767 include_once( "SkinNostalgia.php" );
1768 include_once( "SkinCologneBlue.php" );