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