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