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