JeLuF's image resizing code
[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 global $wgDebugComments;
85
86 wfProfileIn( "Skin::outputPage" );
87 $this->initPage();
88 $out->out( $out->headElement() );
89
90 $out->out( "\n<body" );
91 $ops = $this->getBodyOptions();
92 foreach ( $ops as $name => $val ) {
93 $out->out( " $name='$val'" );
94 }
95 $out->out( ">\n" );
96 if ( $wgDebugComments ) {
97 $out->out( "<!-- Wiki debugging output:\n" .
98 $out->mDebugtext . "-->\n" );
99 }
100 $out->out( $this->beforeContent() );
101
102 $out->out( $out->mBodytext );
103
104 $out->out( $this->afterContent() );
105
106 wfProfileClose();
107 $out->out( $out->reportTime() );
108
109 $out->out( "\n</body></html>" );
110 }
111
112 function getHeadScripts() {
113 global $wgStyleSheetPath;
114 $r = "<script type=\"text/javascript\" src=\"{$wgStyleSheetPath}/wikibits.js\"></script>\n";
115 return $r;
116 }
117
118 function getUserStyles()
119 {
120 $s = "<style type='text/css'><!--\n";
121 $s .= $this->doGetUserStyles();
122 $s .= "//--></style>\n";
123 return $s;
124 }
125
126 function doGetUserStyles()
127 {
128 global $wgUser;
129
130 $s = "";
131 if ( 1 == $wgUser->getOption( "underline" ) ) {
132 # Don't override browser settings
133 } else {
134 # CHECK MERGE @@@
135 # Force no underline
136 $s .= "a.stub, a.new, a.internal, a.external { " .
137 "text-decoration: none; }\n";
138 }
139 if ( 1 == $wgUser->getOption( "highlightbroken" ) ) {
140 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
141 }
142 if ( 1 == $wgUser->getOption( "justify" ) ) {
143 $s .= "#article { text-align: justify; }\n";
144 }
145 return $s;
146 }
147
148 function getBodyOptions()
149 {
150 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $oldid, $redirect, $diff,$action;
151
152 if ( 0 != $wgTitle->getNamespace() ) {
153 $a = array( "bgcolor" => "#ffffec" );
154 }
155 else $a = array( "bgcolor" => "#FFFFFF" );
156 if($wgOut->isArticle() && $wgUser->getOption("editondblclick")
157 &&
158 (!$wgTitle->isProtected() || $wgUser->isSysop())
159
160 ) {
161 $n = $wgTitle->getPrefixedURL();
162 $t = wfMsg( "editthispage" );
163 $oid = $red = "";
164 if ( $redirect ) { $red = "&redirect={$redirect}"; }
165 if ( $oldid && ! isset( $diff ) ) {
166 $oid = "&oldid={$oldid}";
167 }
168 $s = wfLocalUrlE($n,"action=edit{$oid}{$red}");
169 $s = "document.location = \"" .$s ."\";";
170 $a += array ("ondblclick" => $s);
171
172 }
173 $a['onload'] = $wgOut->getOnloadHandler();
174 return $a;
175 }
176
177 function getExternalLinkAttributes( $link, $text )
178 {
179 global $wgUser, $wgOut, $wgLang;
180
181 $link = urldecode( $link );
182 $link = $wgLang->checkTitleEncoding( $link );
183 $link = str_replace( "_", " ", $link );
184 $link = wfEscapeHTML( $link );
185
186 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
187 else { $r = " class='external'"; }
188
189 if ( 1 == $wgUser->getOption( "hover" ) ) {
190 $r .= " title=\"{$link}\"";
191 }
192 return $r;
193 }
194
195 function getInternalLinkAttributes( $link, $text, $broken = false )
196 {
197 global $wgUser, $wgOut;
198
199 $link = urldecode( $link );
200 $link = str_replace( "_", " ", $link );
201 $link = wfEscapeHTML( $link );
202
203 if ( $wgOut->isPrintable() ) {
204 $r = " class='printable'";
205 } else if ( $broken == "stub" ) {
206 $r = " class='stub'";
207 } else if ( $broken == "yes" ) {
208 $r = " class='new'";
209 } else {
210 $r = " class='internal'";
211 }
212
213 if ( 1 == $wgUser->getOption( "hover" ) ) {
214 $r .= " title=\"{$link}\"";
215 }
216 return $r;
217 }
218
219 function getInternalLinkAttributesObj( &$nt, $text, $broken = false )
220 {
221 global $wgUser, $wgOut;
222
223 if ( $wgOut->isPrintable() ) {
224 $r = " class='printable'";
225 } else if ( $broken == "stub" ) {
226 $r = " class='stub'";
227 } else if ( $broken == "yes" ) {
228 $r = " class='new'";
229 } else {
230 $r = " class='internal'";
231 }
232
233 if ( 1 == $wgUser->getOption( "hover" ) ) {
234 $r .= ' title ="' . $nt->getEscapedText() . '"';
235 }
236 return $r;
237 }
238
239 function getLogo()
240 {
241 global $wgLogo;
242 return $wgLogo;
243 }
244
245 # This will be called immediately after the <body> tag. Split into
246 # two functions to make it easier to subclass.
247 #
248 function beforeContent()
249 {
250 global $wgUser, $wgOut, $wgSiteNotice;
251
252 if ( $wgOut->isPrintable() ) {
253 $s = $this->pageTitle() . $this->pageSubtitle() . "\n";
254 $s .= "\n<div class='bodytext'>";
255 return $s;
256 }
257 if( $wgSiteNotice ) {
258 $note = "\n<div id='notice' style='font-weight: bold; color: red; text-align: center'>$wgSiteNotice</div>\n";
259 } else {
260 $note = "";
261 }
262 return $this->doBeforeContent() . $note;
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 if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ;
409
410 if ( $wgOut->isArticle() ) {
411 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
412 $name = $wgTitle->getDBkey();
413 $link = wfEscapeHTML( wfImageUrl( $name ) );
414 $style = $this->getInternalLinkAttributes( $link, $name );
415 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
416 }
417 # This will show the "Approve" link if $wgUseApproval=true;
418 if ( isset ( $wgUseApproval ) && $wgUseApproval )
419 {
420 $t = $wgTitle->getDBkey();
421 $name = "Approve this article" ;
422 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
423 #wfEscapeHTML( wfImageUrl( $name ) );
424 $style = $this->getExternalLinkAttributes( $link, $name );
425 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
426 } }
427 if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
428 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
429 wfMsg( "currentrev" ) );
430 }
431
432 if ( $wgUser->getNewtalk() ) {
433 # do not show "You have new messages" text when we are viewing our
434 # own talk page
435
436 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
437 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
438 $n =$wgUser->getName();
439 $tl = $this->makeKnownLink( $wgLang->getNsText(
440 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
441 wfMsg("newmessageslink") );
442 $s.=" | <strong>". wfMsg( "newmessages", $tl ) . "</strong>";
443 }
444 }
445 if( $wgUser->isSysop() &&
446 (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
447 ($n = $wgTitle->isDeleted() ) ) {
448 $s .= " | " . wfMsg( "thisisdeleted",
449 $this->makeKnownLink(
450 $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ),
451 wfMsg( "restorelink", $n ) ) );
452 }
453 return $s;
454 }
455
456 function printableLink()
457 {
458 global $wgOut, $wgTitle, $oldid, $action;
459
460 $q = "";
461 foreach( $_GET as $var => $val ) {
462 if( $var != "title" && $var != "printable" )
463 $q .= urlencode( $var ) . "=" . urlencode( $val );
464 }
465 if( !empty( $q ) ) $q .= "&";
466
467 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
468 WfMsg( "printableversion" ), "{$q}printable=yes" );
469 return $s;
470 }
471
472 function pageTitle()
473 {
474 global $wgOut, $wgTitle, $wgUser;
475
476 $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
477 if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
478 return $s;
479 }
480
481 function pageSubtitle()
482 {
483 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
484
485 $sub = $wgOut->getSubtitle();
486 if ( "" == $sub ) {
487 global $wgExtraSubtitle;
488 $sub = wfMsg( "fromwikipedia" ) . $wgExtraSubtitle;
489 }
490 if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
491 $ptext=$wgTitle->getPrefixedText();
492 if(preg_match("/\//",$ptext)) {
493 $sub.="</p><p class='subpages'>";
494 $links=explode("/",$ptext);
495 $c=0;
496 $growinglink="";
497 foreach($links as $link) {
498 $c++;
499 if ($c<count($links)) {
500 $growinglink .= $link;
501 $getlink = $this->makeLink( $growinglink, $link );
502 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
503 if ($c>1) {
504 $sub .= " | ";
505 } else {
506 $sub .="&lt; ";
507 }
508 $sub .= $getlink;
509 $growinglink.="/";
510 }
511
512 }
513 }
514 }
515 $s = "<p class='subtitle'>{$sub}\n";
516 return $s;
517 }
518
519 function nameAndLogin()
520 {
521 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader;
522
523 $li = $wgLang->specialPage( "Userlogin" );
524 $lo = $wgLang->specialPage( "Userlogout" );
525
526 $s = "";
527 if ( 0 == $wgUser->getID() ) {
528 if( $wgShowIPinHeader ) {
529 $n = getenv( "REMOTE_ADDR" );
530
531 $tl = $this->makeKnownLink( $wgLang->getNsText(
532 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
533 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
534
535 $s .= $n . " (".$tl.")";
536 } else {
537 $s .= wfMsg("notloggedin");
538 }
539
540 $rt = $wgTitle->getPrefixedURL();
541 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
542 $q = "";
543 } else { $q = "returnto={$rt}"; }
544
545 $s .= "\n<br>" . $this->makeKnownLink( $li,
546 wfMsg( "login" ), $q );
547 } else {
548 $n = $wgUser->getName();
549 $rt = $wgTitle->getPrefixedURL();
550 $tl = $this->makeKnownLink( $wgLang->getNsText(
551 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
552 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
553
554 $tl = " ({$tl})";
555
556 $s .= $this->makeKnownLink( $wgLang->getNsText(
557 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
558 $this->makeKnownLink( $lo, wfMsg( "logout" ),
559 "returnto={$rt}" ) . " | " .
560 $this->specialLink( "preferences" );
561 }
562 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
563 wfMsg( "help" ) );
564
565 return $s;
566 }
567
568 function searchForm()
569 {
570 global $search;
571
572 $s = "<form name='search' class='inline' method=get action=\""
573 . wfLocalUrl( "" ) . "\">"
574 . "<input type=text name=\"search\" size=19 value=\""
575 . htmlspecialchars(substr($search,0,256)) . "\">\n"
576 . "<input type=submit name=\"go\" value=\"" . wfMsg ("go") . "\">&nbsp;"
577 . "<input type=submit value=\"" . wfMsg ("search") . "\"></form>";
578
579 return $s;
580 }
581
582 function topLinks()
583 {
584 global $wgOut;
585 $sep = " |\n";
586
587 $s = $this->mainPageLink() . $sep
588 . $this->specialLink( "recentchanges" );
589
590 if ( $wgOut->isArticle() ) {
591 $s .= $sep . $this->editThisPage()
592 . $sep . $this->historyLink();
593 }
594 # Many people don't like this dropdown box
595 #$s .= $sep . $this->specialPagesList();
596
597 return $s;
598 }
599
600 function bottomLinks()
601 {
602 global $wgOut, $wgUser, $wgTitle;
603 $sep = " |\n";
604
605 $s = "";
606 if ( $wgOut->isArticle() ) {
607 $s .= "<strong>" . $this->editThisPage() . "</strong>";
608 if ( 0 != $wgUser->getID() ) {
609 $s .= $sep . $this->watchThisPage();
610 }
611 $s .= $sep . $this->talkLink()
612 . $sep . $this->historyLink()
613 . $sep . $this->whatLinksHere()
614 . $sep . $this->watchPageLinksLink();
615
616 if ( $wgTitle->getNamespace() == Namespace::getUser()
617 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
618
619 {
620 $id=User::idFromName($wgTitle->getText());
621 $ip=User::isIP($wgTitle->getText());
622
623 if($id || $ip) { # both anons and non-anons have contri list
624 $s .= $sep . $this->userContribsLink();
625 }
626 if ( 0 != $wgUser->getID() ) { # show only to signed in users
627 if($id) { # can only email non-anons
628 $s .= $sep . $this->emailUserLink();
629 }
630 }
631 }
632 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
633 $s .= "\n<br>" . $this->deleteThisPage() .
634 $sep . $this->protectThisPage() .
635 $sep . $this->moveThisPage();
636 }
637 $s .= "<br>\n" . $this->otherLanguages();
638 }
639 return $s;
640 }
641
642 function pageStats()
643 {
644 global $wgOut, $wgLang, $wgArticle;
645 global $oldid, $diff, $wgDisableCounters;
646
647 if ( ! $wgOut->isArticle() ) { return ""; }
648 if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
649 if ( 0 == $wgArticle->getID() ) { return ""; }
650
651 if ( $wgDisableCounters ) {
652 $s = "";
653 } else {
654 $count = $wgArticle->getCount();
655 $s = wfMsg( "viewcount", $count );
656 }
657 $s .= $this->lastModified();
658 $s .= " " . wfMsg( "gnunote" );
659 return "<span id='pagestats'>{$s}</span>";
660 }
661
662 function lastModified()
663 {
664 global $wgLang, $wgArticle;
665
666 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
667 $s = " " . wfMsg( "lastmodified", $d );
668 return $s;
669 }
670
671 function logoText( $align = "" )
672 {
673 if ( "" != $align ) { $a = " align='{$align}'"; }
674 else { $a = ""; }
675
676 $mp = wfMsg( "mainpage" );
677 $s = "<a href=\"" . wfLocalUrlE( urlencode( $mp ) )
678 . "\"><img{$a} border=0 src=\""
679 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
680 return $s;
681 }
682
683 function quickBar()
684 {
685 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
686 global $wpPreview, $wgDisableUploads, $wgRemoteUploads;
687
688 $fname = "Skin::quickBar";
689 wfProfileIn( $fname );
690
691 $tns=$wgTitle->getNamespace();
692
693 $s = "\n<div id='quickbar'>";
694 $s .= "\n" . $this->logoText() . "\n<hr class='sep'>";
695
696 $sep = "\n<br>";
697 $s .= $this->mainPageLink()
698 . $sep . $this->specialLink( "recentchanges" )
699 . $sep . $this->specialLink( "randompage" );
700 if ($wgUser->getID()) {
701 $s.= $sep . $this->specialLink( "watchlist" ) ;
702 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
703 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
704
705 }
706 // only show watchlist link if logged in
707 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
708 $s .= "\n<br><hr class='sep'>";
709 $articleExists = $wgTitle->getArticleId();
710 if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
711 if($wgOut->isArticle()) {
712 $s .= "<strong>" . $this->editThisPage() . "</strong>";
713 } else { # backlink to the article in edit or history mode
714 if($articleExists){ # no backlink if no article
715 switch($tns) {
716 case 0:
717 $text = wfMsg("articlepage");
718 break;
719 case 1:
720 $text = wfMsg("viewtalkpage");
721 break;
722 case 2:
723 $text = wfMsg("userpage");
724 break;
725 case 3:
726 $text = wfMsg("viewtalkpage");
727 break;
728 case 4:
729 $text = wfMsg("wikipediapage");
730 break;
731 case 5:
732 $text = wfMsg("viewtalkpage");
733 break;
734 case 6:
735 $text = wfMsg("imagepage");
736 break;
737 case 7:
738 $text = wfMsg("viewtalkpage");
739 break;
740 default:
741 $text= wfMsg("articlepage");
742 }
743
744 $link = $wgTitle->getText();
745 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
746 $link = $nstext . ":" . $link ;
747 }
748
749 $s .= $this->makeLink( $link, $text );
750 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
751 # we just throw in a "New page" text to tell the user that he's in edit mode,
752 # and to avoid messing with the separator that is prepended to the next item
753 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
754 }
755
756 }
757
758
759 if( $tns%2 && $action!="edit" && !$wpPreview) {
760 $s.="<br>".$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("postcomment"),"action=edit&section=new");
761 }
762
763 /*
764 watching could cause problems in edit mode:
765 if user edits article, then loads "watch this article" in background and then saves
766 article with "Watch this article" checkbox disabled, the article is transparently
767 unwatched. Therefore we do not show the "Watch this page" link in edit mode
768 */
769 if ( 0 != $wgUser->getID() && $articleExists) {
770 if($action!="edit" && $action!="history" &&
771 $action != "submit" )
772 {
773 $s .= $sep . $this->watchThisPage();
774 }
775 if ( $wgTitle->userCanEdit() )
776 $s .= $sep . $this->moveThisPage();
777 }
778 if ( $wgUser->isSysop() and $articleExists ) {
779 $s .= $sep . $this->deleteThisPage() .
780 $sep . $this->protectThisPage();
781 }
782 $s .= $sep . $this->talkLink();
783 if ($articleExists && $action !="history") {
784 $s .= $sep . $this->historyLink();
785 }
786 $s.=$sep . $this->whatLinksHere();
787
788 if($wgOut->isArticle()) {
789 $s .= $sep . $this->watchPageLinksLink();
790 }
791
792 if ( Namespace::getUser() == $wgTitle->getNamespace()
793 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
794 ) {
795
796 $id=User::idFromName($wgTitle->getText());
797 $ip=User::isIP($wgTitle->getText());
798
799 if($id||$ip) {
800 $s .= $sep . $this->userContribsLink();
801 }
802 if ( 0 != $wgUser->getID() ) {
803 if($id) { # can only email real users
804 $s .= $sep . $this->emailUserLink();
805 }
806 }
807 }
808 $s .= "\n<br><hr class='sep'>";
809 }
810
811 if ( 0 != $wgUser->getID() && ( !$wgDisableUploads || $wgRemoteUploads ) ) {
812 $s .= $this->specialLink( "upload" ) . $sep;
813 }
814 $s .= $this->specialLink( "specialpages" )
815 . $sep . $this->bugReportsLink();
816
817 global $wgSiteSupportPage;
818 if( $wgSiteSupportPage ) {
819 $s .= "\n<br><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
820 "\" class=\"internal\">" . wfMsg( "sitesupport" ) . "</a>";
821 }
822
823 $s .= "\n<br></div>\n";
824 wfProfileOut( $fname );
825 return $s;
826 }
827
828 function specialPagesList()
829 {
830 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
831 $a = array();
832
833 $validSP = $wgLang->getValidSpecialPages();
834
835 foreach ( $validSP as $name => $desc ) {
836 if ( "" == $desc ) { continue; }
837 $a[$name] = $desc;
838 }
839 if ( $wgUser->isSysop() )
840 {
841 $sysopSP = $wgLang->getSysopSpecialPages();
842
843 foreach ( $sysopSP as $name => $desc ) {
844 if ( "" == $desc ) { continue; }
845 $a[$name] = $desc ;
846 }
847 }
848 if ( $wgUser->isDeveloper() )
849 {
850 $devSP = $wgLang->getDeveloperSpecialPages();
851
852 foreach ( $devSP as $name => $desc ) {
853 if ( "" == $desc ) { continue; }
854 $a[$name] = $desc ;
855 }
856 }
857 $go = wfMsg( "go" );
858 $sp = wfMsg( "specialpages" );
859 $spp = $wgLang->specialPage( "Specialpages" );
860
861 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
862 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
863 $s .= "<select name=\"wpDropdown\">\n";
864 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
865
866 foreach ( $a as $name => $desc ) {
867 $p = $wgLang->specialPage( $name );
868 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
869 }
870 $s .= "</select>\n";
871 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
872 $s .= "</form>\n";
873 return $s;
874 }
875
876 function mainPageLink()
877 {
878 $mp = wfMsg( "mainpage" );
879 $s = $this->makeKnownLink( $mp, $mp );
880 return $s;
881 }
882
883 function copyrightLink()
884 {
885 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
886 wfMsg( "copyrightpagename" ) );
887 return $s;
888 }
889
890 function aboutLink()
891 {
892 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
893 wfMsg( "aboutwikipedia" ) );
894 return $s;
895 }
896
897
898 function disclaimerLink()
899 {
900 $s = $this->makeKnownLink( wfMsg( "disclaimerpage" ),
901 wfMsg( "disclaimers" ) );
902 return $s;
903 }
904
905 function editThisPage()
906 {
907 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
908
909 if ( ! $wgOut->isArticle() || $diff ) {
910 $s = wfMsg( "protectedpage" );
911 } else {
912 $n = $wgTitle->getPrefixedText();
913 if ( $wgTitle->userCanEdit() ) {
914 $t = wfMsg( "editthispage" );
915 } else {
916 #$t = wfMsg( "protectedpage" );
917 $t = wfMsg( "viewsource" );
918 }
919 $oid = $red = "";
920
921 if ( $redirect ) { $red = "&redirect={$redirect}"; }
922 if ( $oldid && ! isset( $diff ) ) {
923 $oid = "&oldid={$oldid}";
924 }
925 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
926 }
927 return $s;
928 }
929
930 function deleteThisPage()
931 {
932 global $wgUser, $wgOut, $wgTitle, $diff;
933
934 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
935 $n = $wgTitle->getPrefixedText();
936 $t = wfMsg( "deletethispage" );
937
938 $s = $this->makeKnownLink( $n, $t, "action=delete" );
939 } else {
940 $s = "";
941 }
942 return $s;
943 }
944
945 function protectThisPage()
946 {
947 global $wgUser, $wgOut, $wgTitle, $diff;
948
949 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
950 $n = $wgTitle->getPrefixedText();
951
952 if ( $wgTitle->isProtected() ) {
953 $t = wfMsg( "unprotectthispage" );
954 $q = "action=unprotect";
955 } else {
956 $t = wfMsg( "protectthispage" );
957 $q = "action=protect";
958 }
959 $s = $this->makeKnownLink( $n, $t, $q );
960 } else {
961 $s = "";
962 }
963 return $s;
964 }
965
966 function watchThisPage()
967 {
968 global $wgUser, $wgOut, $wgTitle, $diff;
969
970 if ( $wgOut->isArticle() && ( ! $diff ) ) {
971 $n = $wgTitle->getPrefixedText();
972
973 if ( $wgTitle->userIsWatching() ) {
974 $t = wfMsg( "unwatchthispage" );
975 $q = "action=unwatch";
976 } else {
977 $t = wfMsg( "watchthispage" );
978 $q = "action=watch";
979 }
980 $s = $this->makeKnownLink( $n, $t, $q );
981 } else {
982 $s = wfMsg( "notanarticle" );
983 }
984 return $s;
985 }
986
987 function moveThisPage()
988 {
989 global $wgTitle, $wgLang;
990
991 if ( $wgTitle->userCanEdit() ) {
992 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
993 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
994 } // no message if page is protected - would be redundant
995 return $s;
996 }
997
998 function historyLink()
999 {
1000 global $wgTitle;
1001
1002 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1003 wfMsg( "history" ), "action=history" );
1004 return $s;
1005 }
1006
1007 function whatLinksHere()
1008 {
1009 global $wgTitle, $wgLang;
1010
1011 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
1012 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
1013 return $s;
1014 }
1015
1016 function userContribsLink()
1017 {
1018 global $wgTitle, $wgLang;
1019
1020 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1021 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
1022 return $s;
1023 }
1024
1025 function emailUserLink()
1026 {
1027 global $wgTitle, $wgLang;
1028
1029 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
1030 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
1031 return $s;
1032 }
1033
1034 function watchPageLinksLink()
1035 {
1036 global $wgOut, $wgTitle, $wgLang;
1037
1038 if ( ! $wgOut->isArticle() ) {
1039 $s = "(" . wfMsg( "notanarticle" ) . ")";
1040 } else {
1041 $s = $this->makeKnownLink( $wgLang->specialPage(
1042 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
1043 "target=" . $wgTitle->getPrefixedURL() );
1044 }
1045 return $s;
1046 }
1047
1048 function otherLanguages()
1049 {
1050 global $wgOut, $wgLang, $wgTitle, $wgUseNewInterlanguage;
1051
1052 $a = $wgOut->getLanguageLinks();
1053 # TEST THIS @@@
1054 if ( 0 == count( $a ) ) {
1055 if ( !$wgUseNewInterlanguage ) return "";
1056 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1057 if ( $ns != 0 AND $ns != 1 ) return "" ;
1058 $pn = "Intl" ;
1059 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
1060 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1061 wfMsg( "intl" ) , $x );
1062 }
1063
1064 if ( !$wgUseNewInterlanguage ) {
1065 $s = wfMsg( "otherlanguages" ) . ": ";
1066 } else {
1067 global $wgLanguageCode ;
1068 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
1069 $x .= "&xl=".$wgLanguageCode ;
1070 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
1071 wfMsg( "otherlanguages" ) , $x ) . ": " ;
1072 }
1073
1074 $s = wfMsg( "otherlanguages" ) . ": ";
1075 $first = true;
1076 if($wgLang->isRTL()) $s .= "<span dir='LTR'>";
1077 foreach( $a as $l ) {
1078 if ( ! $first ) { $s .= " | "; }
1079 $first = false;
1080
1081 $nt = Title::newFromText( $l );
1082 $url = $nt->getFullURL();
1083 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
1084
1085 if ( "" == $text ) { $text = $l; }
1086 $style = $this->getExternalLinkAttributes( $l, $text );
1087 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1088 }
1089 if($wgLang->isRTL()) $s .= "</span>";
1090 return $s;
1091 }
1092
1093 function bugReportsLink()
1094 {
1095 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
1096 wfMsg( "bugreports" ) );
1097 return $s;
1098 }
1099
1100 function dateLink()
1101 {
1102 global $wgLinkCache;
1103 $t1 = Title::newFromText( gmdate( "F j" ) );
1104 $t2 = Title::newFromText( gmdate( "Y" ) );
1105
1106 $wgLinkCache->suspend();
1107 $id = $t1->getArticleID();
1108 $wgLinkCache->resume();
1109
1110 if ( 0 == $id ) {
1111 $s = $this->makeBrokenLink( $t1->getText() );
1112 } else {
1113 $s = $this->makeKnownLink( $t1->getText() );
1114 }
1115 $s .= ", ";
1116
1117 $wgLinkCache->suspend();
1118 $id = $t2->getArticleID();
1119 $wgLinkCache->resume();
1120
1121 if ( 0 == $id ) {
1122 $s .= $this->makeBrokenLink( $t2->getText() );
1123 } else {
1124 $s .= $this->makeKnownLink( $t2->getText() );
1125 }
1126 return $s;
1127 }
1128
1129 function talkLink()
1130 {
1131 global $wgLang, $wgTitle, $wgLinkCache;
1132
1133 $tns = $wgTitle->getNamespace();
1134 if ( -1 == $tns ) { return ""; }
1135
1136 $pn = $wgTitle->getText();
1137 $tp = wfMsg( "talkpage" );
1138 if ( Namespace::isTalk( $tns ) ) {
1139 $lns = Namespace::getSubject( $tns );
1140 switch($tns) {
1141 case 1:
1142 $text = wfMsg("articlepage");
1143 break;
1144 case 3:
1145 $text = wfMsg("userpage");
1146 break;
1147 case 5:
1148 $text = wfMsg("wikipediapage");
1149 break;
1150 case 7:
1151 $text = wfMsg("imagepage");
1152 break;
1153 default:
1154 $text= wfMsg("articlepage");
1155 }
1156 } else {
1157
1158 $lns = Namespace::getTalk( $tns );
1159 $text=$tp;
1160 }
1161 $n = $wgLang->getNsText( $lns );
1162 if ( "" == $n ) { $link = $pn; }
1163 else { $link = "{$n}:{$pn}"; }
1164
1165 $wgLinkCache->suspend();
1166 $s = $this->makeLink( $link, $text );
1167 $wgLinkCache->resume();
1168
1169 return $s;
1170 }
1171
1172 function commentLink()
1173 {
1174 global $wgLang, $wgTitle, $wgLinkCache;
1175
1176 $tns = $wgTitle->getNamespace();
1177 if ( -1 == $tns ) { return ""; }
1178
1179 $lns = ( Namespace::isTalk( $tns ) ) ? $tns : Namespace::getTalk( $tns );
1180
1181 # assert Namespace::isTalk( $lns )
1182
1183 $n = $wgLang->getNsText( $lns );
1184 $pn = $wgTitle->getText();
1185
1186 $link = "{$n}:{$pn}";
1187
1188 $wgLinkCache->suspend();
1189 $s = $this->makeKnownLink($link, wfMsg("postcomment"), "action=edit&section=new");
1190 $wgLinkCache->resume();
1191
1192 return $s;
1193 }
1194
1195 # After all the page content is transformed into HTML, it makes
1196 # a final pass through here for things like table backgrounds.
1197 #
1198 function transformContent( $text )
1199 {
1200 return $text;
1201 }
1202
1203 # Note: This function MUST call getArticleID() on the link,
1204 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1205 #
1206 function makeLink( $title, $text = "", $query = "", $trail = "" ) {
1207 wfProfileIn( "Skin::makeLink" );
1208 $nt = Title::newFromText( $title );
1209 if ($nt) {
1210 $result = $this->makeLinkObj( Title::newFromText( $title ), $text, $query, $trail );
1211 } else {
1212 wfDebug( "Invalid title passed to Skin::makeLink(): \"$title\"\n" );
1213 $result = $text == "" ? $title : $text;
1214 }
1215
1216 wfProfileOut( "Skin::makeLink" );
1217 return $result;
1218 }
1219
1220 function makeKnownLink( $title, $text = "", $query = "", $trail = "" ) {
1221 $nt = Title::newFromText( $title );
1222 if ($nt) {
1223 return $this->makeKnownLinkObj( Title::newFromText( $title ), $text, $query, $trail );
1224 } else {
1225 wfDebug( "Invalid title passed to Skin::makeKnownLink(): \"$title\"\n" );
1226 return $text == "" ? $title : $text;
1227 }
1228 }
1229
1230 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" ) {
1231 $nt = Title::newFromText( $title );
1232 if ($nt) {
1233 return $this->makeBrokenLinkObj( Title::newFromText( $title ), $text, $query, $trail );
1234 } else {
1235 wfDebug( "Invalid title passed to Skin::makeBrokenLink(): \"$title\"\n" );
1236 return $text == "" ? $title : $text;
1237 }
1238 }
1239
1240 function makeStubLink( $title, $text = "", $query = "", $trail = "" ) {
1241 $nt = Title::newFromText( $title );
1242 if ($nt) {
1243 return $this->makeStubLinkObj( Title::newFromText( $title ), $text, $query, $trail );
1244 } else {
1245 wfDebug( "Invalid title passed to Skin::makeStubLink(): \"$title\"\n" );
1246 return $text == "" ? $title : $text;
1247 }
1248 }
1249
1250 # Pass a title object, not a title string
1251 function makeLinkObj( &$nt, $text= "", $query = "", $trail = "" )
1252 {
1253 global $wgOut, $wgUser;
1254 if ( $nt->isExternal() ) {
1255 $u = $nt->getFullURL();
1256 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1257 $style = $this->getExternalLinkAttributes( $link, $text );
1258
1259 $inside = "";
1260 if ( "" != $trail ) {
1261 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1262 $inside = $m[1];
1263 $trail = $m[2];
1264 }
1265 }
1266 $retVal = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1267 } elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1268 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail );
1269 } elseif ( ( -1 == $nt->getNamespace() ) ||
1270 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1271 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail );
1272 } else {
1273 $aid = $nt->getArticleID() ;
1274 if ( 0 == $aid ) {
1275 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail );
1276 } else {
1277 $threshold = $wgUser->getOption("stubthreshold") ;
1278 if ( $threshold > 0 ) {
1279 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'", DB_READ ) ;
1280
1281 if ( wfNumRows( $res ) > 0 ) {
1282 $s = wfFetchObject( $res );
1283 $size = $s->x;
1284 if ( $s->cur_is_redirect OR $s->cur_namespace != 0 ) {
1285 $size = $threshold*2 ; # Really big
1286 }
1287 wfFreeResult( $res );
1288 } else {
1289 $size = $threshold*2 ; # Really big
1290 }
1291 } else {
1292 $size = 1 ;
1293 }
1294 if ( $size < $threshold ) {
1295 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail );
1296 } else {
1297 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail );
1298 }
1299 }
1300 }
1301 return $retVal;
1302 }
1303
1304 # Pass a title object, not a title string
1305 function makeKnownLinkObj( &$nt, $text = "", $query = "", $trail = "" )
1306 {
1307 global $wgOut, $wgTitle;
1308
1309 $fname = "Skin::makeKnownLinkObj";
1310 wfProfileIn( $fname );
1311
1312 $link = $nt->getPrefixedURL();
1313
1314 if ( "" == $link ) {
1315 $u = "";
1316 if ( "" == $text ) { $text = $nt->getFragment(); }
1317 } else {
1318 $u = wfLocalUrlE( $link, $query );
1319 }
1320 if ( "" != $nt->getFragment() ) {
1321 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1322 }
1323 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1324 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1325
1326 $inside = "";
1327 if ( "" != $trail ) {
1328 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1329 $inside = $m[1];
1330 $trail = $m[2];
1331 }
1332 }
1333 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1334 wfProfileOut( $fname );
1335 return $r;
1336 }
1337
1338 # Pass a title object, not a title string
1339 function makeBrokenLinkObj( &$nt, $text = "", $query = "", $trail = "" )
1340 {
1341 global $wgOut, $wgUser;
1342
1343 $fname = "Skin::makeBrokenLinkObj";
1344 wfProfileIn( $fname );
1345
1346 $link = $nt->getPrefixedURL();
1347
1348 if ( "" == $query ) { $q = "action=edit"; }
1349 else { $q = "action=edit&{$query}"; }
1350 $u = wfLocalUrlE( $link, $q );
1351
1352 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1353 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1354
1355 $inside = "";
1356 if ( "" != $trail ) {
1357 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1358 $inside = $m[1];
1359 $trail = $m[2];
1360 }
1361 }
1362 if ( $wgOut->isPrintable() ||
1363 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1364 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1365 } else {
1366 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1367 }
1368
1369 wfProfileOut( $fname );
1370 return $s;
1371 }
1372
1373 # Pass a title object, not a title string
1374 function makeStubLinkObj( &$nt, $text = "", $query = "", $trail = "" )
1375 {
1376 global $wgOut, $wgUser;
1377
1378 $link = $nt->getPrefixedURL();
1379
1380 $u = wfLocalUrlE( $link, $query );
1381
1382 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1383 $style = $this->getInternalLinkAttributesObj( $nt, $text, "stub" );
1384
1385 $inside = "";
1386 if ( "" != $trail ) {
1387 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1388 $inside = $m[1];
1389 $trail = $m[2];
1390 }
1391 }
1392 if ( $wgOut->isPrintable() ||
1393 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1394 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1395 } else {
1396 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1397 }
1398 return $s;
1399 }
1400
1401 function fnamePart( $url )
1402 {
1403 $basename = strrchr( $url, "/" );
1404 if ( false === $basename ) { $basename = $url; }
1405 else { $basename = substr( $basename, 1 ); }
1406 return wfEscapeHTML( $basename );
1407 }
1408
1409 function makeImage( $url, $alt = "" )
1410 {
1411 global $wgOut;
1412
1413 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1414 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1415 return $s;
1416 }
1417
1418 function makeImageLink( $name, $url, $alt = "" ) {
1419 $nt = Title::makeTitle( Namespace::getImage(), $name );
1420 return $this->makeImageLinkObj( $nt, $alt );
1421 }
1422
1423 function makeImageLinkObj( $nt, $alt = "" ) {
1424 global $wgLang, $wgUseImageResize;
1425 $link = $nt->getPrefixedURL();
1426 $name = $nt->getDBKey();
1427 $url = wfImageUrl( $name );
1428 $align = "";
1429
1430 if ( $wgUseImageResize ) {
1431 # Check if the alt text is of the form "options|alt text"
1432 # Options are:
1433 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1434 # * left no resizing, just left align. label is used for alt= only
1435 # * right same, but right aligned
1436 # * none same, but not aligned
1437 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1438
1439 $part = explode( "|", $alt);
1440
1441 if ( count($part) > 1 ) {
1442 $mwThumb =& MagicWord::get( MAG_IMG_THUMBNAIL );
1443 $mwLeft =& MagicWord::get( MAG_IMG_LEFT );
1444 $mwRight =& MagicWord::get( MAG_IMG_RIGHT );
1445 $mwNone =& MagicWord::get( MAG_IMG_NONE );
1446 $mwWidth =& MagicWord::get( MAG_IMG_WIDTH );
1447 $alt = $part[count($part)-1];
1448
1449 $thumb=false;
1450
1451 foreach( $part as $key => $val ) {
1452 if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1453 $thumb=true;
1454 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1455 # remember to set an alignment, don't render immediately
1456 $align = "right";
1457 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1458 # remember to set an alignment, don't render immediately
1459 $align = "left";
1460 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1461 # remember to set an alignment, don't render immediately
1462 $align = "none";
1463 } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1464 # $match is the image width in pixels
1465 $width = intval($match);
1466 }
1467 }
1468 }
1469
1470 if ( $thumb ) {
1471
1472 # Create a thumbnail. Alignment depends on language
1473 # writing direction, # right aligned for left-to-right-
1474 # languages ("Western languages"), left-aligned
1475 # for right-to-left-languages ("Semitic languages")
1476 #
1477 # If thumbnail width has not been provided, it is set
1478 # here to 180 pixels
1479 if ( $align == "" ) {
1480 $align = $wgLang->isRTL() ? "left" : "right";
1481 }
1482 if ( ! isset($width) ) {
1483 $width = 180;
1484 }
1485 return $this->makeThumbLinkObj( $nt, $alt, $align, $width );
1486
1487 } elseif ( isset($width) ) {
1488
1489 # Create a resized image, without the additional thumbnail
1490 # features
1491 $url = $this->createThumb( $name, $width );
1492 }
1493 } # endif $wgUseImageResize
1494
1495 if ( empty( $alt ) ) {
1496 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1497 }
1498 $alt = htmlspecialchars( $alt );
1499
1500 $u = wfLocalUrlE( $link );
1501 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1502 "<img border=\"0\" src=\"{$url}\" alt=\"{$alt}\"></a>";
1503 if ( "" != $align ) {
1504 $s = "<div class=\"float{$align}\">{$s}</div>";
1505 }
1506 return $s;
1507 }
1508
1509 function createThumb( $name, $width ) {
1510 global $wgUploadDirectory;
1511 global $wgImageMagickConvertCommand;
1512 $imgPath = wfImagePath( $name );
1513 $thumbName = $width."px-".$icon.$name;
1514 $thumbPath = wfImageArchiveDir( $thumbName, "thumb" )."/".$thumbName;
1515 $thumbUrl = wfImageArchiveUrl( $thumbName, "thumb" );
1516
1517 if ( (! file_exists( $thumbPath ))
1518 || ( filemtime($thumbPath) < filemtime($imgPath) ) ) {
1519 $cmd = $wgImageMagickConvertCommand .
1520 " -quality 95 -geometry {$width}x ".
1521 escapeshellarg($imgPath) . " " .
1522 escapeshellarg($thumbPath);
1523 $conv = shell_exec( $cmd );
1524 }
1525 return $thumbUrl;
1526 }
1527
1528 function makeThumbLinkObj( $nt, $label = "", $align = "right", $boxwidth = 180 ) {
1529 global $wgUploadPath;
1530 $name = $nt->getDBKey();
1531 $image = Title::makeTitle( Namespace::getImage(), $name );
1532 $link = $image->getPrefixedURL();
1533 $url = wfImageUrl( $name );
1534 $path = wfImagePath( $name );
1535
1536 list($width, $height, $type, $attr) = getimagesize( $path );
1537 $cwidth = $boxwidth;
1538 $cheight = intval( $height/($width/$cwidth) );
1539 if ($cheight > $boxwidth*1.5) {
1540 $cheight = $boxwidth*1.3;
1541 $cwidth = intval( $width/($height/$cheight) );
1542 }
1543 if ( $cwidth > $width ) {
1544 $cwidth = $width;
1545 $cheight = $height;
1546 }
1547
1548 $thumbUrl = $this->createThumb( $name, $cwidth );
1549
1550 $u = wfLocalUrlE( $link );
1551
1552 $more = wfMsg( "thumbnail-more" );
1553
1554 $s = "<div class=\"thumbnail-{$align}\" style=\"width:{$boxwidth}px;\">" .
1555 "<a href=\"{$u}\" class=\"internal\" title=\"{$label}\">" .
1556 "<img border=\"0\" src=\"{$thumbUrl}\" alt=\"{$label}\" width=\"{$cwidth}\" height=\"{$cheight}\"></a>" .
1557 "<a href=\"{$u}\" class=\"internal\" title=\"{$more}\">" .
1558 "<img border=\"0\" src=\"{$wgUploadPath}/magnify-clip.png\" width=\"26\" height=\"24\" align=\"right\" alt=\"{$more}\"></a>" .
1559 "<p>{$label}</div></p>";
1560 return $s;
1561 }
1562
1563 function makeMediaLink( $name, $url, $alt = "" ) {
1564 $nt = Title::makeTitle( Namespace::getMedia(), $name );
1565 return $this->makeMediaLinkObj( $nt, $alt );
1566 }
1567
1568 function makeMediaLinkObj( $nt, $alt = "" )
1569 {
1570 $name = $nt->getDBKey();
1571 $url = wfImageUrl( $name );
1572 if ( empty( $alt ) ) {
1573 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1574 }
1575
1576 $u = htmlspecialchars( $url );
1577 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1578 return $s;
1579 }
1580
1581 function specialLink( $name, $key = "" )
1582 {
1583 global $wgLang;
1584
1585 if ( "" == $key ) { $key = strtolower( $name ); }
1586 $pn = $wgLang->ucfirst( $name );
1587 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1588 wfMsg( $key ) );
1589 }
1590
1591 # Called by history lists and recent changes
1592 #
1593
1594 function beginRecentChangesList()
1595 {
1596 $rc_cache = array() ;
1597 $rccc = 0 ;
1598 $this->lastdate = "";
1599 return "";
1600 }
1601
1602 function beginImageHistoryList()
1603 {
1604 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1605 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1606 return $s;
1607 }
1608
1609 function endRecentChangesList()
1610 {
1611 $s = $this->recentChangesBlock() ;
1612 $s .= "</ul>\n";
1613 return $s;
1614 }
1615
1616 function endImageHistoryList()
1617 {
1618 $s = "</ul>\n";
1619 return $s;
1620 }
1621
1622 function recentChangesBlockLine ( $y ) {
1623 global $wgUploadPath ;
1624
1625 $M = wfMsg( "minoreditletter" );
1626 $N = wfMsg( "newpageletter" );
1627 $r = "" ;
1628 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ;
1629 $r .= "<tt>" ;
1630 if ( $y->isnew ) $r .= $N ;
1631 else $r .= "&nbsp;" ;
1632 if ( $y->isminor ) $r .= $M ;
1633 else $r .= "&nbsp;" ;
1634 $r .= " ".$y->timestamp." " ;
1635 $r .= "</tt>" ;
1636 $link = $y->link ;
1637 if ( $y->watched ) $link = "<strong>{$link}</strong>" ;
1638 $r .= $link ;
1639
1640 $r .= " (" ;
1641 $r .= $y->curlink ;
1642 $r .= "; " ;
1643 $r .= $this->makeKnownLink( $y->secureName, wfMsg( "hist" ), "action=history" );
1644
1645 $r .= ") . . ".$y->userlink ;
1646 $r .= $y->usertalklink ;
1647 if ( $y->usercomment != "" )
1648 $r .= " <em>(".wfEscapeHTML($y->usercomment).")</em>" ;
1649 $r .= "<br>\n" ;
1650 return $r ;
1651 }
1652
1653 function recentChangesBlockGroup ( $y ) {
1654 global $wgUploadPath ;
1655
1656 $r = "" ;
1657 $M = wfMsg( "minoreditletter" );
1658 $N = wfMsg( "newpageletter" );
1659 $isnew = false ;
1660 $userlinks = array () ;
1661 foreach ( $y AS $x ) {
1662 $oldid = $x->diffid ;
1663 if ( $x->isnew ) $isnew = true ;
1664 $u = $x->userlink ;
1665 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1666 $userlinks[$u]++ ;
1667 }
1668
1669 krsort ( $userlinks ) ;
1670 asort ( $userlinks ) ;
1671 $users = array () ;
1672 $u = array_keys ( $userlinks ) ;
1673 foreach ( $u as $x ) {
1674 $z = $x ;
1675 if ( $userlinks[$x] > 1 ) $z .= " ({$userlinks[$x]}&times;)" ;
1676 array_push ( $users , $z ) ;
1677 }
1678 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1679
1680 $e = $y ;
1681 $e = array_shift ( $e ) ;
1682
1683 # Arrow
1684 $rci = "RCI{$this->rccc}" ;
1685 $rcl = "RCL{$this->rccc}" ;
1686 $rcm = "RCM{$this->rccc}" ;
1687 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1688 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1689 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1690 $tl .= "</a>" ;
1691 $r .= $tl ;
1692
1693 # Main line
1694 $r .= "<tt>" ;
1695 if ( $isnew ) $r .= $N ;
1696 else $r .= "&nbsp;" ;
1697 $r .= "&nbsp;" ; # Minor
1698 $r .= " ".$e->timestamp." " ;
1699 $r .= "</tt>" ;
1700
1701 $link = $e->link ;
1702 if ( $e->watched ) $link = "<strong>{$link}</strong>" ;
1703 $r .= $link ;
1704
1705 if ( !$e->islog ) {
1706 $r .= " (".count($y)." " ;
1707 if ( $isnew ) $r .= wfMsg("changes");
1708 else $r .= $this->makeKnownLink( $e->secureName , wfMsg("changes") , "diff=0&oldid=".$oldid ) ;
1709 $r .= "; " ;
1710 $r .= $this->makeKnownLink( $e->secureName, wfMsg( "history" ), "action=history" );
1711 $r .= ")" ;
1712 }
1713
1714 $r .= $users ;
1715 $r .= "<br>\n" ;
1716
1717 # Sub-entries
1718 $r .= "<div id='{$rci}' style='display:none'>" ;
1719 foreach ( $y AS $x )
1720 {
1721 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1722 $r .= "<tt>&nbsp; &nbsp; &nbsp; &nbsp;" ;
1723 if ( $x->isnew ) $r .= $N ;
1724 else $r .= "&nbsp;" ;
1725 if ( $x->isminor ) $r .= $M ;
1726 else $r .= "&nbsp;" ;
1727 $r .= "</tt>" ;
1728
1729 $o = "" ;
1730 if ( $x->oldid != 0 ) $o = "oldid=".$x->oldid ;
1731 if ( $x->islog ) $link = $x->timestamp ;
1732 else $link = $this->makeKnownLink( $x->secureName, $x->timestamp , $o ) ;
1733 $link = "<tt>{$link}</tt>" ;
1734
1735
1736 $r .= $link ;
1737 $r .= " (" ;
1738 $r .= $x->curlink ;
1739 $r .= "; " ;
1740 $r .= $x->lastlink ;
1741 $r .= ") . . ".$x->userlink ;
1742 $r .= $x->usertalklink ;
1743 if ( $x->usercomment != "" )
1744 $r .= " <em>(".wfEscapeHTML($x->usercomment).")</em>" ;
1745 $r .= "<br>\n" ;
1746 }
1747 $r .= "</div>\n" ;
1748
1749 $this->rccc++ ;
1750 return $r ;
1751 }
1752
1753 function recentChangesBlock ()
1754 {
1755 global $wgUploadPath ;
1756 if ( count ( $this->rc_cache ) == 0 ) return "" ;
1757 $k = array_keys ( $this->rc_cache ) ;
1758 foreach ( $k AS $x )
1759 {
1760 $y = $this->rc_cache[$x] ;
1761 if ( count ( $y ) < 2 ) {
1762 $r .= $this->recentChangesBlockLine ( array_shift ( $y ) ) ;
1763 } else {
1764 $r .= $this->recentChangesBlockGroup ( $y ) ;
1765 }
1766 }
1767
1768 return "<div align=left>{$r}</div>" ;
1769 }
1770
1771 function recentChangesLine( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1772 {
1773 global $wgUser ;
1774 $usenew = $wgUser->getOption( "usenewrc" );
1775 if ( $usenew )
1776 $r = $this->recentChangesLineNew ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1777 else
1778 $r = $this->recentChangesLineOld ( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched , $oldid , $diffid ) ;
1779 return $r ;
1780 }
1781
1782 function recentChangesLineOld( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0, $diffid = 0 )
1783 {
1784 global $wgTitle, $wgLang, $wgUser;
1785
1786 $d = $wgLang->date( $ts, true);
1787 $s = "";
1788 if ( $d != $this->lastdate ) {
1789 if ( "" != $this->lastdate ) { $s .= "</ul>\n"; }
1790 $s .= "<h4>{$d}</h4>\n<ul>";
1791 $this->lastdate = $d;
1792 }
1793 $h = $wgLang->time( $ts, true );
1794 $t = Title::makeName( $ns, $ttl );
1795 $clink = $this->makeKnownLink( $t , "" );
1796 $nt = Title::newFromText( $t );
1797
1798 if ( $watched ) {
1799 $clink = "<strong>{$clink}</strong>";
1800 }
1801 $hlink = $this->makeKnownLink( $t, wfMsg( "hist" ), "action=history" );
1802 if ( $isnew || $nt->isLog() ) {
1803 $dlink = wfMsg( "diff" );
1804 } else {
1805 $dlink = $this->makeKnownLink( $t, wfMsg( "diff" ),
1806 "diff={$oldid}&oldid={$diffid}" ); # Finagle's law
1807 }
1808 if ( 0 == $u ) {
1809 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1810 $ut, "target=" . $ut );
1811 } else {
1812 $ul = $this->makeLink( $wgLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
1813 }
1814
1815 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1816 global $wgDisableAnonTalk;
1817 if( 0 == $u && $wgDisableAnonTalk ) {
1818 $utl = "";
1819 } else {
1820 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1821 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1822 }
1823 $cr = wfMsg( "currentrev" );
1824
1825 $s .= "<li> ({$dlink}) ({$hlink}) . .";
1826 $M = wfMsg( "minoreditletter" );
1827 $N = wfMsg( "newpageletter" );
1828 if ( $isminor ) { $s .= " <strong>{$M}</strong>"; }
1829 if ( $isnew ) { $s .= "<strong>{$N}</strong>"; }
1830 $s .= " {$clink}; {$h} . . {$ul}";
1831
1832 $blink="";
1833 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1834 $blink = $this->makeKnownLink( $wgLang->specialPage(
1835 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1836
1837 }
1838 if($blink) {
1839 if($utl) $utl .= " | ";
1840 $utl .= $blink;
1841 }
1842 if($utl) $s.=" ({$utl})";
1843
1844 if ( "" != $c && "*" != $c ) {
1845 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1846 }
1847 $s .= "</li>\n";
1848
1849 return $s;
1850 }
1851
1852 function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1853 {
1854 global $wgTitle, $wgLang, $wgUser;
1855
1856 $rc = new RecentChangesClass ;
1857
1858 $d = $wgLang->date( $ts, true);
1859 $s = "";
1860 $ret = "" ;
1861 if ( $d != $this->lastdate ) {
1862 $ret = $this->recentChangesBlock () ;
1863 $this->rc_cache = array() ;
1864 $ret .= "<h4>{$d}</h4>\n";
1865 $this->lastdate = $d;
1866 }
1867 $h = $wgLang->time( $ts, true );
1868 $t = Title::makeName( $ns, $ttl );
1869 $clink = $this->makeKnownLink( $t, "" ) ;
1870 if ( $oldid == 0 ) $c2link = $clink ;
1871 else $c2link = $this->makeKnownLink( $t, "" , "oldid={$oldid}" );
1872 $nt = Title::newFromText( $t );
1873
1874 $rc->timestamp = $h ;
1875 $rc->oldid = $oldid ;
1876 $rc->diffid = $diffid ;
1877 $rc->watched = $watched ;
1878 $rc->isnew = $isnew ;
1879 $rc->isminor = $isminor ;
1880 $rc->secureName = $t ;
1881 $rc->displayName = $nt ;
1882 $rc->link = $clink ;
1883 $rc->usercomment = $c ;
1884 $rc->islog = $nt->isLog() ;
1885
1886 if ( ( $isnew && $oldid == 0 ) || $nt->isLog() ) {
1887 $dlink = wfMsg( "cur" );
1888 } else {
1889 $dlink = $this->makeKnownLink( $t, wfMsg( "cur" ),
1890 "diff=0&oldid={$oldid}" );
1891 }
1892
1893 if ( $diffid == 0 || $nt->isLog() ) {
1894 $plink = wfMsg( "last" );
1895 } else {
1896 $plink = $this->makeKnownLink( $t, wfMsg( "last" ),
1897 "diff={$oldid}&oldid={$diffid}" );
1898 }
1899
1900 if ( 0 == $u ) {
1901 $ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1902 $ut, "target=" . $ut );
1903 } else { $ul = $this->makeLink( $wgLang->getNsText(
1904 Namespace::getUser() ) . ":{$ut}", $ut ); }
1905
1906 $rc->userlink = $ul ;
1907 $rc->lastlink = $plink ;
1908 $rc->curlink = $dlink ;
1909
1910 $utns=$wgLang->getNsText(Namespace::getTalk(Namespace::getUser()));
1911 $talkname=$wgLang->getNsText(Namespace::getTalk(0)); # use the shorter name
1912 $utl= $this->makeLink($utns . ":{$ut}", $talkname );
1913
1914 global $wgDisableAnonTalk;
1915 if ( ( 0 == $u ) && $wgUser->isSysop() ) {
1916 $blink = $this->makeKnownLink( $wgLang->specialPage(
1917 "Blockip" ), wfMsg( "blocklink" ), "ip={$ut}" );
1918 if( $wgDisableAnonTalk )
1919 $rc->usertalklink = " ({$blink})";
1920 else
1921 $rc->usertalklink = " ({$utl} | {$blink})";
1922 } else {
1923 if( $wgDisableAnonTalk && ($u == 0) )
1924 $rc->usertalklink = "";
1925 else
1926 $rc->usertalklink = " ({$utl})";
1927 }
1928
1929 if ( !isset ( $this->rc_cache[$t] ) ) $this->rc_cache[$t] = array() ;
1930 array_push ( $this->rc_cache[$t] , $rc ) ;
1931 return $ret;
1932 }
1933
1934
1935 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
1936 {
1937 global $wgUser, $wgLang, $wgTitle;
1938
1939 $dt = $wgLang->timeanddate( $ts, true );
1940 $del = wfMsg( "deleteimg" );
1941 $cur = wfMsg( "cur" );
1942
1943 if ( $iscur ) {
1944 $url = wfImageUrl( $img );
1945 $rlink = $cur;
1946 if ( $wgUser->isSysop() ) {
1947 $link = wfLocalUrlE( $wgTitle->getPrefixedText(), "image=" . $wgTitle->getURL() .
1948 "&action=delete" );
1949 $style = $this->getInternalLinkAttributes( $link, $del );
1950
1951 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
1952 } else {
1953 $dlink = $del;
1954 }
1955 } else {
1956 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
1957 if( $wgUser->getID() != 0 ) {
1958 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1959 wfMsg( "revertimg" ), "action=revert&oldimage=" .
1960 urlencode( $img ) );
1961 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1962 $del, "action=delete&oldimage=" . urlencode( $img ) );
1963 } else {
1964 # Having live active links for non-logged in users
1965 # means that bots and spiders crawling our site can
1966 # inadvertently change content. Baaaad idea.
1967 $rlink = wfMsg( "revertimg" );
1968 $dlink = $del;
1969 }
1970 }
1971 if ( 0 == $u ) { $ul = $ut; }
1972 else { $ul = $this->makeLink( $wgLang->getNsText(
1973 Namespace::getUser() ) . ":{$ut}", $ut ); }
1974
1975 $nb = wfMsg( "nbytes", $size );
1976 $style = $this->getInternalLinkAttributes( $url, $dt );
1977
1978 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
1979 . " . . {$ul} ({$nb})";
1980
1981 if ( "" != $c && "*" != $c ) {
1982 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
1983 }
1984 $s .= "</li>\n";
1985 return $s;
1986 }
1987
1988 function tocIndent($level) {
1989
1990 while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
1991 return $rv;
1992
1993 }
1994
1995 function tocUnindent($level) {
1996 $rv = "";
1997 while($level-->0) $rv.="</div>\n";
1998 return $rv;
1999 }
2000
2001 // parameter level defines if we are on an indentation level
2002 function tocLine($anchor,$tocline,$level) {
2003
2004 if($level) {
2005
2006 return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
2007 } else {
2008
2009 return "<div style=\"margin-bottom:0px;\">\n".
2010 "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
2011 "</div>\n";
2012 }
2013
2014 }
2015
2016 function tocTable($toc) {
2017 // note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2018 global $printable;
2019
2020 if (!$printable) {
2021 $hideline = " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>";
2022 }
2023 return
2024 "<p><table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
2025 "<b>".wfMsg("toc")."</b>" .
2026 $hideline .
2027 "</td></tr><tr id='tocinside'><td align=\"left\">\n".
2028 $toc."</td></tr></table><P>\n";
2029 }
2030
2031 # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
2032 function editSectionScript($section,$head) {
2033
2034 global $wgTitle,$wgUser,$oldid;
2035 if($oldid) return $head;
2036 $url = wfLocalUrlE(urlencode($wgTitle->getPrefixedText()),"action=edit&section=$section");
2037 return "<span onContextMenu='document.location=\"".$url."\";return false;'>{$head}</span>";
2038 }
2039
2040 function editSectionLink($section) {
2041
2042 global $printable;
2043 global $wgTitle,$wgUser,$oldid;
2044 if($oldid) return "";
2045 if ($printable) return "";
2046 $editurl="&section={$section}";
2047 $url=$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
2048 return "<div style=\"float:right;margin-left:5px;\"><small>[".$url."]</small></div>";
2049
2050 }
2051
2052 // This function is called by EditPage.php and shows a bulletin board style
2053 // toolbar for common editing functions. It can be disabled in the user preferences.
2054 // The necsesary JavaScript code can be found in style/wikibits.js.
2055 function getEditToolbar() {
2056
2057 global $wgUploadPath;
2058
2059 // toolarray an array of arrays which each include the filename of
2060 // the button image (without path), the opening tag, the closing tag,
2061 // and optionally a sample text that is inserted between the two when no
2062 // selection is highlighted.
2063 // The tip text is shown when the user moves the mouse over the button.
2064 $toolarray=array(
2065 array( "image"=>"button_bold.gif",
2066 "open"=>"\\'\\'\\'",
2067 "close"=>"\\'\\'\\'",
2068 "sample"=>wfMsg("bold_sample"),
2069 "tip"=>wfMsg("bold_tip")),
2070 array( "image"=>"button_italic.gif",
2071 "open"=>"\\'\\'",
2072 "close"=>"\\'\\'",
2073 "sample"=>wfMsg("italic_sample"),
2074 "tip"=>wfMsg("italic_tip")),
2075 array( "image"=>"button_link.gif",
2076 "open"=>"[[",
2077 "close"=>"]]",
2078 "sample"=>wfMsg("link_sample"),
2079 "tip"=>wfMsg("link_tip")),
2080 array( "image"=>"button_extlink.gif",
2081 "open"=>"[",
2082 "close"=>"]",
2083 "sample"=>wfMsg("extlink_sample"),
2084 "tip"=>wfMsg("extlink_tip")),
2085 array( "image"=>"button_headline.gif",
2086 "open"=>"\\n== ",
2087 "close"=>" ==\\n",
2088 "sample"=>wfMsg("headline_sample"),
2089 "tip"=>wfMsg("headline_tip")),
2090 array( "image"=>"button_math.gif",
2091 "open"=>"\\<math\\>",
2092 "close"=>"\\</math\\>",
2093 "sample"=>wfMsg("math_sample"),
2094 "tip"=>wfMsg("math_tip")),
2095 array( "image"=>"button_image.gif",
2096 "open"=>"[[Image:",
2097 "close"=>"]]",
2098 "sample"=>wfMsg("image_sample"),
2099 "tip"=>wfMsg("image_tip")),
2100 array( "image"=>"button_media.gif",
2101 "open"=>"[[Media:",
2102 "close"=>"]]",
2103 "sample"=>wfMsg("media_sample"),
2104 "tip"=>wfMsg("media_tip")),
2105 array( "image"=>"button_sig.gif",
2106 "open"=>"--~~~~",
2107 "close"=>"",
2108 "sample"=>"",
2109 "tip"=>wfMsg("sig_tip")),
2110 array( "image"=>"button_hr.gif",
2111 "open"=>"\\n----\\n",
2112 "close"=>"",
2113 "sample"=>"",
2114 "tip"=>wfMsg("hr_tip"))
2115 );
2116 $toolbar.="
2117 <div id=\"toolbar\">";
2118 foreach($toolarray as $tool) {
2119
2120 $image=$tool["image"];
2121 $open=$tool["open"];
2122 $close=$tool["close"];
2123 $sample=$tool["sample"];
2124
2125 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
2126 // Older browsers show a "speedtip" type message only for ALT.
2127 // Ideally these should be different, realistically they
2128 // probably don't need to be.
2129 $tip=$tool["tip"];
2130
2131 $toolbar.=
2132 "<a href=\"#\"".
2133 "onclick=\"javascript:insertTags('$open','$close','$sample');\">".
2134 "<img src=\"$wgUploadPath/$image\" border=\"0\" ALT=\"$tip\" TITLE=\"$tip\">".
2135 "</a>";
2136
2137 }
2138
2139 $toolbar.="</div>";
2140 return $toolbar;
2141
2142 }
2143 }
2144
2145 include_once( "SkinStandard.php" );
2146 include_once( "SkinNostalgia.php" );
2147 include_once( "SkinCologneBlue.php" );
2148
2149 #include_once( "SkinSmarty.php" );
2150
2151 ?>