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