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