URL-escape the main page link on the logo
[mediawiki.git] / includes / Skin.php
blob957687024f409f9e3dbbc5a98abb218b7c10030d
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, $wgUseApproval ;
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>";
351 # This will show the "Approve" link if $wgUseApproval=true;
352 if ( isset ( $wgUseApproval ) && $wgUseApproval )
354 $t = $wgTitle->getDBkey();
355 $name = "Approve this article" ;
356 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
357 #wfEscapeHTML( wfImageUrl( $name ) );
358 $style = $this->getExternalLinkAttributes( $link, $name );
359 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
361 if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
362 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
363 wfMsg( "currentrev" ) );
366 if ( $wgUser->getNewtalk() ) {
367 # do not show "You have new messages" text when we are viewing our
368 # own talk page
370 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
371 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
372 $n =$wgUser->getName();
373 $tl = $this->makeKnownLink( $wgLang->getNsText(
374 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
375 wfMsg("newmessageslink") );
376 $s.=" | <strong>". str_replace( "$1", $tl, wfMsg("newmessages") ) . "</strong>";
379 if( $wgUser->isSysop() &&
380 (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
381 ($n = $wgTitle->isDeleted() ) ) {
382 $s .= " | " . wfMsg( "thisisdeleted",
383 $this->makeKnownLink(
384 $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ),
385 wfMsg( "restorelink", $n ) ) );
387 return $s;
390 function printableLink()
392 global $wgOut, $wgTitle, $oldid, $action;
394 if ( "history" == $action ) { $q = "action=history&"; }
395 else { $q = ""; }
397 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
398 WfMsg( "printableversion" ), "{$q}printable=yes" );
399 return $s;
402 function pageTitle()
404 global $wgOut, $wgTitle, $wgUser;
406 $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
407 if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
408 return $s;
411 function pageSubtitle()
413 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
415 $sub = $wgOut->getSubtitle();
416 if ( "" == $sub ) { $sub = wfMsg( "fromwikipedia" ); }
417 if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
418 $ptext=$wgTitle->getPrefixedText();
419 if(preg_match("/\//",$ptext)) {
420 $sub.="</p><p class='subpages'>";
421 $links=explode("/",$ptext);
422 $c=0;
423 $growinglink="";
424 foreach($links as $link) {
425 $c++;
426 if ($c<count($links)) {
427 $growinglink.=$link;
428 $getlink=$this->makeLink($growinglink,$link);
429 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
430 if ($c>1) {
431 $sub .= " | ";
432 } else {
433 $sub .="&lt; ";
435 $sub .= $getlink;
436 $growinglink.="/";
442 $s = "<p class='subtitle'>{$sub}\n";
443 return $s;
446 function nameAndLogin()
448 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader;
450 $li = $wgLang->specialPage( "Userlogin" );
451 $lo = $wgLang->specialPage( "Userlogout" );
453 $s = "";
454 if ( 0 == $wgUser->getID() ) {
455 if( $wgShowIPinHeader ) {
456 $n = getenv( "REMOTE_ADDR" );
458 $tl = $this->makeKnownLink( $wgLang->getNsText(
459 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
460 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
462 $s .= $n . " (".$tl.")";
463 } else {
464 $s .= wfMsg("notloggedin");
467 $rt = $wgTitle->getPrefixedURL();
468 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
469 $q = "";
470 } else { $q = "returnto={$rt}"; }
472 $s .= "\n<br>" . $this->makeKnownLink( $li,
473 wfMsg( "login" ), $q );
474 } else {
475 $n = $wgUser->getName();
476 $rt = $wgTitle->getPrefixedURL();
477 $tl = $this->makeKnownLink( $wgLang->getNsText(
478 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
479 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
481 $tl = " ({$tl})";
483 $s .= $this->makeKnownLink( $wgLang->getNsText(
484 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
485 $this->makeKnownLink( $lo, wfMsg( "logout" ),
486 "returnto={$rt}" ) . " | " .
487 $this->specialLink( "preferences" );
489 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
490 wfMsg( "help" ) );
492 return $s;
495 function searchForm()
497 global $search;
499 $s = "<form name='search' class='inline' method=get action=\""
500 . wfLocalUrl( "" ) . "\">"
501 . "<input type=text name=\"search\" size=19 value=\""
502 . htmlspecialchars(substr($search,0,256)) . "\">\n"
503 . "<input type=submit name=\"go\" value=\"" . wfMsg ("go") . "\">&nbsp;"
504 . "<input type=submit value=\"" . wfMsg ("search") . "\"></form>";
506 return $s;
509 function topLinks()
511 global $wgOut;
512 $sep = " |\n";
514 $s = $this->mainPageLink() . $sep
515 . $this->specialLink( "recentchanges" );
517 if ( $wgOut->isArticle() ) {
518 $s .= $sep . $this->editThisPage()
519 . $sep . $this->historyLink();
521 # Many people don't like this dropdown box
522 #$s .= $sep . $this->specialPagesList();
524 return $s;
527 function bottomLinks()
529 global $wgOut, $wgUser, $wgTitle;
530 $sep = " |\n";
532 $s = "";
533 if ( $wgOut->isArticle() ) {
534 $s .= "<strong>" . $this->editThisPage() . "</strong>";
535 if ( 0 != $wgUser->getID() ) {
536 $s .= $sep . $this->watchThisPage();
538 $s .= $sep . $this->talkLink()
539 . $sep . $this->historyLink()
540 . $sep . $this->whatLinksHere()
541 . $sep . $this->watchPageLinksLink();
543 if ( $wgTitle->getNamespace() == Namespace::getUser()
544 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
547 $id=User::idFromName($wgTitle->getText());
548 $ip=User::isIP($wgTitle->getText());
550 if($id || $ip) { # both anons and non-anons have contri list
551 $s .= $sep . $this->userContribsLink();
553 if ( 0 != $wgUser->getID() ) { # show only to signed in users
554 if($id) { # can only email non-anons
555 $s .= $sep . $this->emailUserLink();
559 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
560 $s .= "\n<br>" . $this->deleteThisPage() .
561 $sep . $this->protectThisPage() .
562 $sep . $this->moveThisPage();
564 $s .= "<br>\n" . $this->otherLanguages();
566 return $s;
569 function pageStats()
571 global $wgOut, $wgLang, $wgArticle;
572 global $oldid, $diff, $wgDisableCounters;
574 if ( ! $wgOut->isArticle() ) { return ""; }
575 if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
576 if ( 0 == $wgArticle->getID() ) { return ""; }
578 if ( $wgDisableCounters ) {
579 $s = "";
580 } else {
581 $count = $wgArticle->getCount();
582 $s = str_replace( "$1", $count, wfMsg( "viewcount" ) );
584 $s .= $this->lastModified();
585 $s .= " " . wfMsg( "gnunote" );
586 return "<span id='pagestats'>{$s}</span>";
589 function lastModified()
591 global $wgLang, $wgArticle;
593 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
594 $s = " " . str_replace( "$1", $d, wfMsg( "lastmodified" ) );
595 return $s;
598 function logoText( $align = "" )
600 if ( "" != $align ) { $a = " align='{$align}'"; }
601 else { $a = ""; }
603 $mp = wfMsg( "mainpage" );
604 $s = "<a href=\"" . wfLocalUrlE( urlencode( $mp ) )
605 . "\"><img{$a} border=0 src=\""
606 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
607 return $s;
610 function quickBar()
612 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
613 global $wpPreview;
614 wfProfileIn( "Skin::quickBar" );
615 $tns=$wgTitle->getNamespace();
617 $s = "\n<div id='quickbar'>";
618 $s .= "\n" . $this->logoText() . "\n<hr class='sep'>";
620 $sep = "\n<br>";
621 $s .= $this->mainPageLink()
622 . $sep . $this->specialLink( "recentchanges" )
623 . $sep . $this->specialLink( "randompage" );
624 if ($wgUser->getID()) {
625 $s.= $sep . $this->specialLink( "watchlist" ) ;
626 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
627 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
630 // only show watchlist link if logged in
631 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
632 $s .= "\n<br><hr class='sep'>";
633 $articleExists = $wgTitle->getArticleId();
634 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
636 if($wgOut->isArticle()) {
637 $s .= "<strong>" . $this->editThisPage() . "</strong>";
638 } else { # backlink to the article in edit or history mode
639 if($articleExists){ # no backlink if no article
640 switch($tns) {
641 case 0:
642 $text = wfMsg("articlepage");
643 break;
644 case 1:
645 $text = wfMsg("viewtalkpage");
646 break;
647 case 2:
648 $text = wfMsg("userpage");
649 break;
650 case 3:
651 $text = wfMsg("viewtalkpage");
652 break;
653 case 4:
654 $text = wfMsg("wikipediapage");
655 break;
656 case 5:
657 $text = wfMsg("viewtalkpage");
658 break;
659 case 6:
660 $text = wfMsg("imagepage");
661 break;
662 case 7:
663 $text = wfMsg("viewtalkpage");
664 break;
665 default:
666 $text= wfMsg("articlepage");
669 $link = $wgTitle->getText();
670 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
671 $link = $nstext . ":" . $link ;
673 $s .= $this->makeLink($link, $text );
674 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
675 # we just throw in a "New page" text to tell the user that he's in edit mode,
676 # and to avoid messing with the separator that is prepended to the next item
677 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
683 if( $tns%2 && $action!="edit" && !$wpPreview) {
684 $s.="<br>".$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("postcomment"),"action=edit&section=new");
688 watching could cause problems in edit mode:
689 if user edits article, then loads "watch this article" in background and then saves
690 article with "Watch this article" checkbox disabled, the article is transparently
691 unwatched. Therefore we do not show the "Watch this page" link in edit mode
693 if ( 0 != $wgUser->getID() && $articleExists) {
694 if($action!="edit" && $action!="history" &&
695 $action != "submit" )
696 {$s .= $sep . $this->watchThisPage(); }
697 if ( $wgTitle->userCanEdit() ) $s .= $sep . $this->moveThisPage();
699 if ( $wgUser->isSysop() and $articleExists ) {
700 $s .= $sep . $this->deleteThisPage() .
701 $sep . $this->protectThisPage();
703 $s .= $sep . $this->talkLink();
704 if ($articleExists && $action !="history") { $s .= $sep . $this->historyLink();}
705 $s.=$sep . $this->whatLinksHere();
707 if($wgOut->isArticle()) {
708 $s .= $sep . $this->watchPageLinksLink();
711 if ( Namespace::getUser() == $wgTitle->getNamespace()
712 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
715 $id=User::idFromName($wgTitle->getText());
716 $ip=User::isIP($wgTitle->getText());
718 if($id||$ip) {
719 $s .= $sep . $this->userContribsLink();
721 if ( 0 != $wgUser->getID() ) {
722 if($id) { # can only email real users
723 $s .= $sep . $this->emailUserLink();
727 $s .= "\n<br><hr class='sep'>";
730 if ( 0 != $wgUser->getID() ) {
731 $s .= $this->specialLink( "upload" ) . $sep;
733 $s .= $this->specialLink( "specialpages" )
734 . $sep . $this->bugReportsLink();
736 $s .= "\n<br></div>\n";
737 wfProfileOut();
738 return $s;
741 function specialPagesList()
743 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
744 $a = array();
746 $validSP = $wgLang->getValidSpecialPages();
748 foreach ( $validSP as $name => $desc ) {
749 if ( "" == $desc ) { continue; }
750 $a[$name] = $desc;
752 if ( $wgUser->isSysop() )
754 $sysopSP = $wgLang->getSysopSpecialPages();
756 foreach ( $sysopSP as $name => $desc ) {
757 if ( "" == $desc ) { continue; }
758 $a[$name] = $desc ;
761 if ( $wgUser->isDeveloper() )
763 $devSP = $wgLang->getDeveloperSpecialPages();
765 foreach ( $devSP as $name => $desc ) {
766 if ( "" == $desc ) { continue; }
767 $a[$name] = $desc ;
770 $go = wfMsg( "go" );
771 $sp = wfMsg( "specialpages" );
772 $spp = $wgLang->specialPage( "Specialpages" );
774 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
775 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
776 $s .= "<select name=\"wpDropdown\">\n";
777 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
779 foreach ( $a as $name => $desc ) {
780 $p = $wgLang->specialPage( $name );
781 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
783 $s .= "</select>\n";
784 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
785 $s .= "</form>\n";
786 return $s;
789 function mainPageLink()
791 $mp = wfMsg( "mainpage" );
792 $s = $this->makeKnownLink( $mp, $mp );
793 return $s;
796 function copyrightLink()
798 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
799 wfMsg( "copyrightpagename" ) );
800 return $s;
803 function aboutLink()
805 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
806 wfMsg( "aboutwikipedia" ) );
807 return $s;
810 function editThisPage()
812 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
814 if ( ! $wgOut->isArticle() || $diff ) {
815 $s = wfMsg( "protectedpage" );
816 } else if ( $wgTitle->userCanEdit() ) {
817 $n = $wgTitle->getPrefixedText();
818 $t = wfMsg( "editthispage" );
819 $oid = $red = "";
821 if ( $redirect ) { $red = "&redirect={$redirect}"; }
822 if ( $oldid && ! isset( $diff ) ) {
823 $oid = "&oldid={$oldid}";
825 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
826 } else {
827 $s = wfMsg( "protectedpage" );
829 return $s;
832 function deleteThisPage()
834 global $wgUser, $wgOut, $wgTitle, $diff;
836 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
837 $n = $wgTitle->getPrefixedText();
838 $t = wfMsg( "deletethispage" );
840 $s = $this->makeKnownLink( $n, $t, "action=delete" );
841 } else {
842 $s = wfMsg( "error" );
844 return $s;
847 function protectThisPage()
849 global $wgUser, $wgOut, $wgTitle, $diff;
851 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
852 $n = $wgTitle->getPrefixedText();
854 if ( $wgTitle->isProtected() ) {
855 $t = wfMsg( "unprotectthispage" );
856 $q = "action=unprotect";
857 } else {
858 $t = wfMsg( "protectthispage" );
859 $q = "action=protect";
861 $s = $this->makeKnownLink( $n, $t, $q );
862 } else {
863 $s = wfMsg( "error" );
865 return $s;
868 function watchThisPage()
870 global $wgUser, $wgOut, $wgTitle, $diff;
872 if ( $wgOut->isArticle() && ( ! $diff ) ) {
873 $n = $wgTitle->getPrefixedText();
875 if ( $wgTitle->userIsWatching() ) {
876 $t = wfMsg( "unwatchthispage" );
877 $q = "action=unwatch";
878 } else {
879 $t = wfMsg( "watchthispage" );
880 $q = "action=watch";
882 $s = $this->makeKnownLink( $n, $t, $q );
883 } else {
884 $s = wfMsg( "notanarticle" );
886 return $s;
889 function moveThisPage()
891 global $wgTitle, $wgLang;
893 if ( $wgTitle->userCanEdit() ) {
894 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
895 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
896 } // no message if page is protected - would be redundant
897 return $s;
900 function historyLink()
902 global $wgTitle;
904 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
905 wfMsg( "history" ), "action=history" );
906 return $s;
909 function whatLinksHere()
911 global $wgTitle, $wgLang;
913 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
914 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
915 return $s;
918 function userContribsLink()
920 global $wgTitle, $wgLang;
922 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
923 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
924 return $s;
927 function emailUserLink()
929 global $wgTitle, $wgLang;
931 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
932 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
933 return $s;
936 function watchPageLinksLink()
938 global $wgOut, $wgTitle, $wgLang;
940 if ( ! $wgOut->isArticle() ) {
941 $s = "(" . wfMsg( "notanarticle" ) . ")";
942 } else {
943 $s = $this->makeKnownLink( $wgLang->specialPage(
944 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
945 "target=" . $wgTitle->getPrefixedURL() );
947 return $s;
950 function otherLanguages()
952 global $wgOut, $wgLang, $wgTitle , $wgUseNewInterlanguage ;
954 $a = $wgOut->getLanguageLinks();
955 if ( 0 == count( $a ) ) {
956 if ( !$wgUseNewInterlanguage ) return "";
957 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
958 if ( $ns != 0 AND $ns != 1 ) return "" ;
959 $pn = "Intl" ;
960 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
961 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
962 wfMsg( "intl" ) , $x );
965 if ( !$wgUseNewInterlanguage ) {
966 $s = wfMsg( "otherlanguages" ) . ": ";
967 } else {
968 global $wgLanguageCode ;
969 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
970 $x .= "&xl=".$wgLanguageCode ;
971 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
972 wfMsg( "otherlanguages" ) , $x ) . ": " ;
975 $first = true;
976 if($wgLang->isRTL()) $s .= "<span dir='LTR'>";
977 foreach( $a as $l ) {
978 if ( ! $first ) { $s .= " | "; }
979 $first = false;
981 $nt = Title::newFromText( $l );
982 $url = $nt->getFullURL();
983 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
985 if ( "" == $text ) { $text = $l; }
986 $style = $this->getExternalLinkAttributes( $l, $text );
987 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
989 if($wgLang->isRTL()) $s .= "</span>";
990 return $s;
993 function bugReportsLink()
995 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
996 wfMsg( "bugreports" ) );
997 return $s;
1000 function dateLink()
1002 global $wgLinkCache;
1003 $t1 = Title::newFromText( gmdate( "F j" ) );
1004 $t2 = Title::newFromText( gmdate( "Y" ) );
1006 $wgLinkCache->suspend();
1007 $id = $t1->getArticleID();
1008 $wgLinkCache->resume();
1010 if ( 0 == $id ) {
1011 $s = $this->makeBrokenLink( $t1->getText() );
1012 } else {
1013 $s = $this->makeKnownLink( $t1->getText() );
1015 $s .= ", ";
1017 $wgLinkCache->suspend();
1018 $id = $t2->getArticleID();
1019 $wgLinkCache->resume();
1021 if ( 0 == $id ) {
1022 $s .= $this->makeBrokenLink( $t2->getText() );
1023 } else {
1024 $s .= $this->makeKnownLink( $t2->getText() );
1026 return $s;
1029 function talkLink()
1031 global $wgLang, $wgTitle, $wgLinkCache;
1033 $tns = $wgTitle->getNamespace();
1034 if ( -1 == $tns ) { return ""; }
1036 $pn = $wgTitle->getText();
1037 $tp = wfMsg( "talkpage" );
1038 if ( Namespace::isTalk( $tns ) ) {
1039 $lns = Namespace::getSubject( $tns );
1040 switch($tns) {
1041 case 1:
1042 $text = wfMsg("articlepage");
1043 break;
1044 case 3:
1045 $text = wfMsg("userpage");
1046 break;
1047 case 5:
1048 $text = wfMsg("wikipediapage");
1049 break;
1050 case 7:
1051 $text = wfMsg("imagepage");
1052 break;
1053 default:
1054 $text= wfMsg("articlepage");
1056 } else {
1058 $lns = Namespace::getTalk( $tns );
1059 $text=$tp;
1061 $n = $wgLang->getNsText( $lns );
1062 if ( "" == $n ) { $link = $pn; }
1063 else { $link = "{$n}:{$pn}"; }
1065 $wgLinkCache->suspend();
1066 $s = $this->makeLink( $link, $text );
1067 $wgLinkCache->resume();
1069 return $s;
1072 # After all the page content is transformed into HTML, it makes
1073 # a final pass through here for things like table backgrounds.
1075 function transformContent( $text )
1077 return $text;
1080 # Note: This function MUST call getArticleID() on the link,
1081 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1083 function makeLink( $title, $text= "", $query = "", $trail = "" )
1085 global $wgOut, $wgUser;
1087 $nt = Title::newFromText( $title );
1089 if ( $nt->isExternal() ) {
1090 $u = $nt->getFullURL();
1091 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1092 $style = $this->getExternalLinkAttributes( $link, $text );
1094 $inside = "";
1095 if ( "" != $trail ) {
1096 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1097 $inside = $m[1];
1098 $trail = $m[2];
1101 return "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1103 if ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1104 return $this->makeKnownLink( $title, $text, $query, $trail );
1106 if ( ( -1 == $nt->getNamespace() ) ||
1107 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1108 return $this->makeKnownLink( $title, $text, $query, $trail );
1110 $aid = $nt->getArticleID() ;
1111 if ( 0 == $aid ) {
1112 return $this->makeBrokenLink( $title, $text, $query, $trail );
1113 } else {
1114 $threshold = $wgUser->getOption("stubthreshold") ;
1115 if ( $threshold > 0 ) {
1116 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'" ) ;
1118 if ( wfNumRows( $res ) > 0 ) {
1119 $s = wfFetchObject( $res );
1120 $size = $s->x;
1121 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
1122 $size = $threshold*2 ; # Really big
1123 wfFreeResult( $res );
1124 } else $size = $threshold*2 ; # Really big
1125 } else $size = 1 ;
1127 if ( $size < $threshold )
1128 return $this->makeStubLink( $title, $text, $query, $trail );
1129 return $this->makeKnownLink( $title, $text, $query, $trail );
1133 function makeKnownLink( $title, $text = "", $query = "", $trail = "" )
1135 global $wgOut, $wgTitle;
1137 $nt = Title::newFromText( $title );
1138 $link = $nt->getPrefixedURL();
1140 if ( "" == $link ) {
1141 $u = "";
1142 if ( "" == $text ) { $text = $nt->getFragment(); }
1143 } else {
1144 $u = wfLocalUrlE( $link, $query );
1146 if ( "" != $nt->getFragment() ) {
1147 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1149 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1150 $style = $this->getInternalLinkAttributes( $link, $text );
1152 $inside = "";
1153 if ( "" != $trail ) {
1154 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1155 $inside = $m[1];
1156 $trail = $m[2];
1159 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1160 return $r;
1163 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" )
1165 global $wgOut, $wgUser;
1167 $nt = Title::newFromText( $title );
1168 $link = $nt->getPrefixedURL();
1170 if ( "" == $query ) { $q = "action=edit"; }
1171 else { $q = "action=edit&{$query}"; }
1172 $u = wfLocalUrlE( $link, $q );
1174 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1175 $style = $this->getInternalLinkAttributes( $link, $text, "yes" );
1177 $inside = "";
1178 if ( "" != $trail ) {
1179 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1180 $inside = $m[1];
1181 $trail = $m[2];
1184 if ( $wgOut->isPrintable() ||
1185 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1186 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1187 } else {
1188 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1190 return $s;
1193 function makeStubLink( $title, $text = "", $query = "", $trail = "" )
1195 global $wgOut, $wgUser;
1197 $nt = Title::newFromText( $title );
1198 $link = $nt->getPrefixedURL();
1200 $u = wfLocalUrlE( $link, $query );
1202 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1203 $style = $this->getInternalLinkAttributes( $link, $text, "stub" );
1205 $inside = "";
1206 if ( "" != $trail ) {
1207 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1208 $inside = $m[1];
1209 $trail = $m[2];
1212 if ( $wgOut->isPrintable() ||
1213 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1214 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1215 } else {
1216 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1218 return $s;
1221 function fnamePart( $url )
1223 $basename = strrchr( $url, "/" );
1224 if ( false === $basename ) { $basename = $url; }
1225 else { $basename = substr( $basename, 1 ); }
1226 return wfEscapeHTML( $basename );
1229 function makeImage( $url, $alt = "" )
1231 global $wgOut;
1233 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1234 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1235 return $s;
1238 function makeImageLink( $name, $url, $alt = "" )
1240 global $wgOut, $wgTitle, $wgLang;
1242 $nt = Title::newFromText( $wgLang->getNsText(
1243 Namespace::getImage() ) . ":{$name}" );
1244 $link = $nt->getPrefixedURL();
1245 if ( "" == $alt ) { $alt = $name; }
1247 $u = wfLocalUrlE( $link );
1248 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1249 "<img border=0 src=\"{$url}\" alt=\"{$alt}\"></a>";
1250 return $s;
1253 function makeMediaLink( $name, $url, $alt = "" )
1255 global $wgOut, $wgTitle;
1257 if ( "" == $alt ) { $alt = $name; }
1258 $u = wfEscapeHTML( $url );
1259 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1260 return $s;
1263 function specialLink( $name, $key = "" )
1265 global $wgLang;
1267 if ( "" == $key ) { $key = strtolower( $name ); }
1268 $pn = $wgLang->ucfirst( $name );
1269 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1270 wfMsg( $key ) );
1273 # Called by history lists and recent changes
1276 function beginRecentChangesList()
1278 $rc_cache = array() ;
1279 $rccc = 0 ;
1280 $this->lastdate = "";
1281 return "";
1284 function beginHistoryList()
1286 $this->lastdate = $this->lastline = "";
1287 $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
1288 return $s;
1291 function beginImageHistoryList()
1293 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1294 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1295 return $s;
1298 function endRecentChangesList()
1300 $s = $this->recentChangesBlock() ;
1301 $s .= "</ul>\n";
1302 return $s;
1305 function endHistoryList()
1307 $last = wfMsg( "last" );
1309 $s = preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
1310 $s .= "</ul>\n";
1311 return $s;
1314 function endImageHistoryList()
1316 $s = "</ul>\n";
1317 return $s;
1320 function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor )
1322 global $wgLang;
1324 $artname = Title::makeName( $ns, $ttl );
1325 $last = wfMsg( "last" );
1326 $cur = wfMsg( "cur" );
1327 $cr = wfMsg( "currentrev" );
1329 if ( $oid && $this->lastline ) {
1330 $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->makeKnownLink(
1331 $artname, $last, "diff=\\1&oldid={$oid}" ), $this->lastline );
1332 } else {
1333 $ret = "";
1335 $dt = $wgLang->timeanddate( $ts, true );
1337 if ( $oid ) { $q = "oldid={$oid}"; }
1338 else { $q = ""; }
1339 $link = $this->makeKnownLink( $artname, $dt, $q );
1341 if ( 0 == $u ) {
1342 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1343 $ut, "target=" . $ut );
1344 } else { $ul = $this->makeLink( $wgLang->getNsText(
1345 Namespace::getUser() ) . ":{$ut}", $ut ); }
1347 $s = "<li>";
1348 if ( $oid ) {
1349 $curlink = $this->makeKnownLink( $artname, $cur,
1350 "diff=0&oldid={$oid}" );
1351 } else {
1352 $curlink = $cur;
1354 $s .= "({$curlink}) (!OLDID!{$oid}!) . .";
1356 $M = wfMsg( "minoreditletter" );
1357 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1358 $s .= " {$link} . . {$ul}";
1360 if ( "" != $c && "*" != $c ) { $s .= " <em>(" . wfEscapeHTML($c) . ")</em>"; }
1361 $s .= "</li>\n";
1363 $this->lastline = $s;
1364 return $ret;
1367 function recentChangesBlockLine ( $y ) {
1368 global $wgUploadPath ;
1370 $M = wfMsg( "minoreditletter" );
1371 $N = wfMsg( "newpageletter" );
1372 $r = "" ;
1373 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;
1374 $r .= "<tt>" ;
1375 if ( $y->isnew ) $r .= $N ;
1376 else $r .= "&nbsp;" ;
1377 if ( $y->isminor ) $r .= $M ;
1378 else $r .= "&nbsp;" ;
1379 $r .= " ".$y->timestamp." " ;
1380 $r .= "</tt>" ;
1381 $link = $y->link ;
1382 if ( $y->watched ) $link = "<strong>{$link}</strong>" ;
1383 $r .= $link ;
1385 $r .= " (" ;
1386 $r .= $y->curlink ;
1387 $r .= "; " ;
1388 $r .= $this->makeKnownLink( $y->secureName, wfMsg( "hist" ), "action=history" );
1390 $r .= ") . . ".$y->userlink ;
1391 $r .= $y->usertalklink ;
1392 if ( $y->usercomment != "" )
1393 $r .= " <em>(".wfEscapeHTML($y->usercomment).")</em>" ;
1394 $r .= "<br>\n" ;
1395 return $r ;
1398 function recentChangesBlockGroup ( $y ) {
1399 global $wgUploadPath ;
1401 $r = "" ;
1402 $M = wfMsg( "minoreditletter" );
1403 $N = wfMsg( "newpageletter" );
1404 $isnew = false ;
1405 $userlinks = array () ;
1406 foreach ( $y AS $x ) {
1407 $oldid = $x->diffid ;
1408 if ( $x->isnew ) $isnew = true ;
1409 $u = $x->userlink ;
1410 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1411 $userlinks[$u]++ ;
1414 krsort ( $userlinks ) ;
1415 asort ( $userlinks ) ;
1416 $users = array () ;
1417 $u = array_keys ( $userlinks ) ;
1418 foreach ( $u as $x ) {
1419 $z = $x ;
1420 if ( $userlinks[$x] > 1 ) $z .= " ({$userlinks[$x]}&times;)" ;
1421 array_push ( $users , $z ) ;
1423 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1425 $e = $y ;
1426 $e = array_shift ( $e ) ;
1428 # Arrow
1429 $rci = "RCI{$this->rccc}" ;
1430 $rcl = "RCL{$this->rccc}" ;
1431 $rcm = "RCM{$this->rccc}" ;
1432 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1433 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1434 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1435 $tl .= "</a>" ;
1436 $r .= $tl ;
1438 # Main line
1439 $r .= "<tt>" ;
1440 if ( $isnew ) $r .= $N ;
1441 else $r .= "&nbsp;" ;
1442 $r .= "&nbsp;" ; # Minor
1443 $r .= " ".$e->timestamp." " ;
1444 $r .= "</tt>" ;
1446 $link = $e->link ;
1447 if ( $e->watched ) $link = "<strong>{$link}</strong>" ;
1448 $r .= $link ;
1450 if ( !$e->islog ) {
1451 $r .= " (".count($y)." " ;
1452 if ( $isnew ) $r .= wfMsg("changes");
1453 else $r .= $this->makeKnownLink( $e->secureName , wfMsg("changes") , "diff=0&oldid=".$oldid ) ;
1454 $r .= "; " ;
1455 $r .= $this->makeKnownLink( $e->secureName, wfMsg( "history" ), "action=history" );
1456 $r .= ")" ;
1459 $r .= $users ;
1460 $r .= "<br>\n" ;
1462 # Sub-entries
1463 $r .= "<div id='{$rci}' style='display:none'>" ;
1464 foreach ( $y AS $x )
1466 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1467 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
1468 if ( $x->isnew ) $r .= $N ;
1469 else $r .= "&nbsp;" ;
1470 if ( $x->isminor ) $r .= $M ;
1471 else $r .= "&nbsp;" ;
1472 $r .= "</tt>" ;
1474 $o = "" ;
1475 if ( $x->oldid != 0 ) $o = "oldid=".$x->oldid ;
1476 if ( $x->islog ) $link = $x->timestamp ;
1477 else $link = $this->makeKnownLink( $x->secureName, $x->timestamp , $o ) ;
1478 $link = "<tt>{$link}</tt>" ;
1481 $r .= $link ;
1482 $r .= " (" ;
1483 $r .= $x->curlink ;
1484 $r .= "; " ;
1485 $r .= $x->lastlink ;
1486 $r .= ") . . ".$x->userlink ;
1487 $r .= $x->usertalklink ;
1488 if ( $x->usercomment != "" )
1489 $r .= " <em>(".wfEscapeHTML($x->usercomment).")</em>" ;
1490 $r .= "<br>\n" ;
1492 $r .= "</div>\n" ;
1494 $this->rccc++ ;
1495 return $r ;
1498 function recentChangesBlock ()
1500 global $wgUploadPath ;
1501 if ( count ( $this->rc_cache ) == 0 ) return "" ;
1502 $k = array_keys ( $this->rc_cache ) ;
1503 foreach ( $k AS $x )
1505 $y = $this->rc_cache[$x] ;
1506 if ( count ( $y ) < 2 ) {
1507 $r .= $this->recentChangesBlockLine ( array_shift ( $y ) ) ;
1508 } else {
1509 $r .= $this->recentChangesBlockGroup ( $y ) ;
1513 return "<div align=left>{$r}</div>" ;
1516 function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1518 global $wgUser ;
1519 $usenew = $wgUser->getOption( "usenewrc" );
1520 if ( $usenew )
1521 $r = $this->recentChangesLineNew ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1522 else
1523 $r = $this->recentChangesLineOld ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1524 return $r ;
1527 function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 )
1529 global $wgTitle, $wgLang, $wgUser;
1531 $d = $wgLang->date( $ts, true);
1532 $s = "";
1533 if ( $d != $this->lastdate ) {
1534 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
1535 $s .= "<h4>{$d}</h4>\n<ul>";
1536 $this->lastdate = $d;
1538 $h = $wgLang->time( $ts, true );
1539 $t = Title::makeName( $ns, $ttl );
1540 $clink = $this->makeKnownLink( $t , "" );
1541 $nt = Title::newFromText( $t );
1543 if ( $watched ) {
1544 $clink = "<strong>{$clink}</strong>";
1546 $hlink = $this->makeKnownLink( $t, wfMsg( "hist" ), "action=history" );
1547 if ( $isnew || $nt->isLog() ) {
1548 $dlink = wfMsg( "diff" );
1549 } else {
1550 $dlink = $this->makeKnownLink( $t, wfMsg( "diff" ),
1551 "diff={$oldid}&oldid={$diffid}" ); # Finagle's law
1553 if ( 0 == $u ) {
1554 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1555 $ut, "target=" . $ut );
1556 } else { $ul = $this->makeLink( $wgLang->getNsText(
1557 Namespace::getUser() ) . ":{$ut}", $ut ); }
1559 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1560 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1561 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1562 $cr = wfMsg( "currentrev" );
1564 $s .= "<li> ({$dlink}) ({$hlink}) . .";
1565 $M = wfMsg( "minoreditletter" );
1566 $N = wfMsg( "newpageletter" );
1567 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1568 if ( $isnew ) { $s .= "<strong>{$N}</strong>"; }
1569 $s .= " {$clink}; {$h} . . {$ul}";
1571 $blink="";
1572 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1573 $blink = $this->makeKnownLink( $wgLang->specialPage(
1574 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1577 if(!$blink) {
1578 $utl = "({$utl})";
1579 } else {
1580 $utl = "({$utl} | {$blink})";
1582 $s.=" {$utl}";
1584 if ( "" != $c && "*" != $c ) {
1585 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1587 $s .= "</li>\n";
1589 return $s;
1592 function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1594 global $wgTitle, $wgLang, $wgUser;
1596 $rc = new RecentChangesClass ;
1598 $d = $wgLang->date( $ts, true);
1599 $s = "";
1600 $ret = "" ;
1601 if ( $d != $this->lastdate ) {
1602 $ret = $this->recentChangesBlock () ;
1603 $this->rc_cache = array() ;
1604 $ret .= "<h4>{$d}</h4>\n";
1605 $this->lastdate = $d;
1607 $h = $wgLang->time( $ts, true );
1608 $t = Title::makeName( $ns, $ttl );
1609 $clink = $this->makeKnownLink( $t, "" ) ;
1610 if ( $oldid == 0 ) $c2link = $clink ;
1611 else $c2link = $this->makeKnownLink( $t, "" , "oldid={$oldid}" );
1612 $nt = Title::newFromText( $t );
1614 $rc->timestamp = $h ;
1615 $rc->oldid = $oldid ;
1616 $rc->diffid = $diffid ;
1617 $rc->watched = $watched ;
1618 $rc->isnew = $isnew ;
1619 $rc->isminor = $isminor ;
1620 $rc->secureName = $t ;
1621 $rc->displayName = $nt ;
1622 $rc->link = $clink ;
1623 $rc->usercomment = $c ;
1624 $rc->islog = $nt->isLog() ;
1626 if ( ( $isnew && $oldid == 0 ) || $nt->isLog() ) {
1627 $dlink = wfMsg( "cur" );
1628 } else {
1629 $dlink = $this->makeKnownLink( $t, wfMsg( "cur" ),
1630 "diff=0&oldid={$oldid}" );
1633 if ( $diffid == 0 || $nt->isLog() ) {
1634 $plink = wfMsg( "last" );
1635 } else {
1636 $plink = $this->makeKnownLink( $t, wfMsg( "last" ),
1637 "diff={$oldid}&oldid={$diffid}" );
1640 if ( 0 == $u ) {
1641 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1642 $ut, "target=" . $ut );
1643 } else { $ul = $this->makeLink( $wgLang->getNsText(
1644 Namespace::getUser() ) . ":{$ut}", $ut ); }
1646 $rc->userlink = $ul ;
1647 $rc->lastlink = $plink ;
1648 $rc->curlink = $dlink ;
1650 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1651 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1652 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1654 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1655 $blink = $this->makeKnownLink( $wgLang->specialPage(
1656 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1657 $rc->usertalklink= " ({$utl} | {$blink})";
1658 } else {
1659 $rc->usertalklink=" ({$utl})";
1662 if ( !isset ( $this->rc_cache[$t] ) ) $this->rc_cache[$t] = array() ;
1663 array_push ( $this->rc_cache[$t] , $rc ) ;
1664 return $ret;
1668 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
1670 global $wgUser, $wgLang, $wgTitle;
1672 $dt = $wgLang->timeanddate( $ts, true );
1673 $del = wfMsg( "deleteimg" );
1674 $cur = wfMsg( "cur" );
1676 if ( $iscur ) {
1677 $url = wfImageUrl( $img );
1678 $rlink = $cur;
1679 if ( $wgUser->isSysop() ) {
1680 $link = wfLocalUrlE( $wgTitle->getPrefixedText(), "image=" . $wgTitle->getURL() .
1681 "&action=delete" );
1682 $style = $this->getInternalLinkAttributes( $link, $del );
1684 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
1685 } else {
1686 $dlink = $del;
1688 } else {
1689 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
1690 if( $wgUser->getID() != 0 ) {
1691 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1692 wfMsg( "revertimg" ), "action=revert&oldimage=" .
1693 urlencode( $img ) );
1694 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1695 $del, "action=delete&oldimage=" . urlencode( $img ) );
1696 } else {
1697 # Having live active links for non-logged in users
1698 # means that bots and spiders crawling our site can
1699 # inadvertently change content. Baaaad idea.
1700 $rlink = wfMsg( "revertimg" );
1701 $dlink = $del;
1704 if ( 0 == $u ) { $ul = $ut; }
1705 else { $ul = $this->makeLink( $wgLang->getNsText(
1706 Namespace::getUser() ) . ":{$ut}", $ut ); }
1708 $nb = str_replace( "$1", $size, wfMsg( "nbytes" ) );
1709 $style = $this->getInternalLinkAttributes( $url, $dt );
1711 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
1712 . " . . {$ul} ({$nb})";
1714 if ( "" != $c && "*" != $c ) {
1715 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1717 $s .= "</li>\n";
1718 return $s;
1721 function tocIndent($level) {
1723 while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
1724 return $rv;
1728 function tocUnindent($level) {
1729 while($level-->0) $rv.="</div>\n";
1730 return $rv;
1733 // parameter level defines if we are on an indentation level
1734 function tocLine($anchor,$tocline,$level) {
1736 if($level) {
1738 return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
1739 } else {
1741 return "<div style=\"margin-bottom:0px;\">\n".
1742 "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
1743 "</div>\n";
1748 function tocTable($toc) {
1749 // note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
1750 global $printable;
1752 if (!$printable) {
1753 $hideline = " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>";
1755 return
1756 "<p><table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
1757 "<b>".wfMsg("toc")."</b>" .
1758 $hideline .
1759 "</td></tr><tr id='tocinside'><td align=\"left\">\n".
1760 $toc."</td></tr></table><P>\n";
1763 # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
1764 function editSectionScript($section,$head) {
1766 global $wgTitle,$wgUser,$oldid;
1767 if($oldid) return $head;
1768 $url = wfLocalUrlE(urlencode($wgTitle->getPrefixedText()),"action=edit&section=$section");
1769 return "<span onContextMenu='document.location=\"".$url."\";return false;'>{$head}</span>";
1772 function editSectionLink($section) {
1774 global $printable;
1775 global $wgTitle,$wgUser,$oldid;
1776 if($oldid) return "";
1777 if ($printable) return "";
1778 $editurl="&section={$section}";
1779 $url=$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
1780 return "<div style=\"float:right;margin-left:5px;\"><small>[".$url."]</small></div>";
1785 include_once( "SkinStandard.php" );
1786 include_once( "SkinNostalgia.php" );
1787 include_once( "SkinCologneBlue.php" );