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