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