7b53b6ee3ef4c4649c2e0f802438c6c6ae1c3ec6
[lhc/web/wiklou.git] / includes / Skin.php
1 <?php
2
3 require_once( "Feed.php" );
4 require_once( "Image.php" );
5
6 # See skin.doc
7
8 # These are the INTERNAL names, which get mapped
9 # directly to class names. For display purposes, the
10 # Language class has internationalized names
11 #
12 /* private */ $wgValidSkinNames = array(
13 'standard' => "Standard",
14 'nostalgia' => "Nostalgia",
15 'cologneblue' => "CologneBlue"
16 );
17 if( $wgUsePHPTal ) {
18 #$wgValidSkinNames[] = "PHPTal";
19 #$wgValidSkinNames['davinci'] = "DaVinci";
20 #$wgValidSkinNames['mono'] = "Mono";
21 $wgValidSkinNames['monobook'] = "MonoBook";
22 #$wgValidSkinNames['monobookminimal'] = "MonoBookMinimal";
23 }
24
25 require_once( "RecentChange.php" );
26
27 class RCCacheEntry extends RecentChange
28 {
29 var $secureName, $link;
30 var $curlink , $lastlink , $usertalklink , $versionlink ;
31 var $userlink, $timestamp, $watched;
32
33 function newFromParent( $rc )
34 {
35 $rc2 = new RCCacheEntry;
36 $rc2->mAttribs = $rc->mAttribs;
37 $rc2->mExtra = $rc->mExtra;
38 return $rc2;
39 }
40 } ;
41
42 class Skin {
43
44 /* private */ var $lastdate, $lastline;
45 var $linktrail ; # linktrail regexp
46 var $rc_cache ; # Cache for Enhanced Recent Changes
47 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
48 var $rcMoveIndex;
49
50 function Skin()
51 {
52 $this->linktrail = wfMsg("linktrail");
53 }
54
55 function getSkinNames()
56 {
57 global $wgValidSkinNames;
58 return $wgValidSkinNames;
59 }
60
61 function getStylesheet()
62 {
63 return "wikistandard.css";
64 }
65
66 function qbSetting()
67 {
68 global $wgOut, $wgUser;
69
70 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
71 $q = $wgUser->getOption( "quickbar" );
72 if ( "" == $q ) { $q = 0; }
73 return $q;
74 }
75
76 function initPage( &$out )
77 {
78 $fname = "Skin::initPage";
79 wfProfileIn( $fname );
80
81 $out->addLink( array( "rel" => "shortcut icon", "href" => "/favicon.ico" ) );
82
83 $this->addMetadataLinks($out);
84
85 wfProfileOut( $fname );
86 }
87
88 function addMetadataLinks( &$out ) {
89 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
90 global $wgRightsPage, $wgRightsUrl;
91
92 if( $out->isArticleRelated() ) {
93 # note: buggy CC software only reads first "meta" link
94 if( $wgEnableCreativeCommonsRdf ) {
95 $out->addMetadataLink( array(
96 'title' => 'Creative Commons',
97 'type' => 'application/rdf+xml',
98 'href' => $wgTitle->getLocalURL( "action=creativecommons") ) );
99 }
100 if( $wgEnableDublinCoreRdf ) {
101 $out->addMetadataLink( array(
102 'title' => 'Dublin Core',
103 'type' => 'application/rdf+xml',
104 'href' => $wgTitle->getLocalURL( "action=dublincore" ) ) );
105 }
106 }
107 $copyright = "";
108 if( $wgRightsPage ) {
109 $copy = Title::newFromText( $wgRightsPage );
110 if( $copy ) {
111 $copyright = $copy->getLocalURL();
112 }
113 }
114 if( !$copyright && $wgRightsUrl ) {
115 $copyright = $wgRightsUrl;
116 }
117 if( $copyright ) {
118 $out->addLink( array(
119 "rel" => "copyright",
120 "href" => $copyright ) );
121 }
122 }
123
124 function outputPage( &$out ) {
125 global $wgDebugComments;
126
127 wfProfileIn( "Skin::outputPage" );
128 $this->initPage( $out );
129 $out->out( $out->headElement() );
130
131 $out->out( "\n<body" );
132 $ops = $this->getBodyOptions();
133 foreach ( $ops as $name => $val ) {
134 $out->out( " $name='$val'" );
135 }
136 $out->out( ">\n" );
137 if ( $wgDebugComments ) {
138 $out->out( "<!-- Wiki debugging output:\n" .
139 $out->mDebugtext . "-->\n" );
140 }
141 $out->out( $this->beforeContent() );
142
143 $out->out( $out->mBodytext . "\n" );
144
145 $out->out( $this->afterContent() );
146
147 wfProfileClose();
148 $out->out( $out->reportTime() );
149
150 $out->out( "\n</body></html>" );
151 }
152
153 function getHeadScripts() {
154 global $wgStylePath;
155 $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/wikibits.js\"></script>\n";
156 return $r;
157 }
158
159 function getUserStyles()
160 {
161 global $wgOut, $wgStylePath;
162 $sheet = $this->getStylesheet();
163 $s = "<style type='text/css'>\n";
164 $s .= "/*/*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
165 $s .= "@import url(\"$wgStylePath/$sheet\");\n";
166 $s .= $this->doGetUserStyles();
167 $s .= "/* */\n";
168 $s .= "</style>\n";
169 return $s;
170 }
171
172 function doGetUserStyles()
173 {
174 global $wgUser;
175
176 $s = "";
177 if ( 1 == $wgUser->getOption( "underline" ) ) {
178 # Don't override browser settings
179 } else {
180 # CHECK MERGE @@@
181 # Force no underline
182 $s .= "a { " .
183 "text-decoration: none; }\n";
184 }
185 if ( 1 == $wgUser->getOption( "highlightbroken" ) ) {
186 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
187 }
188 if ( 1 == $wgUser->getOption( "justify" ) ) {
189 $s .= "#article { text-align: justify; }\n";
190 }
191 return $s;
192 }
193
194 function getBodyOptions()
195 {
196 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
197
198 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
199
200 if ( 0 != $wgTitle->getNamespace() ) {
201 $a = array( "bgcolor" => "#ffffec" );
202 }
203 else $a = array( "bgcolor" => "#FFFFFF" );
204 if($wgOut->isArticle() && $wgUser->getOption("editondblclick") &&
205 (!$wgTitle->isProtected() || $wgUser->isSysop()) ) {
206 $t = wfMsg( "editthispage" );
207 $oid = $red = "";
208 if ( !empty($redirect) ) {
209 $red = "&redirect={$redirect}";
210 }
211 if ( !empty($oldid) && ! isset( $diff ) ) {
212 $oid = "&oldid={$oldid}";
213 }
214 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
215 $s = "document.location = \"" .$s ."\";";
216 $a += array ("ondblclick" => $s);
217
218 }
219 $a['onload'] = $wgOut->getOnloadHandler();
220 return $a;
221 }
222
223 function getExternalLinkAttributes( $link, $text )
224 {
225 global $wgUser, $wgOut, $wgLang;
226
227 $link = urldecode( $link );
228 $link = $wgLang->checkTitleEncoding( $link );
229 $link = str_replace( "_", " ", $link );
230 $link = wfEscapeHTML( $link );
231
232 $r = " class='external'";
233
234 if ( 1 == $wgUser->getOption( "hover" ) ) {
235 $r .= " title=\"{$link}\"";
236 }
237 return $r;
238 }
239
240 function getInternalLinkAttributes( $link, $text, $broken = false )
241 {
242 global $wgUser, $wgOut;
243
244 $link = urldecode( $link );
245 $link = str_replace( "_", " ", $link );
246 $link = wfEscapeHTML( $link );
247
248 if ( $broken == "stub" ) {
249 $r = " class='stub'";
250 } else if ( $broken == "yes" ) {
251 $r = " class='new'";
252 } else {
253 $r = "";
254 }
255
256 if ( 1 == $wgUser->getOption( "hover" ) ) {
257 $r .= " title=\"{$link}\"";
258 }
259 return $r;
260 }
261
262 function getInternalLinkAttributesObj( &$nt, $text, $broken = false )
263 {
264 global $wgUser, $wgOut;
265
266 if ( $broken == "stub" ) {
267 $r = " class='stub'";
268 } else if ( $broken == "yes" ) {
269 $r = " class='new'";
270 } else {
271 $r = "";
272 }
273
274 if ( 1 == $wgUser->getOption( "hover" ) ) {
275 $r .= ' title ="' . $nt->getEscapedText() . '"';
276 }
277 return $r;
278 }
279
280 function getLogo()
281 {
282 global $wgLogo;
283 return $wgLogo;
284 }
285
286 # This will be called immediately after the <body> tag. Split into
287 # two functions to make it easier to subclass.
288 #
289 function beforeContent()
290 {
291 global $wgUser, $wgOut, $wgSiteNotice;
292
293 if( $wgSiteNotice ) {
294 $note = "\n<div id='notice' style='font-weight: bold; color: red; text-align: center'>$wgSiteNotice</div>\n";
295 } else {
296 $note = "";
297 }
298 return $this->doBeforeContent() . $note;
299 }
300
301 function doBeforeContent()
302 {
303 global $wgUser, $wgOut, $wgTitle, $wgLang;
304 $fname = "Skin::doBeforeContent";
305 wfProfileIn( $fname );
306
307 $s = "";
308 $qb = $this->qbSetting();
309
310 if( $langlinks = $this->otherLanguages() ) {
311 $rows = 2;
312 $borderhack = "";
313 } else {
314 $rows = 1;
315 $langlinks = false;
316 $borderhack = "class='top'";
317 }
318
319 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
320 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
321
322 $shove = ($qb != 0);
323 $left = ($qb == 1 || $qb == 3);
324 if($wgLang->isRTL()) $left = !$left;
325
326 if ( !$shove ) {
327 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
328 $this->logoText() . "</td>";
329 } elseif( $left ) {
330 $s .= $this->getQuickbarCompensator( $rows );
331 }
332 $l = $wgLang->isRTL() ? "right" : "left";
333 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
334
335 $s .= $this->topLinks() ;
336 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
337
338 $r = $wgLang->isRTL() ? "left" : "right";
339 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
340 $s .= $this->nameAndLogin();
341 $s .= "\n<br />" . $this->searchForm() . "</td>";
342
343 if ( $langlinks ) {
344 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
345 }
346
347 if ( $shove && !$left ) { # Right
348 $s .= $this->getQuickbarCompensator( $rows );
349 }
350 $s .= "</tr>\n</table>\n</div>\n";
351 $s .= "\n<div id='article'>\n";
352
353 $s .= $this->pageTitle();
354 $s .= $this->pageSubtitle() ;
355 $s .= $this->getCategories();
356 wfProfileOut( $fname );
357 return $s;
358 }
359
360 function getCategories () {
361 global $wgOut, $wgTitle, $wgUser, $wgParser;
362 global $wgUseCategoryMagic;
363 if( !$wgUseCategoryMagic ) return "" ;
364 if( count( $wgOut->mCategoryLinks ) == 0 ) return "";
365 if( !$wgOut->isArticle() ) return "";
366
367 $t = implode ( " | " , $wgOut->mCategoryLinks ) ;
368 $s = $this->makeKnownLink( "Special:Categories",
369 wfMsg( "categories" ), "article=" . urlencode( $wgTitle->getPrefixedDBkey() ) )
370 . ": " . $t;
371 return "<p class='catlinks'>$s</p>";
372 }
373
374 function getQuickbarCompensator( $rows = 1 )
375 {
376 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
377 }
378
379 # This gets called immediately before the </body> tag.
380 #
381 function afterContent()
382 {
383 global $wgUser, $wgOut, $wgServer;
384 global $wgTitle, $wgLang;
385
386 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
387 return $printfooter . $this->doAfterContent();
388 }
389
390 function printFooter() {
391 global $wgTitle;
392 $url = htmlspecialchars( $wgTitle->getFullURL() );
393 return "<p>" . wfMsg( "retrievedfrom", "<a href=\"$url\">$url</a>" ) .
394 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
395 }
396
397 function doAfterContent()
398 {
399 global $wgUser, $wgOut, $wgLang;
400 $fname = "Skin::doAfterContent";
401 wfProfileIn( $fname );
402 wfProfileIn( "$fname-1" );
403
404 $s = "\n</div><br clear='all' />\n";
405 $s .= "\n<div id='footer'>";
406 $s .= "<table border='0' cellspacing='0'><tr>";
407
408 wfProfileOut( "$fname-1" );
409 wfProfileIn( "$fname-2" );
410
411 $qb = $this->qbSetting();
412 $shove = ($qb != 0);
413 $left = ($qb == 1 || $qb == 3);
414 if($wgLang->isRTL()) $left = !$left;
415
416 if ( $shove && $left ) { # Left
417 $s .= $this->getQuickbarCompensator();
418 }
419 wfProfileOut( "$fname-2" );
420 wfProfileIn( "$fname-3" );
421 $l = $wgLang->isRTL() ? "right" : "left";
422 $s .= "<td class='bottom' align='$l' valign='top'>";
423
424 $s .= $this->bottomLinks();
425 $s .= "\n<br />" . $this->mainPageLink()
426 . " | " . $this->aboutLink()
427 . " | " . $this->specialLink( "recentchanges" )
428 . " | " . $this->searchForm()
429 . "<br /><span id='pagestats'>" . $this->pageStats() . "</span>";
430
431 $s .= "</td>";
432 if ( $shove && !$left ) { # Right
433 $s .= $this->getQuickbarCompensator();
434 }
435 $s .= "</tr></table>\n</div>\n</div>\n";
436
437 wfProfileOut( "$fname-3" );
438 wfProfileIn( "$fname-4" );
439 if ( 0 != $qb ) { $s .= $this->quickBar(); }
440 wfProfileOut( "$fname-4" );
441 wfProfileOut( $fname );
442 return $s;
443 }
444
445 function pageTitleLinks()
446 {
447 global $wgOut, $wgTitle, $wgUser, $wgLang, $wgUseApproval, $wgRequest;
448
449 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
450 $action = $wgRequest->getText( 'action' );
451
452 $s = $this->printableLink();
453 if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ;
454
455 if ( $wgOut->isArticleRelated() ) {
456 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
457 $name = $wgTitle->getDBkey();
458 $link = wfEscapeHTML( Image::wfImageUrl( $name ) );
459 $style = $this->getInternalLinkAttributes( $link, $name );
460 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
461 }
462 # This will show the "Approve" link if $wgUseApproval=true;
463 if ( isset ( $wgUseApproval ) && $wgUseApproval )
464 {
465 $t = $wgTitle->getDBkey();
466 $name = "Approve this article" ;
467 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
468 #wfEscapeHTML( wfImageUrl( $name ) );
469 $style = $this->getExternalLinkAttributes( $link, $name );
470 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
471 }
472 }
473 if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
474 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
475 wfMsg( "currentrev" ) );
476 }
477
478 if ( $wgUser->getNewtalk() ) {
479 # do not show "You have new messages" text when we are viewing our
480 # own talk page
481
482 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
483 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
484 $n =$wgUser->getName();
485 $tl = $this->makeKnownLink( $wgLang->getNsText(
486 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
487 wfMsg("newmessageslink") );
488 $s.=" | <strong>". wfMsg( "newmessages", $tl ) . "</strong>";
489 }
490 }
491 if( $wgUser->isSysop() &&
492 (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
493 ($n = $wgTitle->isDeleted() ) ) {
494 $s .= " | " . wfMsg( "thisisdeleted",
495 $this->makeKnownLink(
496 $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ),
497 wfMsg( "restorelink", $n ) ) );
498 }
499 return $s;
500 }
501
502 function printableLink()
503 {
504 global $wgOut, $wgFeedClasses, $wgRequest;
505
506 $baseurl = $_SERVER['REQUEST_URI'];
507 if( strpos( "?", $baseurl ) == false ) {
508 $baseurl .= "?";
509 } else {
510 $baseurl .= "&";
511 }
512 $baseurl = htmlspecialchars( $baseurl );
513 $printurl = $wgRequest->escapeAppendQuery( "printable=yes" );
514
515 $s = "<a href=\"$printurl\">" . wfMsg( "printableversion" ) . "</a>";
516 if( $wgOut->isSyndicated() ) {
517 foreach( $wgFeedClasses as $format => $class ) {
518 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
519 $s .= " | <a href=\"$feedurl\">{$format}</a>";
520 }
521 }
522 return $s;
523 }
524
525 function pageTitle()
526 {
527 global $wgOut, $wgTitle, $wgUser;
528
529 $s = "<h1 class='pagetitle'>" . htmlspecialchars( $wgOut->getPageTitle() ) . "</h1>";
530 if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
531 return $s;
532 }
533
534 function pageSubtitle()
535 {
536 global $wgOut;
537
538 $sub = $wgOut->getSubtitle();
539 if ( "" == $sub ) {
540 global $wgExtraSubtitle;
541 $sub = wfMsg( "fromwikipedia" ) . $wgExtraSubtitle;
542 }
543 $subpages = $this->subPageSubtitle();
544 $sub .= !empty($subpages)?"</p><p class='subpages'>$subpages":'';
545 $s = "<p class='subtitle'>{$sub}</p>\n";
546 return $s;
547 }
548
549 function subPageSubtitle()
550 {
551 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
552 $subpages = '';
553 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
554 $ptext=$wgTitle->getPrefixedText();
555 if(preg_match("/\//",$ptext)) {
556 $links=explode("/",$ptext);
557 $c=0;
558 $growinglink="";
559 foreach($links as $link) {
560 $c++;
561 if ($c<count($links)) {
562 $growinglink .= $link;
563 $getlink = $this->makeLink( $growinglink, $link );
564 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
565 if ($c>1) {
566 $subpages .= " | ";
567 } else {
568 $subpages .="&lt; ";
569 }
570 $subpages .= $getlink;
571 $growinglink.="/";
572 }
573 }
574 }
575 }
576 return $subpages;
577 }
578
579 function nameAndLogin()
580 {
581 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader, $wgIP;
582
583 $li = $wgLang->specialPage( "Userlogin" );
584 $lo = $wgLang->specialPage( "Userlogout" );
585
586 $s = "";
587 if ( 0 == $wgUser->getID() ) {
588 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) {
589 $n = $wgIP;
590
591 $tl = $this->makeKnownLink( $wgLang->getNsText(
592 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
593 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
594
595 $s .= $n . " (".$tl.")";
596 } else {
597 $s .= wfMsg("notloggedin");
598 }
599
600 $rt = $wgTitle->getPrefixedURL();
601 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
602 $q = "";
603 } else { $q = "returnto={$rt}"; }
604
605 $s .= "\n<br />" . $this->makeKnownLink( $li,
606 wfMsg( "login" ), $q );
607 } else {
608 $n = $wgUser->getName();
609 $rt = $wgTitle->getPrefixedURL();
610 $tl = $this->makeKnownLink( $wgLang->getNsText(
611 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
612 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
613
614 $tl = " ({$tl})";
615
616 $s .= $this->makeKnownLink( $wgLang->getNsText(
617 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br />" .
618 $this->makeKnownLink( $lo, wfMsg( "logout" ),
619 "returnto={$rt}" ) . " | " .
620 $this->specialLink( "preferences" );
621 }
622 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
623 wfMsg( "help" ) );
624
625 return $s;
626 }
627
628 function getSearchLink() {
629 $searchPage =& Title::makeTitle( NS_SPECIAL, "Search" );
630 return $searchPage->getLocalURL();
631 }
632
633 function escapeSearchLink() {
634 return htmlspecialchars( $this->getSearchLink() );
635 }
636
637 function searchForm()
638 {
639 global $wgRequest;
640 $search = $wgRequest->getText( 'search' );
641
642 $s = "<form name='search' class='inline' method='post' action=\""
643 . $this->escapeSearchLink() . "\">\n"
644 . "<input type='text' name=\"search\" size='19' value=\""
645 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
646 . "<input type='submit' name=\"go\" value=\"" . wfMsg ("go") . "\" />&nbsp;"
647 . "<input type='submit' name=\"fulltext\" value=\"" . wfMsg ("search") . "\" />\n</form>";
648
649 return $s;
650 }
651
652 function topLinks()
653 {
654 global $wgOut;
655 $sep = " |\n";
656
657 $s = $this->mainPageLink() . $sep
658 . $this->specialLink( "recentchanges" );
659
660 if ( $wgOut->isArticleRelated() ) {
661 $s .= $sep . $this->editThisPage()
662 . $sep . $this->historyLink();
663 }
664 # Many people don't like this dropdown box
665 #$s .= $sep . $this->specialPagesList();
666
667 return $s;
668 }
669
670 function bottomLinks()
671 {
672 global $wgOut, $wgUser, $wgTitle;
673 $sep = " |\n";
674
675 $s = "";
676 if ( $wgOut->isArticleRelated() ) {
677 $s .= "<strong>" . $this->editThisPage() . "</strong>";
678 if ( 0 != $wgUser->getID() ) {
679 $s .= $sep . $this->watchThisPage();
680 }
681 $s .= $sep . $this->talkLink()
682 . $sep . $this->historyLink()
683 . $sep . $this->whatLinksHere()
684 . $sep . $this->watchPageLinksLink();
685
686 if ( $wgTitle->getNamespace() == Namespace::getUser()
687 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
688
689 {
690 $id=User::idFromName($wgTitle->getText());
691 $ip=User::isIP($wgTitle->getText());
692
693 if($id || $ip) { # both anons and non-anons have contri list
694 $s .= $sep . $this->userContribsLink();
695 }
696 if ( 0 != $wgUser->getID() ) { # show only to signed in users
697 if($id) { # can only email non-anons
698 $s .= $sep . $this->emailUserLink();
699 }
700 }
701 }
702 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
703 $s .= "\n<br />" . $this->deleteThisPage() .
704 $sep . $this->protectThisPage() .
705 $sep . $this->moveThisPage();
706 }
707 $s .= "<br />\n" . $this->otherLanguages();
708 }
709 return $s;
710 }
711
712 function pageStats()
713 {
714 global $wgOut, $wgLang, $wgArticle, $wgRequest;
715 global $wgDisableCounters;
716
717 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
718 if ( ! $wgOut->isArticle() ) { return ""; }
719 if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
720 if ( 0 == $wgArticle->getID() ) { return ""; }
721
722 $s = "";
723 if ( !$wgDisableCounters ) {
724 $count = $wgLang->formatNum( $wgArticle->getCount() );
725 if ( $count ) {
726 $s = wfMsg( "viewcount", $count );
727 }
728 }
729
730 $s .= " " . $this->getCredits();
731
732 return $s . " " . $this->getCopyright();
733 }
734
735 function getCredits() {
736 global $wgMaxCredits;
737
738 $s = '';
739
740 if (!isset($wgMaxCredits) || $wgMaxCredits == 0) {
741 $s = $this->lastModified();
742 } else {
743 $s = $this->getAuthorCredits();
744 if ($wgMaxCredits > 1) {
745 $s .= " " . $this->getContributorCredits();
746 }
747 }
748
749 return $s;
750 }
751
752 function getAuthorCredits() {
753 global $wgLang, $wgArticle;
754
755 $last_author = $wgArticle->getUser();
756
757 if ($last_author == 0) {
758 $author_credit = wfMsg("anonymous");
759 } else {
760 $real_name = User::whoIsReal($last_author);
761 if (!empty($real_name)) {
762 $author_credit = $real_name;
763 } else {
764 $author_credit = wfMsg("siteuser", User::whoIs($last_author));
765 }
766 }
767
768 $timestamp = $wgArticle->getTimestamp();
769 if ( $timestamp ) {
770 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
771 } else {
772 $d = "";
773 }
774 return wfMsg("lastmodifiedby", $d, $author_credit);
775 }
776
777 function getContributorCredits() {
778
779 global $wgArticle, $wgMaxCredits, $wgLang;
780
781 # don't count last editor
782
783 $contributors = $wgArticle->getContributors($wgMaxCredits - 1);
784
785 $real_names = array();
786 $user_names = array();
787
788 # Sift for real versus user names
789
790 foreach ($contributors as $user_id => $user_parts) {
791 if ($user_id != 0) {
792 if (!empty($user_parts[1])) {
793 $real_names[$user_id] = $user_parts[1];
794 } else {
795 $user_names[$user_id] = $user_parts[0];
796 }
797 }
798 }
799
800 $real = $wgLang->listToText(array_values($real_names));
801 $user = $wgLang->listToText(array_values($user_names));
802
803 if (!empty($user)) {
804 $user = wfMsg("siteusers", $user);
805 }
806
807 if ($contributors[0] && $contributors[0][0] > 0) {
808 $anon = wfMsg("anonymous");
809 } else {
810 $anon = '';
811 }
812
813 $creds = $wgLang->listToText(array($real, $user, $anon));
814
815 return wfMsg("othercontribs", $creds);
816 }
817
818 function getCopyright() {
819 global $wgRightsPage, $wgRightsUrl, $wgRightsText;
820 $out = "";
821 if( $wgRightsPage ) {
822 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
823 } elseif( $wgRightsUrl ) {
824 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
825 } else {
826 # Give up now
827 return $out;
828 }
829 $out .= wfMsg( "copyright", $link );
830 return $out;
831 }
832
833 function getCopyrightIcon() {
834 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
835 $out = "";
836 if( $wgRightsIcon ) {
837 $icon = htmlspecialchars( $wgRightsIcon );
838 if( $wgRightsUrl ) {
839 $url = htmlspecialchars( $wgRightsUrl );
840 $out .= "<a href=\"$url\">";
841 }
842 $text = htmlspecialchars( $wgRightsText );
843 $out .= "<img src=\"$icon\" alt='$text' />";
844 if( $wgRightsUrl ) {
845 $out .= "</a>";
846 }
847 }
848 return $out;
849 }
850
851 function getPoweredBy() {
852 global $wgStylePath;
853 $url = htmlspecialchars( "$wgStylePath/images/poweredby_mediawiki_88x31.png" );
854 $img = "<a href='http://www.mediawiki.org/'><img src='$url' alt='MediaWiki' /></a>";
855 return $img;
856 }
857
858 function lastModified()
859 {
860 global $wgLang, $wgArticle;
861
862 $timestamp = $wgArticle->getTimestamp();
863 if ( $timestamp ) {
864 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
865 $s = " " . wfMsg( "lastmodified", $d );
866 } else {
867 $s = "";
868 }
869 return $s;
870 }
871
872 function logoText( $align = "" )
873 {
874 if ( "" != $align ) { $a = " align='{$align}'"; }
875 else { $a = ""; }
876
877 $mp = wfMsg( "mainpage" );
878 $titleObj = Title::newFromText( $mp );
879 $s = "<a href=\"" . $titleObj->escapeLocalURL()
880 . "\"><img{$a} src=\""
881 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\" /></a>";
882 return $s;
883 }
884
885 function quickBar()
886 {
887 global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgLang;
888 global $wgDisableUploads, $wgRemoteUploads;
889
890 $fname = "Skin::quickBar";
891 wfProfileIn( $fname );
892
893 $action = $wgRequest->getText( 'action' );
894 $wpPreview = $wgRequest->getBool( 'wpPreview' );
895 $tns=$wgTitle->getNamespace();
896
897 $s = "\n<div id='quickbar'>";
898 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
899
900 $sep = "\n<br />";
901 $s .= $this->mainPageLink()
902 . $sep . $this->specialLink( "recentchanges" )
903 . $sep . $this->specialLink( "randompage" );
904 if ($wgUser->getID()) {
905 $s.= $sep . $this->specialLink( "watchlist" ) ;
906 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
907 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
908
909 }
910 // only show watchlist link if logged in
911 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
912 $s .= "\n<br /><hr class='sep' />";
913 $articleExists = $wgTitle->getArticleId();
914 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
915 if($wgOut->isArticle()) {
916 $s .= "<strong>" . $this->editThisPage() . "</strong>";
917 } else { # backlink to the article in edit or history mode
918 if($articleExists){ # no backlink if no article
919 switch($tns) {
920 case 0:
921 $text = wfMsg("articlepage");
922 break;
923 case 1:
924 $text = wfMsg("viewtalkpage");
925 break;
926 case 2:
927 $text = wfMsg("userpage");
928 break;
929 case 3:
930 $text = wfMsg("viewtalkpage");
931 break;
932 case 4:
933 $text = wfMsg("wikipediapage");
934 break;
935 case 5:
936 $text = wfMsg("viewtalkpage");
937 break;
938 case 6:
939 $text = wfMsg("imagepage");
940 break;
941 case 7:
942 $text = wfMsg("viewtalkpage");
943 break;
944 default:
945 $text= wfMsg("articlepage");
946 }
947
948 $link = $wgTitle->getText();
949 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
950 $link = $nstext . ":" . $link ;
951 }
952
953 $s .= $this->makeLink( $link, $text );
954 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
955 # we just throw in a "New page" text to tell the user that he's in edit mode,
956 # and to avoid messing with the separator that is prepended to the next item
957 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
958 }
959
960 }
961
962
963 if( $tns%2 && $action!="edit" && !$wpPreview) {
964 $s.="<br />".$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("postcomment"),"action=edit&section=new");
965 }
966
967 /*
968 watching could cause problems in edit mode:
969 if user edits article, then loads "watch this article" in background and then saves
970 article with "Watch this article" checkbox disabled, the article is transparently
971 unwatched. Therefore we do not show the "Watch this page" link in edit mode
972 */
973 if ( 0 != $wgUser->getID() && $articleExists) {
974 if($action!="edit" && $action != "submit" )
975 {
976 $s .= $sep . $this->watchThisPage();
977 }
978 if ( $wgTitle->userCanEdit() )
979 $s .= $sep . $this->moveThisPage();
980 }
981 if ( $wgUser->isSysop() and $articleExists ) {
982 $s .= $sep . $this->deleteThisPage() .
983 $sep . $this->protectThisPage();
984 }
985 $s .= $sep . $this->talkLink();
986 if ($articleExists && $action !="history") {
987 $s .= $sep . $this->historyLink();
988 }
989 $s.=$sep . $this->whatLinksHere();
990
991 if($wgOut->isArticleRelated()) {
992 $s .= $sep . $this->watchPageLinksLink();
993 }
994
995 if ( Namespace::getUser() == $wgTitle->getNamespace()
996 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
997 ) {
998
999 $id=User::idFromName($wgTitle->getText());
1000 $ip=User::isIP($wgTitle->getText());
1001
1002 if($id||$ip) {
1003 $s .= $sep . $this->userContribsLink();
1004 }
1005 if ( 0 != $wgUser->getID() ) {
1006 if($id) { # can only email real users
1007 $s .= $sep . $this->emailUserLink();
1008 }
1009 }
1010 }
1011 $s .= "\n<br /><hr class='sep' />";
1012 }
1013
1014 if ( 0 != $wgUser->getID() && ( !$wgDisableUploads || $wgRemoteUploads ) ) {
1015 $s .= $this->specialLink( "upload" ) . $sep;
1016 }
1017 $s .= $this->specialLink( "specialpages" )
1018 . $sep . $this->bugReportsLink();
1019
1020 global $wgSiteSupportPage;
1021 if( $wgSiteSupportPage ) {
1022 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
1023 "\" class=\"internal\">" . wfMsg( "sitesupport" ) . "</a>";
1024 }
1025
1026 $s .= "\n<br /></div>\n";
1027 wfProfileOut( $fname );
1028 return $s;
1029 }
1030
1031 function specialPagesList()
1032 {
1033 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
1034 $a = array();
1035
1036 $validSP = $wgLang->getValidSpecialPages();
1037
1038 foreach ( $validSP as $name => $desc ) {
1039 if ( "" == $desc ) { continue; }
1040 $a[$name] = $desc;
1041 }
1042 if ( $wgUser->isSysop() )
1043 {
1044 $sysopSP = $wgLang->getSysopSpecialPages();
1045
1046 foreach ( $sysopSP as $name => $desc ) {
1047 if ( "" == $desc ) { continue; }
1048 $a[$name] = $desc ;
1049 }
1050 }
1051 if ( $wgUser->isDeveloper() )
1052 {
1053 $devSP = $wgLang->getDeveloperSpecialPages();
1054
1055 foreach ( $devSP as $name => $desc ) {
1056 if ( "" == $desc ) { continue; }
1057 $a[$name] = $desc ;
1058 }
1059 }
1060 $go = wfMsg( "go" );
1061 $sp = wfMsg( "specialpages" );
1062 $spp = $wgLang->specialPage( "Specialpages" );
1063
1064 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
1065 "action=\"" . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1066 $s .= "<select name=\"wpDropdown\">\n";
1067 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1068
1069 foreach ( $a as $name => $desc ) {
1070 $p = $wgLang->specialPage( $name );
1071 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1072 }
1073 $s .= "</select>\n";
1074 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1075 $s .= "</form>\n";
1076 return $s;
1077 }
1078
1079 function mainPageLink()
1080 {
1081 $mp = wfMsg( "mainpage" );
1082 $s = $this->makeKnownLink( $mp, $mp );
1083 return $s;
1084 }
1085
1086 function copyrightLink()
1087 {
1088 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
1089 wfMsg( "copyrightpagename" ) );
1090 return $s;
1091 }
1092
1093 function aboutLink()
1094 {
1095 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
1096 wfMsg( "aboutwikipedia" ) );
1097 return $s;
1098 }
1099
1100
1101 function disclaimerLink()
1102 {
1103 $s = $this->makeKnownLink( wfMsg( "disclaimerpage" ),
1104 wfMsg( "disclaimers" ) );
1105 return $s;
1106 }
1107
1108 function editThisPage()
1109 {
1110 global $wgOut, $wgTitle, $wgRequest;
1111
1112 $oldid = $wgRequest->getVal( 'oldid' );
1113 $diff = $wgRequest->getVal( 'diff' );
1114 $redirect = $wgRequest->getVal( 'redirect' );
1115
1116 if ( ! $wgOut->isArticleRelated() ) {
1117 $s = wfMsg( "protectedpage" );
1118 } else {
1119 $n = $wgTitle->getPrefixedText();
1120 if ( $wgTitle->userCanEdit() ) {
1121 $t = wfMsg( "editthispage" );
1122 } else {
1123 #$t = wfMsg( "protectedpage" );
1124 $t = wfMsg( "viewsource" );
1125 }
1126 $oid = $red = "";
1127
1128 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1129 if ( $oldid && ! isset( $diff ) ) {
1130 $oid = "&oldid={$oldid}";
1131 }
1132 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
1133 }
1134 return $s;
1135 }
1136
1137 function deleteThisPage()
1138 {
1139 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1140
1141 $diff = $wgRequest->getVal( 'diff' );
1142 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1143 $n = $wgTitle->getPrefixedText();
1144 $t = wfMsg( "deletethispage" );
1145
1146 $s = $this->makeKnownLink( $n, $t, "action=delete" );
1147 } else {
1148 $s = "";
1149 }
1150 return $s;
1151 }
1152
1153 function protectThisPage()
1154 {
1155 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1156
1157 $diff = $wgRequest->getVal( 'diff' );
1158 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1159 $n = $wgTitle->getPrefixedText();
1160
1161 if ( $wgTitle->isProtected() ) {
1162 $t = wfMsg( "unprotectthispage" );
1163 $q = "action=unprotect";
1164 } else {
1165 $t = wfMsg( "protectthispage" );
1166 $q = "action=protect";
1167 }
1168 $s = $this->makeKnownLink( $n, $t, $q );
1169 } else {
1170 $s = "";
1171 }
1172 return $s;
1173 }
1174
1175 function watchThisPage()
1176 {
1177 global $wgUser, $wgOut, $wgTitle;
1178
1179 if ( $wgOut->isArticleRelated() ) {
1180 $n = $wgTitle->getPrefixedText();
1181
1182 if ( $wgTitle->userIsWatching() ) {
1183 $t = wfMsg( "unwatchthispage" );
1184 $q = "action=unwatch";
1185 } else {
1186 $t = wfMsg( "watchthispage" );
1187 $q = "action=watch";
1188 }
1189 $s = $this->makeKnownLink( $n, $t, $q );
1190 } else {
1191 $s = wfMsg( "notanarticle" );
1192 }
1193 return $s;
1194 }
1195
1196 function moveThisPage()
1197 {
1198 global $wgTitle, $wgLang;
1199
1200 if ( $wgTitle->userCanEdit() ) {
1201 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
1202 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
1203 } // no message if page is protected - would be redundant
1204 return $s;
1205 }
1206
1207 function historyLink()
1208 {
1209 global $wgTitle;
1210
1211 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1212 wfMsg( "history" ), "action=history" );
1213 return $s;
1214 }
1215
1216 function whatLinksHere()
1217 {
1218 global $wgTitle, $wgLang;
1219
1220 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
1221 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
1222 return $s;
1223 }
1224
1225 function userContribsLink()
1226 {
1227 global $wgTitle, $wgLang;
1228
1229 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1230 wfMsg( "contributions" ), "target=" . $wgTitle->getPartialURL() );
1231 return $s;
1232 }
1233
1234 function emailUserLink()
1235 {
1236 global $wgTitle, $wgLang;
1237
1238 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
1239 wfMsg( "emailuser" ), "target=" . $wgTitle->getPartialURL() );
1240 return $s;
1241 }
1242
1243 function watchPageLinksLink()
1244 {
1245 global $wgOut, $wgTitle, $wgLang;
1246
1247 if ( ! $wgOut->isArticleRelated() ) {
1248 $s = "(" . wfMsg( "notanarticle" ) . ")";
1249 } else {
1250 $s = $this->makeKnownLink( $wgLang->specialPage(
1251 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
1252 "target=" . $wgTitle->getPrefixedURL() );
1253 }
1254 return $s;
1255 }
1256
1257 function otherLanguages()
1258 {
1259 global $wgOut, $wgLang, $wgTitle, $wgUseNewInterlanguage;
1260
1261 $a = $wgOut->getLanguageLinks();
1262 if ( 0 == count( $a ) ) {
1263 if ( !$wgUseNewInterlanguage ) return "";
1264 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1265 if ( $ns != 0 AND $ns != 1 ) return "" ;
1266 $pn = "Intl" ;
1267 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
1268 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1269 wfMsg( "intl" ) , $x );
1270 }
1271
1272 if ( !$wgUseNewInterlanguage ) {
1273 $s = wfMsg( "otherlanguages" ) . ": ";
1274 } else {
1275 global $wgLanguageCode ;
1276 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
1277 $x .= "&xl=".$wgLanguageCode ;
1278 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
1279 wfMsg( "otherlanguages" ) , $x ) . ": " ;
1280 }
1281
1282 $s = wfMsg( "otherlanguages" ) . ": ";
1283 $first = true;
1284 if($wgLang->isRTL()) $s .= "<span dir='LTR'>";
1285 foreach( $a as $l ) {
1286 if ( ! $first ) { $s .= " | "; }
1287 $first = false;
1288
1289 $nt = Title::newFromText( $l );
1290 $url = $nt->getFullURL();
1291 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
1292
1293 if ( "" == $text ) { $text = $l; }
1294 $style = $this->getExternalLinkAttributes( $l, $text );
1295 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1296 }
1297 if($wgLang->isRTL()) $s .= "</span>";
1298 return $s;
1299 }
1300
1301 function bugReportsLink()
1302 {
1303 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
1304 wfMsg( "bugreports" ) );
1305 return $s;
1306 }
1307
1308 function dateLink()
1309 {
1310 global $wgLinkCache;
1311 $t1 = Title::newFromText( gmdate( "F j" ) );
1312 $t2 = Title::newFromText( gmdate( "Y" ) );
1313
1314 $wgLinkCache->suspend();
1315 $id = $t1->getArticleID();
1316 $wgLinkCache->resume();
1317
1318 if ( 0 == $id ) {
1319 $s = $this->makeBrokenLink( $t1->getText() );
1320 } else {
1321 $s = $this->makeKnownLink( $t1->getText() );
1322 }
1323 $s .= ", ";
1324
1325 $wgLinkCache->suspend();
1326 $id = $t2->getArticleID();
1327 $wgLinkCache->resume();
1328
1329 if ( 0 == $id ) {
1330 $s .= $this->makeBrokenLink( $t2->getText() );
1331 } else {
1332 $s .= $this->makeKnownLink( $t2->getText() );
1333 }
1334 return $s;
1335 }
1336
1337 function talkLink()
1338 {
1339 global $wgLang, $wgTitle, $wgLinkCache;
1340
1341 $tns = $wgTitle->getNamespace();
1342 if ( -1 == $tns ) { return ""; }
1343
1344 $pn = $wgTitle->getText();
1345 $tp = wfMsg( "talkpage" );
1346 if ( Namespace::isTalk( $tns ) ) {
1347 $lns = Namespace::getSubject( $tns );
1348 switch($tns) {
1349 case 1:
1350 $text = wfMsg("articlepage");
1351 break;
1352 case 3:
1353 $text = wfMsg("userpage");
1354 break;
1355 case 5:
1356 $text = wfMsg("wikipediapage");
1357 break;
1358 case 7:
1359 $text = wfMsg("imagepage");
1360 break;
1361 default:
1362 $text= wfMsg("articlepage");
1363 }
1364 } else {
1365
1366 $lns = Namespace::getTalk( $tns );
1367 $text=$tp;
1368 }
1369 $n = $wgLang->getNsText( $lns );
1370 if ( "" == $n ) { $link = $pn; }
1371 else { $link = "{$n}:{$pn}"; }
1372
1373 $wgLinkCache->suspend();
1374 $s = $this->makeLink( $link, $text );
1375 $wgLinkCache->resume();
1376
1377 return $s;
1378 }
1379
1380 function commentLink()
1381 {
1382 global $wgLang, $wgTitle, $wgLinkCache;
1383
1384 $tns = $wgTitle->getNamespace();
1385 if ( -1 == $tns ) { return ""; }
1386
1387 $lns = ( Namespace::isTalk( $tns ) ) ? $tns : Namespace::getTalk( $tns );
1388
1389 # assert Namespace::isTalk( $lns )
1390
1391 $n = $wgLang->getNsText( $lns );
1392 $pn = $wgTitle->getText();
1393
1394 $link = "{$n}:{$pn}";
1395
1396 $wgLinkCache->suspend();
1397 $s = $this->makeKnownLink($link, wfMsg("postcomment"), "action=edit&section=new");
1398 $wgLinkCache->resume();
1399
1400 return $s;
1401 }
1402
1403 # After all the page content is transformed into HTML, it makes
1404 # a final pass through here for things like table backgrounds.
1405 #
1406 function transformContent( $text )
1407 {
1408 return $text;
1409 }
1410
1411 # Note: This function MUST call getArticleID() on the link,
1412 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1413 #
1414 function makeLink( $title, $text = "", $query = "", $trail = "" ) {
1415 wfProfileIn( "Skin::makeLink" );
1416 $nt = Title::newFromText( $title );
1417 if ($nt) {
1418 $result = $this->makeLinkObj( Title::newFromText( $title ), $text, $query, $trail );
1419 } else {
1420 wfDebug( "Invalid title passed to Skin::makeLink(): \"$title\"\n" );
1421 $result = $text == "" ? $title : $text;
1422 }
1423
1424 wfProfileOut( "Skin::makeLink" );
1425 return $result;
1426 }
1427
1428 function makeKnownLink( $title, $text = "", $query = "", $trail = "", $prefix = '',$aprops = '') {
1429 $nt = Title::newFromText( $title );
1430 if ($nt) {
1431 return $this->makeKnownLinkObj( Title::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
1432 } else {
1433 wfDebug( "Invalid title passed to Skin::makeKnownLink(): \"$title\"\n" );
1434 return $text == "" ? $title : $text;
1435 }
1436 }
1437
1438 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" ) {
1439 $nt = Title::newFromText( $title );
1440 if ($nt) {
1441 return $this->makeBrokenLinkObj( Title::newFromText( $title ), $text, $query, $trail );
1442 } else {
1443 wfDebug( "Invalid title passed to Skin::makeBrokenLink(): \"$title\"\n" );
1444 return $text == "" ? $title : $text;
1445 }
1446 }
1447
1448 function makeStubLink( $title, $text = "", $query = "", $trail = "" ) {
1449 $nt = Title::newFromText( $title );
1450 if ($nt) {
1451 return $this->makeStubLinkObj( Title::newFromText( $title ), $text, $query, $trail );
1452 } else {
1453 wfDebug( "Invalid title passed to Skin::makeStubLink(): \"$title\"\n" );
1454 return $text == "" ? $title : $text;
1455 }
1456 }
1457
1458 # Pass a title object, not a title string
1459 function makeLinkObj( &$nt, $text= "", $query = "", $trail = "", $prefix = "" )
1460 {
1461 global $wgOut, $wgUser;
1462 if ( $nt->isExternal() ) {
1463 $u = $nt->getFullURL();
1464 $link = $nt->getPrefixedURL();
1465 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1466 $style = $this->getExternalLinkAttributes( $link, $text );
1467
1468 $inside = "";
1469 if ( "" != $trail ) {
1470 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1471 $inside = $m[1];
1472 $trail = $m[2];
1473 }
1474 }
1475 $retVal = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1476 } elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1477 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1478 } elseif ( ( -1 == $nt->getNamespace() ) ||
1479 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1480 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1481 } else {
1482 $aid = $nt->getArticleID() ;
1483 if ( 0 == $aid ) {
1484 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
1485 } else {
1486 $threshold = $wgUser->getOption("stubthreshold") ;
1487 if ( $threshold > 0 ) {
1488 $res = wfQuery ( "SELECT LENGTH(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'", DB_READ ) ;
1489
1490 if ( wfNumRows( $res ) > 0 ) {
1491 $s = wfFetchObject( $res );
1492 $size = $s->x;
1493 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 ) {
1494 $size = $threshold*2 ; # Really big
1495 }
1496 wfFreeResult( $res );
1497 } else {
1498 $size = $threshold*2 ; # Really big
1499 }
1500 } else {
1501 $size = 1 ;
1502 }
1503 if ( $size < $threshold ) {
1504 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
1505 } else {
1506 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1507 }
1508 }
1509 }
1510 return $retVal;
1511 }
1512
1513 # Pass a title object, not a title string
1514 function makeKnownLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" , $aprops = '')
1515 {
1516 global $wgOut, $wgTitle;
1517
1518 $fname = "Skin::makeKnownLinkObj";
1519 wfProfileIn( $fname );
1520
1521 $link = $nt->getPrefixedURL();
1522
1523 if ( "" == $link ) {
1524 $u = "";
1525 if ( "" == $text ) {
1526 $text = htmlspecialchars( $nt->getFragment() );
1527 }
1528 } else {
1529 $u = $nt->escapeLocalURL( $query );
1530 }
1531 if ( "" != $nt->getFragment() ) {
1532 $u .= "#" . htmlspecialchars( $nt->getFragment() );
1533 }
1534 if ( "" == $text ) {
1535 $text = htmlspecialchars( $nt->getPrefixedText() );
1536 }
1537 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1538
1539 $inside = "";
1540 if ( "" != $trail ) {
1541 if ( preg_match( $this->linktrail, $trail, $m ) ) {
1542 $inside = $m[1];
1543 $trail = $m[2];
1544 }
1545 }
1546 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
1547 wfProfileOut( $fname );
1548 return $r;
1549 }
1550
1551 # Pass a title object, not a title string
1552 function makeBrokenLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" )
1553 {
1554 global $wgOut, $wgUser;
1555
1556 $fname = "Skin::makeBrokenLinkObj";
1557 wfProfileIn( $fname );
1558
1559 if ( "" == $query ) {
1560 $q = "action=edit";
1561 } else {
1562 $q = "action=edit&{$query}";
1563 }
1564 $u = $nt->escapeLocalURL( $q );
1565
1566 if ( "" == $text ) {
1567 $text = htmlspecialchars( $nt->getPrefixedText() );
1568 }
1569 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1570
1571 $inside = "";
1572 if ( "" != $trail ) {
1573 if ( preg_match( $this->linktrail, $trail, $m ) ) {
1574 $inside = $m[1];
1575 $trail = $m[2];
1576 }
1577 }
1578 if ( $wgUser->getOption( "highlightbroken" ) ) {
1579 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1580 } else {
1581 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1582 }
1583
1584 wfProfileOut( $fname );
1585 return $s;
1586 }
1587
1588 # Pass a title object, not a title string
1589 function makeStubLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" )
1590 {
1591 global $wgOut, $wgUser;
1592
1593 $link = $nt->getPrefixedURL();
1594
1595 $u = $nt->escapeLocalURL( $query );
1596
1597 if ( "" == $text ) {
1598 $text = htmlspecialchars( $nt->getPrefixedText() );
1599 }
1600 $style = $this->getInternalLinkAttributesObj( $nt, $text, "stub" );
1601
1602 $inside = "";
1603 if ( "" != $trail ) {
1604 if ( preg_match( $this->linktrail, $trail, $m ) ) {
1605 $inside = $m[1];
1606 $trail = $m[2];
1607 }
1608 }
1609 if ( $wgUser->getOption( "highlightbroken" ) ) {
1610 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1611 } else {
1612 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1613 }
1614 return $s;
1615 }
1616
1617 function makeSelfLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" )
1618 {
1619 $u = $nt->escapeLocalURL( $query );
1620 if ( "" == $text ) {
1621 $text = htmlspecialchars( $nt->getPrefixedText() );
1622 }
1623 $inside = "";
1624 if ( "" != $trail ) {
1625 if ( preg_match( $this->linktrail, $trail, $m ) ) {
1626 $inside = $m[1];
1627 $trail = $m[2];
1628 }
1629 }
1630 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
1631 }
1632
1633 /* these are used extensively in SkinPHPTal, but also some other places */
1634 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1635 $title = Title::makeTitle( NS_SPECIAL, $name );
1636 $this->checkTitle(&$title, &$name);
1637 return $title->getLocalURL( $urlaction );
1638 }
1639 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1640 $title = Title::newFromText( $name );
1641 $title = $title->getTalkPage();
1642 $this->checkTitle(&$title, &$name);
1643 return $title->getLocalURL( $urlaction );
1644 }
1645 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1646 $title = Title::newFromText( $name );
1647 $title= $title->getSubjectPage();
1648 $this->checkTitle(&$title, &$name);
1649 return $title->getLocalURL( $urlaction );
1650 }
1651 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1652 $title = Title::newFromText( wfMsg($name) );
1653 $this->checkTitle(&$title, &$name);
1654 return $title->getLocalURL( $urlaction );
1655 }
1656 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1657 $title = Title::newFromText( $name );
1658 $this->checkTitle(&$title, &$name);
1659 return $title->getLocalURL( $urlaction );
1660 }
1661
1662 # make sure we have some title to operate on, mind the '&'
1663 /*static*/ function &checkTitle ( $title, $name ) {
1664 if(!is_object($title)) {
1665 $title = Title::newFromText( $name );
1666 if(!is_object($title)) {
1667 $title = Title::newFromText( '<error: link target missing>' );
1668 }
1669 }
1670 }
1671
1672 function fnamePart( $url )
1673 {
1674 $basename = strrchr( $url, "/" );
1675 if ( false === $basename ) { $basename = $url; }
1676 else { $basename = substr( $basename, 1 ); }
1677 return wfEscapeHTML( $basename );
1678 }
1679
1680 function makeImage( $url, $alt = "" )
1681 {
1682 global $wgOut;
1683
1684 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1685 $s = "<img src=\"{$url}\" alt=\"{$alt}\" />";
1686 return $s;
1687 }
1688
1689 function makeImageLink( $name, $url, $alt = "" ) {
1690 $nt = Title::makeTitle( Namespace::getImage(), $name );
1691 return $this->makeImageLinkObj( $nt, $alt );
1692 }
1693
1694 function makeImageLinkObj( $nt, $alt = "" ) {
1695 global $wgLang, $wgUseImageResize;
1696 $img = Image::newFromTitle( $nt );
1697 $url = $img->getURL();
1698
1699 $align = "";
1700 $prefix = $postfix = "";
1701
1702 if ( $wgUseImageResize ) {
1703 # Check if the alt text is of the form "options|alt text"
1704 # Options are:
1705 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1706 # * left no resizing, just left align. label is used for alt= only
1707 # * right same, but right aligned
1708 # * none same, but not aligned
1709 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1710 # * center center the image
1711 # * framed Keep original image size, no magnify-button.
1712
1713 $part = explode( "|", $alt);
1714
1715 $mwThumb =& MagicWord::get( MAG_IMG_THUMBNAIL );
1716 $mwLeft =& MagicWord::get( MAG_IMG_LEFT );
1717 $mwRight =& MagicWord::get( MAG_IMG_RIGHT );
1718 $mwNone =& MagicWord::get( MAG_IMG_NONE );
1719 $mwWidth =& MagicWord::get( MAG_IMG_WIDTH );
1720 $mwCenter =& MagicWord::get( MAG_IMG_CENTER );
1721 $mwFramed =& MagicWord::get( MAG_IMG_FRAMED );
1722 $alt = $part[count($part)-1];
1723
1724 $height = $framed = $thumb = false;
1725
1726 foreach( $part as $key => $val ) {
1727 if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1728 $thumb=true;
1729 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1730 # remember to set an alignment, don't render immediately
1731 $align = "right";
1732 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1733 # remember to set an alignment, don't render immediately
1734 $align = "left";
1735 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
1736 # remember to set an alignment, don't render immediately
1737 $align = "center";
1738 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1739 # remember to set an alignment, don't render immediately
1740 $align = "none";
1741 } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1742 # $match is the image width in pixels
1743 if ( preg_match( "/^([0-9]*)x([0-9]*)$/", $match, $m ) ) {
1744 $width = intval( $m[1] );
1745 $height = intval( $m[2] );
1746 } else {
1747 $width = intval($match);
1748 }
1749 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
1750 $framed=true;
1751 }
1752 }
1753 if ( "center" == $align )
1754 {
1755 $prefix = '<span style="text-align: center">';
1756 $postfix = '</span>';
1757 $align = "none";
1758 }
1759
1760 if ( $thumb || $framed ) {
1761
1762 # Create a thumbnail. Alignment depends on language
1763 # writing direction, # right aligned for left-to-right-
1764 # languages ("Western languages"), left-aligned
1765 # for right-to-left-languages ("Semitic languages")
1766 #
1767 # If thumbnail width has not been provided, it is set
1768 # here to 180 pixels
1769 if ( $align == "" ) {
1770 $align = $wgLang->isRTL() ? "left" : "right";
1771 }
1772 if ( ! isset($width) ) {
1773 $width = 180;
1774 }
1775 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed ).$postfix;
1776
1777 } elseif ( isset($width) ) {
1778
1779 # Create a resized image, without the additional thumbnail
1780 # features
1781
1782 if ( ( ! $height === false )
1783 && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
1784 print "height=$height<br>\nimg->getHeight() = ".$img->getHeight()."<br>\n";
1785 print "rescaling by factor ". $height / $img->getHeight() . "<br>\n";
1786 $width = $img->getWidth() * $height / $img->getHeight();
1787 }
1788 $url = $img->createThumb( $width );
1789 }
1790 } # endif $wgUseImageResize
1791
1792 if ( empty( $alt ) ) {
1793 $alt = preg_replace( '/\.(.+?)^/', '', $img->getName() );
1794 }
1795 $alt = htmlspecialchars( $alt );
1796
1797 $u = $nt->escapeLocalURL();
1798 if ( $url == "" )
1799 {
1800 $s = str_replace( "$1", $img->getName(), wfMsg("missingimage") );
1801 $s .= "<br>{$alt}<br>{$url}<br>\n";
1802 } else {
1803 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1804 "<img src=\"{$url}\" alt=\"{$alt}\" /></a>";
1805 }
1806 if ( "" != $align ) {
1807 $s = "<div class=\"float{$align}\"><span>{$s}</span>\n</div>";
1808 }
1809 return $prefix.$s.$postfix;
1810 }
1811
1812
1813 function makeThumbLinkObj( $img, $label = "", $align = "right", $boxwidth = 180, $boxheight=false, $framed=false ) {
1814 global $wgStylePath, $wgLang;
1815 # $image = Title::makeTitle( Namespace::getImage(), $name );
1816 $url = $img->getURL();
1817
1818 #$label = htmlspecialchars( $label );
1819 $alt = preg_replace( "/<[^>]*>/", "", $label);
1820 $alt = htmlspecialchars( $alt );
1821
1822 if ( $img->exists() )
1823 {
1824 $width = $img->getWidth();
1825 $height = $img->getHeight();
1826 } else {
1827 $width = $height = 200;
1828 }
1829 if ( $framed )
1830 {
1831 // Use image dimensions, don't scale
1832 $boxwidth = $width;
1833 $oboxwidth = $boxwidth + 2;
1834 $boxheight = $height;
1835 $thumbUrl = $url;
1836 } else {
1837 $h = intval( $height/($width/$boxwidth) );
1838 $oboxwidth = $boxwidth + 2;
1839 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
1840 {
1841 $boxwidth *= $boxheight/$h;
1842 } else {
1843 $boxheight = $h;
1844 }
1845 $thumbUrl = $img->createThumb( $boxwidth );
1846 }
1847
1848 $u = $img->getEscapeLocalURL();
1849
1850 $more = htmlspecialchars( wfMsg( "thumbnail-more" ) );
1851 $magnifyalign = $wgLang->isRTL() ? "left" : "right";
1852 $textalign = $wgLang->isRTL() ? ' style="text-align:right"' : "";
1853
1854 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
1855 if ( $thumbUrl == "" ) {
1856 $s .= str_replace( "$1", $img->getName(), wfMsg("missingimage") );
1857 $zoomicon = '';
1858 } else {
1859 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1860 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1861 'width="'.$boxwidth.'" height="'.$boxheight.'" /></a>';
1862 if ( $framed ) {
1863 $zoomicon="";
1864 } else {
1865 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1866 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1867 '<img src="'.$wgStylePath.'/images/magnify-clip.png" ' .
1868 'width="15" height="11" alt="'.$more.'" /></a></div>';
1869 }
1870 }
1871 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div>\n</div>";
1872 return $s;
1873 }
1874
1875 function makeMediaLink( $name, $url, $alt = "" ) {
1876 $nt = Title::makeTitle( Namespace::getMedia(), $name );
1877 return $this->makeMediaLinkObj( $nt, $alt );
1878 }
1879
1880 function makeMediaLinkObj( $nt, $alt = "" )
1881 {
1882 $name = $nt->getDBKey();
1883 $url = Image::wfImageUrl( $name );
1884 if ( empty( $alt ) ) {
1885 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1886 }
1887
1888 $u = htmlspecialchars( $url );
1889 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1890 return $s;
1891 }
1892
1893 function specialLink( $name, $key = "" )
1894 {
1895 global $wgLang;
1896
1897 if ( "" == $key ) { $key = strtolower( $name ); }
1898 $pn = $wgLang->ucfirst( $name );
1899 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1900 wfMsg( $key ) );
1901 }
1902
1903 function makeExternalLink( $url, $text, $escape = true ) {
1904 $style = $this->getExternalLinkAttributes( $url, $text );
1905 $url = htmlspecialchars( $url );
1906 if( $escape ) {
1907 $text = htmlspecialchars( $text );
1908 }
1909 return "<a href=\"$url\"$style>$text</a>";
1910 }
1911
1912 # Called by history lists and recent changes
1913 #
1914
1915 # Returns text for the start of the tabular part of RC
1916 function beginRecentChangesList()
1917 {
1918 $this->rc_cache = array() ;
1919 $this->rcMoveIndex = 0;
1920 $this->rcCacheIndex = 0 ;
1921 $this->lastdate = "";
1922 $this->rclistOpen = false;
1923 return "";
1924 }
1925
1926 function beginImageHistoryList()
1927 {
1928 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1929 "<p>" . wfMsg( "imghistlegend" ) . "</p>\n<ul class='special'>";
1930 return $s;
1931 }
1932
1933 # Returns text for the end of RC
1934 # If enhanced RC is in use, returns pretty much all the text
1935 function endRecentChangesList()
1936 {
1937 $s = $this->recentChangesBlock() ;
1938 if( $this->rclistOpen ) {
1939 $s .= "</ul>\n";
1940 }
1941 return $s;
1942 }
1943
1944 # Enhanced RC ungrouped line
1945 function recentChangesBlockLine ( $rcObj )
1946 {
1947 global $wgStylePath, $wgLang ;
1948
1949 # Get rc_xxxx variables
1950 extract( $rcObj->mAttribs ) ;
1951 $curIdEq = "curid=$rc_cur_id";
1952
1953 # Spacer image
1954 $r = "" ;
1955
1956 $r .= "<img src='{$wgStylePath}/images/Arr_.png' width='12' height='12' border='0' />" ; $r .= "<tt>" ;
1957
1958 if ( $rc_type == RC_MOVE ) {
1959 $r .= "&nbsp;&nbsp;";
1960 } else {
1961 # M & N (minor & new)
1962 $M = wfMsg( "minoreditletter" );
1963 $N = wfMsg( "newpageletter" );
1964
1965 if ( $rc_type == RC_NEW ) {
1966 $r .= $N ;
1967 } else {
1968 $r .= "&nbsp;" ;
1969 }
1970 if ( $rc_minor ) {
1971 $r .= $M ;
1972 } else {
1973 $r .= "&nbsp;" ;
1974 }
1975 }
1976
1977 # Timestamp
1978 $r .= " ".$rcObj->timestamp." " ;
1979 $r .= "</tt>" ;
1980
1981 # Article link
1982 $link = $rcObj->link ;
1983 if ( $rcObj->watched ) $link = "<strong>{$link}</strong>" ;
1984 $r .= $link ;
1985
1986 # Cur
1987 $r .= " (" ;
1988 $r .= $rcObj->curlink ;
1989 $r .= "; " ;
1990
1991 # Hist
1992 $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" );
1993
1994 # User/talk
1995 $r .= ") . . ".$rcObj->userlink ;
1996 $r .= $rcObj->usertalklink ;
1997
1998 # Comment
1999 if ( $rc_comment != "" && $rc_type != RC_MOVE ) {
2000 $rc_comment=$this->formatComment($rc_comment);
2001 $r .= $wgLang->emphasize( " (".$rc_comment.")" );
2002 }
2003
2004 $r .= "<br />\n" ;
2005 return $r ;
2006 }
2007
2008 # Enhanced RC group
2009 function recentChangesBlockGroup ( $block )
2010 {
2011 global $wgStylePath, $wgLang ;
2012
2013 $r = "" ;
2014 $M = wfMsg( "minoreditletter" );
2015 $N = wfMsg( "newpageletter" );
2016
2017 # Collate list of users
2018 $isnew = false ;
2019 $userlinks = array () ;
2020 foreach ( $block AS $rcObj ) {
2021 $oldid = $rcObj->mAttribs['rc_last_oldid'];
2022 if ( $rcObj->mAttribs['rc_new'] ) $isnew = true ;
2023 $u = $rcObj->userlink ;
2024 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
2025 $userlinks[$u]++ ;
2026 }
2027
2028 # Sort the list and convert to text
2029 krsort ( $userlinks ) ;
2030 asort ( $userlinks ) ;
2031 $users = array () ;
2032 foreach ( $userlinks as $userlink => $count) {
2033 $text = $userlink ;
2034 if ( $count > 1 ) $text .= " ({$count}&times;)" ;
2035 array_push ( $users , $text ) ;
2036 }
2037 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
2038
2039 # Arrow
2040 $rci = "RCI{$this->rcCacheIndex}" ;
2041 $rcl = "RCL{$this->rcCacheIndex}" ;
2042 $rcm = "RCM{$this->rcCacheIndex}" ;
2043 $toggleLink = "javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")" ;
2044 $arrowdir = $wgLang->isRTL() ? "l" : "r";
2045 $tl = "<span id='{$rcm}'><a href='$toggleLink'><img src='{$wgStylePath}/images/Arr_{$arrowdir}.png' width='12' height='12' /></a></span>" ;
2046 $tl .= "<span id='{$rcl}' style='display:none'><a href='$toggleLink'><img src='{$wgStylePath}/images/Arr_d.png' width='12' height='12' /></a></span>" ;
2047 $r .= $tl ;
2048
2049 # Main line
2050 # M/N
2051 $r .= "<tt>" ;
2052 if ( $isnew ) $r .= $N ;
2053 else $r .= "&nbsp;" ;
2054 $r .= "&nbsp;" ; # Minor
2055
2056 # Timestamp
2057 $r .= " ".$block[0]->timestamp." " ;
2058 $r .= "</tt>" ;
2059
2060 # Article link
2061 $link = $block[0]->link ;
2062 if ( $block[0]->watched ) $link = "<strong>{$link}</strong>" ;
2063 $r .= $link ;
2064
2065 $curIdEq = "curid=" . $block[0]->mAttribs['rc_cur_id'];
2066 if ( $block[0]->mAttribs['rc_type'] != RC_LOG ) {
2067 # Changes
2068 $r .= " (".count($block)." " ;
2069 if ( $isnew ) $r .= wfMsg("changes");
2070 else $r .= $this->makeKnownLinkObj( $block[0]->getTitle() , wfMsg("changes") ,
2071 "{$curIdEq}&diff=0&oldid=".$oldid ) ;
2072 $r .= "; " ;
2073
2074 # History
2075 $r .= $this->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( "history" ), "{$curIdEq}&action=history" );
2076 $r .= ")" ;
2077 }
2078
2079 $r .= $users ;
2080 $r .= "<br />\n" ;
2081
2082 # Sub-entries
2083 $r .= "<div id='{$rci}' style='display:none'>" ;
2084 foreach ( $block AS $rcObj ) {
2085 # Get rc_xxxx variables
2086 extract( $rcObj->mAttribs );
2087
2088 $r .= "<img src='{$wgStylePath}/images/Arr_.png' width=12 height=12 />";
2089 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
2090 if ( $rc_new ) $r .= $N ;
2091 else $r .= "&nbsp;" ;
2092 if ( $rc_minor ) $r .= $M ;
2093 else $r .= "&nbsp;" ;
2094 $r .= "</tt>" ;
2095
2096 $o = "" ;
2097 if ( $rc_last_oldid != 0 ) {
2098 $o = "oldid=".$rc_last_oldid ;
2099 }
2100 if ( $rc_type == RC_LOG ) {
2101 $link = $rcObj->timestamp ;
2102 } else {
2103 $link = $this->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp , "{$curIdEq}&$o" ) ;
2104 }
2105 $link = "<tt>{$link}</tt>" ;
2106
2107 $r .= $link ;
2108 $r .= " (" ;
2109 $r .= $rcObj->curlink ;
2110 $r .= "; " ;
2111 $r .= $rcObj->lastlink ;
2112 $r .= ") . . ".$rcObj->userlink ;
2113 $r .= $rcObj->usertalklink ;
2114 if ( $rc_comment != "" ) {
2115 $rc_comment=$this->formatComment($rc_comment);
2116 $r .= $wgLang->emphasize( " (".$rc_comment.")" ) ;
2117 }
2118 $r .= "<br />\n" ;
2119 }
2120 $r .= "</div>\n" ;
2121
2122 $this->rcCacheIndex++ ;
2123 return $r ;
2124 }
2125
2126 # If enhanced RC is in use, this function takes the previously cached
2127 # RC lines, arranges them, and outputs the HTML
2128 function recentChangesBlock ()
2129 {
2130 global $wgStylePath ;
2131 if ( count ( $this->rc_cache ) == 0 ) return "" ;
2132 $blockOut = "";
2133 foreach ( $this->rc_cache AS $secureName => $block ) {
2134 if ( count ( $block ) < 2 ) {
2135 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
2136 } else {
2137 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
2138 }
2139 }
2140
2141 return "<div>{$blockOut}</div>" ;
2142 }
2143
2144 # Called in a loop over all displayed RC entries
2145 # Either returns the line, or caches it for later use
2146 function recentChangesLine( &$rc, $watched = false )
2147 {
2148 global $wgUser ;
2149 $usenew = $wgUser->getOption( "usenewrc" );
2150 if ( $usenew )
2151 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
2152 else
2153 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
2154 return $line ;
2155 }
2156
2157 function recentChangesLineOld( &$rc, $watched = false )
2158 {
2159 global $wgTitle, $wgLang, $wgUser, $wgRCSeconds;
2160
2161 # Extract DB fields into local scope
2162 extract( $rc->mAttribs );
2163 $curIdEq = "curid=" . $rc_cur_id;
2164
2165 # Make date header if necessary
2166 $date = $wgLang->date( $rc_timestamp, true);
2167 $s = "";
2168 if ( $date != $this->lastdate ) {
2169 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
2170 $s .= "<h4>{$date}</h4>\n<ul class='special'>";
2171 $this->lastdate = $date;
2172 $this->rclistOpen = true;
2173 }
2174 $s .= "<li> ";
2175
2176 if ( $rc_type == RC_MOVE ) {
2177 # Diff
2178 $s .= "(" . wfMsg( "diff" ) . ") (";
2179 # Hist
2180 $s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), wfMsg( "hist" ), "action=history" ) .
2181 ") . . ";
2182
2183 # "[[x]] moved to [[y]]"
2184
2185 $s .= wfMsg( "1movedto2", $this->makeKnownLinkObj( $rc->getTitle(), "", "redirect=no" ),
2186 $this->makeKnownLinkObj( $rc->getMovedToTitle(), "" ) );
2187
2188 } else {
2189 # Diff link
2190 if ( $rc_type == RC_NEW || $rc_type == RC_LOG ) {
2191 $diffLink = wfMsg( "diff" );
2192 } else {
2193 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "diff" ),
2194 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}" ,'' ,'' , ' tabindex="'.$rc->counter.'"');
2195 }
2196 $s .= "($diffLink) (";
2197
2198 # History link
2199 $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" );
2200 $s .= ") . . ";
2201
2202 # M and N (minor and new)
2203 $M = wfMsg( "minoreditletter" );
2204 $N = wfMsg( "newpageletter" );
2205 if ( $rc_minor ) { $s .= " <strong>{$M}</strong>"; }
2206 if ( $rc_type == RC_NEW ) { $s .= "<strong>{$N}</strong>"; }
2207
2208 # Article link
2209 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), "" );
2210
2211 if ( $watched ) {
2212 $articleLink = "<strong>{$articleLink}</strong>";
2213 }
2214 $s .= " $articleLink";
2215
2216 }
2217
2218 # Timestamp
2219 $s .= "; " . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . " . . ";
2220
2221 # User link (or contributions for unregistered users)
2222 if ( 0 == $rc_user ) {
2223 $userLink = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
2224 $rc_user_text, "target=" . $rc_user_text );
2225 } else {
2226 $userLink = $this->makeLink( $wgLang->getNsText( NS_USER ) . ":{$rc_user_text}", $rc_user_text );
2227 }
2228 $s .= $userLink;
2229
2230 # User talk link
2231 $talkname=$wgLang->getNsText(NS_TALK); # use the shorter name
2232 global $wgDisableAnonTalk;
2233 if( 0 == $rc_user && $wgDisableAnonTalk ) {
2234 $userTalkLink = "";
2235 } else {
2236 $utns=$wgLang->getNsText(NS_USER_TALK);
2237 $userTalkLink= $this->makeLink($utns . ":{$rc_user_text}", $talkname );
2238 }
2239 # Block link
2240 $blockLink="";
2241 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2242 $blockLink = $this->makeKnownLink( $wgLang->specialPage(
2243 "Blockip" ), wfMsg( "blocklink" ), "ip={$rc_user_text}" );
2244
2245 }
2246 if($blockLink) {
2247 if($userTalkLink) $userTalkLink .= " | ";
2248 $userTalkLink .= $blockLink;
2249 }
2250 if($userTalkLink) $s.=" ({$userTalkLink})";
2251
2252 # Add comment
2253 if ( "" != $rc_comment && "*" != $rc_comment && $rc_type != RC_MOVE ) {
2254 $rc_comment=$this->formatComment($rc_comment);
2255 $s .= $wgLang->emphasize(" (" . $rc_comment . ")");
2256 }
2257 $s .= "</li>\n";
2258
2259 return $s;
2260 }
2261
2262 # function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
2263 function recentChangesLineNew( &$baseRC, $watched = false )
2264 {
2265 global $wgTitle, $wgLang, $wgUser, $wgRCSeconds;
2266
2267 # Create a specialised object
2268 $rc = RCCacheEntry::newFromParent( $baseRC ) ;
2269
2270 # Extract fields from DB into the function scope (rc_xxxx variables)
2271 extract( $rc->mAttribs );
2272 $curIdEq = "curid=" . $rc_cur_id;
2273
2274 # If it's a new day, add the headline and flush the cache
2275 $date = $wgLang->date( $rc_timestamp, true);
2276 $ret = "" ;
2277 if ( $date != $this->lastdate ) {
2278 # Process current cache
2279 $ret = $this->recentChangesBlock () ;
2280 $this->rc_cache = array() ;
2281 $ret .= "<h4>{$date}</h4>\n";
2282 $this->lastdate = $date;
2283 }
2284
2285 # Make article link
2286 if ( $rc_type == RC_MOVE ) {
2287 $clink = $this->makeKnownLinkObj( $rc->getTitle(), "", "redirect=no" );
2288 $clink .= " " . wfMsg("movedto") . " ";
2289 $clink .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), "" );
2290 } else {
2291 $clink = $this->makeKnownLinkObj( $rc->getTitle(), "" ) ;
2292 }
2293
2294 $time = $wgLang->time( $rc_timestamp, true, $wgRCSeconds );
2295 $rc->watched = $watched ;
2296 $rc->link = $clink ;
2297 $rc->timestamp = $time;
2298
2299 # Make "cur" link
2300 if ( ( $rc_type == RC_NEW && $rc_this_oldid == 0 ) || $rc_type == RC_LOG || $rc_type == RC_MOVE) {
2301 $curLink = wfMsg( "cur" );
2302 } else {
2303 $curLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "cur" ),
2304 "{$curIdEq}&diff=0&oldid={$rc_this_oldid}" ,'' ,'' , ' tabindex="'.$baseRC->counter.'"' );
2305 }
2306
2307 # Make "last" link
2308 $titleObj = $rc->getTitle();
2309 if ( $rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE ) {
2310 $lastLink = wfMsg( "last" );
2311 } else {
2312 $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "last" ),
2313 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}" );
2314 }
2315
2316 # Make user link (or user contributions for unregistered users)
2317 if ( 0 == $rc_user ) {
2318 $userLink = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
2319 $rc_user_text, "target=" . $rc_user_text );
2320 } else {
2321 $userLink = $this->makeLink( $wgLang->getNsText(
2322 Namespace::getUser() ) . ":{$rc_user_text}", $rc_user_text );
2323 }
2324
2325 $rc->userlink = $userLink ;
2326 $rc->lastlink = $lastLink ;
2327 $rc->curlink = $curLink ;
2328
2329 # Make user talk link
2330 $utns=$wgLang->getNsText(NS_USER_TALK);
2331 $talkname=$wgLang->getNsText(NS_TALK); # use the shorter name
2332 $userTalkLink= $this->makeLink($utns . ":{$rc_user_text}", $talkname );
2333
2334 global $wgDisableAnonTalk;
2335 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2336 $blockLink = $this->makeKnownLink( $wgLang->specialPage(
2337 "Blockip" ), wfMsg( "blocklink" ), "ip={$rc_user_text}" );
2338 if( $wgDisableAnonTalk )
2339 $rc->usertalklink = " ({$blockLink})";
2340 else
2341 $rc->usertalklink = " ({$userTalkLink} | {$blockLink})";
2342 } else {
2343 if( $wgDisableAnonTalk && ($rc_user == 0) )
2344 $rc->usertalklink = "";
2345 else
2346 $rc->usertalklink = " ({$userTalkLink})";
2347 }
2348
2349 # Put accumulated information into the cache, for later display
2350 # Page moves go on their own line
2351 $title = $rc->getTitle();
2352 $secureName = $title->getPrefixedDBkey();
2353 if ( $rc_type == RC_MOVE ) {
2354 # Use an @ character to prevent collision with page names
2355 $this->rc_cache["@@" . ($this->rcMoveIndex++)] = array($rc);
2356 } else {
2357 if ( !isset ( $this->rc_cache[$secureName] ) ) $this->rc_cache[$secureName] = array() ;
2358 array_push ( $this->rc_cache[$secureName] , $rc ) ;
2359 }
2360 return $ret;
2361 }
2362
2363 function endImageHistoryList()
2364 {
2365 $s = "</ul>\n";
2366 return $s;
2367 }
2368
2369 /* This function is called by all recent changes variants, by the page history,
2370 and by the user contributions list. It is responsible for formatting edit
2371 comments. It escapes any HTML in the comment, but adds some CSS to format
2372 auto-generated comments (from section editing) and formats [[wikilinks]].
2373 Main author: Erik Möller (moeller@scireview.de)
2374 */
2375 function formatComment($comment)
2376 {
2377 global $wgLang;
2378 $comment=wfEscapeHTML($comment);
2379
2380 # The pattern for autogen comments is / * foo * /, which makes for
2381 # some nasty regex.
2382 # We look for all comments, match any text before and after the comment,
2383 # add a separator where needed and format the comment itself with CSS
2384 while (preg_match("/(.*)\/\*\s*(.*?)\s*\*\/(.*)/", $comment,$match)) {
2385 $pre=$match[1];
2386 $auto=$match[2];
2387 $post=$match[3];
2388 $sep="-";
2389 if($pre) { $auto="$sep ".$auto; }
2390 if($post) { $auto.=" $sep"; }
2391 $auto="<span class=\"autocomment\">".$auto."</span>";
2392 $comment=$pre.$auto.$post;
2393 }
2394
2395 # format regular and media links - all other wiki formatting
2396 # is ignored
2397 while(preg_match("/\[\[(.*?)(\|(.*?))*\]\]/",$comment,$match)) {
2398
2399 $medians = $wgLang->getNsText(Namespace::getMedia());
2400 $func="makeLink";
2401 if(preg_match("/^".$medians."/i",$match[1])) {
2402 $func="makeMediaLink";
2403 }
2404 if(isset($match[3]) ) {
2405 $comment=
2406 preg_replace("/\[\[(.*?)\]\]/",
2407 $this->$func($match[1],$match[3]),$comment,1);
2408 } else {
2409 $comment=
2410 preg_replace("/\[\[(.*?)\]\]/",
2411 $this->$func($match[1],$match[1]),$comment,1);
2412 }
2413 }
2414
2415 return $comment;
2416
2417 }
2418
2419 function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description )
2420 {
2421 global $wgUser, $wgLang, $wgTitle;
2422
2423 $datetime = $wgLang->timeanddate( $timestamp, true );
2424 $del = wfMsg( "deleteimg" );
2425 $cur = wfMsg( "cur" );
2426
2427 if ( $iscur ) {
2428 $url = Image::wfImageUrl( $img );
2429 $rlink = $cur;
2430 if ( $wgUser->isSysop() ) {
2431 $link = $wgTitle->escapeLocalURL( "image=" . $wgTitle->getPartialURL() .
2432 "&action=delete" );
2433 $style = $this->getInternalLinkAttributes( $link, $del );
2434
2435 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
2436 } else {
2437 $dlink = $del;
2438 }
2439 } else {
2440 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
2441 if( $wgUser->getID() != 0 ) {
2442 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2443 wfMsg( "revertimg" ), "action=revert&oldimage=" .
2444 urlencode( $img ) );
2445 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2446 $del, "action=delete&oldimage=" . urlencode( $img ) );
2447 } else {
2448 # Having live active links for non-logged in users
2449 # means that bots and spiders crawling our site can
2450 # inadvertently change content. Baaaad idea.
2451 $rlink = wfMsg( "revertimg" );
2452 $dlink = $del;
2453 }
2454 }
2455 if ( 0 == $user ) {
2456 $userlink = $usertext;
2457 } else {
2458 $userlink = $this->makeLink( $wgLang->getNsText( Namespace::getUser() ) .
2459 ":{$usertext}", $usertext );
2460 }
2461 $nbytes = wfMsg( "nbytes", $size );
2462 $style = $this->getInternalLinkAttributes( $url, $datetime );
2463
2464 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a>"
2465 . " . . {$userlink} ({$nbytes})";
2466
2467 if ( "" != $description && "*" != $description ) {
2468 $sk=$wgUser->getSkin();
2469 $s .= $wgLang->emphasize(" (" . $sk->formatComment($description) . ")");
2470 }
2471 $s .= "</li>\n";
2472 return $s;
2473 }
2474
2475 function tocIndent($level) {
2476 return str_repeat( "<div class='tocindent'>\n", $level>0 ? $level : 0 );
2477 }
2478
2479 function tocUnindent($level) {
2480 return str_repeat( "</div>\n", $level>0 ? $level : 0 );
2481 }
2482
2483 # parameter level defines if we are on an indentation level
2484 function tocLine( $anchor, $tocline, $level ) {
2485 $link = "<a href=\"#$anchor\">$tocline</a><br />";
2486 if($level) {
2487 return "$link\n";
2488 } else {
2489 return "<div class='tocline'>$link</div>\n";
2490 }
2491
2492 }
2493
2494 function tocTable($toc) {
2495 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2496 # try min-width & co when somebody gets a chance
2497 $hideline = " <script type='text/javascript'>showTocToggle(\"" . addslashes( wfMsg("showtoc") ) . "\",\"" . addslashes( wfMsg("hidetoc") ) . "\")</script>";
2498 return
2499 "<table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
2500 "<b>".wfMsg("toc")."</b>" .
2501 $hideline .
2502 "</td></tr><tr id='tocinside'><td>\n".
2503 $toc."</td></tr></table>\n";
2504 }
2505
2506 # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
2507 function editSectionScript( $section, $head ) {
2508 global $wgTitle, $wgRequest;
2509 if( $wgRequest->getInt( "oldid" ) && ( $wgRequest->getVal( "diff" ) != "0" ) ) {
2510 return $head;
2511 }
2512 $url = $wgTitle->escapeLocalURL( "action=edit&section=$section" );
2513 return "<span oncontextmenu='document.location=\"$url\";return false;'>{$head}</span>";
2514 }
2515
2516 function editSectionLink( $section ) {
2517 global $wgRequest;
2518 global $wgTitle, $wgUser, $wgLang;
2519
2520 if( $wgRequest->getInt( "oldid" ) && ( $wgRequest->getVal( "diff" ) != "0" ) ) {
2521 # Section edit links would be out of sync on an old page.
2522 # But, if we're diffing to the current page, they'll be
2523 # correct.
2524 return "";
2525 }
2526
2527 $editurl = "&section={$section}";
2528 $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
2529
2530 if( $wgLang->isRTL() ) {
2531 $farside = "left";
2532 $nearside = "right";
2533 } else {
2534 $farside = "right";
2535 $nearside = "left";
2536 }
2537 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2538
2539 }
2540
2541 // This function is called by EditPage.php and shows a bulletin board style
2542 // toolbar for common editing functions. It can be disabled in the user preferences.
2543 // The necsesary JavaScript code can be found in style/wikibits.js.
2544 function getEditToolbar() {
2545 global $wgStylePath, $wgLang, $wgMimeType;
2546
2547 // toolarray an array of arrays which each include the filename of
2548 // the button image (without path), the opening tag, the closing tag,
2549 // and optionally a sample text that is inserted between the two when no
2550 // selection is highlighted.
2551 // The tip text is shown when the user moves the mouse over the button.
2552
2553 // Already here are accesskeys (key), which are not used yet until someone
2554 // can figure out a way to make them work in IE. However, we should make
2555 // sure these keys are not defined on the edit page.
2556 $toolarray=array(
2557 array( "image"=>"button_bold.png",
2558 "open"=>"\'\'\'",
2559 "close"=>"\'\'\'",
2560 "sample"=>wfMsg("bold_sample"),
2561 "tip"=>wfMsg("bold_tip"),
2562 "key"=>"B"
2563 ),
2564 array( "image"=>"button_italic.png",
2565 "open"=>"\'\'",
2566 "close"=>"\'\'",
2567 "sample"=>wfMsg("italic_sample"),
2568 "tip"=>wfMsg("italic_tip"),
2569 "key"=>"I"
2570 ),
2571 array( "image"=>"button_link.png",
2572 "open"=>"[[",
2573 "close"=>"]]",
2574 "sample"=>wfMsg("link_sample"),
2575 "tip"=>wfMsg("link_tip"),
2576 "key"=>"L"
2577 ),
2578 array( "image"=>"button_extlink.png",
2579 "open"=>"[",
2580 "close"=>"]",
2581 "sample"=>wfMsg("extlink_sample"),
2582 "tip"=>wfMsg("extlink_tip"),
2583 "key"=>"X"
2584 ),
2585 array( "image"=>"button_headline.png",
2586 "open"=>"\\n== ",
2587 "close"=>" ==\\n",
2588 "sample"=>wfMsg("headline_sample"),
2589 "tip"=>wfMsg("headline_tip"),
2590 "key"=>"H"
2591 ),
2592 array( "image"=>"button_image.png",
2593 "open"=>"[[".$wgLang->getNsText(NS_IMAGE).":",
2594 "close"=>"]]",
2595 "sample"=>wfMsg("image_sample"),
2596 "tip"=>wfMsg("image_tip"),
2597 "key"=>"D"
2598 ),
2599 array( "image"=>"button_media.png",
2600 "open"=>"[[".$wgLang->getNsText(NS_MEDIA).":",
2601 "close"=>"]]",
2602 "sample"=>wfMsg("media_sample"),
2603 "tip"=>wfMsg("media_tip"),
2604 "key"=>"M"
2605 ),
2606 array( "image"=>"button_math.png",
2607 "open"=>"\\<math\\>",
2608 "close"=>"\\</math\\>",
2609 "sample"=>wfMsg("math_sample"),
2610 "tip"=>wfMsg("math_tip"),
2611 "key"=>"C"
2612 ),
2613 array( "image"=>"button_nowiki.png",
2614 "open"=>"\\<nowiki\\>",
2615 "close"=>"\\</nowiki\\>",
2616 "sample"=>wfMsg("nowiki_sample"),
2617 "tip"=>wfMsg("nowiki_tip"),
2618 "key"=>"N"
2619 ),
2620 array( "image"=>"button_sig.png",
2621 "open"=>"--~~~~",
2622 "close"=>"",
2623 "sample"=>"",
2624 "tip"=>wfMsg("sig_tip"),
2625 "key"=>"Y"
2626 ),
2627 array( "image"=>"button_hr.png",
2628 "open"=>"\\n----\\n",
2629 "close"=>"",
2630 "sample"=>"",
2631 "tip"=>wfMsg("hr_tip"),
2632 "key"=>"R"
2633 )
2634 );
2635 $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
2636
2637 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
2638 foreach($toolarray as $tool) {
2639
2640 $image=$wgStylePath."/images/".$tool["image"];
2641 $open=$tool["open"];
2642 $close=$tool["close"];
2643 $sample = addslashes( $tool["sample"] );
2644
2645 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
2646 // Older browsers show a "speedtip" type message only for ALT.
2647 // Ideally these should be different, realistically they
2648 // probably don't need to be.
2649 $tip = addslashes( $tool["tip"] );
2650
2651 #$key = $tool["key"];
2652
2653 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
2654 }
2655
2656 $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
2657 $toolbar.="document.writeln(\"</div>\");\n";
2658
2659 $toolbar.="/*]]>*/\n</script>";
2660 return $toolbar;
2661 }
2662 }
2663
2664 require_once( "SkinStandard.php" );
2665 require_once( "SkinNostalgia.php" );
2666 require_once( "SkinCologneBlue.php" );
2667
2668 if( $wgUsePHPTal ) {
2669 require_once( "SkinPHPTal.php" );
2670 }
2671
2672
2673 ?>