fix two typo / cleanup
[mediawiki.git] / includes / Skin.php
blobdad6d940ba6ba56899dbcd94815eafa1460d26cb
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" #, "Smarty", "Montparnasse"
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 $fname = "Skin::initPage";
74 wfProfileIn( $fname );
76 $wgOut->addLink( "shortcut icon", "", "/favicon.ico" );
77 if ( $wgOut->isPrintable() ) { $ss = "wikiprintable.css"; }
78 else { $ss = $this->getStylesheet(); }
79 $wgOut->addLink( "stylesheet", "", "{$wgStyleSheetPath}/{$ss}" );
80 wfProfileOut( $fname );
83 function outputPage( &$out ) {
84 wfProfileIn( "Skin::outputPage" );
85 $this->initPage();
86 $out->out( $out->headElement() );
88 $out->out( "\n<body" );
89 $ops = $this->getBodyOptions();
90 foreach ( $ops as $name => $val ) {
91 $out->out( " $name='$val'" );
93 $out->out( ">\n" );
94 if ( $wgDebugComments ) {
95 $out->out( "<!-- Wiki debugging output:\n" .
96 $out->mDebugtext . "-->\n" );
98 $out->out( $this->beforeContent() );
100 $out->out( $out->mBodytext );
102 $out->out( $this->afterContent() );
104 wfProfileClose();
105 $out->out( $out->reportTime() );
107 $out->out( "\n</body></html>" );
110 function getHeadScripts() {
111 global $wgStyleSheetPath;
112 $r = "<script type=\"text/javascript\" src=\"{$wgStyleSheetPath}/wikibits.js\"></script>\n";
113 return $r;
116 function getUserStyles()
118 $s = "<style type='text/css'><!--\n";
119 $s .= $this->doGetUserStyles();
120 $s .= "//--></style>\n";
121 return $s;
124 function doGetUserStyles()
126 global $wgUser;
128 $s = "";
129 if ( 1 == $wgUser->getOption( "underline" ) ) {
130 # Don't override browser settings
131 } else {
132 # Force no underline
133 $s .= "a.stub, a.new, a.internal, a.external { " .
134 "text-decoration: none; }\n";
136 if ( 1 == $wgUser->getOption( "highlightbroken" ) ) {
137 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
139 if ( 1 == $wgUser->getOption( "justify" ) ) {
140 $s .= "#article { text-align: justify; }\n";
142 return $s;
145 function getBodyOptions()
147 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $oldid, $redirect, $diff,$action;
149 if ( 0 != $wgTitle->getNamespace() ) {
150 $a = array( "bgcolor" => "#ffffec" );
152 else $a = array( "bgcolor" => "#FFFFFF" );
153 if($wgOut->isArticle() && $wgUser->getOption("editondblclick")
155 (!$wgTitle->isProtected() || $wgUser->isSysop())
158 $n = $wgTitle->getPrefixedURL();
159 $t = wfMsg( "editthispage" );
160 $oid = $red = "";
161 if ( $redirect ) { $red = "&redirect={$redirect}"; }
162 if ( $oldid && ! isset( $diff ) ) {
163 $oid = "&oldid={$oldid}";
165 $s = wfLocalUrlE($n,"action=edit{$oid}{$red}");
166 $s = "document.location = \"" .$s ."\";";
167 $a += array ("ondblclick" => $s);
170 if($action=="edit") { # set focus in edit box
171 $foc = "document.editform.wpTextbox1.focus()";
172 if($a['onload']) {
173 $a['onload'] .= ";$foc";
174 } else {
175 $a['onload'] = $foc;
178 return $a;
181 function getExternalLinkAttributes( $link, $text )
183 global $wgUser, $wgOut, $wgLang;
185 $link = urldecode( $link );
186 $link = $wgLang->checkTitleEncoding( $link );
187 $link = str_replace( "_", " ", $link );
188 $link = wfEscapeHTML( $link );
190 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
191 else { $r = " class='external'"; }
193 if ( 1 == $wgUser->getOption( "hover" ) ) {
194 $r .= " title=\"{$link}\"";
196 return $r;
199 function getInternalLinkAttributes( $link, $text, $broken = false )
201 global $wgUser, $wgOut;
203 $link = urldecode( $link );
204 $link = str_replace( "_", " ", $link );
205 $link = wfEscapeHTML( $link );
207 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
208 else if ( $broken == "stub" ) { $r = " class='stub'"; }
209 else if ( $broken == "yes" ) { $r = " class='new'"; }
210 else { $r = " class='internal'"; }
212 if ( 1 == $wgUser->getOption( "hover" ) ) {
213 $r .= " title=\"{$link}\"";
215 return $r;
218 function getLogo()
220 global $wgLogo;
221 return $wgLogo;
224 # This will be called immediately after the <body> tag. Split into
225 # two functions to make it easier to subclass.
227 function beforeContent()
229 global $wgUser, $wgOut;
231 if ( $wgOut->isPrintable() ) {
232 $s = $this->pageTitle() . $this->pageSubtitle() . "\n";
233 $s .= "\n<div class='bodytext'>";
234 return $s;
236 return $this->doBeforeContent();
239 function doBeforeContent()
241 global $wgUser, $wgOut, $wgTitle, $wgLang;
242 $fname = "Skin::doBeforeContent";
243 wfProfileIn( $fname );
245 $s = "";
246 $qb = $this->qbSetting();
248 if( $langlinks = $this->otherLanguages() ) {
249 $rows = 2;
250 $borderhack = "";
251 } else {
252 $rows = 1;
253 $langlinks = false;
254 $borderhack = "class='top'";
257 $s .= "\n<div id='content'>\n<div id='topbar'>" .
258 "<table width='98%' border=0 cellspacing=0><tr>";
260 $shove = ($qb != 0);
261 $left = ($qb == 1 || $qb == 3);
262 if($wgLang->isRTL()) $left = !$left;
264 if ( !$shove ) {
265 $s .= "<td class='top' align=left valign=top rowspan='{$rows}'>" .
266 $this->logoText() . "</td>";
267 } elseif( $left ) {
268 $s .= $this->getQuickbarCompensator( $rows );
270 $l = $wgLang->isRTL() ? "right" : "left";
271 $s .= "<td {$borderhack} align='$l' valign='top'>";
273 $s .= $this->topLinks() ;
274 $s .= "<p class='subtitle'>" . $this->pageTitleLinks();
276 $r = $wgLang->isRTL() ? "left" : "right";
277 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap>";
278 $s .= $this->nameAndLogin();
279 $s .= "\n<br>" . $this->searchForm() . "</td>";
281 if ( $langlinks ) {
282 $s .= "</tr>\n<tr><td class='top' colspan=\"2\">$langlinks</td>";
285 if ( $shove && !$left ) { # Right
286 $s .= $this->getQuickbarCompensator( $rows );
288 $s .= "</tr></table>\n</div>\n";
289 $s .= "\n<div id='article'>";
291 $s .= $this->pageTitle();
292 $s .= $this->pageSubtitle() ;
293 $s .= getCategories(); // For some odd reason, zhis can't be a function of the object
294 $s .= "\n<p>";
295 wfProfileOut( $fname );
296 return $s;
299 function getQuickbarCompensator( $rows = 1 )
301 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
304 # This gets called immediately before the </body> tag.
306 function afterContent()
308 global $wgUser, $wgOut, $wgServer, $HTTP_SERVER_VARS;
309 global $wgTitle;
311 if ( $wgOut->isPrintable() ) {
312 $s = "\n</div>\n";
314 $u = $wgServer . $wgTitle->getFullURL();
315 $rf = wfMsg( "retrievedfrom", $u );
317 if ( $wgOut->isArticle() ) {
318 $lm = "<br>" . $this->lastModified();
319 } else { $lm = ""; }
321 $cr = wfMsg( "gnunote" );
322 $s .= "<p><em>{$rf}{$lm} {$cr}</em>\n";
323 return $s;
325 return $this->doAfterContent();
328 function doAfterContent()
330 global $wgUser, $wgOut, $wgLang;
331 $fname = "Skin::doAfterContent";
332 wfProfileIn( $fname );
334 $s = "\n</div><br clear=all>\n";
336 $s .= "\n<div id='footer'>";
337 $s .= "<table width='98%' border=0 cellspacing=0><tr>";
339 $qb = $this->qbSetting();
340 $shove = ($qb != 0);
341 $left = ($qb == 1 || $qb == 3);
342 if($wgLang->isRTL()) $left = !$left;
344 if ( $shove && $left ) { # Left
345 $s .= $this->getQuickbarCompensator();
347 $l = $wgLang->isRTL() ? "right" : "left";
348 $s .= "<td class='bottom' align='$l' valign='top'>";
350 $s .= $this->bottomLinks();
351 $s .= "\n<br>" . $this->mainPageLink()
352 . " | " . $this->aboutLink()
353 . " | " . $this->specialLink( "recentchanges" )
354 . " | " . $this->searchForm()
355 . "<br>" . $this->pageStats();
357 $s .= "</td>";
358 if ( $shove && !$left ) { # Right
359 $s .= $this->getQuickbarCompensator();
361 $s .= "</tr></table>\n</div>\n</div>\n";
363 if ( 0 != $qb ) { $s .= $this->quickBar(); }
364 wfProfileOut( $fname );
365 return $s;
368 function pageTitleLinks()
370 global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang, $wgUseApproval ;
372 $s = $this->printableLink();
374 if ( $wgOut->isArticle() ) {
375 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
376 $name = $wgTitle->getDBkey();
377 $link = wfEscapeHTML( wfImageUrl( $name ) );
378 $style = $this->getInternalLinkAttributes( $link, $name );
379 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
381 # This will show the "Approve" link if $wgUseApproval=true;
382 if ( isset ( $wgUseApproval ) && $wgUseApproval )
384 $t = $wgTitle->getDBkey();
385 $name = "Approve this article" ;
386 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
387 #wfEscapeHTML( wfImageUrl( $name ) );
388 $style = $this->getExternalLinkAttributes( $link, $name );
389 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
391 if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
392 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
393 wfMsg( "currentrev" ) );
396 if ( $wgUser->getNewtalk() ) {
397 # do not show "You have new messages" text when we are viewing our
398 # own talk page
400 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
401 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
402 $n =$wgUser->getName();
403 $tl = $this->makeKnownLink( $wgLang->getNsText(
404 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
405 wfMsg("newmessageslink") );
406 $s.=" | <strong>". str_replace( "$1", $tl, wfMsg("newmessages") ) . "</strong>";
409 if( $wgUser->isSysop() &&
410 (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
411 ($n = $wgTitle->isDeleted() ) ) {
412 $s .= " | " . wfMsg( "thisisdeleted",
413 $this->makeKnownLink(
414 $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ),
415 wfMsg( "restorelink", $n ) ) );
417 return $s;
420 function printableLink()
422 global $wgOut, $wgTitle, $oldid, $action;
424 if ( "history" == $action ) { $q = "action=history&"; }
425 else { $q = ""; }
427 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
428 WfMsg( "printableversion" ), "{$q}printable=yes" );
429 return $s;
432 function pageTitle()
434 global $wgOut, $wgTitle, $wgUser;
436 $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
437 if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
438 return $s;
441 function pageSubtitle()
443 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
445 $sub = $wgOut->getSubtitle();
446 if ( "" == $sub ) { $sub = wfMsg( "fromwikipedia" ); }
447 if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
448 $ptext=$wgTitle->getPrefixedText();
449 if(preg_match("/\//",$ptext)) {
450 $sub.="</p><p class='subpages'>";
451 $links=explode("/",$ptext);
452 $c=0;
453 $growinglink="";
454 foreach($links as $link) {
455 $c++;
456 if ($c<count($links)) {
457 $growinglink.=$link;
458 $getlink=$this->makeLink($growinglink,$link);
459 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
460 if ($c>1) {
461 $sub .= " | ";
462 } else {
463 $sub .="&lt; ";
465 $sub .= $getlink;
466 $growinglink.="/";
472 $s = "<p class='subtitle'>{$sub}\n";
473 return $s;
476 function nameAndLogin()
478 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader;
480 $li = $wgLang->specialPage( "Userlogin" );
481 $lo = $wgLang->specialPage( "Userlogout" );
483 $s = "";
484 if ( 0 == $wgUser->getID() ) {
485 if( $wgShowIPinHeader ) {
486 $n = getenv( "REMOTE_ADDR" );
488 $tl = $this->makeKnownLink( $wgLang->getNsText(
489 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
490 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
492 $s .= $n . " (".$tl.")";
493 } else {
494 $s .= wfMsg("notloggedin");
497 $rt = $wgTitle->getPrefixedURL();
498 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
499 $q = "";
500 } else { $q = "returnto={$rt}"; }
502 $s .= "\n<br>" . $this->makeKnownLink( $li,
503 wfMsg( "login" ), $q );
504 } else {
505 $n = $wgUser->getName();
506 $rt = $wgTitle->getPrefixedURL();
507 $tl = $this->makeKnownLink( $wgLang->getNsText(
508 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
509 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
511 $tl = " ({$tl})";
513 $s .= $this->makeKnownLink( $wgLang->getNsText(
514 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
515 $this->makeKnownLink( $lo, wfMsg( "logout" ),
516 "returnto={$rt}" ) . " | " .
517 $this->specialLink( "preferences" );
519 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
520 wfMsg( "help" ) );
522 return $s;
525 function searchForm()
527 global $search;
529 $s = "<form name='search' class='inline' method=get action=\""
530 . wfLocalUrl( "" ) . "\">"
531 . "<input type=text name=\"search\" size=19 value=\""
532 . htmlspecialchars(substr($search,0,256)) . "\">\n"
533 . "<input type=submit name=\"go\" value=\"" . wfMsg ("go") . "\">&nbsp;"
534 . "<input type=submit value=\"" . wfMsg ("search") . "\"></form>";
536 return $s;
539 function topLinks()
541 global $wgOut;
542 $sep = " |\n";
544 $s = $this->mainPageLink() . $sep
545 . $this->specialLink( "recentchanges" );
547 if ( $wgOut->isArticle() ) {
548 $s .= $sep . $this->editThisPage()
549 . $sep . $this->historyLink();
551 # Many people don't like this dropdown box
552 #$s .= $sep . $this->specialPagesList();
554 return $s;
557 function bottomLinks()
559 global $wgOut, $wgUser, $wgTitle;
560 $sep = " |\n";
562 $s = "";
563 if ( $wgOut->isArticle() ) {
564 $s .= "<strong>" . $this->editThisPage() . "</strong>";
565 if ( 0 != $wgUser->getID() ) {
566 $s .= $sep . $this->watchThisPage();
568 $s .= $sep . $this->talkLink()
569 . $sep . $this->historyLink()
570 . $sep . $this->whatLinksHere()
571 . $sep . $this->watchPageLinksLink();
573 if ( $wgTitle->getNamespace() == Namespace::getUser()
574 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
577 $id=User::idFromName($wgTitle->getText());
578 $ip=User::isIP($wgTitle->getText());
580 if($id || $ip) { # both anons and non-anons have contri list
581 $s .= $sep . $this->userContribsLink();
583 if ( 0 != $wgUser->getID() ) { # show only to signed in users
584 if($id) { # can only email non-anons
585 $s .= $sep . $this->emailUserLink();
589 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
590 $s .= "\n<br>" . $this->deleteThisPage() .
591 $sep . $this->protectThisPage() .
592 $sep . $this->moveThisPage();
594 $s .= "<br>\n" . $this->otherLanguages();
596 return $s;
599 function pageStats()
601 global $wgOut, $wgLang, $wgArticle;
602 global $oldid, $diff, $wgDisableCounters;
604 if ( ! $wgOut->isArticle() ) { return ""; }
605 if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
606 if ( 0 == $wgArticle->getID() ) { return ""; }
608 if ( $wgDisableCounters ) {
609 $s = "";
610 } else {
611 $count = $wgArticle->getCount();
612 $s = str_replace( "$1", $count, wfMsg( "viewcount" ) );
614 $s .= $this->lastModified();
615 $s .= " " . wfMsg( "gnunote" );
616 return "<span id='pagestats'>{$s}</span>";
619 function lastModified()
621 global $wgLang, $wgArticle;
623 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
624 $s = " " . str_replace( "$1", $d, wfMsg( "lastmodified" ) );
625 return $s;
628 function logoText( $align = "" )
630 if ( "" != $align ) { $a = " align='{$align}'"; }
631 else { $a = ""; }
633 $mp = wfMsg( "mainpage" );
634 $s = "<a href=\"" . wfLocalUrlE( urlencode( $mp ) )
635 . "\"><img{$a} border=0 src=\""
636 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
637 return $s;
640 function quickBar()
642 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
643 global $wpPreview;
644 $fname = "Skin::quickBar";
645 wfProfileIn( $fname );
647 $tns=$wgTitle->getNamespace();
649 $s = "\n<div id='quickbar'>";
650 $s .= "\n" . $this->logoText() . "\n<hr class='sep'>";
652 $sep = "\n<br>";
653 $s .= $this->mainPageLink()
654 . $sep . $this->specialLink( "recentchanges" )
655 . $sep . $this->specialLink( "randompage" );
656 if ($wgUser->getID()) {
657 $s.= $sep . $this->specialLink( "watchlist" ) ;
658 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
659 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
662 // only show watchlist link if logged in
663 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
664 $s .= "\n<br><hr class='sep'>";
665 $articleExists = $wgTitle->getArticleId();
666 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
667 if($wgOut->isArticle()) {
668 $s .= "<strong>" . $this->editThisPage() . "</strong>";
669 } else { # backlink to the article in edit or history mode
670 if($articleExists){ # no backlink if no article
671 switch($tns) {
672 case 0:
673 $text = wfMsg("articlepage");
674 break;
675 case 1:
676 $text = wfMsg("viewtalkpage");
677 break;
678 case 2:
679 $text = wfMsg("userpage");
680 break;
681 case 3:
682 $text = wfMsg("viewtalkpage");
683 break;
684 case 4:
685 $text = wfMsg("wikipediapage");
686 break;
687 case 5:
688 $text = wfMsg("viewtalkpage");
689 break;
690 case 6:
691 $text = wfMsg("imagepage");
692 break;
693 case 7:
694 $text = wfMsg("viewtalkpage");
695 break;
696 default:
697 $text= wfMsg("articlepage");
700 $link = $wgTitle->getText();
701 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
702 $link = $nstext . ":" . $link ;
704 $s .= $this->makeLink($link, $text );
705 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
706 # we just throw in a "New page" text to tell the user that he's in edit mode,
707 # and to avoid messing with the separator that is prepended to the next item
708 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
714 if( $tns%2 && $action!="edit" && !$wpPreview) {
715 $s.="<br>".$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("postcomment"),"action=edit&section=new");
719 watching could cause problems in edit mode:
720 if user edits article, then loads "watch this article" in background and then saves
721 article with "Watch this article" checkbox disabled, the article is transparently
722 unwatched. Therefore we do not show the "Watch this page" link in edit mode
724 if ( 0 != $wgUser->getID() && $articleExists) {
725 if($action!="edit" && $action!="history" &&
726 $action != "submit" )
727 {$s .= $sep . $this->watchThisPage(); }
728 if ( $wgTitle->userCanEdit() ) $s .= $sep . $this->moveThisPage();
730 if ( $wgUser->isSysop() and $articleExists ) {
731 $s .= $sep . $this->deleteThisPage() .
732 $sep . $this->protectThisPage();
734 $s .= $sep . $this->talkLink();
735 if ($articleExists && $action !="history") { $s .= $sep . $this->historyLink();}
736 $s.=$sep . $this->whatLinksHere();
738 if($wgOut->isArticle()) {
739 $s .= $sep . $this->watchPageLinksLink();
742 if ( Namespace::getUser() == $wgTitle->getNamespace()
743 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
746 $id=User::idFromName($wgTitle->getText());
747 $ip=User::isIP($wgTitle->getText());
749 if($id||$ip) {
750 $s .= $sep . $this->userContribsLink();
752 if ( 0 != $wgUser->getID() ) {
753 if($id) { # can only email real users
754 $s .= $sep . $this->emailUserLink();
758 $s .= "\n<br><hr class='sep'>";
761 if ( 0 != $wgUser->getID() ) {
762 $s .= $this->specialLink( "upload" ) . $sep;
764 $s .= $this->specialLink( "specialpages" )
765 . $sep . $this->bugReportsLink();
767 $s .= "\n<br></div>\n";
768 wfProfileOut( $fname );
769 return $s;
772 function specialPagesList()
774 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
775 $a = array();
777 $validSP = $wgLang->getValidSpecialPages();
779 foreach ( $validSP as $name => $desc ) {
780 if ( "" == $desc ) { continue; }
781 $a[$name] = $desc;
783 if ( $wgUser->isSysop() )
785 $sysopSP = $wgLang->getSysopSpecialPages();
787 foreach ( $sysopSP as $name => $desc ) {
788 if ( "" == $desc ) { continue; }
789 $a[$name] = $desc ;
792 if ( $wgUser->isDeveloper() )
794 $devSP = $wgLang->getDeveloperSpecialPages();
796 foreach ( $devSP as $name => $desc ) {
797 if ( "" == $desc ) { continue; }
798 $a[$name] = $desc ;
801 $go = wfMsg( "go" );
802 $sp = wfMsg( "specialpages" );
803 $spp = $wgLang->specialPage( "Specialpages" );
805 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
806 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
807 $s .= "<select name=\"wpDropdown\">\n";
808 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
810 foreach ( $a as $name => $desc ) {
811 $p = $wgLang->specialPage( $name );
812 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
814 $s .= "</select>\n";
815 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
816 $s .= "</form>\n";
817 return $s;
820 function mainPageLink()
822 $mp = wfMsg( "mainpage" );
823 $s = $this->makeKnownLink( $mp, $mp );
824 return $s;
827 function copyrightLink()
829 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
830 wfMsg( "copyrightpagename" ) );
831 return $s;
834 function aboutLink()
836 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
837 wfMsg( "aboutwikipedia" ) );
838 return $s;
841 function editThisPage()
843 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
845 if ( ! $wgOut->isArticle() || $diff ) {
846 $s = wfMsg( "protectedpage" );
847 } else if ( $wgTitle->userCanEdit() ) {
848 $n = $wgTitle->getPrefixedText();
849 $t = wfMsg( "editthispage" );
850 $oid = $red = "";
852 if ( $redirect ) { $red = "&redirect={$redirect}"; }
853 if ( $oldid && ! isset( $diff ) ) {
854 $oid = "&oldid={$oldid}";
856 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
857 } else {
858 $s = wfMsg( "protectedpage" );
860 return $s;
863 function deleteThisPage()
865 global $wgUser, $wgOut, $wgTitle, $diff;
867 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
868 $n = $wgTitle->getPrefixedText();
869 $t = wfMsg( "deletethispage" );
871 $s = $this->makeKnownLink( $n, $t, "action=delete" );
872 } else {
873 $s = wfMsg( "error" );
875 return $s;
878 function protectThisPage()
880 global $wgUser, $wgOut, $wgTitle, $diff;
882 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
883 $n = $wgTitle->getPrefixedText();
885 if ( $wgTitle->isProtected() ) {
886 $t = wfMsg( "unprotectthispage" );
887 $q = "action=unprotect";
888 } else {
889 $t = wfMsg( "protectthispage" );
890 $q = "action=protect";
892 $s = $this->makeKnownLink( $n, $t, $q );
893 } else {
894 $s = wfMsg( "error" );
896 return $s;
899 function watchThisPage()
901 global $wgUser, $wgOut, $wgTitle, $diff;
903 if ( $wgOut->isArticle() && ( ! $diff ) ) {
904 $n = $wgTitle->getPrefixedText();
906 if ( $wgTitle->userIsWatching() ) {
907 $t = wfMsg( "unwatchthispage" );
908 $q = "action=unwatch";
909 } else {
910 $t = wfMsg( "watchthispage" );
911 $q = "action=watch";
913 $s = $this->makeKnownLink( $n, $t, $q );
914 } else {
915 $s = wfMsg( "notanarticle" );
917 return $s;
920 function moveThisPage()
922 global $wgTitle, $wgLang;
924 if ( $wgTitle->userCanEdit() ) {
925 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
926 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
927 } // no message if page is protected - would be redundant
928 return $s;
931 function historyLink()
933 global $wgTitle;
935 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
936 wfMsg( "history" ), "action=history" );
937 return $s;
940 function whatLinksHere()
942 global $wgTitle, $wgLang;
944 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
945 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
946 return $s;
949 function userContribsLink()
951 global $wgTitle, $wgLang;
953 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
954 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
955 return $s;
958 function emailUserLink()
960 global $wgTitle, $wgLang;
962 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
963 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
964 return $s;
967 function watchPageLinksLink()
969 global $wgOut, $wgTitle, $wgLang;
971 if ( ! $wgOut->isArticle() ) {
972 $s = "(" . wfMsg( "notanarticle" ) . ")";
973 } else {
974 $s = $this->makeKnownLink( $wgLang->specialPage(
975 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
976 "target=" . $wgTitle->getPrefixedURL() );
978 return $s;
981 function otherLanguages()
983 global $wgOut, $wgLang, $wgTitle , $wgUseNewInterlanguage ;
985 $a = $wgOut->getLanguageLinks();
986 if ( 0 == count( $a ) ) {
987 if ( !$wgUseNewInterlanguage ) return "";
988 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
989 if ( $ns != 0 AND $ns != 1 ) return "" ;
990 $pn = "Intl" ;
991 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
992 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
993 wfMsg( "intl" ) , $x );
996 if ( !$wgUseNewInterlanguage ) {
997 $s = wfMsg( "otherlanguages" ) . ": ";
998 } else {
999 global $wgLanguageCode ;
1000 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
1001 $x .= "&xl=".$wgLanguageCode ;
1002 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
1003 wfMsg( "otherlanguages" ) , $x ) . ": " ;
1006 $first = true;
1007 if($wgLang->isRTL()) $s .= "<span dir='LTR'>";
1008 foreach( $a as $l ) {
1009 if ( ! $first ) { $s .= " | "; }
1010 $first = false;
1012 $nt = Title::newFromText( $l );
1013 $url = $nt->getFullURL();
1014 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
1016 if ( "" == $text ) { $text = $l; }
1017 $style = $this->getExternalLinkAttributes( $l, $text );
1018 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1020 if($wgLang->isRTL()) $s .= "</span>";
1021 return $s;
1024 function bugReportsLink()
1026 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
1027 wfMsg( "bugreports" ) );
1028 return $s;
1031 function dateLink()
1033 global $wgLinkCache;
1034 $t1 = Title::newFromText( gmdate( "F j" ) );
1035 $t2 = Title::newFromText( gmdate( "Y" ) );
1037 $wgLinkCache->suspend();
1038 $id = $t1->getArticleID();
1039 $wgLinkCache->resume();
1041 if ( 0 == $id ) {
1042 $s = $this->makeBrokenLink( $t1->getText() );
1043 } else {
1044 $s = $this->makeKnownLink( $t1->getText() );
1046 $s .= ", ";
1048 $wgLinkCache->suspend();
1049 $id = $t2->getArticleID();
1050 $wgLinkCache->resume();
1052 if ( 0 == $id ) {
1053 $s .= $this->makeBrokenLink( $t2->getText() );
1054 } else {
1055 $s .= $this->makeKnownLink( $t2->getText() );
1057 return $s;
1060 function talkLink()
1062 global $wgLang, $wgTitle, $wgLinkCache;
1064 $tns = $wgTitle->getNamespace();
1065 if ( -1 == $tns ) { return ""; }
1067 $pn = $wgTitle->getText();
1068 $tp = wfMsg( "talkpage" );
1069 if ( Namespace::isTalk( $tns ) ) {
1070 $lns = Namespace::getSubject( $tns );
1071 switch($tns) {
1072 case 1:
1073 $text = wfMsg("articlepage");
1074 break;
1075 case 3:
1076 $text = wfMsg("userpage");
1077 break;
1078 case 5:
1079 $text = wfMsg("wikipediapage");
1080 break;
1081 case 7:
1082 $text = wfMsg("imagepage");
1083 break;
1084 default:
1085 $text= wfMsg("articlepage");
1087 } else {
1089 $lns = Namespace::getTalk( $tns );
1090 $text=$tp;
1092 $n = $wgLang->getNsText( $lns );
1093 if ( "" == $n ) { $link = $pn; }
1094 else { $link = "{$n}:{$pn}"; }
1096 $wgLinkCache->suspend();
1097 $s = $this->makeLink( $link, $text );
1098 $wgLinkCache->resume();
1100 return $s;
1103 # After all the page content is transformed into HTML, it makes
1104 # a final pass through here for things like table backgrounds.
1106 function transformContent( $text )
1108 return $text;
1111 # Note: This function MUST call getArticleID() on the link,
1112 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1114 function makeLink( $title, $text= "", $query = "", $trail = "" )
1116 global $wgOut, $wgUser;
1118 $nt = Title::newFromText( $title );
1120 if ( $nt->isExternal() ) {
1121 $u = $nt->getFullURL();
1122 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1123 $style = $this->getExternalLinkAttributes( $link, $text );
1125 $inside = "";
1126 if ( "" != $trail ) {
1127 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1128 $inside = $m[1];
1129 $trail = $m[2];
1132 return "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1134 if ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1135 return $this->makeKnownLink( $title, $text, $query, $trail );
1137 if ( ( -1 == $nt->getNamespace() ) ||
1138 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1139 return $this->makeKnownLink( $title, $text, $query, $trail );
1141 $aid = $nt->getArticleID() ;
1142 if ( 0 == $aid ) {
1143 return $this->makeBrokenLink( $title, $text, $query, $trail );
1144 } else {
1145 $threshold = $wgUser->getOption("stubthreshold") ;
1146 if ( $threshold > 0 ) {
1147 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'", DB_READ ) ;
1149 if ( wfNumRows( $res ) > 0 ) {
1150 $s = wfFetchObject( $res );
1151 $size = $s->x;
1152 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
1153 $size = $threshold*2 ; # Really big
1154 wfFreeResult( $res );
1155 } else $size = $threshold*2 ; # Really big
1156 } else $size = 1 ;
1158 if ( $size < $threshold )
1159 return $this->makeStubLink( $title, $text, $query, $trail );
1160 return $this->makeKnownLink( $title, $text, $query, $trail );
1164 function makeKnownLink( $title, $text = "", $query = "", $trail = "" )
1166 global $wgOut, $wgTitle;
1168 $nt = Title::newFromText( $title );
1169 $link = $nt->getPrefixedURL();
1171 if ( "" == $link ) {
1172 $u = "";
1173 if ( "" == $text ) { $text = $nt->getFragment(); }
1174 } else {
1175 $u = wfLocalUrlE( $link, $query );
1177 if ( "" != $nt->getFragment() ) {
1178 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1180 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1181 $style = $this->getInternalLinkAttributes( $link, $text );
1183 $inside = "";
1184 if ( "" != $trail ) {
1185 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1186 $inside = $m[1];
1187 $trail = $m[2];
1190 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1191 return $r;
1194 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" )
1196 global $wgOut, $wgUser;
1198 $nt = Title::newFromText( $title );
1199 $link = $nt->getPrefixedURL();
1201 if ( "" == $query ) { $q = "action=edit"; }
1202 else { $q = "action=edit&{$query}"; }
1203 $u = wfLocalUrlE( $link, $q );
1205 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1206 $style = $this->getInternalLinkAttributes( $link, $text, "yes" );
1208 $inside = "";
1209 if ( "" != $trail ) {
1210 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1211 $inside = $m[1];
1212 $trail = $m[2];
1215 if ( $wgOut->isPrintable() ||
1216 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1217 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1218 } else {
1219 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1221 return $s;
1224 function makeStubLink( $title, $text = "", $query = "", $trail = "" )
1226 global $wgOut, $wgUser;
1228 $nt = Title::newFromText( $title );
1229 $link = $nt->getPrefixedURL();
1231 $u = wfLocalUrlE( $link, $query );
1233 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1234 $style = $this->getInternalLinkAttributes( $link, $text, "stub" );
1236 $inside = "";
1237 if ( "" != $trail ) {
1238 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1239 $inside = $m[1];
1240 $trail = $m[2];
1243 if ( $wgOut->isPrintable() ||
1244 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1245 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1246 } else {
1247 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1249 return $s;
1252 function fnamePart( $url )
1254 $basename = strrchr( $url, "/" );
1255 if ( false === $basename ) { $basename = $url; }
1256 else { $basename = substr( $basename, 1 ); }
1257 return wfEscapeHTML( $basename );
1260 function makeImage( $url, $alt = "" )
1262 global $wgOut;
1264 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1265 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1266 return $s;
1269 function makeImageLink( $name, $url, $alt = "" )
1271 global $wgOut, $wgTitle, $wgLang;
1273 $nt = Title::newFromText( $wgLang->getNsText(
1274 Namespace::getImage() ) . ":{$name}" );
1275 $link = $nt->getPrefixedURL();
1276 if ( "" == $alt ) { $alt = $name; }
1278 $u = wfLocalUrlE( $link );
1279 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1280 "<img border=0 src=\"{$url}\" alt=\"{$alt}\"></a>";
1281 return $s;
1284 function makeMediaLink( $name, $url, $alt = "" )
1286 global $wgOut, $wgTitle;
1288 if ( "" == $alt ) { $alt = $name; }
1289 $u = wfEscapeHTML( $url );
1290 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1291 return $s;
1294 function specialLink( $name, $key = "" )
1296 global $wgLang;
1298 if ( "" == $key ) { $key = strtolower( $name ); }
1299 $pn = $wgLang->ucfirst( $name );
1300 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1301 wfMsg( $key ) );
1304 # Called by history lists and recent changes
1307 function beginRecentChangesList()
1309 $rc_cache = array() ;
1310 $rccc = 0 ;
1311 $this->lastdate = "";
1312 return "";
1315 function beginHistoryList()
1317 $this->lastdate = $this->lastline = "";
1318 $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
1319 return $s;
1322 function beginImageHistoryList()
1324 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1325 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1326 return $s;
1329 function endRecentChangesList()
1331 $s = $this->recentChangesBlock() ;
1332 $s .= "</ul>\n";
1333 return $s;
1336 function endHistoryList()
1338 $last = wfMsg( "last" );
1340 $s = preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
1341 $s .= "</ul>\n";
1342 return $s;
1345 function endImageHistoryList()
1347 $s = "</ul>\n";
1348 return $s;
1351 function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor )
1353 global $wgLang;
1355 $artname = Title::makeName( $ns, $ttl );
1356 $last = wfMsg( "last" );
1357 $cur = wfMsg( "cur" );
1358 $cr = wfMsg( "currentrev" );
1360 if ( $oid && $this->lastline ) {
1361 $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->makeKnownLink(
1362 $artname, $last, "diff=\\1&oldid={$oid}" ), $this->lastline );
1363 } else {
1364 $ret = "";
1366 $dt = $wgLang->timeanddate( $ts, true );
1368 if ( $oid ) { $q = "oldid={$oid}"; }
1369 else { $q = ""; }
1370 $link = $this->makeKnownLink( $artname, $dt, $q );
1372 if ( 0 == $u ) {
1373 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1374 $ut, "target=" . $ut );
1375 } else { $ul = $this->makeLink( $wgLang->getNsText(
1376 Namespace::getUser() ) . ":{$ut}", $ut ); }
1378 $s = "<li>";
1379 if ( $oid ) {
1380 $curlink = $this->makeKnownLink( $artname, $cur,
1381 "diff=0&oldid={$oid}" );
1382 } else {
1383 $curlink = $cur;
1385 $s .= "({$curlink}) (!OLDID!{$oid}!) . .";
1387 $M = wfMsg( "minoreditletter" );
1388 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1389 $s .= " {$link} . . {$ul}";
1391 if ( "" != $c && "*" != $c ) { $s .= " <em>(" . wfEscapeHTML($c) . ")</em>"; }
1392 $s .= "</li>\n";
1394 $this->lastline = $s;
1395 return $ret;
1398 function recentChangesBlockLine ( $y ) {
1399 global $wgUploadPath ;
1401 $M = wfMsg( "minoreditletter" );
1402 $N = wfMsg( "newpageletter" );
1403 $r = "" ;
1404 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;
1405 $r .= "<tt>" ;
1406 if ( $y->isnew ) $r .= $N ;
1407 else $r .= "&nbsp;" ;
1408 if ( $y->isminor ) $r .= $M ;
1409 else $r .= "&nbsp;" ;
1410 $r .= " ".$y->timestamp." " ;
1411 $r .= "</tt>" ;
1412 $link = $y->link ;
1413 if ( $y->watched ) $link = "<strong>{$link}</strong>" ;
1414 $r .= $link ;
1416 $r .= " (" ;
1417 $r .= $y->curlink ;
1418 $r .= "; " ;
1419 $r .= $this->makeKnownLink( $y->secureName, wfMsg( "hist" ), "action=history" );
1421 $r .= ") . . ".$y->userlink ;
1422 $r .= $y->usertalklink ;
1423 if ( $y->usercomment != "" )
1424 $r .= " <em>(".wfEscapeHTML($y->usercomment).")</em>" ;
1425 $r .= "<br>\n" ;
1426 return $r ;
1429 function recentChangesBlockGroup ( $y ) {
1430 global $wgUploadPath ;
1432 $r = "" ;
1433 $M = wfMsg( "minoreditletter" );
1434 $N = wfMsg( "newpageletter" );
1435 $isnew = false ;
1436 $userlinks = array () ;
1437 foreach ( $y AS $x ) {
1438 $oldid = $x->diffid ;
1439 if ( $x->isnew ) $isnew = true ;
1440 $u = $x->userlink ;
1441 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1442 $userlinks[$u]++ ;
1445 krsort ( $userlinks ) ;
1446 asort ( $userlinks ) ;
1447 $users = array () ;
1448 $u = array_keys ( $userlinks ) ;
1449 foreach ( $u as $x ) {
1450 $z = $x ;
1451 if ( $userlinks[$x] > 1 ) $z .= " ({$userlinks[$x]}&times;)" ;
1452 array_push ( $users , $z ) ;
1454 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1456 $e = $y ;
1457 $e = array_shift ( $e ) ;
1459 # Arrow
1460 $rci = "RCI{$this->rccc}" ;
1461 $rcl = "RCL{$this->rccc}" ;
1462 $rcm = "RCM{$this->rccc}" ;
1463 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1464 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1465 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1466 $tl .= "</a>" ;
1467 $r .= $tl ;
1469 # Main line
1470 $r .= "<tt>" ;
1471 if ( $isnew ) $r .= $N ;
1472 else $r .= "&nbsp;" ;
1473 $r .= "&nbsp;" ; # Minor
1474 $r .= " ".$e->timestamp." " ;
1475 $r .= "</tt>" ;
1477 $link = $e->link ;
1478 if ( $e->watched ) $link = "<strong>{$link}</strong>" ;
1479 $r .= $link ;
1481 if ( !$e->islog ) {
1482 $r .= " (".count($y)." " ;
1483 if ( $isnew ) $r .= wfMsg("changes");
1484 else $r .= $this->makeKnownLink( $e->secureName , wfMsg("changes") , "diff=0&oldid=".$oldid ) ;
1485 $r .= "; " ;
1486 $r .= $this->makeKnownLink( $e->secureName, wfMsg( "history" ), "action=history" );
1487 $r .= ")" ;
1490 $r .= $users ;
1491 $r .= "<br>\n" ;
1493 # Sub-entries
1494 $r .= "<div id='{$rci}' style='display:none'>" ;
1495 foreach ( $y AS $x )
1497 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1498 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
1499 if ( $x->isnew ) $r .= $N ;
1500 else $r .= "&nbsp;" ;
1501 if ( $x->isminor ) $r .= $M ;
1502 else $r .= "&nbsp;" ;
1503 $r .= "</tt>" ;
1505 $o = "" ;
1506 if ( $x->oldid != 0 ) $o = "oldid=".$x->oldid ;
1507 if ( $x->islog ) $link = $x->timestamp ;
1508 else $link = $this->makeKnownLink( $x->secureName, $x->timestamp , $o ) ;
1509 $link = "<tt>{$link}</tt>" ;
1512 $r .= $link ;
1513 $r .= " (" ;
1514 $r .= $x->curlink ;
1515 $r .= "; " ;
1516 $r .= $x->lastlink ;
1517 $r .= ") . . ".$x->userlink ;
1518 $r .= $x->usertalklink ;
1519 if ( $x->usercomment != "" )
1520 $r .= " <em>(".wfEscapeHTML($x->usercomment).")</em>" ;
1521 $r .= "<br>\n" ;
1523 $r .= "</div>\n" ;
1525 $this->rccc++ ;
1526 return $r ;
1529 function recentChangesBlock ()
1531 global $wgUploadPath ;
1532 if ( count ( $this->rc_cache ) == 0 ) return "" ;
1533 $k = array_keys ( $this->rc_cache ) ;
1534 foreach ( $k AS $x )
1536 $y = $this->rc_cache[$x] ;
1537 if ( count ( $y ) < 2 ) {
1538 $r .= $this->recentChangesBlockLine ( array_shift ( $y ) ) ;
1539 } else {
1540 $r .= $this->recentChangesBlockGroup ( $y ) ;
1544 return "<div align=left>{$r}</div>" ;
1547 function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1549 global $wgUser ;
1550 $usenew = $wgUser->getOption( "usenewrc" );
1551 if ( $usenew )
1552 $r = $this->recentChangesLineNew ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1553 else
1554 $r = $this->recentChangesLineOld ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1555 return $r ;
1558 function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 )
1560 global $wgTitle, $wgLang, $wgUser;
1562 $d = $wgLang->date( $ts, true);
1563 $s = "";
1564 if ( $d != $this->lastdate ) {
1565 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
1566 $s .= "<h4>{$d}</h4>\n<ul>";
1567 $this->lastdate = $d;
1569 $h = $wgLang->time( $ts, true );
1570 $t = Title::makeName( $ns, $ttl );
1571 $clink = $this->makeKnownLink( $t , "" );
1572 $nt = Title::newFromText( $t );
1574 if ( $watched ) {
1575 $clink = "<strong>{$clink}</strong>";
1577 $hlink = $this->makeKnownLink( $t, wfMsg( "hist" ), "action=history" );
1578 if ( $isnew || $nt->isLog() ) {
1579 $dlink = wfMsg( "diff" );
1580 } else {
1581 $dlink = $this->makeKnownLink( $t, wfMsg( "diff" ),
1582 "diff={$oldid}&oldid={$diffid}" ); # Finagle's law
1584 if ( 0 == $u ) {
1585 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1586 $ut, "target=" . $ut );
1587 } else { $ul = $this->makeLink( $wgLang->getNsText(
1588 Namespace::getUser() ) . ":{$ut}", $ut ); }
1590 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1591 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1592 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1593 $cr = wfMsg( "currentrev" );
1595 $s .= "<li> ({$dlink}) ({$hlink}) . .";
1596 $M = wfMsg( "minoreditletter" );
1597 $N = wfMsg( "newpageletter" );
1598 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1599 if ( $isnew ) { $s .= "<strong>{$N}</strong>"; }
1600 $s .= " {$clink}; {$h} . . {$ul}";
1602 $blink="";
1603 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1604 $blink = $this->makeKnownLink( $wgLang->specialPage(
1605 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1608 if(!$blink) {
1609 $utl = "({$utl})";
1610 } else {
1611 $utl = "({$utl} | {$blink})";
1613 $s.=" {$utl}";
1615 if ( "" != $c && "*" != $c ) {
1616 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1618 $s .= "</li>\n";
1620 return $s;
1623 function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1625 global $wgTitle, $wgLang, $wgUser;
1627 $rc = new RecentChangesClass ;
1629 $d = $wgLang->date( $ts, true);
1630 $s = "";
1631 $ret = "" ;
1632 if ( $d != $this->lastdate ) {
1633 $ret = $this->recentChangesBlock () ;
1634 $this->rc_cache = array() ;
1635 $ret .= "<h4>{$d}</h4>\n";
1636 $this->lastdate = $d;
1638 $h = $wgLang->time( $ts, true );
1639 $t = Title::makeName( $ns, $ttl );
1640 $clink = $this->makeKnownLink( $t, "" ) ;
1641 if ( $oldid == 0 ) $c2link = $clink ;
1642 else $c2link = $this->makeKnownLink( $t, "" , "oldid={$oldid}" );
1643 $nt = Title::newFromText( $t );
1645 $rc->timestamp = $h ;
1646 $rc->oldid = $oldid ;
1647 $rc->diffid = $diffid ;
1648 $rc->watched = $watched ;
1649 $rc->isnew = $isnew ;
1650 $rc->isminor = $isminor ;
1651 $rc->secureName = $t ;
1652 $rc->displayName = $nt ;
1653 $rc->link = $clink ;
1654 $rc->usercomment = $c ;
1655 $rc->islog = $nt->isLog() ;
1657 if ( ( $isnew && $oldid == 0 ) || $nt->isLog() ) {
1658 $dlink = wfMsg( "cur" );
1659 } else {
1660 $dlink = $this->makeKnownLink( $t, wfMsg( "cur" ),
1661 "diff=0&oldid={$oldid}" );
1664 if ( $diffid == 0 || $nt->isLog() ) {
1665 $plink = wfMsg( "last" );
1666 } else {
1667 $plink = $this->makeKnownLink( $t, wfMsg( "last" ),
1668 "diff={$oldid}&oldid={$diffid}" );
1671 if ( 0 == $u ) {
1672 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1673 $ut, "target=" . $ut );
1674 } else { $ul = $this->makeLink( $wgLang->getNsText(
1675 Namespace::getUser() ) . ":{$ut}", $ut ); }
1677 $rc->userlink = $ul ;
1678 $rc->lastlink = $plink ;
1679 $rc->curlink = $dlink ;
1681 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1682 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1683 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1685 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1686 $blink = $this->makeKnownLink( $wgLang->specialPage(
1687 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1688 $rc->usertalklink= " ({$utl} | {$blink})";
1689 } else {
1690 $rc->usertalklink=" ({$utl})";
1693 if ( !isset ( $this->rc_cache[$t] ) ) $this->rc_cache[$t] = array() ;
1694 array_push ( $this->rc_cache[$t] , $rc ) ;
1695 return $ret;
1699 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
1701 global $wgUser, $wgLang, $wgTitle;
1703 $dt = $wgLang->timeanddate( $ts, true );
1704 $del = wfMsg( "deleteimg" );
1705 $cur = wfMsg( "cur" );
1707 if ( $iscur ) {
1708 $url = wfImageUrl( $img );
1709 $rlink = $cur;
1710 if ( $wgUser->isSysop() ) {
1711 $link = wfLocalUrlE( $wgTitle->getPrefixedText(), "image=" . $wgTitle->getURL() .
1712 "&action=delete" );
1713 $style = $this->getInternalLinkAttributes( $link, $del );
1715 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
1716 } else {
1717 $dlink = $del;
1719 } else {
1720 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
1721 if( $wgUser->getID() != 0 ) {
1722 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1723 wfMsg( "revertimg" ), "action=revert&oldimage=" .
1724 urlencode( $img ) );
1725 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1726 $del, "action=delete&oldimage=" . urlencode( $img ) );
1727 } else {
1728 # Having live active links for non-logged in users
1729 # means that bots and spiders crawling our site can
1730 # inadvertently change content. Baaaad idea.
1731 $rlink = wfMsg( "revertimg" );
1732 $dlink = $del;
1735 if ( 0 == $u ) { $ul = $ut; }
1736 else { $ul = $this->makeLink( $wgLang->getNsText(
1737 Namespace::getUser() ) . ":{$ut}", $ut ); }
1739 $nb = str_replace( "$1", $size, wfMsg( "nbytes" ) );
1740 $style = $this->getInternalLinkAttributes( $url, $dt );
1742 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
1743 . " . . {$ul} ({$nb})";
1745 if ( "" != $c && "*" != $c ) {
1746 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1748 $s .= "</li>\n";
1749 return $s;
1752 function tocIndent($level) {
1754 while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
1755 return $rv;
1759 function tocUnindent($level) {
1760 while($level-->0) $rv.="</div>\n";
1761 return $rv;
1764 // parameter level defines if we are on an indentation level
1765 function tocLine($anchor,$tocline,$level) {
1767 if($level) {
1769 return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
1770 } else {
1772 return "<div style=\"margin-bottom:0px;\">\n".
1773 "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
1774 "</div>\n";
1779 function tocTable($toc) {
1780 // note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
1781 global $printable;
1783 if (!$printable) {
1784 $hideline = " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>";
1786 return
1787 "<p><table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
1788 "<b>".wfMsg("toc")."</b>" .
1789 $hideline .
1790 "</td></tr><tr id='tocinside'><td align=\"left\">\n".
1791 $toc."</td></tr></table><P>\n";
1794 # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
1795 function editSectionScript($section,$head) {
1797 global $wgTitle,$wgUser,$oldid;
1798 if($oldid) return $head;
1799 $url = wfLocalUrlE(urlencode($wgTitle->getPrefixedText()),"action=edit&section=$section");
1800 return "<span onContextMenu='document.location=\"".$url."\";return false;'>{$head}</span>";
1803 function editSectionLink($section) {
1805 global $printable;
1806 global $wgTitle,$wgUser,$oldid;
1807 if($oldid) return "";
1808 if ($printable) return "";
1809 $editurl="&section={$section}";
1810 $url=$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
1811 return "<div style=\"float:right;margin-left:5px;\"><small>[".$url."]</small></div>";
1816 include_once( "SkinStandard.php" );
1817 include_once( "SkinNostalgia.php" );
1818 include_once( "SkinCologneBlue.php" );
1820 #include_once( "SkinSmarty.php" );