Initial revision
[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 $count = $wgArticle->getCount();
537 $s = str_replace( "$1", $count, wfMsg( "viewcount" ) );
538
539 $s .= $this->lastModified();
540 $s .= " ".wfMsg( "gnunote" ) ;
541 return "<span id='pagestats'>{$s}</span>";
542 }
543
544 function lastModified()
545 {
546 global $wgLang, $wgArticle;
547
548 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
549 $s = " " . str_replace( "$1", $d, wfMsg( "lastmodified" ) );
550 return $s;
551 }
552
553 function logoText( $align = "" )
554 {
555 if ( "" != $align ) { $a = " align='{$align}'"; }
556 else { $a = ""; }
557
558 $mp = wfMsg( "mainpage" );
559 $s = "<a href=\"" . wfLocalUrlE( $mp ) . "\"><img{$a} border=0 src=\""
560 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
561 return $s;
562 }
563
564 function quickBar()
565 {
566 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
567 global $wpPreview;
568 wfProfileIn( "Skin::quickBar" );
569
570 $s = "\n<div id='quickbar'>";
571 $s .= "\n" . $this->logoText() . "\n<hr>";
572
573 $sep = "\n<br>";
574 $s .= $this->mainPageLink()
575 . $sep . $this->specialLink( "recentchanges" )
576 . $sep . $this->specialLink( "randompage" );
577 if ($wgUser->getID()) {
578 $s.= $sep . $this->specialLink( "watchlist" ) ;
579 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
580 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
581
582 }
583 // only show watchlist link if logged in
584 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
585 $s .= "\n<hr>";
586 $articleExists = $wgTitle->getArticleId();
587 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
588
589 if($wgOut->isArticle()) {
590 $s .= "<strong>" . $this->editThisPage() . "</strong>";
591 } else { # backlink to the article in edit or history mode
592
593 if($articleExists){ # no backlink if no article
594 $tns=$wgTitle->getNamespace();
595 switch($tns) {
596 case 0:
597 $text = wfMsg("articlepage");
598 break;
599 case 1:
600 $text = wfMsg("viewtalkpage");
601 break;
602 case 2:
603 $text = wfMsg("userpage");
604 break;
605 case 3:
606 $text = wfMsg("viewtalkpage");
607 break;
608 case 4:
609 $text = wfMsg("wikipediapage");
610 break;
611 case 5:
612 $text = wfMsg("viewtalkpage");
613 break;
614 case 6:
615 $text = wfMsg("imagepage");
616 break;
617 case 7:
618 $text = wfMsg("viewtalkpage");
619 break;
620 default:
621 $text= wfMsg("articlepage");
622 }
623
624 $link = $wgTitle->getText();
625 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
626 $link = $nstext . ":" . $link ;
627 }
628 $s .= $this->makeLink($link, $text );
629 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
630 # we just throw in a "New page" text to tell the user that he's in edit mode,
631 # and to avoid messing with the separator that is prepended to the next item
632 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
633 }
634
635 }
636
637 /*
638 watching could cause problems in edit mode:
639 if user edits article, then loads "watch this article" in background and then saves
640 article with "Watch this article" checkbox disabled, the article is transparently
641 unwatched. Therefore we do not show the "Watch this page" link in edit mode
642 */
643 if ( 0 != $wgUser->getID() && $articleExists) {
644 if($action!="edit" && $action!="history" &&
645 $action != "submit" )
646 {$s .= $sep . $this->watchThisPage(); }
647 if ( $wgTitle->userCanEdit() ) $s .= $sep . $this->moveThisPage();
648 }
649 if ( $wgUser->isSysop() and $articleExists ) {
650 $s .= $sep . $this->deleteThisPage() .
651 $sep . $this->protectThisPage();
652 }
653 $s .= $sep . $this->talkLink();
654 if ($articleExists && $action !="history") { $s .= $sep . $this->historyLink();}
655 $s.=$sep . $this->whatLinksHere();
656
657 if($wgOut->isArticle()) {
658 $s .= $sep . $this->watchPageLinksLink();
659 }
660
661 if ( Namespace::getUser() == $wgTitle->getNamespace()
662 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
663 ) {
664
665 $id=User::idFromName($wgTitle->getText());
666 $ip=User::isIP($wgTitle->getText());
667
668 if($id||$ip) {
669 $s .= $sep . $this->userContribsLink();
670 }
671 if ( 0 != $wgUser->getID() ) {
672 if($id) { # can only email real users
673 $s .= $sep . $this->emailUserLink();
674 }
675 }
676 }
677 $s .= "\n<hr>";
678 }
679
680 if ( 0 != $wgUser->getID() ) {
681 $s .= $this->specialLink( "upload" ) . $sep;
682 }
683 $s .= $this->specialLink( "specialpages" )
684 . $sep . $this->bugReportsLink();
685
686 $s .= "\n</div>\n";
687 wfProfileOut();
688 return $s;
689 }
690
691 function specialPagesList()
692 {
693 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
694 $a = array();
695
696 $validSP = $wgLang->getValidSpecialPages();
697
698 foreach ( $validSP as $name => $desc ) {
699 if ( "" == $desc ) { continue; }
700 $a[$name] = $desc;
701 }
702 if ( $wgUser->isSysop() )
703 {
704 $sysopSP = $wgLang->getSysopSpecialPages();
705
706 foreach ( $sysopSP as $name => $desc ) {
707 if ( "" == $desc ) { continue; }
708 $a[$name] = $desc ;
709 }
710 }
711 if ( $wgUser->isDeveloper() )
712 {
713 $devSP = $wgLang->getDeveloperSpecialPages();
714
715 foreach ( $devSP as $name => $desc ) {
716 if ( "" == $desc ) { continue; }
717 $a[$name] = $desc ;
718 }
719 }
720 $go = wfMsg( "go" );
721 $sp = wfMsg( "specialpages" );
722 $spp = $wgLang->specialPage( "Specialpages" );
723
724 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
725 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
726 $s .= "<select name=\"wpDropdown\">\n";
727 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
728
729 foreach ( $a as $name => $desc ) {
730 $p = $wgLang->specialPage( $name );
731 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
732 }
733 $s .= "</select>\n";
734 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
735 $s .= "</form>\n";
736 return $s;
737 }
738
739 function mainPageLink()
740 {
741 $mp = wfMsg( "mainpage" );
742 $s = $this->makeKnownLink( $mp, $mp );
743 return $s;
744 }
745
746 function copyrightLink()
747 {
748 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
749 wfMsg( "copyrightpagename" ) );
750 return $s;
751 }
752
753 function aboutLink()
754 {
755 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
756 wfMsg( "aboutwikipedia" ) );
757 return $s;
758 }
759
760 function editThisPage()
761 {
762 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
763
764 if ( ! $wgOut->isArticle() || $diff ) {
765 $s = wfMsg( "protectedpage" );
766 } else if ( $wgTitle->userCanEdit() ) {
767 $n = $wgTitle->getPrefixedText();
768 $t = wfMsg( "editthispage" );
769 $oid = $red = "";
770
771 if ( $redirect ) { $red = "&redirect={$redirect}"; }
772 if ( $oldid && ! isset( $diff ) ) {
773 $oid = "&oldid={$oldid}";
774 }
775 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
776 } else {
777 $s = wfMsg( "protectedpage" );
778 }
779 return $s;
780 }
781
782 function deleteThisPage()
783 {
784 global $wgUser, $wgOut, $wgTitle, $diff;
785
786 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
787 $n = $wgTitle->getPrefixedText();
788 $t = wfMsg( "deletethispage" );
789
790 $s = $this->makeKnownLink( $n, $t, "action=delete" );
791 } else {
792 $s = wfMsg( "error" );
793 }
794 return $s;
795 }
796
797 function protectThisPage()
798 {
799 global $wgUser, $wgOut, $wgTitle, $diff;
800
801 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
802 $n = $wgTitle->getPrefixedText();
803
804 if ( $wgTitle->isProtected() ) {
805 $t = wfMsg( "unprotectthispage" );
806 $q = "action=unprotect";
807 } else {
808 $t = wfMsg( "protectthispage" );
809 $q = "action=protect";
810 }
811 $s = $this->makeKnownLink( $n, $t, $q );
812 } else {
813 $s = wfMsg( "error" );
814 }
815 return $s;
816 }
817
818 function watchThisPage()
819 {
820 global $wgUser, $wgOut, $wgTitle, $diff;
821
822 if ( $wgOut->isArticle() && ( ! $diff ) ) {
823 $n = $wgTitle->getPrefixedText();
824
825 if ( $wgTitle->userIsWatching() ) {
826 $t = wfMsg( "unwatchthispage" );
827 $q = "action=unwatch";
828 } else {
829 $t = wfMsg( "watchthispage" );
830 $q = "action=watch";
831 }
832 $s = $this->makeKnownLink( $n, $t, $q );
833 } else {
834 $s = wfMsg( "notanarticle" );
835 }
836 return $s;
837 }
838
839 function moveThisPage()
840 {
841 global $wgTitle, $wgLang;
842
843 if ( $wgTitle->userCanEdit() ) {
844 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
845 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
846 } // no message if page is protected - would be redundant
847 return $s;
848 }
849
850 function historyLink()
851 {
852 global $wgTitle;
853
854 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
855 wfMsg( "history" ), "action=history" );
856 return $s;
857 }
858
859 function whatLinksHere()
860 {
861 global $wgTitle, $wgLang;
862
863 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
864 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
865 return $s;
866 }
867
868 function userContribsLink()
869 {
870 global $wgTitle, $wgLang;
871
872 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
873 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
874 return $s;
875 }
876
877 function emailUserLink()
878 {
879 global $wgTitle, $wgLang;
880
881 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
882 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
883 return $s;
884 }
885
886 function watchPageLinksLink()
887 {
888 global $wgOut, $wgTitle, $wgLang;
889
890 if ( ! $wgOut->isArticle() ) {
891 $s = "(" . wfMsg( "notanarticle" ) . ")";
892 } else {
893 $s = $this->makeKnownLink( $wgLang->specialPage(
894 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
895 "target=" . $wgTitle->getPrefixedURL() );
896 }
897 return $s;
898 }
899
900 function otherLanguages()
901 {
902 global $wgOut, $wgLang, $wgTitle , $wgUseNewInterlanguage ;
903
904 $a = $wgOut->getLanguageLinks();
905 if ( 0 == count( $a ) ) {
906 if ( !$wgUseNewInterlanguage ) return "";
907 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
908 if ( $ns != 0 AND $ns != 1 ) return "" ;
909 $pn = "Intl" ;
910 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
911 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
912 wfMsg( "intl" ) , $x );
913 }
914
915 if ( !$wgUseNewInterlanguage ) {
916 $s = wfMsg( "otherlanguages" ) . ": ";
917 } else {
918 global $wgLanguageCode ;
919 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
920 $x .= "&xl=".$wgLanguageCode ;
921 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
922 wfMsg( "otherlanguages" ) , $x ) . ": " ;
923 }
924
925 $first = true;
926 foreach( $a as $l ) {
927 if ( ! $first ) { $s .= " | "; }
928 $first = false;
929
930 $nt = Title::newFromText( $l );
931 $url = $nt->getFullURL();
932 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
933
934 if ( "" == $text ) { $text = $l; }
935 $style = $this->getExternalLinkAttributes( $l, $text );
936 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
937 }
938 return $s;
939 }
940
941 function bugReportsLink()
942 {
943 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
944 wfMsg( "bugreports" ) );
945 return $s;
946 }
947
948 function dateLink()
949 {
950 global $wgLinkCache;
951 $t1 = Title::newFromText( date( "F j" ) );
952 $t2 = Title::newFromText( date( "Y" ) );
953
954 $wgLinkCache->suspend();
955 $id = $t1->getArticleID();
956 $wgLinkCache->resume();
957
958 if ( 0 == $id ) {
959 $s = $this->makeBrokenLink( $t1->getText() );
960 } else {
961 $s = $this->makeKnownLink( $t1->getText() );
962 }
963 $s .= ", ";
964
965 $wgLinkCache->suspend();
966 $id = $t2->getArticleID();
967 $wgLinkCache->resume();
968
969 if ( 0 == $id ) {
970 $s .= $this->makeBrokenLink( $t2->getText() );
971 } else {
972 $s .= $this->makeKnownLink( $t2->getText() );
973 }
974 return $s;
975 }
976
977 function talkLink()
978 {
979 global $wgLang, $wgTitle, $wgLinkCache;
980
981 $tns = $wgTitle->getNamespace();
982 if ( -1 == $tns ) { return ""; }
983
984 $pn = $wgTitle->getText();
985 $tp = wfMsg( "talkpage" );
986 if ( Namespace::isTalk( $tns ) ) {
987 $lns = Namespace::getSubject( $tns );
988 switch($tns) {
989 case 1:
990 $text = wfMsg("articlepage");
991 break;
992 case 3:
993 $text = wfMsg("userpage");
994 break;
995 case 5:
996 $text = wfMsg("wikipediapage");
997 break;
998 case 7:
999 $text = wfMsg("imagepage");
1000 break;
1001 default:
1002 $text= wfMsg("articlepage");
1003 }
1004 } else {
1005
1006 $lns = Namespace::getTalk( $tns );
1007 $text=$tp;
1008 }
1009 $n = $wgLang->getNsText( $lns );
1010 if ( "" == $n ) { $link = $pn; }
1011 else { $link = "{$n}:{$pn}"; }
1012
1013 $wgLinkCache->suspend();
1014 $s = $this->makeLink( $link, $text );
1015 $wgLinkCache->resume();
1016
1017 return $s;
1018 }
1019
1020 # After all the page content is transformed into HTML, it makes
1021 # a final pass through here for things like table backgrounds.
1022 #
1023 function transformContent( $text )
1024 {
1025 return $text;
1026 }
1027
1028 # Note: This function MUST call getArticleID() on the link,
1029 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1030 #
1031 function makeLink( $title, $text= "", $query = "", $trail = "" )
1032 {
1033 global $wgOut, $wgUser;
1034
1035 $nt = Title::newFromText( $title );
1036
1037 if ( $nt->isExternal() ) {
1038 $u = $nt->getFullURL();
1039 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1040 $style = $this->getExternalLinkAttributes( $link, $text );
1041
1042 $inside = "";
1043 if ( "" != $trail ) {
1044 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1045 $inside = $m[1];
1046 $trail = $m[2];
1047 }
1048 }
1049 return "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1050 }
1051 if ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1052 return $this->makeKnownLink( $title, $text, $query, $trail );
1053 }
1054 if ( ( -1 == $nt->getNamespace() ) ||
1055 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1056 return $this->makeKnownLink( $title, $text, $query, $trail );
1057 }
1058 $aid = $nt->getArticleID() ;
1059 if ( 0 == $aid ) {
1060 return $this->makeBrokenLink( $title, $text, $query, $trail );
1061 } else {
1062 $threshold = $wgUser->getOption("stubthreshold") ;
1063 if ( $threshold > 0 ) {
1064 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'" ) ;
1065
1066 if ( wfNumRows( $res ) > 0 ) {
1067 $s = wfFetchObject( $res );
1068 $size = $s->x;
1069 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
1070 $size = $threshold*2 ; # Really big
1071 wfFreeResult( $res );
1072 } else $size = $threshold*2 ; # Really big
1073 } else $size = 1 ;
1074
1075 if ( $size < $threshold )
1076 return $this->makeStubLink( $title, $text, $query, $trail );
1077 return $this->makeKnownLink( $title, $text, $query, $trail );
1078 }
1079 }
1080
1081 function makeKnownLink( $title, $text = "", $query = "", $trail = "" )
1082 {
1083 global $wgOut, $wgTitle;
1084
1085 $nt = Title::newFromText( $title );
1086 $link = $nt->getPrefixedURL();
1087
1088 if ( "" == $link ) {
1089 $u = "";
1090 if ( "" == $text ) { $text = $nt->getFragment(); }
1091 } else {
1092 $u = wfLocalUrlE( $link, $query );
1093 }
1094 if ( "" != $nt->getFragment() ) {
1095 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1096 }
1097 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1098 $style = $this->getInternalLinkAttributes( $link, $text );
1099
1100 $inside = "";
1101 if ( "" != $trail ) {
1102 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1103 $inside = $m[1];
1104 $trail = $m[2];
1105 }
1106 }
1107 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1108 return $r;
1109 }
1110
1111 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" )
1112 {
1113 global $wgOut, $wgUser;
1114
1115 $nt = Title::newFromText( $title );
1116 $link = $nt->getPrefixedURL();
1117
1118 if ( "" == $query ) { $q = "action=edit"; }
1119 else { $q = "action=edit&{$query}"; }
1120 $u = wfLocalUrlE( $link, $q );
1121
1122 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1123 $style = $this->getInternalLinkAttributes( $link, $text, "yes" );
1124
1125 $inside = "";
1126 if ( "" != $trail ) {
1127 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1128 $inside = $m[1];
1129 $trail = $m[2];
1130 }
1131 }
1132 if ( $wgOut->isPrintable() ||
1133 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1134 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1135 } else {
1136 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1137 }
1138 return $s;
1139 }
1140
1141 function makeStubLink( $title, $text = "", $query = "", $trail = "" )
1142 {
1143 global $wgOut, $wgUser;
1144
1145 $nt = Title::newFromText( $title );
1146 $link = $nt->getPrefixedURL();
1147
1148 $u = wfLocalUrlE( $link, $query );
1149
1150 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1151 $style = $this->getInternalLinkAttributes( $link, $text, "stub" );
1152
1153 $inside = "";
1154 if ( "" != $trail ) {
1155 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1156 $inside = $m[1];
1157 $trail = $m[2];
1158 }
1159 }
1160 if ( $wgOut->isPrintable() ||
1161 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1162 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1163 } else {
1164 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1165 }
1166 return $s;
1167 }
1168
1169 function fnamePart( $url )
1170 {
1171 $basename = strrchr( $url, "/" );
1172 if ( false === $basename ) { $basename = $url; }
1173 else { $basename = substr( $basename, 1 ); }
1174 return wfEscapeHTML( $basename );
1175 }
1176
1177 function makeImage( $url, $alt = "" )
1178 {
1179 global $wgOut;
1180
1181 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1182 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1183 return $s;
1184 }
1185
1186 function makeImageLink( $name, $url, $alt = "" )
1187 {
1188 global $wgOut, $wgTitle, $wgLang;
1189
1190 $nt = Title::newFromText( $wgLang->getNsText(
1191 Namespace::getImage() ) . ":{$name}" );
1192 $link = $nt->getPrefixedURL();
1193 if ( "" == $alt ) { $alt = $name; }
1194
1195 $u = wfLocalUrlE( $link );
1196 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1197 "<img border=0 src=\"{$url}\" alt=\"{$alt}\"></a>";
1198 return $s;
1199 }
1200
1201 function makeMediaLink( $name, $url, $alt = "" )
1202 {
1203 global $wgOut, $wgTitle;
1204
1205 if ( "" == $alt ) { $alt = $name; }
1206 $u = wfEscapeHTML( $url );
1207 $s = "<a href=\"{$u}\" class='media' title=\"{$alt}\">{$alt}</a>";
1208 return $s;
1209 }
1210
1211 function specialLink( $name, $key = "" )
1212 {
1213 global $wgLang;
1214
1215 if ( "" == $key ) { $key = strtolower( $name ); }
1216 $pn = $wgLang->ucfirst( $name );
1217 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1218 wfMsg( $key ) );
1219 }
1220
1221 # Called by history lists and recent changes
1222 #
1223
1224 function beginRecentChangesList()
1225 {
1226 $rc_cache = array() ;
1227 $rccc = 0 ;
1228 $this->lastdate = "";
1229 return "";
1230 }
1231
1232 function beginHistoryList()
1233 {
1234 $this->lastdate = $this->lastline = "";
1235 $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
1236 return $s;
1237 }
1238
1239 function beginImageHistoryList()
1240 {
1241 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1242 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1243 return $s;
1244 }
1245
1246 function endRecentChangesList()
1247 {
1248 $s = $this->recentChangesBlock() ;
1249 $s .= "</ul>\n";
1250 return $s;
1251 }
1252
1253 function endHistoryList()
1254 {
1255 $last = wfMsg( "last" );
1256
1257 $s = preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
1258 $s .= "</ul>\n";
1259 return $s;
1260 }
1261
1262 function endImageHistoryList()
1263 {
1264 $s = "</ul>\n";
1265 return $s;
1266 }
1267
1268 function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor )
1269 {
1270 global $wgLang;
1271
1272 $artname = Title::makeName( $ns, $ttl );
1273 $last = wfMsg( "last" );
1274 $cur = wfMsg( "cur" );
1275 $cr = wfMsg( "currentrev" );
1276
1277 if ( $oid && $this->lastline ) {
1278 $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->makeKnownLink(
1279 $artname, $last, "diff=\\1&oldid={$oid}" ), $this->lastline );
1280 } else {
1281 $ret = "";
1282 }
1283 $dt = $wgLang->timeanddate( $ts, true );
1284
1285 if ( $oid ) { $q = "oldid={$oid}"; }
1286 else { $q = ""; }
1287 $link = $this->makeKnownLink( $artname, $dt, $q );
1288
1289 if ( 0 == $u ) {
1290 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1291 $ut, "target=" . $ut );
1292 } else { $ul = $this->makeLink( $wgLang->getNsText(
1293 Namespace::getUser() ) . ":{$ut}", $ut ); }
1294
1295 $s = "<li>";
1296 if ( $oid ) {
1297 $curlink = $this->makeKnownLink( $artname, $cur,
1298 "diff=0&oldid={$oid}" );
1299 } else {
1300 $curlink = $cur;
1301 }
1302 $s .= "({$curlink}) (!OLDID!{$oid}!) . .";
1303
1304 $M = wfMsg( "minoreditletter" );
1305 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1306 $s .= " {$link} . . {$ul}";
1307
1308 if ( "" != $c && "*" != $c ) { $s .= " <em>(" . wfEscapeHTML($c) . ")</em>"; }
1309 $s .= "</li>\n";
1310
1311 $this->lastline = $s;
1312 return $ret;
1313 }
1314
1315 function recentChangesBlockLine ( $y ) {
1316 global $wgUploadPath ;
1317
1318 $M = wfMsg( "minoreditletter" );
1319 $N = wfMsg( "newpageletter" );
1320 $r = "" ;
1321 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;
1322 $r .= "<tt>" ;
1323 if ( $y->isnew ) $r .= $N ;
1324 else $r .= "&nbsp;" ;
1325 if ( $y->isminor ) $r .= $M ;
1326 else $r .= "&nbsp;" ;
1327 $r .= " ".$y->timestamp." " ;
1328 $r .= "</tt>" ;
1329 $link = $y->link ;
1330 if ( $y->watched ) $link = "<strong>{$link}</strong>" ;
1331 $r .= $link ;
1332
1333 $r .= " (" ;
1334 $r .= $y->curlink ;
1335 $r .= "; " ;
1336 $r .= $this->makeKnownLink( $y->secureName, wfMsg( "hist" ), "action=history" );
1337
1338 $r .= ") . . ".$y->userlink ;
1339 $r .= $y->usertalklink ;
1340 if ( $y->usercomment != "" )
1341 $r .= " <em>(".wfEscapeHTML($y->usercomment).")</em>" ;
1342 $r .= "<br>\n" ;
1343 return $r ;
1344 }
1345
1346 function recentChangesBlockGroup ( $y ) {
1347 global $wgUploadPath ;
1348
1349 $r = "" ;
1350 $M = wfMsg( "minoreditletter" );
1351 $N = wfMsg( "newpageletter" );
1352 $isnew = false ;
1353 $userlinks = array () ;
1354 foreach ( $y AS $x ) {
1355 $oldid = $x->diffid ;
1356 if ( $x->isnew ) $isnew = true ;
1357 $u = $x->userlink ;
1358 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1359 $userlinks[$u]++ ;
1360 }
1361
1362 krsort ( $userlinks ) ;
1363 asort ( $userlinks ) ;
1364 $users = array () ;
1365 $u = array_keys ( $userlinks ) ;
1366 foreach ( $u as $x ) {
1367 $z = $x ;
1368 if ( $userlinks[$x] > 1 ) $z .= " ({$userlinks[$x]}&times;)" ;
1369 array_push ( $users , $z ) ;
1370 }
1371 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1372
1373 $e = $y ;
1374 $e = array_shift ( $e ) ;
1375
1376 # Arrow
1377 $rci = "RCI{$this->rccc}" ;
1378 $rcl = "RCL{$this->rccc}" ;
1379 $rcm = "RCM{$this->rccc}" ;
1380 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1381 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1382 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1383 $tl .= "</a>" ;
1384 $r .= $tl ;
1385
1386 # Main line
1387 $r .= "<tt>" ;
1388 if ( $isnew ) $r .= $N ;
1389 else $r .= "&nbsp;" ;
1390 $r .= "&nbsp;" ; # Minor
1391 $r .= " ".$e->timestamp." " ;
1392 $r .= "</tt>" ;
1393
1394 $link = $e->link ;
1395 if ( $e->watched ) $link = "<strong>{$link}</strong>" ;
1396 $r .= $link ;
1397
1398 if ( !$e->islog ) {
1399 $r .= " (".count($y)." " ;
1400 if ( $isnew ) $r .= wfMsg("changes");
1401 else $r .= $this->makeKnownLink( $e->secureName , wfMsg("changes") , "diff=0&oldid=".$oldid ) ;
1402 $r .= "; " ;
1403 $r .= $this->makeKnownLink( $e->secureName, wfMsg( "history" ), "action=history" );
1404 $r .= ")" ;
1405 }
1406
1407 $r .= $users ;
1408 $r .= "<br>\n" ;
1409
1410 # Sub-entries
1411 $r .= "<div id='{$rci}' style='display:none'>" ;
1412 foreach ( $y AS $x )
1413 {
1414 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1415 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
1416 if ( $x->isnew ) $r .= $N ;
1417 else $r .= "&nbsp;" ;
1418 if ( $x->isminor ) $r .= $M ;
1419 else $r .= "&nbsp;" ;
1420 $r .= "</tt>" ;
1421
1422 $o = "" ;
1423 if ( $x->oldid != 0 ) $o = "oldid=".$x->oldid ;
1424 if ( $x->islog ) $link = $x->timestamp ;
1425 else $link = $this->makeKnownLink( $x->secureName, $x->timestamp , $o ) ;
1426 $link = "<tt>{$link}</tt>" ;
1427
1428
1429 $r .= $link ;
1430 $r .= " (" ;
1431 $r .= $x->curlink ;
1432 $r .= "; " ;
1433 $r .= $x->lastlink ;
1434 $r .= ") . . ".$x->userlink ;
1435 $r .= $x->usertalklink ;
1436 if ( $x->usercomment != "" )
1437 $r .= " <em>(".wfEscapeHTML($x->usercomment).")</em>" ;
1438 $r .= "<br>\n" ;
1439 }
1440 $r .= "</div>\n" ;
1441
1442 $this->rccc++ ;
1443 return $r ;
1444 }
1445
1446 function recentChangesBlock ()
1447 {
1448 global $wgUploadPath ;
1449 if ( count ( $this->rc_cache ) == 0 ) return "" ;
1450 $k = array_keys ( $this->rc_cache ) ;
1451 foreach ( $k AS $x )
1452 {
1453 $y = $this->rc_cache[$x] ;
1454 if ( count ( $y ) < 2 ) {
1455 $r .= $this->recentChangesBlockLine ( array_shift ( $y ) ) ;
1456 } else {
1457 $r .= $this->recentChangesBlockGroup ( $y ) ;
1458 }
1459 }
1460
1461 return "<div align=left>{$r}</div>" ;
1462 }
1463
1464 function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1465 {
1466 global $wgUser ;
1467 $usenew = $wgUser->getOption( "usenewrc" );
1468 if ( $usenew )
1469 $r = $this->recentChangesLineNew ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1470 else
1471 $r = $this->recentChangesLineOld ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1472 return $r ;
1473 }
1474
1475 function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 )
1476 {
1477 global $wgTitle, $wgLang, $wgUser;
1478
1479 $d = $wgLang->date( $ts, true);
1480 $s = "";
1481 if ( $d != $this->lastdate ) {
1482 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
1483 $s .= "<h4>{$d}</h4>\n<ul>";
1484 $this->lastdate = $d;
1485 }
1486 $h = $wgLang->time( $ts, true );
1487 $t = Title::makeName( $ns, $ttl );
1488 $clink = $this->makeKnownLink( $t , "" );
1489 $nt = Title::newFromText( $t );
1490
1491 if ( $watched ) {
1492 $clink = "<strong>{$clink}</strong>";
1493 }
1494 $hlink = $this->makeKnownLink( $t, wfMsg( "hist" ), "action=history" );
1495 if ( $isnew || $nt->isLog() ) {
1496 $dlink = wfMsg( "diff" );
1497 } else {
1498 $dlink = $this->makeKnownLink( $t, wfMsg( "diff" ),
1499 "diff={$oldid}&oldid={$diffid}" ); # Finagle's law
1500 }
1501 if ( 0 == $u ) {
1502 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1503 $ut, "target=" . $ut );
1504 } else { $ul = $this->makeLink( $wgLang->getNsText(
1505 Namespace::getUser() ) . ":{$ut}", $ut ); }
1506
1507 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1508 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1509 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1510 $cr = wfMsg( "currentrev" );
1511
1512 $s .= "<li> ({$dlink}) ({$hlink}) . .";
1513 $M = wfMsg( "minoreditletter" );
1514 $N = wfMsg( "newpageletter" );
1515 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1516 if ( $isnew ) { $s .= "<strong>{$N}</strong>"; }
1517 $s .= " {$clink}; {$h} . . {$ul}";
1518
1519 $blink="";
1520 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1521 $blink = $this->makeKnownLink( $wgLang->specialPage(
1522 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1523
1524 }
1525 if(!$blink) {
1526 $utl = "({$utl})";
1527 } else {
1528 $utl = "({$utl} | {$blink})";
1529 }
1530 $s.=" {$utl}";
1531
1532 if ( "" != $c && "*" != $c ) {
1533 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1534 }
1535 $s .= "</li>\n";
1536
1537 return $s;
1538 }
1539
1540 function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1541 {
1542 global $wgTitle, $wgLang, $wgUser;
1543
1544 $rc = new RecentChangesClass ;
1545
1546 $d = $wgLang->date( $ts, true);
1547 $s = "";
1548 $ret = "" ;
1549 if ( $d != $this->lastdate ) {
1550 $ret = $this->recentChangesBlock () ;
1551 $this->rc_cache = array() ;
1552 $ret .= "<h4>{$d}</h4>\n";
1553 $this->lastdate = $d;
1554 }
1555 $h = $wgLang->time( $ts, true );
1556 $t = Title::makeName( $ns, $ttl );
1557 $clink = $this->makeKnownLink( $t, "" ) ;
1558 if ( $oldid == 0 ) $c2link = $clink ;
1559 else $c2link = $this->makeKnownLink( $t, "" , "oldid={$oldid}" );
1560 $nt = Title::newFromText( $t );
1561
1562 $rc->timestamp = $h ;
1563 $rc->oldid = $oldid ;
1564 $rc->diffid = $diffid ;
1565 $rc->watched = $watched ;
1566 $rc->isnew = $isnew ;
1567 $rc->isminor = $isminor ;
1568 $rc->secureName = $t ;
1569 $rc->displayName = $nt ;
1570 $rc->link = $clink ;
1571 $rc->usercomment = $c ;
1572 $rc->islog = $nt->isLog() ;
1573
1574 if ( ( $isnew && $oldid == 0 ) || $nt->isLog() ) {
1575 $dlink = wfMsg( "cur" );
1576 } else {
1577 $dlink = $this->makeKnownLink( $t, wfMsg( "cur" ),
1578 "diff=0&oldid={$oldid}" );
1579 }
1580
1581 if ( $diffid == 0 || $nt->isLog() ) {
1582 $plink = wfMsg( "last" );
1583 } else {
1584 $plink = $this->makeKnownLink( $t, wfMsg( "last" ),
1585 "diff={$oldid}&oldid={$diffid}" );
1586 }
1587
1588 if ( 0 == $u ) {
1589 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1590 $ut, "target=" . $ut );
1591 } else { $ul = $this->makeLink( $wgLang->getNsText(
1592 Namespace::getUser() ) . ":{$ut}", $ut ); }
1593
1594 $rc->userlink = $ul ;
1595 $rc->lastlink = $plink ;
1596 $rc->curlink = $dlink ;
1597
1598 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1599 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1600 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1601
1602 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1603 $blink = $this->makeKnownLink( $wgLang->specialPage(
1604 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1605 $rc->usertalklink= " ({$utl} | {$blink})";
1606 } else {
1607 $rc->usertalklink=" ({$utl})";
1608 }
1609
1610 if ( !isset ( $this->rc_cache[$t] ) ) $this->rc_cache[$t] = array() ;
1611 array_push ( $this->rc_cache[$t] , $rc ) ;
1612 return $ret;
1613 }
1614
1615
1616 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
1617 {
1618 global $wgUser, $wgLang, $wgTitle;
1619
1620 $dt = $wgLang->timeanddate( $ts, true );
1621 $del = wfMsg( "deleteimg" );
1622 $cur = wfMsg( "cur" );
1623
1624 if ( $iscur ) {
1625 $url = wfImageUrl( $img );
1626 $rlink = $cur;
1627 if ( $wgUser->isSysop() ) {
1628 $link = wfLocalUrlE( "", "image=" . $wgTitle->getURL() .
1629 "&action=delete" );
1630 $style = $this->getInternalLinkAttributes( $link, $del );
1631
1632 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
1633 } else {
1634 $dlink = $del;
1635 }
1636 } else {
1637 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
1638 if( $wgUser->getID() != 0 ) {
1639 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1640 wfMsg( "revertimg" ), "action=revert&oldimage=" .
1641 urlencode( $img ) );
1642 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1643 $del, "action=delete&oldimage=" . urlencode( $img ) );
1644 } else {
1645 # Having live active links for non-logged in users
1646 # means that bots and spiders crawling our site can
1647 # inadvertently change content. Baaaad idea.
1648 $rlink = wfMsg( "revertimg" );
1649 $dlink = $del;
1650 }
1651 }
1652 if ( 0 == $u ) { $ul = $ut; }
1653 else { $ul = $this->makeLink( $wgLang->getNsText(
1654 Namespace::getUser() ) . ":{$ut}", $ut ); }
1655
1656 $nb = str_replace( "$1", $size, wfMsg( "nbytes" ) );
1657 $style = $this->getInternalLinkAttributes( $url, $dt );
1658
1659 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
1660 . " . . {$ul} ({$nb})";
1661
1662 if ( "" != $c && "*" != $c ) {
1663 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1664 }
1665 $s .= "</li>\n";
1666 return $s;
1667 }
1668 }
1669
1670 include_once( "SkinStandard.php" );
1671 include_once( "SkinNostalgia.php" );
1672 include_once( "SkinCologneBlue.php" );
1673
1674 ?>