One more password bug fix, DisableCounters flag.
[lhc/web/wiklou.git] / includes / Skin.php
1 <?
2 # See skin.doc
3
4 # These are the INTERNAL names, which get mapped
5 # directly to class names. For display purposes, the
6 # Language class has internationalized names
7 #
8 /* private */ $wgValidSkinNames = array(
9 "Standard", "Nostalgia", "CologneBlue"
10 );
11
12 class RecentChangesClass {
13 var $secureName , $displayName , $link , $namespace ;
14 var $oldid , $diffid , $timestamp , $curlink , $lastlink , $usertalklink , $versionlink ;
15 var $usercomment , $userlink ;
16 var $isminor , $isnew , $watched , $islog ;
17 } ;
18
19 class Skin {
20
21 /* private */ var $lastdate, $lastline;
22
23 var $rc_cache ; # Cache for Enhanced Recent Changes
24 var $rccc ; # Recent Changes Cache Counter for visibility toggle
25
26
27 function Skin()
28 {
29 }
30
31 function getSkinNames()
32 {
33 global $wgValidSkinNames;
34 return $wgValidSkinNames;
35 }
36
37 function getStylesheet()
38 {
39 return "wikistandard.css";
40 }
41
42 function qbSetting()
43 {
44 global $wgOut, $wgUser;
45
46 if ( $wgOut->isQuickbarSupressed() ) { return 0; }
47 $q = $wgUser->getOption( "quickbar" );
48 if ( "" == $q ) { $q = 0; }
49 return $q;
50 }
51
52 function initPage()
53 {
54 global $wgOut, $wgStyleSheetPath;
55 wfProfileIn( "Skin::initPage" );
56
57 $wgOut->addLink( "shortcut icon", "", "/favicon.ico" );
58 if ( $wgOut->isPrintable() ) { $ss = "wikiprintable.css"; }
59 else { $ss = $this->getStylesheet(); }
60 $wgOut->addLink( "stylesheet", "", "{$wgStyleSheetPath}/{$ss}" );
61 wfProfileOut();
62 }
63
64 function getHeadScripts() {
65 $r = "
66 <SCRIPT TYPE=\"text/javascript\">
67 function toggleVisibility( _levelId, _otherId, _linkId) {
68 var thisLevel = document.getElementById( _levelId );
69 var otherLevel = document.getElementById( _otherId );
70 var linkLevel = document.getElementById( _linkId );
71 if ( thisLevel.style.display == 'none' ) {
72 thisLevel.style.display = 'block';
73 otherLevel.style.display = 'none';
74 linkLevel.style.display = 'inline';
75 } else {
76 thisLevel.style.display = 'none';
77 otherLevel.style.display = 'inline';
78 linkLevel.style.display = 'none';
79 }
80 }
81 </SCRIPT>
82 " ;
83 return $r;
84 }
85
86 function getUserStyles()
87 {
88 $s = "<style type='text/css' media='screen'><!--\n";
89 $s .= $this->doGetUserStyles();
90 $s .= "//--></style>\n";
91 return $s;
92 }
93
94 function doGetUserStyles()
95 {
96 global $wgUser;
97
98 $s = "";
99 if ( 1 == $wgUser->getOption( "underline" ) ) {
100 $s .= "a.stub, a.new, a.internal, a.external { " .
101 "text-decoration: underline; }\n";
102 } else {
103 $s .= "a.stub, a.new, a.internal, a.external { " .
104 "text-decoration: none; }\n";
105 }
106 if ( 1 == $wgUser->getOption( "highlightbroken" ) ) {
107 $s .= "a.new { color: #CC2200; }\n" .
108 "#quickbar a.new { color: CC2200; }\n";
109 }
110 if ( 1 == $wgUser->getOption( "justify" ) ) {
111 $s .= "#article { text-align: justify; }\n";
112 }
113 return $s;
114 }
115
116 function getBodyOptions()
117 {
118 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $oldid, $redirect, $diff,$action;
119
120 if ( 0 != $wgTitle->getNamespace() ) {
121 $a = array( "bgcolor" => "#FFFFDD" );
122 }
123 else $a = array( "bgcolor" => "#FFFFFF" );
124 if($wgOut->isArticle() && $wgUser->getOption("editondblclick")
125 &&
126 (!$wgTitle->isProtected() || $wgUser->isSysop())
127
128 ) {
129 $n = $wgTitle->getPrefixedURL();
130 $t = wfMsg( "editthispage" );
131 $oid = $red = "";
132 if ( $redirect ) { $red = "&redirect={$redirect}"; }
133 if ( $oldid && ! isset( $diff ) ) {
134 $oid = "&oldid={$oldid}";
135 }
136 $s = wfLocalUrlE($n,"action=edit{$oid}{$red}");
137 $s = "document.location = \"" .$s ."\";";
138 $a += array ("ondblclick" => $s);
139
140 }
141 if($action=="edit") { # set focus in edit box
142 $a += array("onLoad"=>"document.editform.wpTextbox1.focus()");
143 }
144 return $a;
145 }
146
147 function getExternalLinkAttributes( $link, $text )
148 {
149 global $wgUser, $wgOut, $wgLang;
150
151 $link = urldecode( $link );
152 $link = $wgLang->checkTitleEncoding( $link );
153 $link = str_replace( "_", " ", $link );
154 $link = wfEscapeHTML( $link );
155
156 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
157 else { $r = " class='external'"; }
158
159 if ( 1 == $wgUser->getOption( "hover" ) ) {
160 $r .= " title=\"{$link}\"";
161 }
162 return $r;
163 }
164
165 function getInternalLinkAttributes( $link, $text, $broken = false )
166 {
167 global $wgUser, $wgOut;
168
169 $link = urldecode( $link );
170 $link = str_replace( "_", " ", $link );
171 $link = wfEscapeHTML( $link );
172
173 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
174 else if ( $broken == "stub" ) { $r = " class='stub'"; }
175 else if ( $broken == "yes" ) { $r = " class='new'"; }
176 else { $r = " class='internal'"; }
177
178 if ( 1 == $wgUser->getOption( "hover" ) ) {
179 $r .= " title=\"{$link}\"";
180 }
181 return $r;
182 }
183
184 function getLogo()
185 {
186 global $wgLogo;
187 return $wgLogo;
188 }
189
190 # This will be called immediately after the <body> tag. Split into
191 # two functions to make it easier to subclass.
192 #
193 function beforeContent()
194 {
195 global $wgUser, $wgOut;
196
197 if ( $wgOut->isPrintable() ) {
198 $s = $this->pageTitle() . $this->pageSubtitle() . "\n";
199 $s .= "\n<div class='bodytext'>";
200 return $s;
201 }
202 return $this->doBeforeContent();
203 }
204
205 function doBeforeContent()
206 {
207 global $wgUser, $wgOut, $wgTitle;
208 wfProfileIn( "Skin::doBeforeContent" );
209
210 $s = "";
211 $qb = $this->qbSetting();
212
213 if( $langlinks = $this->otherLanguages() ) {
214 $rows = 2;
215 $borderhack = "";
216 } else {
217 $rows = 1;
218 $langlinks = false;
219 $borderhack = "class='top'";
220 }
221
222 $s .= "\n<div id='content'>\n<div id='topbar'>" .
223 "<table width='98%' border=0 cellspacing=0><tr>";
224
225 if ( 0 == $qb ) {
226 $s .= "<td class='top' align=left valign=top rowspan='{$rows}'>" .
227 $this->logoText() . "</td>";
228 } else if ( 1 == $qb || 3 == $qb ) { # Left
229 $s .= $this->getQuickbarCompensator( $rows );
230 }
231 $s .= "<td {$borderhack} align=left valign=top>";
232
233 $s .= $this->topLinks() ;
234 $s .= "<p class='subtitle'>" . $this->pageTitleLinks();
235
236 $s .= "</td>\n<td {$borderhack} valign=top align=right nowrap>";
237 $s .= $this->nameAndLogin();
238 $s .= "\n<br>" . $this->searchForm() . "</td>";
239
240 if ( $langlinks ) {
241 $s .= "</tr>\n<tr><td class='top' colspan=\"2\">$langlinks</td>";
242 }
243
244 if ( 2 == $qb ) { # Right
245 $s .= $this->getQuickbarCompensator( $rows );
246 }
247 $s .= "</tr></table>\n</div>\n";
248 $s .= "\n<div id='article'>";
249
250 $s .= $this->pageTitle();
251 $s .= $this->pageSubtitle() . "\n<p>";
252 wfProfileOut();
253 return $s;
254 }
255
256 function getQuickbarCompensator( $rows = 1 )
257 {
258 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
259 }
260
261 # This gets called immediately before the </body> tag.
262 #
263 function afterContent()
264 {
265 global $wgUser, $wgOut, $wgServer, $HTTP_SERVER_VARS;
266
267 if ( $wgOut->isPrintable() ) {
268 $s = "\n</div>\n";
269
270 $u = $wgServer . $HTTP_SERVER_VARS['REQUEST_URI'];
271 $u = preg_replace( "/[?&]printable=yes/", "", $u );
272 $rf = str_replace( "$1", $u, wfMsg( "retrievedfrom" ) );
273
274 if ( $wgOut->isArticle() ) {
275 $lm = "<br>" . $this->lastModified();
276 } else { $lm = ""; }
277
278 $s .= "<p><em>{$rf}{$lm}</em>\n";
279 return $s;
280 }
281 return $this->doAfterContent();
282 }
283
284 function doAfterContent()
285 {
286 global $wgUser, $wgOut;
287 wfProfileIn( "Skin::doAfterContent" );
288
289 $s = "\n</div><br clear=all>\n";
290
291 $s .= "\n<div id='footer'>";
292 $s .= "<table width='98%' border=0 cellspacing=0><tr>";
293
294 $qb = $this->qbSetting();
295 if ( 1 == $qb || 3 == $qb ) { # Left
296 $s .= $this->getQuickbarCompensator();
297 }
298 $s .= "<td class='bottom' align=left valign=top>";
299
300 $s .= $this->bottomLinks();
301 $s .= "\n<br>" . $this->mainPageLink()
302 . " | " . $this->aboutLink()
303 . " | " . $this->specialLink( "recentchanges" )
304 . " | " . $this->searchForm()
305 . "<br>" . $this->pageStats();
306
307 $s .= "</td>";
308 if ( 2 == $qb ) { # Right
309 $s .= $this->getQuickbarCompensator();
310 }
311 $s .= "</tr></table>\n</div>\n</div>\n";
312
313 if ( 0 != $qb ) { $s .= $this->quickBar(); }
314 wfProfileOut();
315 return $s;
316 }
317
318 function pageTitleLinks()
319 {
320 global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang;
321
322 $s = $this->printableLink();
323
324 if ( $wgOut->isArticle() ) {
325 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
326 $name = $wgTitle->getDBkey();
327 $link = wfEscapeHTML( wfImageUrl( $name ) );
328 $style = $this->getInternalLinkAttributes( $link, $name );
329 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
330 }
331 }
332 if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
333 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
334 wfMsg( "currentrev" ) );
335 }
336
337 if ( $wgUser->getNewtalk() ) {
338 # do not show "You have new messages" text when we are viewing our
339 # own talk page
340
341 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
342 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
343 $n =$wgUser->getName();
344 $tl = $this->makeKnownLink( $wgLang->getNsText(
345 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
346 wfMsg("newmessageslink") );
347 $s.=" | <strong>". str_replace( "$1", $tl, wfMsg("newmessages") ) . "</strong>";
348 }
349 }
350 return $s;
351 }
352
353 function printableLink()
354 {
355 global $wgOut, $wgTitle, $oldid, $action;
356
357 if ( "history" == $action ) { $q = "action=history&"; }
358 else { $q = ""; }
359
360 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
361 WfMsg( "printableversion" ), "{$q}printable=yes" );
362 return $s;
363 }
364
365 function pageTitle()
366 {
367 global $wgOut, $wgTitle;
368
369 $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
370 return $s;
371 }
372
373 function pageSubtitle()
374 {
375 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
376
377 $sub = $wgOut->getSubtitle();
378 if ( "" == $sub ) { $sub = wfMsg( "fromwikipedia" ); }
379 if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
380 $ptext=$wgTitle->getPrefixedText();
381 if(preg_match("/\//",$ptext)) {
382 $sub.="</p><p class='subpages'>";
383 $links=explode("/",$ptext);
384 $c=0;
385 $growinglink="";
386 foreach($links as $link) {
387 $c++;
388 if ($c<count($links)) {
389 $growinglink.=$link;
390 $getlink=$this->makeLink($growinglink,$link);
391 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
392 if ($c>1) {
393 $sub .= " | ";
394 } else {
395 $sub .="&lt; ";
396 }
397 $sub .= $getlink;
398 $growinglink.="/";
399 }
400
401 }
402 }
403 }
404 $s = "<p class='subtitle'>{$sub}\n";
405 return $s;
406 }
407
408 function nameAndLogin()
409 {
410 global $wgUser, $wgTitle, $wgLang;
411
412 $li = $wgLang->specialPage( "Userlogin" );
413 $lo = $wgLang->specialPage( "Userlogout" );
414
415 $s = "";
416 if ( 0 == $wgUser->getID() ) {
417 $n = getenv( "REMOTE_ADDR" );
418 $rt = $wgTitle->getPrefixedURL();
419 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
420 $q = "";
421 } else { $q = "returnto={$rt}"; }
422
423
424 $tl = $this->makeKnownLink( $wgLang->getNsText(
425 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
426 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
427
428 $s .= $n . " (".$tl.")" . "\n<br>" . $this->makeKnownLink( $li,
429 wfMsg( "login" ), $q );
430
431 $tl = " ({$tl})";
432
433 } else {
434 $n = $wgUser->getName();
435 $rt = $wgTitle->getPrefixedURL();
436 $tl = $this->makeKnownLink( $wgLang->getNsText(
437 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
438 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
439
440 $tl = " ({$tl})";
441
442 $s .= $this->makeKnownLink( $wgLang->getNsText(
443 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
444 $this->makeKnownLink( $lo, wfMsg( "logout" ),
445 "returnto={$rt}" ) . " | " .
446 $this->specialLink( "preferences" );
447 }
448 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
449 wfMsg( "help" ) );
450
451 return $s;
452 }
453
454 function searchForm()
455 {
456 global $search;
457 $s = "<form id=\"search\" class=\"inline\" method=\"get\" action=\""
458 . wfLocalUrl( "" ) . "\">"
459 . "<input type=text name=\"search\" size=19 value=\""
460 . htmlspecialchars(substr($search,0,256)) . "\">\n"
461 . "<input type=submit value=\"" . wfMsg( "search" )
462 . "\">&nbsp;<input type=submit name=\"go\" value=\""
463 . wfMsg ("go") . "\"></form>";
464
465 return $s;
466 }
467
468 function topLinks()
469 {
470 global $wgOut;
471 $sep = " |\n";
472
473 $s = $this->mainPageLink() . $sep
474 . $this->specialLink( "recentchanges" );
475
476 if ( $wgOut->isArticle() ) {
477 $s .= $sep . $this->editThisPage()
478 . $sep . $this->historyLink();
479 }
480 $s .= $sep . $this->specialPagesList();
481
482 return $s;
483 }
484
485 function bottomLinks()
486 {
487 global $wgOut, $wgUser, $wgTitle;
488 $sep = " |\n";
489
490 $s = "";
491 if ( $wgOut->isArticle() ) {
492 $s .= "<strong>" . $this->editThisPage() . "</strong>";
493 if ( 0 != $wgUser->getID() ) {
494 $s .= $sep . $this->watchThisPage();
495 }
496 $s .= $sep . $this->talkLink()
497 . $sep . $this->historyLink()
498 . $sep . $this->whatLinksHere()
499 . $sep . $this->watchPageLinksLink();
500
501 if ( $wgTitle->getNamespace() == Namespace::getUser()
502 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
503
504 {
505 $id=User::idFromName($wgTitle->getText());
506 $ip=User::isIP($wgTitle->getText());
507
508 if($id || $ip) { # both anons and non-anons have contri list
509 $s .= $sep . $this->userContribsLink();
510 }
511 if ( 0 != $wgUser->getID() ) { # show only to signed in users
512 if($id) { # can only email non-anons
513 $s .= $sep . $this->emailUserLink();
514 }
515 }
516 }
517 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
518 $s .= "\n<br>" . $this->deleteThisPage() .
519 $sep . $this->protectThisPage() .
520 $sep . $this->moveThisPage();
521 }
522 $s .= "<br>\n" . $this->otherLanguages();
523 }
524 return $s;
525 }
526
527 function pageStats()
528 {
529 global $wgOut, $wgLang, $wgArticle;
530 global $oldid, $diff;
531
532 if ( ! $wgOut->isArticle() ) { return ""; }
533 if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
534 if ( 0 == $wgArticle->getID() ) { return ""; }
535
536 if ( $wgDisableCounts ) {
537 $s = "";
538 } else {
539 $count = $wgArticle->getCount();
540 $s = str_replace( "$1", $count, wfMsg( "viewcount" ) );
541 }
542 $s .= $this->lastModified();
543 $s .= " " . wfMsg( "gnunote" );
544 return "<span id='pagestats'>{$s}</span>";
545 }
546
547 function lastModified()
548 {
549 global $wgLang, $wgArticle;
550
551 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
552 $s = " " . str_replace( "$1", $d, wfMsg( "lastmodified" ) );
553 return $s;
554 }
555
556 function logoText( $align = "" )
557 {
558 if ( "" != $align ) { $a = " align='{$align}'"; }
559 else { $a = ""; }
560
561 $mp = wfMsg( "mainpage" );
562 $s = "<a href=\"" . wfLocalUrlE( $mp ) . "\"><img{$a} border=0 src=\""
563 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
564 return $s;
565 }
566
567 function quickBar()
568 {
569 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
570 global $wpPreview;
571 wfProfileIn( "Skin::quickBar" );
572
573 $s = "\n<div id='quickbar'>";
574 $s .= "\n" . $this->logoText() . "\n<hr>";
575
576 $sep = "\n<br>";
577 $s .= $this->mainPageLink()
578 . $sep . $this->specialLink( "recentchanges" )
579 . $sep . $this->specialLink( "randompage" );
580 if ($wgUser->getID()) {
581 $s.= $sep . $this->specialLink( "watchlist" ) ;
582 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
583 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
584
585 }
586 // only show watchlist link if logged in
587 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
588 $s .= "\n<hr>";
589 $articleExists = $wgTitle->getArticleId();
590 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
591
592 if($wgOut->isArticle()) {
593 $s .= "<strong>" . $this->editThisPage() . "</strong>";
594 } else { # backlink to the article in edit or history mode
595
596 if($articleExists){ # no backlink if no article
597 $tns=$wgTitle->getNamespace();
598 switch($tns) {
599 case 0:
600 $text = wfMsg("articlepage");
601 break;
602 case 1:
603 $text = wfMsg("viewtalkpage");
604 break;
605 case 2:
606 $text = wfMsg("userpage");
607 break;
608 case 3:
609 $text = wfMsg("viewtalkpage");
610 break;
611 case 4:
612 $text = wfMsg("wikipediapage");
613 break;
614 case 5:
615 $text = wfMsg("viewtalkpage");
616 break;
617 case 6:
618 $text = wfMsg("imagepage");
619 break;
620 case 7:
621 $text = wfMsg("viewtalkpage");
622 break;
623 default:
624 $text= wfMsg("articlepage");
625 }
626
627 $link = $wgTitle->getText();
628 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
629 $link = $nstext . ":" . $link ;
630 }
631 $s .= $this->makeLink($link, $text );
632 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
633 # we just throw in a "New page" text to tell the user that he's in edit mode,
634 # and to avoid messing with the separator that is prepended to the next item
635 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
636 }
637
638 }
639
640 /*
641 watching could cause problems in edit mode:
642 if user edits article, then loads "watch this article" in background and then saves
643 article with "Watch this article" checkbox disabled, the article is transparently
644 unwatched. Therefore we do not show the "Watch this page" link in edit mode
645 */
646 if ( 0 != $wgUser->getID() && $articleExists) {
647 if($action!="edit" && $action!="history" &&
648 $action != "submit" )
649 {$s .= $sep . $this->watchThisPage(); }
650 if ( $wgTitle->userCanEdit() ) $s .= $sep . $this->moveThisPage();
651 }
652 if ( $wgUser->isSysop() and $articleExists ) {
653 $s .= $sep . $this->deleteThisPage() .
654 $sep . $this->protectThisPage();
655 }
656 $s .= $sep . $this->talkLink();
657 if ($articleExists && $action !="history") { $s .= $sep . $this->historyLink();}
658 $s.=$sep . $this->whatLinksHere();
659
660 if($wgOut->isArticle()) {
661 $s .= $sep . $this->watchPageLinksLink();
662 }
663
664 if ( Namespace::getUser() == $wgTitle->getNamespace()
665 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
666 ) {
667
668 $id=User::idFromName($wgTitle->getText());
669 $ip=User::isIP($wgTitle->getText());
670
671 if($id||$ip) {
672 $s .= $sep . $this->userContribsLink();
673 }
674 if ( 0 != $wgUser->getID() ) {
675 if($id) { # can only email real users
676 $s .= $sep . $this->emailUserLink();
677 }
678 }
679 }
680 $s .= "\n<hr>";
681 }
682
683 if ( 0 != $wgUser->getID() ) {
684 $s .= $this->specialLink( "upload" ) . $sep;
685 }
686 $s .= $this->specialLink( "specialpages" )
687 . $sep . $this->bugReportsLink();
688
689 $s .= "\n</div>\n";
690 wfProfileOut();
691 return $s;
692 }
693
694 function specialPagesList()
695 {
696 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
697 $a = array();
698
699 $validSP = $wgLang->getValidSpecialPages();
700
701 foreach ( $validSP as $name => $desc ) {
702 if ( "" == $desc ) { continue; }
703 $a[$name] = $desc;
704 }
705 if ( $wgUser->isSysop() )
706 {
707 $sysopSP = $wgLang->getSysopSpecialPages();
708
709 foreach ( $sysopSP as $name => $desc ) {
710 if ( "" == $desc ) { continue; }
711 $a[$name] = $desc ;
712 }
713 }
714 if ( $wgUser->isDeveloper() )
715 {
716 $devSP = $wgLang->getDeveloperSpecialPages();
717
718 foreach ( $devSP as $name => $desc ) {
719 if ( "" == $desc ) { continue; }
720 $a[$name] = $desc ;
721 }
722 }
723 $go = wfMsg( "go" );
724 $sp = wfMsg( "specialpages" );
725 $spp = $wgLang->specialPage( "Specialpages" );
726
727 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
728 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
729 $s .= "<select name=\"wpDropdown\">\n";
730 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
731
732 foreach ( $a as $name => $desc ) {
733 $p = $wgLang->specialPage( $name );
734 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
735 }
736 $s .= "</select>\n";
737 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
738 $s .= "</form>\n";
739 return $s;
740 }
741
742 function mainPageLink()
743 {
744 $mp = wfMsg( "mainpage" );
745 $s = $this->makeKnownLink( $mp, $mp );
746 return $s;
747 }
748
749 function copyrightLink()
750 {
751 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
752 wfMsg( "copyrightpagename" ) );
753 return $s;
754 }
755
756 function aboutLink()
757 {
758 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
759 wfMsg( "aboutwikipedia" ) );
760 return $s;
761 }
762
763 function editThisPage()
764 {
765 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
766
767 if ( ! $wgOut->isArticle() || $diff ) {
768 $s = wfMsg( "protectedpage" );
769 } else if ( $wgTitle->userCanEdit() ) {
770 $n = $wgTitle->getPrefixedText();
771 $t = wfMsg( "editthispage" );
772 $oid = $red = "";
773
774 if ( $redirect ) { $red = "&redirect={$redirect}"; }
775 if ( $oldid && ! isset( $diff ) ) {
776 $oid = "&oldid={$oldid}";
777 }
778 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
779 } else {
780 $s = wfMsg( "protectedpage" );
781 }
782 return $s;
783 }
784
785 function deleteThisPage()
786 {
787 global $wgUser, $wgOut, $wgTitle, $diff;
788
789 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
790 $n = $wgTitle->getPrefixedText();
791 $t = wfMsg( "deletethispage" );
792
793 $s = $this->makeKnownLink( $n, $t, "action=delete" );
794 } else {
795 $s = wfMsg( "error" );
796 }
797 return $s;
798 }
799
800 function protectThisPage()
801 {
802 global $wgUser, $wgOut, $wgTitle, $diff;
803
804 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
805 $n = $wgTitle->getPrefixedText();
806
807 if ( $wgTitle->isProtected() ) {
808 $t = wfMsg( "unprotectthispage" );
809 $q = "action=unprotect";
810 } else {
811 $t = wfMsg( "protectthispage" );
812 $q = "action=protect";
813 }
814 $s = $this->makeKnownLink( $n, $t, $q );
815 } else {
816 $s = wfMsg( "error" );
817 }
818 return $s;
819 }
820
821 function watchThisPage()
822 {
823 global $wgUser, $wgOut, $wgTitle, $diff;
824
825 if ( $wgOut->isArticle() && ( ! $diff ) ) {
826 $n = $wgTitle->getPrefixedText();
827
828 if ( $wgTitle->userIsWatching() ) {
829 $t = wfMsg( "unwatchthispage" );
830 $q = "action=unwatch";
831 } else {
832 $t = wfMsg( "watchthispage" );
833 $q = "action=watch";
834 }
835 $s = $this->makeKnownLink( $n, $t, $q );
836 } else {
837 $s = wfMsg( "notanarticle" );
838 }
839 return $s;
840 }
841
842 function moveThisPage()
843 {
844 global $wgTitle, $wgLang;
845
846 if ( $wgTitle->userCanEdit() ) {
847 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
848 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
849 } // no message if page is protected - would be redundant
850 return $s;
851 }
852
853 function historyLink()
854 {
855 global $wgTitle;
856
857 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
858 wfMsg( "history" ), "action=history" );
859 return $s;
860 }
861
862 function whatLinksHere()
863 {
864 global $wgTitle, $wgLang;
865
866 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
867 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
868 return $s;
869 }
870
871 function userContribsLink()
872 {
873 global $wgTitle, $wgLang;
874
875 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
876 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
877 return $s;
878 }
879
880 function emailUserLink()
881 {
882 global $wgTitle, $wgLang;
883
884 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
885 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
886 return $s;
887 }
888
889 function watchPageLinksLink()
890 {
891 global $wgOut, $wgTitle, $wgLang;
892
893 if ( ! $wgOut->isArticle() ) {
894 $s = "(" . wfMsg( "notanarticle" ) . ")";
895 } else {
896 $s = $this->makeKnownLink( $wgLang->specialPage(
897 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
898 "target=" . $wgTitle->getPrefixedURL() );
899 }
900 return $s;
901 }
902
903 function otherLanguages()
904 {
905 global $wgOut, $wgLang, $wgTitle , $wgUseNewInterlanguage ;
906
907 $a = $wgOut->getLanguageLinks();
908 if ( 0 == count( $a ) ) {
909 if ( !$wgUseNewInterlanguage ) return "";
910 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
911 if ( $ns != 0 AND $ns != 1 ) return "" ;
912 $pn = "Intl" ;
913 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
914 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
915 wfMsg( "intl" ) , $x );
916 }
917
918 if ( !$wgUseNewInterlanguage ) {
919 $s = wfMsg( "otherlanguages" ) . ": ";
920 } else {
921 global $wgLanguageCode ;
922 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
923 $x .= "&xl=".$wgLanguageCode ;
924 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
925 wfMsg( "otherlanguages" ) , $x ) . ": " ;
926 }
927
928 $first = true;
929 foreach( $a as $l ) {
930 if ( ! $first ) { $s .= " | "; }
931 $first = false;
932
933 $nt = Title::newFromText( $l );
934 $url = $nt->getFullURL();
935 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
936
937 if ( "" == $text ) { $text = $l; }
938 $style = $this->getExternalLinkAttributes( $l, $text );
939 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
940 }
941 return $s;
942 }
943
944 function bugReportsLink()
945 {
946 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
947 wfMsg( "bugreports" ) );
948 return $s;
949 }
950
951 function dateLink()
952 {
953 global $wgLinkCache;
954 $t1 = Title::newFromText( date( "F j" ) );
955 $t2 = Title::newFromText( date( "Y" ) );
956
957 $wgLinkCache->suspend();
958 $id = $t1->getArticleID();
959 $wgLinkCache->resume();
960
961 if ( 0 == $id ) {
962 $s = $this->makeBrokenLink( $t1->getText() );
963 } else {
964 $s = $this->makeKnownLink( $t1->getText() );
965 }
966 $s .= ", ";
967
968 $wgLinkCache->suspend();
969 $id = $t2->getArticleID();
970 $wgLinkCache->resume();
971
972 if ( 0 == $id ) {
973 $s .= $this->makeBrokenLink( $t2->getText() );
974 } else {
975 $s .= $this->makeKnownLink( $t2->getText() );
976 }
977 return $s;
978 }
979
980 function talkLink()
981 {
982 global $wgLang, $wgTitle, $wgLinkCache;
983
984 $tns = $wgTitle->getNamespace();
985 if ( -1 == $tns ) { return ""; }
986
987 $pn = $wgTitle->getText();
988 $tp = wfMsg( "talkpage" );
989 if ( Namespace::isTalk( $tns ) ) {
990 $lns = Namespace::getSubject( $tns );
991 switch($tns) {
992 case 1:
993 $text = wfMsg("articlepage");
994 break;
995 case 3:
996 $text = wfMsg("userpage");
997 break;
998 case 5:
999 $text = wfMsg("wikipediapage");
1000 break;
1001 case 7:
1002 $text = wfMsg("imagepage");
1003 break;
1004 default:
1005 $text= wfMsg("articlepage");
1006 }
1007 } else {
1008
1009 $lns = Namespace::getTalk( $tns );
1010 $text=$tp;
1011 }
1012 $n = $wgLang->getNsText( $lns );
1013 if ( "" == $n ) { $link = $pn; }
1014 else { $link = "{$n}:{$pn}"; }
1015
1016 $wgLinkCache->suspend();
1017 $s = $this->makeLink( $link, $text );
1018 $wgLinkCache->resume();
1019
1020 return $s;
1021 }
1022
1023 # After all the page content is transformed into HTML, it makes
1024 # a final pass through here for things like table backgrounds.
1025 #
1026 function transformContent( $text )
1027 {
1028 return $text;
1029 }
1030
1031 # Note: This function MUST call getArticleID() on the link,
1032 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1033 #
1034 function makeLink( $title, $text= "", $query = "", $trail = "" )
1035 {
1036 global $wgOut, $wgUser;
1037
1038 $nt = Title::newFromText( $title );
1039
1040 if ( $nt->isExternal() ) {
1041 $u = $nt->getFullURL();
1042 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1043 $style = $this->getExternalLinkAttributes( $link, $text );
1044
1045 $inside = "";
1046 if ( "" != $trail ) {
1047 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1048 $inside = $m[1];
1049 $trail = $m[2];
1050 }
1051 }
1052 return "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1053 }
1054 if ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1055 return $this->makeKnownLink( $title, $text, $query, $trail );
1056 }
1057 if ( ( -1 == $nt->getNamespace() ) ||
1058 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1059 return $this->makeKnownLink( $title, $text, $query, $trail );
1060 }
1061 $aid = $nt->getArticleID() ;
1062 if ( 0 == $aid ) {
1063 return $this->makeBrokenLink( $title, $text, $query, $trail );
1064 } else {
1065 $threshold = $wgUser->getOption("stubthreshold") ;
1066 if ( $threshold > 0 ) {
1067 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'" ) ;
1068
1069 if ( wfNumRows( $res ) > 0 ) {
1070 $s = wfFetchObject( $res );
1071 $size = $s->x;
1072 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
1073 $size = $threshold*2 ; # Really big
1074 wfFreeResult( $res );
1075 } else $size = $threshold*2 ; # Really big
1076 } else $size = 1 ;
1077
1078 if ( $size < $threshold )
1079 return $this->makeStubLink( $title, $text, $query, $trail );
1080 return $this->makeKnownLink( $title, $text, $query, $trail );
1081 }
1082 }
1083
1084 function makeKnownLink( $title, $text = "", $query = "", $trail = "" )
1085 {
1086 global $wgOut, $wgTitle;
1087
1088 $nt = Title::newFromText( $title );
1089 $link = $nt->getPrefixedURL();
1090
1091 if ( "" == $link ) {
1092 $u = "";
1093 if ( "" == $text ) { $text = $nt->getFragment(); }
1094 } else {
1095 $u = wfLocalUrlE( $link, $query );
1096 }
1097 if ( "" != $nt->getFragment() ) {
1098 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1099 }
1100 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1101 $style = $this->getInternalLinkAttributes( $link, $text );
1102
1103 $inside = "";
1104 if ( "" != $trail ) {
1105 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1106 $inside = $m[1];
1107 $trail = $m[2];
1108 }
1109 }
1110 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1111 return $r;
1112 }
1113
1114 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" )
1115 {
1116 global $wgOut, $wgUser;
1117
1118 $nt = Title::newFromText( $title );
1119 $link = $nt->getPrefixedURL();
1120
1121 if ( "" == $query ) { $q = "action=edit"; }
1122 else { $q = "action=edit&{$query}"; }
1123 $u = wfLocalUrlE( $link, $q );
1124
1125 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1126 $style = $this->getInternalLinkAttributes( $link, $text, "yes" );
1127
1128 $inside = "";
1129 if ( "" != $trail ) {
1130 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1131 $inside = $m[1];
1132 $trail = $m[2];
1133 }
1134 }
1135 if ( $wgOut->isPrintable() ||
1136 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1137 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1138 } else {
1139 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1140 }
1141 return $s;
1142 }
1143
1144 function makeStubLink( $title, $text = "", $query = "", $trail = "" )
1145 {
1146 global $wgOut, $wgUser;
1147
1148 $nt = Title::newFromText( $title );
1149 $link = $nt->getPrefixedURL();
1150
1151 $u = wfLocalUrlE( $link, $query );
1152
1153 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1154 $style = $this->getInternalLinkAttributes( $link, $text, "stub" );
1155
1156 $inside = "";
1157 if ( "" != $trail ) {
1158 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1159 $inside = $m[1];
1160 $trail = $m[2];
1161 }
1162 }
1163 if ( $wgOut->isPrintable() ||
1164 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1165 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1166 } else {
1167 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1168 }
1169 return $s;
1170 }
1171
1172 function fnamePart( $url )
1173 {
1174 $basename = strrchr( $url, "/" );
1175 if ( false === $basename ) { $basename = $url; }
1176 else { $basename = substr( $basename, 1 ); }
1177 return wfEscapeHTML( $basename );
1178 }
1179
1180 function makeImage( $url, $alt = "" )
1181 {
1182 global $wgOut;
1183
1184 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1185 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1186 return $s;
1187 }
1188
1189 function makeImageLink( $name, $url, $alt = "" )
1190 {
1191 global $wgOut, $wgTitle, $wgLang;
1192
1193 $nt = Title::newFromText( $wgLang->getNsText(
1194 Namespace::getImage() ) . ":{$name}" );
1195 $link = $nt->getPrefixedURL();
1196 if ( "" == $alt ) { $alt = $name; }
1197
1198 $u = wfLocalUrlE( $link );
1199 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1200 "<img border=0 src=\"{$url}\" alt=\"{$alt}\"></a>";
1201 return $s;
1202 }
1203
1204 function makeMediaLink( $name, $url, $alt = "" )
1205 {
1206 global $wgOut, $wgTitle;
1207
1208 if ( "" == $alt ) { $alt = $name; }
1209 $u = wfEscapeHTML( $url );
1210 $s = "<a href=\"{$u}\" class='media' title=\"{$alt}\">{$alt}</a>";
1211 return $s;
1212 }
1213
1214 function specialLink( $name, $key = "" )
1215 {
1216 global $wgLang;
1217
1218 if ( "" == $key ) { $key = strtolower( $name ); }
1219 $pn = $wgLang->ucfirst( $name );
1220 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1221 wfMsg( $key ) );
1222 }
1223
1224 # Called by history lists and recent changes
1225 #
1226
1227 function beginRecentChangesList()
1228 {
1229 $rc_cache = array() ;
1230 $rccc = 0 ;
1231 $this->lastdate = "";
1232 return "";
1233 }
1234
1235 function beginHistoryList()
1236 {
1237 $this->lastdate = $this->lastline = "";
1238 $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
1239 return $s;
1240 }
1241
1242 function beginImageHistoryList()
1243 {
1244 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1245 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1246 return $s;
1247 }
1248
1249 function endRecentChangesList()
1250 {
1251 $s = $this->recentChangesBlock() ;
1252 $s .= "</ul>\n";
1253 return $s;
1254 }
1255
1256 function endHistoryList()
1257 {
1258 $last = wfMsg( "last" );
1259
1260 $s = preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
1261 $s .= "</ul>\n";
1262 return $s;
1263 }
1264
1265 function endImageHistoryList()
1266 {
1267 $s = "</ul>\n";
1268 return $s;
1269 }
1270
1271 function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor )
1272 {
1273 global $wgLang;
1274
1275 $artname = Title::makeName( $ns, $ttl );
1276 $last = wfMsg( "last" );
1277 $cur = wfMsg( "cur" );
1278 $cr = wfMsg( "currentrev" );
1279
1280 if ( $oid && $this->lastline ) {
1281 $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->makeKnownLink(
1282 $artname, $last, "diff=\\1&oldid={$oid}" ), $this->lastline );
1283 } else {
1284 $ret = "";
1285 }
1286 $dt = $wgLang->timeanddate( $ts, true );
1287
1288 if ( $oid ) { $q = "oldid={$oid}"; }
1289 else { $q = ""; }
1290 $link = $this->makeKnownLink( $artname, $dt, $q );
1291
1292 if ( 0 == $u ) {
1293 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1294 $ut, "target=" . $ut );
1295 } else { $ul = $this->makeLink( $wgLang->getNsText(
1296 Namespace::getUser() ) . ":{$ut}", $ut ); }
1297
1298 $s = "<li>";
1299 if ( $oid ) {
1300 $curlink = $this->makeKnownLink( $artname, $cur,
1301 "diff=0&oldid={$oid}" );
1302 } else {
1303 $curlink = $cur;
1304 }
1305 $s .= "({$curlink}) (!OLDID!{$oid}!) . .";
1306
1307 $M = wfMsg( "minoreditletter" );
1308 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1309 $s .= " {$link} . . {$ul}";
1310
1311 if ( "" != $c && "*" != $c ) { $s .= " <em>(" . wfEscapeHTML($c) . ")</em>"; }
1312 $s .= "</li>\n";
1313
1314 $this->lastline = $s;
1315 return $ret;
1316 }
1317
1318 function recentChangesBlockLine ( $y ) {
1319 global $wgUploadPath ;
1320
1321 $M = wfMsg( "minoreditletter" );
1322 $N = wfMsg( "newpageletter" );
1323 $r = "" ;
1324 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;
1325 $r .= "<tt>" ;
1326 if ( $y->isnew ) $r .= $N ;
1327 else $r .= "&nbsp;" ;
1328 if ( $y->isminor ) $r .= $M ;
1329 else $r .= "&nbsp;" ;
1330 $r .= " ".$y->timestamp." " ;
1331 $r .= "</tt>" ;
1332 $link = $y->link ;
1333 if ( $y->watched ) $link = "<strong>{$link}</strong>" ;
1334 $r .= $link ;
1335
1336 $r .= " (" ;
1337 $r .= $y->curlink ;
1338 $r .= "; " ;
1339 $r .= $this->makeKnownLink( $y->secureName, wfMsg( "hist" ), "action=history" );
1340
1341 $r .= ") . . ".$y->userlink ;
1342 $r .= $y->usertalklink ;
1343 if ( $y->usercomment != "" )
1344 $r .= " <em>(".wfEscapeHTML($y->usercomment).")</em>" ;
1345 $r .= "<br>\n" ;
1346 return $r ;
1347 }
1348
1349 function recentChangesBlockGroup ( $y ) {
1350 global $wgUploadPath ;
1351
1352 $r = "" ;
1353 $M = wfMsg( "minoreditletter" );
1354 $N = wfMsg( "newpageletter" );
1355 $isnew = false ;
1356 $userlinks = array () ;
1357 foreach ( $y AS $x ) {
1358 $oldid = $x->diffid ;
1359 if ( $x->isnew ) $isnew = true ;
1360 $u = $x->userlink ;
1361 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1362 $userlinks[$u]++ ;
1363 }
1364
1365 krsort ( $userlinks ) ;
1366 asort ( $userlinks ) ;
1367 $users = array () ;
1368 $u = array_keys ( $userlinks ) ;
1369 foreach ( $u as $x ) {
1370 $z = $x ;
1371 if ( $userlinks[$x] > 1 ) $z .= " ({$userlinks[$x]}&times;)" ;
1372 array_push ( $users , $z ) ;
1373 }
1374 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1375
1376 $e = $y ;
1377 $e = array_shift ( $e ) ;
1378
1379 # Arrow
1380 $rci = "RCI{$this->rccc}" ;
1381 $rcl = "RCL{$this->rccc}" ;
1382 $rcm = "RCM{$this->rccc}" ;
1383 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1384 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1385 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1386 $tl .= "</a>" ;
1387 $r .= $tl ;
1388
1389 # Main line
1390 $r .= "<tt>" ;
1391 if ( $isnew ) $r .= $N ;
1392 else $r .= "&nbsp;" ;
1393 $r .= "&nbsp;" ; # Minor
1394 $r .= " ".$e->timestamp." " ;
1395 $r .= "</tt>" ;
1396
1397 $link = $e->link ;
1398 if ( $e->watched ) $link = "<strong>{$link}</strong>" ;
1399 $r .= $link ;
1400
1401 if ( !$e->islog ) {
1402 $r .= " (".count($y)." " ;
1403 if ( $isnew ) $r .= wfMsg("changes");
1404 else $r .= $this->makeKnownLink( $e->secureName , wfMsg("changes") , "diff=0&oldid=".$oldid ) ;
1405 $r .= "; " ;
1406 $r .= $this->makeKnownLink( $e->secureName, wfMsg( "history" ), "action=history" );
1407 $r .= ")" ;
1408 }
1409
1410 $r .= $users ;
1411 $r .= "<br>\n" ;
1412
1413 # Sub-entries
1414 $r .= "<div id='{$rci}' style='display:none'>" ;
1415 foreach ( $y AS $x )
1416 {
1417 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1418 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
1419 if ( $x->isnew ) $r .= $N ;
1420 else $r .= "&nbsp;" ;
1421 if ( $x->isminor ) $r .= $M ;
1422 else $r .= "&nbsp;" ;
1423 $r .= "</tt>" ;
1424
1425 $o = "" ;
1426 if ( $x->oldid != 0 ) $o = "oldid=".$x->oldid ;
1427 if ( $x->islog ) $link = $x->timestamp ;
1428 else $link = $this->makeKnownLink( $x->secureName, $x->timestamp , $o ) ;
1429 $link = "<tt>{$link}</tt>" ;
1430
1431
1432 $r .= $link ;
1433 $r .= " (" ;
1434 $r .= $x->curlink ;
1435 $r .= "; " ;
1436 $r .= $x->lastlink ;
1437 $r .= ") . . ".$x->userlink ;
1438 $r .= $x->usertalklink ;
1439 if ( $x->usercomment != "" )
1440 $r .= " <em>(".wfEscapeHTML($x->usercomment).")</em>" ;
1441 $r .= "<br>\n" ;
1442 }
1443 $r .= "</div>\n" ;
1444
1445 $this->rccc++ ;
1446 return $r ;
1447 }
1448
1449 function recentChangesBlock ()
1450 {
1451 global $wgUploadPath ;
1452 if ( count ( $this->rc_cache ) == 0 ) return "" ;
1453 $k = array_keys ( $this->rc_cache ) ;
1454 foreach ( $k AS $x )
1455 {
1456 $y = $this->rc_cache[$x] ;
1457 if ( count ( $y ) < 2 ) {
1458 $r .= $this->recentChangesBlockLine ( array_shift ( $y ) ) ;
1459 } else {
1460 $r .= $this->recentChangesBlockGroup ( $y ) ;
1461 }
1462 }
1463
1464 return "<div align=left>{$r}</div>" ;
1465 }
1466
1467 function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1468 {
1469 global $wgUser ;
1470 $usenew = $wgUser->getOption( "usenewrc" );
1471 if ( $usenew )
1472 $r = $this->recentChangesLineNew ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1473 else
1474 $r = $this->recentChangesLineOld ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1475 return $r ;
1476 }
1477
1478 function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 )
1479 {
1480 global $wgTitle, $wgLang, $wgUser;
1481
1482 $d = $wgLang->date( $ts, true);
1483 $s = "";
1484 if ( $d != $this->lastdate ) {
1485 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
1486 $s .= "<h4>{$d}</h4>\n<ul>";
1487 $this->lastdate = $d;
1488 }
1489 $h = $wgLang->time( $ts, true );
1490 $t = Title::makeName( $ns, $ttl );
1491 $clink = $this->makeKnownLink( $t , "" );
1492 $nt = Title::newFromText( $t );
1493
1494 if ( $watched ) {
1495 $clink = "<strong>{$clink}</strong>";
1496 }
1497 $hlink = $this->makeKnownLink( $t, wfMsg( "hist" ), "action=history" );
1498 if ( $isnew || $nt->isLog() ) {
1499 $dlink = wfMsg( "diff" );
1500 } else {
1501 $dlink = $this->makeKnownLink( $t, wfMsg( "diff" ),
1502 "diff={$oldid}&oldid={$diffid}" ); # Finagle's law
1503 }
1504 if ( 0 == $u ) {
1505 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1506 $ut, "target=" . $ut );
1507 } else { $ul = $this->makeLink( $wgLang->getNsText(
1508 Namespace::getUser() ) . ":{$ut}", $ut ); }
1509
1510 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1511 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1512 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1513 $cr = wfMsg( "currentrev" );
1514
1515 $s .= "<li> ({$dlink}) ({$hlink}) . .";
1516 $M = wfMsg( "minoreditletter" );
1517 $N = wfMsg( "newpageletter" );
1518 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1519 if ( $isnew ) { $s .= "<strong>{$N}</strong>"; }
1520 $s .= " {$clink}; {$h} . . {$ul}";
1521
1522 $blink="";
1523 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1524 $blink = $this->makeKnownLink( $wgLang->specialPage(
1525 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1526
1527 }
1528 if(!$blink) {
1529 $utl = "({$utl})";
1530 } else {
1531 $utl = "({$utl} | {$blink})";
1532 }
1533 $s.=" {$utl}";
1534
1535 if ( "" != $c && "*" != $c ) {
1536 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1537 }
1538 $s .= "</li>\n";
1539
1540 return $s;
1541 }
1542
1543 function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1544 {
1545 global $wgTitle, $wgLang, $wgUser;
1546
1547 $rc = new RecentChangesClass ;
1548
1549 $d = $wgLang->date( $ts, true);
1550 $s = "";
1551 $ret = "" ;
1552 if ( $d != $this->lastdate ) {
1553 $ret = $this->recentChangesBlock () ;
1554 $this->rc_cache = array() ;
1555 $ret .= "<h4>{$d}</h4>\n";
1556 $this->lastdate = $d;
1557 }
1558 $h = $wgLang->time( $ts, true );
1559 $t = Title::makeName( $ns, $ttl );
1560 $clink = $this->makeKnownLink( $t, "" ) ;
1561 if ( $oldid == 0 ) $c2link = $clink ;
1562 else $c2link = $this->makeKnownLink( $t, "" , "oldid={$oldid}" );
1563 $nt = Title::newFromText( $t );
1564
1565 $rc->timestamp = $h ;
1566 $rc->oldid = $oldid ;
1567 $rc->diffid = $diffid ;
1568 $rc->watched = $watched ;
1569 $rc->isnew = $isnew ;
1570 $rc->isminor = $isminor ;
1571 $rc->secureName = $t ;
1572 $rc->displayName = $nt ;
1573 $rc->link = $clink ;
1574 $rc->usercomment = $c ;
1575 $rc->islog = $nt->isLog() ;
1576
1577 if ( ( $isnew && $oldid == 0 ) || $nt->isLog() ) {
1578 $dlink = wfMsg( "cur" );
1579 } else {
1580 $dlink = $this->makeKnownLink( $t, wfMsg( "cur" ),
1581 "diff=0&oldid={$oldid}" );
1582 }
1583
1584 if ( $diffid == 0 || $nt->isLog() ) {
1585 $plink = wfMsg( "last" );
1586 } else {
1587 $plink = $this->makeKnownLink( $t, wfMsg( "last" ),
1588 "diff={$oldid}&oldid={$diffid}" );
1589 }
1590
1591 if ( 0 == $u ) {
1592 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1593 $ut, "target=" . $ut );
1594 } else { $ul = $this->makeLink( $wgLang->getNsText(
1595 Namespace::getUser() ) . ":{$ut}", $ut ); }
1596
1597 $rc->userlink = $ul ;
1598 $rc->lastlink = $plink ;
1599 $rc->curlink = $dlink ;
1600
1601 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1602 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1603 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1604
1605 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1606 $blink = $this->makeKnownLink( $wgLang->specialPage(
1607 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1608 $rc->usertalklink= " ({$utl} | {$blink})";
1609 } else {
1610 $rc->usertalklink=" ({$utl})";
1611 }
1612
1613 if ( !isset ( $this->rc_cache[$t] ) ) $this->rc_cache[$t] = array() ;
1614 array_push ( $this->rc_cache[$t] , $rc ) ;
1615 return $ret;
1616 }
1617
1618
1619 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
1620 {
1621 global $wgUser, $wgLang, $wgTitle;
1622
1623 $dt = $wgLang->timeanddate( $ts, true );
1624 $del = wfMsg( "deleteimg" );
1625 $cur = wfMsg( "cur" );
1626
1627 if ( $iscur ) {
1628 $url = wfImageUrl( $img );
1629 $rlink = $cur;
1630 if ( $wgUser->isSysop() ) {
1631 $link = wfLocalUrlE( "", "image=" . $wgTitle->getURL() .
1632 "&action=delete" );
1633 $style = $this->getInternalLinkAttributes( $link, $del );
1634
1635 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
1636 } else {
1637 $dlink = $del;
1638 }
1639 } else {
1640 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
1641 if( $wgUser->getID() != 0 ) {
1642 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1643 wfMsg( "revertimg" ), "action=revert&oldimage=" .
1644 urlencode( $img ) );
1645 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1646 $del, "action=delete&oldimage=" . urlencode( $img ) );
1647 } else {
1648 # Having live active links for non-logged in users
1649 # means that bots and spiders crawling our site can
1650 # inadvertently change content. Baaaad idea.
1651 $rlink = wfMsg( "revertimg" );
1652 $dlink = $del;
1653 }
1654 }
1655 if ( 0 == $u ) { $ul = $ut; }
1656 else { $ul = $this->makeLink( $wgLang->getNsText(
1657 Namespace::getUser() ) . ":{$ut}", $ut ); }
1658
1659 $nb = str_replace( "$1", $size, wfMsg( "nbytes" ) );
1660 $style = $this->getInternalLinkAttributes( $url, $dt );
1661
1662 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
1663 . " . . {$ul} ({$nb})";
1664
1665 if ( "" != $c && "*" != $c ) {
1666 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1667 }
1668 $s .= "</li>\n";
1669 return $s;
1670 }
1671 }
1672
1673 include_once( "SkinStandard.php" );
1674 include_once( "SkinNostalgia.php" );
1675 include_once( "SkinCologneBlue.php" );
1676
1677 ?>