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