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