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