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