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