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