4 # These are the INTERNAL names, which get mapped
5 # directly to class names. For display purposes, the
6 # Language class has internationalized names
8 /* private */ $wgValidSkinNames = array(
9 "Standard", "Nostalgia", "CologneBlue" #, "Smarty", "Montparnasse"
12 include_once( "RecentChange.php" );
14 # For some odd PHP bug, this function can't be part of a class
15 function getCategories ()
17 global $wgOut , $wgTitle , $wgUseCategoryMagic , $wgUser ;
18 if ( !isset ( $wgUseCategoryMagic ) ||
!$wgUseCategoryMagic ) return "" ;
19 if ( count ( $wgOut->mCategoryLinks
) == 0 ) return "" ;
20 if ( !$wgOut->isArticle() ) return "" ;
21 $sk = $wgUser->getSkin() ;
24 $s .= $sk->makeKnownLink ( "Special:Categories" , "Categories" , "article=".$wgTitle->getDBkey() ) ;
25 $t = implode ( " | " , $wgOut->mCategoryLinks
) ;
26 if ( $t != "" ) $s .= " : " ;
31 class RCCacheEntry
extends RecentChange
33 var $secureName, $link;
34 var $curlink , $lastlink , $usertalklink , $versionlink ;
35 var $userlink, $timestamp, $watched;
37 function newFromParent( $rc )
39 $rc2 = new RCCacheEntry
;
40 $rc2->mAttribs
= $rc->mAttribs
;
41 $rc2->mExtra
= $rc->mExtra
;
48 /* private */ var $lastdate, $lastline;
50 var $rc_cache ; # Cache for Enhanced Recent Changes
51 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
58 function getSkinNames()
60 global $wgValidSkinNames;
61 return $wgValidSkinNames;
64 function getStylesheet()
66 return "wikistandard.css";
71 global $wgOut, $wgUser;
73 if ( $wgOut->isQuickbarSupressed() ) { return 0; }
74 $q = $wgUser->getOption( "quickbar" );
75 if ( "" == $q ) { $q = 0; }
79 function initPage( &$out )
81 global $wgStyleSheetPath;
82 $fname = "Skin::initPage";
83 wfProfileIn( $fname );
85 $out->addLink( "shortcut icon", "", "/favicon.ico" );
86 if ( $out->isPrintable() ) { $ss = "wikiprintable.css"; }
87 else { $ss = $this->getStylesheet(); }
88 $out->addLink( "stylesheet", "", "{$wgStyleSheetPath}/{$ss}" );
89 wfProfileOut( $fname );
92 function outputPage( &$out ) {
93 global $wgDebugComments;
95 wfProfileIn( "Skin::outputPage" );
96 $this->initPage( $out );
97 $out->out( $out->headElement() );
99 $out->out( "\n<body" );
100 $ops = $this->getBodyOptions();
101 foreach ( $ops as $name => $val ) {
102 $out->out( " $name='$val'" );
105 if ( $wgDebugComments ) {
106 $out->out( "<!-- Wiki debugging output:\n" .
107 $out->mDebugtext
. "-->\n" );
109 $out->out( $this->beforeContent() );
111 $out->out( $out->mBodytext
);
113 $out->out( $this->afterContent() );
116 $out->out( $out->reportTime() );
118 $out->out( "\n</body></html>" );
121 function getHeadScripts() {
122 global $wgStyleSheetPath;
123 $r = "<script type=\"text/javascript\" src=\"{$wgStyleSheetPath}/wikibits.js\"></script>\n";
127 function getUserStyles()
129 $s = "<style type='text/css'><!--\n";
130 $s .= $this->doGetUserStyles();
131 $s .= "//--></style>\n";
135 function doGetUserStyles()
140 if ( 1 == $wgUser->getOption( "underline" ) ) {
141 # Don't override browser settings
145 $s .= "a.stub, a.new, a.internal, a.external { " .
146 "text-decoration: none; }\n";
148 if ( 1 == $wgUser->getOption( "highlightbroken" ) ) {
149 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
151 if ( 1 == $wgUser->getOption( "justify" ) ) {
152 $s .= "#article { text-align: justify; }\n";
157 function getBodyOptions()
159 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $oldid, $redirect, $diff,$action;
161 if ( 0 != $wgTitle->getNamespace() ) {
162 $a = array( "bgcolor" => "#ffffec" );
164 else $a = array( "bgcolor" => "#FFFFFF" );
165 if($wgOut->isArticle() && $wgUser->getOption("editondblclick")
167 (!$wgTitle->isProtected() ||
$wgUser->isSysop())
170 $n = $wgTitle->getPrefixedURL();
171 $t = wfMsg( "editthispage" );
173 if ( $redirect ) { $red = "&redirect={$redirect}"; }
174 if ( $oldid && ! isset( $diff ) ) {
175 $oid = "&oldid={$oldid}";
177 $s = wfLocalUrlE($n,"action=edit{$oid}{$red}");
178 $s = "document.location = \"" .$s ."\";";
179 $a +
= array ("ondblclick" => $s);
182 $a['onload'] = $wgOut->getOnloadHandler();
186 function getExternalLinkAttributes( $link, $text )
188 global $wgUser, $wgOut, $wgLang;
190 $link = urldecode( $link );
191 $link = $wgLang->checkTitleEncoding( $link );
192 $link = str_replace( "_", " ", $link );
193 $link = wfEscapeHTML( $link );
195 if ( $wgOut->isPrintable() ) { $r = " class='printable'"; }
196 else { $r = " class='external'"; }
198 if ( 1 == $wgUser->getOption( "hover" ) ) {
199 $r .= " title=\"{$link}\"";
204 function getInternalLinkAttributes( $link, $text, $broken = false )
206 global $wgUser, $wgOut;
208 $link = urldecode( $link );
209 $link = str_replace( "_", " ", $link );
210 $link = wfEscapeHTML( $link );
212 if ( $wgOut->isPrintable() ) {
213 $r = " class='printable'";
214 } else if ( $broken == "stub" ) {
215 $r = " class='stub'";
216 } else if ( $broken == "yes" ) {
219 $r = " class='internal'";
222 if ( 1 == $wgUser->getOption( "hover" ) ) {
223 $r .= " title=\"{$link}\"";
228 function getInternalLinkAttributesObj( &$nt, $text, $broken = false )
230 global $wgUser, $wgOut;
232 if ( $wgOut->isPrintable() ) {
233 $r = " class='printable'";
234 } else if ( $broken == "stub" ) {
235 $r = " class='stub'";
236 } else if ( $broken == "yes" ) {
239 $r = " class='internal'";
242 if ( 1 == $wgUser->getOption( "hover" ) ) {
243 $r .= ' title ="' . $nt->getEscapedText() . '"';
254 # This will be called immediately after the <body> tag. Split into
255 # two functions to make it easier to subclass.
257 function beforeContent()
259 global $wgUser, $wgOut, $wgSiteNotice;
261 if ( $wgOut->isPrintable() ) {
262 $s = $this->pageTitle() . $this->pageSubtitle() . "\n";
263 $s .= "\n<div class='bodytext'>";
266 if( $wgSiteNotice ) {
267 $note = "\n<div id='notice' style='font-weight: bold; color: red; text-align: center'>$wgSiteNotice</div>\n";
271 return $this->doBeforeContent() . $note;
274 function doBeforeContent()
276 global $wgUser, $wgOut, $wgTitle, $wgLang;
277 $fname = "Skin::doBeforeContent";
278 wfProfileIn( $fname );
281 $qb = $this->qbSetting();
283 if( $langlinks = $this->otherLanguages() ) {
289 $borderhack = "class='top'";
292 $s .= "\n<div id='content'>\n<div id='topbar'>" .
293 "<table width='98%' border=0 cellspacing=0><tr>";
296 $left = ($qb == 1 ||
$qb == 3);
297 if($wgLang->isRTL()) $left = !$left;
300 $s .= "<td class='top' align=left valign=top rowspan='{$rows}'>" .
301 $this->logoText() . "</td>";
303 $s .= $this->getQuickbarCompensator( $rows );
305 $l = $wgLang->isRTL() ?
"right" : "left";
306 $s .= "<td {$borderhack} align='$l' valign='top'>";
308 $s .= $this->topLinks() ;
309 $s .= "<p class='subtitle'>" . $this->pageTitleLinks();
311 $r = $wgLang->isRTL() ?
"left" : "right";
312 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap>";
313 $s .= $this->nameAndLogin();
314 $s .= "\n<br>" . $this->searchForm() . "</td>";
317 $s .= "</tr>\n<tr><td class='top' colspan=\"2\">$langlinks</td>";
320 if ( $shove && !$left ) { # Right
321 $s .= $this->getQuickbarCompensator( $rows );
323 $s .= "</tr></table>\n</div>\n";
324 $s .= "\n<div id='article'>";
326 $s .= $this->pageTitle();
327 $s .= $this->pageSubtitle() ;
328 $s .= getCategories(); // For some odd reason, zhis can't be a function of the object
330 wfProfileOut( $fname );
334 function getQuickbarCompensator( $rows = 1 )
336 return "<td width='152' rowspan='{$rows}'> </td>";
339 # This gets called immediately before the </body> tag.
341 function afterContent()
343 global $wgUser, $wgOut, $wgServer;
346 if ( $wgOut->isPrintable() ) {
349 $u = htmlspecialchars( $wgServer . $wgTitle->getFullURL() );
350 $u = "<a href=\"$u\">$u</a>";
351 $rf = wfMsg( "retrievedfrom", $u );
353 if ( $wgOut->isArticle() ) {
354 $lm = "<br>" . $this->lastModified();
357 $cr = wfMsg( "gnunote" );
358 $s .= "<p><em>{$rf}{$lm} {$cr}</em>\n";
361 return $this->doAfterContent();
364 function doAfterContent()
366 global $wgUser, $wgOut, $wgLang;
367 $fname = "Skin::doAfterContent";
368 wfProfileIn( $fname );
369 wfProfileIn( "$fname-1" );
371 $s = "\n</div><br clear=all>\n";
372 $s .= "\n<div id='footer'>";
373 $s .= "<table width='98%' border=0 cellspacing=0><tr>";
375 wfProfileOut( "$fname-1" );
376 wfProfileIn( "$fname-2" );
378 $qb = $this->qbSetting();
380 $left = ($qb == 1 ||
$qb == 3);
381 if($wgLang->isRTL()) $left = !$left;
383 if ( $shove && $left ) { # Left
384 $s .= $this->getQuickbarCompensator();
386 wfProfileOut( "$fname-2" );
387 wfProfileIn( "$fname-3" );
388 $l = $wgLang->isRTL() ?
"right" : "left";
389 $s .= "<td class='bottom' align='$l' valign='top'>";
391 $s .= $this->bottomLinks();
392 $s .= "\n<br>" . $this->mainPageLink()
393 . " | " . $this->aboutLink()
394 . " | " . $this->specialLink( "recentchanges" )
395 . " | " . $this->searchForm()
396 . "<br>" . $this->pageStats();
399 if ( $shove && !$left ) { # Right
400 $s .= $this->getQuickbarCompensator();
402 $s .= "</tr></table>\n</div>\n</div>\n";
404 wfProfileOut( "$fname-3" );
405 wfProfileIn( "$fname-4" );
406 if ( 0 != $qb ) { $s .= $this->quickBar(); }
407 wfProfileOut( "$fname-4" );
408 wfProfileOut( $fname );
412 function pageTitleLinks()
414 global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang, $wgUseApproval ;
416 $s = $this->printableLink();
417 if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ;
419 if ( $wgOut->isArticleRelated() ) {
420 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
421 $name = $wgTitle->getDBkey();
422 $link = wfEscapeHTML( wfImageUrl( $name ) );
423 $style = $this->getInternalLinkAttributes( $link, $name );
424 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
426 # This will show the "Approve" link if $wgUseApproval=true;
427 if ( isset ( $wgUseApproval ) && $wgUseApproval )
429 $t = $wgTitle->getDBkey();
430 $name = "Approve this article" ;
431 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
432 #wfEscapeHTML( wfImageUrl( $name ) );
433 $style = $this->getExternalLinkAttributes( $link, $name );
434 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
437 if ( "history" == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
438 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
439 wfMsg( "currentrev" ) );
442 if ( $wgUser->getNewtalk() ) {
443 # do not show "You have new messages" text when we are viewing our
446 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
447 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
448 $n =$wgUser->getName();
449 $tl = $this->makeKnownLink( $wgLang->getNsText(
450 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
451 wfMsg("newmessageslink") );
452 $s.=" | <strong>". wfMsg( "newmessages", $tl ) . "</strong>";
455 if( $wgUser->isSysop() &&
456 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
457 ($n = $wgTitle->isDeleted() ) ) {
458 $s .= " | " . wfMsg( "thisisdeleted",
459 $this->makeKnownLink(
460 $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ),
461 wfMsg( "restorelink", $n ) ) );
466 function printableLink()
468 global $wgOut, $wgTitle, $oldid, $action;
471 foreach( $_GET as $var => $val ) {
472 if( $var != "title" && $var != "printable" )
473 $q .= urlencode( $var ) . "=" . urlencode( $val );
475 if( !empty( $q ) ) $q .= "&";
477 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
478 WfMsg( "printableversion" ), "{$q}printable=yes" );
484 global $wgOut, $wgTitle, $wgUser;
486 $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
487 if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
491 function pageSubtitle()
493 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
495 $sub = $wgOut->getSubtitle();
497 global $wgExtraSubtitle;
498 $sub = wfMsg( "fromwikipedia" ) . $wgExtraSubtitle;
500 if($wgOut->isArticle() && $wgNamespacesWithSubpages[$wgTitle->getNamespace()]) {
501 $ptext=$wgTitle->getPrefixedText();
502 if(preg_match("/\//",$ptext)) {
503 $sub.="</p><p class='subpages'>";
504 $links=explode("/",$ptext);
507 foreach($links as $link) {
509 if ($c<count($links)) {
510 $growinglink .= $link;
511 $getlink = $this->makeLink( $growinglink, $link );
512 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
525 $s = "<p class='subtitle'>{$sub}\n";
529 function nameAndLogin()
531 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader;
533 $li = $wgLang->specialPage( "Userlogin" );
534 $lo = $wgLang->specialPage( "Userlogout" );
537 if ( 0 == $wgUser->getID() ) {
538 if( $wgShowIPinHeader ) {
539 $n = getenv( "REMOTE_ADDR" );
541 $tl = $this->makeKnownLink( $wgLang->getNsText(
542 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
543 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
545 $s .= $n . " (".$tl.")";
547 $s .= wfMsg("notloggedin");
550 $rt = $wgTitle->getPrefixedURL();
551 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
553 } else { $q = "returnto={$rt}"; }
555 $s .= "\n<br>" . $this->makeKnownLink( $li,
556 wfMsg( "login" ), $q );
558 $n = $wgUser->getName();
559 $rt = $wgTitle->getPrefixedURL();
560 $tl = $this->makeKnownLink( $wgLang->getNsText(
561 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
562 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
566 $s .= $this->makeKnownLink( $wgLang->getNsText(
567 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br>" .
568 $this->makeKnownLink( $lo, wfMsg( "logout" ),
569 "returnto={$rt}" ) . " | " .
570 $this->specialLink( "preferences" );
572 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
578 function searchForm()
582 $s = "<form name='search' class='inline' method=get action=\""
583 . wfLocalUrl( "" ) . "\">"
584 . "<input type=text name=\"search\" size=19 value=\""
585 . htmlspecialchars(substr($search,0,256)) . "\">\n"
586 . "<input type=submit name=\"go\" value=\"" . wfMsg ("go") . "\"> "
587 . "<input type=submit value=\"" . wfMsg ("search") . "\"></form>";
597 $s = $this->mainPageLink() . $sep
598 . $this->specialLink( "recentchanges" );
600 if ( $wgOut->isArticleRelated() ) {
601 $s .= $sep . $this->editThisPage()
602 . $sep . $this->historyLink();
604 # Many people don't like this dropdown box
605 #$s .= $sep . $this->specialPagesList();
610 function bottomLinks()
612 global $wgOut, $wgUser, $wgTitle;
616 if ( $wgOut->isArticleRelated() ) {
617 $s .= "<strong>" . $this->editThisPage() . "</strong>";
618 if ( 0 != $wgUser->getID() ) {
619 $s .= $sep . $this->watchThisPage();
621 $s .= $sep . $this->talkLink()
622 . $sep . $this->historyLink()
623 . $sep . $this->whatLinksHere()
624 . $sep . $this->watchPageLinksLink();
626 if ( $wgTitle->getNamespace() == Namespace::getUser()
627 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
630 $id=User
::idFromName($wgTitle->getText());
631 $ip=User
::isIP($wgTitle->getText());
633 if($id ||
$ip) { # both anons and non-anons have contri list
634 $s .= $sep . $this->userContribsLink();
636 if ( 0 != $wgUser->getID() ) { # show only to signed in users
637 if($id) { # can only email non-anons
638 $s .= $sep . $this->emailUserLink();
642 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
643 $s .= "\n<br>" . $this->deleteThisPage() .
644 $sep . $this->protectThisPage() .
645 $sep . $this->moveThisPage();
647 $s .= "<br>\n" . $this->otherLanguages();
654 global $wgOut, $wgLang, $wgArticle;
655 global $oldid, $diff, $wgDisableCounters;
657 if ( ! $wgOut->isArticle() ) { return ""; }
658 if ( isset( $oldid ) ||
isset( $diff ) ) { return ""; }
659 if ( 0 == $wgArticle->getID() ) { return ""; }
661 if ( $wgDisableCounters ) {
664 $count = $wgArticle->getCount();
665 $s = wfMsg( "viewcount", $count );
667 $s .= $this->lastModified();
668 $s .= " " . wfMsg( "gnunote" );
669 return "<span id='pagestats'>{$s}</span>";
672 function lastModified()
674 global $wgLang, $wgArticle;
676 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
677 $s = " " . wfMsg( "lastmodified", $d );
681 function logoText( $align = "" )
683 if ( "" != $align ) { $a = " align='{$align}'"; }
686 $mp = wfMsg( "mainpage" );
687 $s = "<a href=\"" . wfLocalUrlE( urlencode( $mp ) )
688 . "\"><img{$a} border=0 src=\""
689 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
695 global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
696 global $wpPreview, $wgDisableUploads, $wgRemoteUploads;
698 $fname = "Skin::quickBar";
699 wfProfileIn( $fname );
701 $tns=$wgTitle->getNamespace();
703 $s = "\n<div id='quickbar'>";
704 $s .= "\n" . $this->logoText() . "\n<hr class='sep'>";
707 $s .= $this->mainPageLink()
708 . $sep . $this->specialLink( "recentchanges" )
709 . $sep . $this->specialLink( "randompage" );
710 if ($wgUser->getID()) {
711 $s.= $sep . $this->specialLink( "watchlist" ) ;
712 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
713 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
716 // only show watchlist link if logged in
717 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
718 $s .= "\n<br><hr class='sep'>";
719 $articleExists = $wgTitle->getArticleId();
720 if ( $wgOut->isArticle() ||
$action =="edit" ||
$action =="history" ||
$wpPreview) {
721 if($wgOut->isArticle()) {
722 $s .= "<strong>" . $this->editThisPage() . "</strong>";
723 } else { # backlink to the article in edit or history mode
724 if($articleExists){ # no backlink if no article
727 $text = wfMsg("articlepage");
730 $text = wfMsg("viewtalkpage");
733 $text = wfMsg("userpage");
736 $text = wfMsg("viewtalkpage");
739 $text = wfMsg("wikipediapage");
742 $text = wfMsg("viewtalkpage");
745 $text = wfMsg("imagepage");
748 $text = wfMsg("viewtalkpage");
751 $text= wfMsg("articlepage");
754 $link = $wgTitle->getText();
755 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
756 $link = $nstext . ":" . $link ;
759 $s .= $this->makeLink( $link, $text );
760 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
761 # we just throw in a "New page" text to tell the user that he's in edit mode,
762 # and to avoid messing with the separator that is prepended to the next item
763 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
769 if( $tns%2
&& $action!="edit" && !$wpPreview) {
770 $s.="<br>".$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("postcomment"),"action=edit§ion=new");
774 watching could cause problems in edit mode:
775 if user edits article, then loads "watch this article" in background and then saves
776 article with "Watch this article" checkbox disabled, the article is transparently
777 unwatched. Therefore we do not show the "Watch this page" link in edit mode
779 if ( 0 != $wgUser->getID() && $articleExists) {
780 if($action!="edit" && $action != "submit" )
782 $s .= $sep . $this->watchThisPage();
784 if ( $wgTitle->userCanEdit() )
785 $s .= $sep . $this->moveThisPage();
787 if ( $wgUser->isSysop() and $articleExists ) {
788 $s .= $sep . $this->deleteThisPage() .
789 $sep . $this->protectThisPage();
791 $s .= $sep . $this->talkLink();
792 if ($articleExists && $action !="history") {
793 $s .= $sep . $this->historyLink();
795 $s.=$sep . $this->whatLinksHere();
797 if($wgOut->isArticleRelated()) {
798 $s .= $sep . $this->watchPageLinksLink();
801 if ( Namespace::getUser() == $wgTitle->getNamespace()
802 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
805 $id=User
::idFromName($wgTitle->getText());
806 $ip=User
::isIP($wgTitle->getText());
809 $s .= $sep . $this->userContribsLink();
811 if ( 0 != $wgUser->getID() ) {
812 if($id) { # can only email real users
813 $s .= $sep . $this->emailUserLink();
817 $s .= "\n<br><hr class='sep'>";
820 if ( 0 != $wgUser->getID() && ( !$wgDisableUploads ||
$wgRemoteUploads ) ) {
821 $s .= $this->specialLink( "upload" ) . $sep;
823 $s .= $this->specialLink( "specialpages" )
824 . $sep . $this->bugReportsLink();
826 global $wgSiteSupportPage;
827 if( $wgSiteSupportPage ) {
828 $s .= "\n<br><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
829 "\" class=\"internal\">" . wfMsg( "sitesupport" ) . "</a>";
832 $s .= "\n<br></div>\n";
833 wfProfileOut( $fname );
837 function specialPagesList()
839 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
842 $validSP = $wgLang->getValidSpecialPages();
844 foreach ( $validSP as $name => $desc ) {
845 if ( "" == $desc ) { continue; }
848 if ( $wgUser->isSysop() )
850 $sysopSP = $wgLang->getSysopSpecialPages();
852 foreach ( $sysopSP as $name => $desc ) {
853 if ( "" == $desc ) { continue; }
857 if ( $wgUser->isDeveloper() )
859 $devSP = $wgLang->getDeveloperSpecialPages();
861 foreach ( $devSP as $name => $desc ) {
862 if ( "" == $desc ) { continue; }
867 $sp = wfMsg( "specialpages" );
868 $spp = $wgLang->specialPage( "Specialpages" );
870 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
871 "action=\"{$wgServer}{$wgRedirectScript}\">\n";
872 $s .= "<select name=\"wpDropdown\">\n";
873 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
875 foreach ( $a as $name => $desc ) {
876 $p = $wgLang->specialPage( $name );
877 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
880 $s .= "<input type=submit value=\"{$go}\" name=redirect>\n";
885 function mainPageLink()
887 $mp = wfMsg( "mainpage" );
888 $s = $this->makeKnownLink( $mp, $mp );
892 function copyrightLink()
894 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
895 wfMsg( "copyrightpagename" ) );
901 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
902 wfMsg( "aboutwikipedia" ) );
907 function disclaimerLink()
909 $s = $this->makeKnownLink( wfMsg( "disclaimerpage" ),
910 wfMsg( "disclaimers" ) );
914 function editThisPage()
916 global $wgOut, $wgTitle, $oldid, $redirect, $diff;
918 if ( ! $wgOut->isArticleRelated() ) {
919 $s = wfMsg( "protectedpage" );
921 $n = $wgTitle->getPrefixedText();
922 if ( $wgTitle->userCanEdit() ) {
923 $t = wfMsg( "editthispage" );
925 #$t = wfMsg( "protectedpage" );
926 $t = wfMsg( "viewsource" );
930 if ( $redirect ) { $red = "&redirect={$redirect}"; }
931 if ( $oldid && ! isset( $diff ) ) {
932 $oid = "&oldid={$oldid}";
934 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
939 function deleteThisPage()
941 global $wgUser, $wgOut, $wgTitle, $diff;
943 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
944 $n = $wgTitle->getPrefixedText();
945 $t = wfMsg( "deletethispage" );
947 $s = $this->makeKnownLink( $n, $t, "action=delete" );
954 function protectThisPage()
956 global $wgUser, $wgOut, $wgTitle, $diff;
958 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
959 $n = $wgTitle->getPrefixedText();
961 if ( $wgTitle->isProtected() ) {
962 $t = wfMsg( "unprotectthispage" );
963 $q = "action=unprotect";
965 $t = wfMsg( "protectthispage" );
966 $q = "action=protect";
968 $s = $this->makeKnownLink( $n, $t, $q );
975 function watchThisPage()
977 global $wgUser, $wgOut, $wgTitle, $diff;
979 if ( $wgOut->isArticleRelated() ) {
980 $n = $wgTitle->getPrefixedText();
982 if ( $wgTitle->userIsWatching() ) {
983 $t = wfMsg( "unwatchthispage" );
984 $q = "action=unwatch";
986 $t = wfMsg( "watchthispage" );
989 $s = $this->makeKnownLink( $n, $t, $q );
991 $s = wfMsg( "notanarticle" );
996 function moveThisPage()
998 global $wgTitle, $wgLang;
1000 if ( $wgTitle->userCanEdit() ) {
1001 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
1002 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
1003 } // no message if page is protected - would be redundant
1007 function historyLink()
1011 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1012 wfMsg( "history" ), "action=history" );
1016 function whatLinksHere()
1018 global $wgTitle, $wgLang;
1020 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
1021 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
1025 function userContribsLink()
1027 global $wgTitle, $wgLang;
1029 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1030 wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
1034 function emailUserLink()
1036 global $wgTitle, $wgLang;
1038 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
1039 wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
1043 function watchPageLinksLink()
1045 global $wgOut, $wgTitle, $wgLang;
1047 if ( ! $wgOut->isArticleRelated() ) {
1048 $s = "(" . wfMsg( "notanarticle" ) . ")";
1050 $s = $this->makeKnownLink( $wgLang->specialPage(
1051 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
1052 "target=" . $wgTitle->getPrefixedURL() );
1057 function otherLanguages()
1059 global $wgOut, $wgLang, $wgTitle, $wgUseNewInterlanguage;
1061 $a = $wgOut->getLanguageLinks();
1063 if ( 0 == count( $a ) ) {
1064 if ( !$wgUseNewInterlanguage ) return "";
1065 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1066 if ( $ns != 0 AND $ns != 1 ) return "" ;
1068 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
1069 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1070 wfMsg( "intl" ) , $x );
1073 if ( !$wgUseNewInterlanguage ) {
1074 $s = wfMsg( "otherlanguages" ) . ": ";
1076 global $wgLanguageCode ;
1077 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
1078 $x .= "&xl=".$wgLanguageCode ;
1079 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
1080 wfMsg( "otherlanguages" ) , $x ) . ": " ;
1083 $s = wfMsg( "otherlanguages" ) . ": ";
1085 if($wgLang->isRTL()) $s .= "<span dir='LTR'>";
1086 foreach( $a as $l ) {
1087 if ( ! $first ) { $s .= " | "; }
1090 $nt = Title
::newFromText( $l );
1091 $url = $nt->getFullURL();
1092 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
1094 if ( "" == $text ) { $text = $l; }
1095 $style = $this->getExternalLinkAttributes( $l, $text );
1096 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1098 if($wgLang->isRTL()) $s .= "</span>";
1102 function bugReportsLink()
1104 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
1105 wfMsg( "bugreports" ) );
1111 global $wgLinkCache;
1112 $t1 = Title
::newFromText( gmdate( "F j" ) );
1113 $t2 = Title
::newFromText( gmdate( "Y" ) );
1115 $wgLinkCache->suspend();
1116 $id = $t1->getArticleID();
1117 $wgLinkCache->resume();
1120 $s = $this->makeBrokenLink( $t1->getText() );
1122 $s = $this->makeKnownLink( $t1->getText() );
1126 $wgLinkCache->suspend();
1127 $id = $t2->getArticleID();
1128 $wgLinkCache->resume();
1131 $s .= $this->makeBrokenLink( $t2->getText() );
1133 $s .= $this->makeKnownLink( $t2->getText() );
1140 global $wgLang, $wgTitle, $wgLinkCache;
1142 $tns = $wgTitle->getNamespace();
1143 if ( -1 == $tns ) { return ""; }
1145 $pn = $wgTitle->getText();
1146 $tp = wfMsg( "talkpage" );
1147 if ( Namespace::isTalk( $tns ) ) {
1148 $lns = Namespace::getSubject( $tns );
1151 $text = wfMsg("articlepage");
1154 $text = wfMsg("userpage");
1157 $text = wfMsg("wikipediapage");
1160 $text = wfMsg("imagepage");
1163 $text= wfMsg("articlepage");
1167 $lns = Namespace::getTalk( $tns );
1170 $n = $wgLang->getNsText( $lns );
1171 if ( "" == $n ) { $link = $pn; }
1172 else { $link = "{$n}:{$pn}"; }
1174 $wgLinkCache->suspend();
1175 $s = $this->makeLink( $link, $text );
1176 $wgLinkCache->resume();
1181 function commentLink()
1183 global $wgLang, $wgTitle, $wgLinkCache;
1185 $tns = $wgTitle->getNamespace();
1186 if ( -1 == $tns ) { return ""; }
1188 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1190 # assert Namespace::isTalk( $lns )
1192 $n = $wgLang->getNsText( $lns );
1193 $pn = $wgTitle->getText();
1195 $link = "{$n}:{$pn}";
1197 $wgLinkCache->suspend();
1198 $s = $this->makeKnownLink($link, wfMsg("postcomment"), "action=edit§ion=new");
1199 $wgLinkCache->resume();
1204 # After all the page content is transformed into HTML, it makes
1205 # a final pass through here for things like table backgrounds.
1207 function transformContent( $text )
1212 # Note: This function MUST call getArticleID() on the link,
1213 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1215 function makeLink( $title, $text = "", $query = "", $trail = "" ) {
1216 wfProfileIn( "Skin::makeLink" );
1217 $nt = Title
::newFromText( $title );
1219 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1221 wfDebug( "Invalid title passed to Skin::makeLink(): \"$title\"\n" );
1222 $result = $text == "" ?
$title : $text;
1225 wfProfileOut( "Skin::makeLink" );
1229 function makeKnownLink( $title, $text = "", $query = "", $trail = "" ) {
1230 $nt = Title
::newFromText( $title );
1232 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1234 wfDebug( "Invalid title passed to Skin::makeKnownLink(): \"$title\"\n" );
1235 return $text == "" ?
$title : $text;
1239 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" ) {
1240 $nt = Title
::newFromText( $title );
1242 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1244 wfDebug( "Invalid title passed to Skin::makeBrokenLink(): \"$title\"\n" );
1245 return $text == "" ?
$title : $text;
1249 function makeStubLink( $title, $text = "", $query = "", $trail = "" ) {
1250 $nt = Title
::newFromText( $title );
1252 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1254 wfDebug( "Invalid title passed to Skin::makeStubLink(): \"$title\"\n" );
1255 return $text == "" ?
$title : $text;
1259 # Pass a title object, not a title string
1260 function makeLinkObj( &$nt, $text= "", $query = "", $trail = "" )
1262 global $wgOut, $wgUser;
1263 if ( $nt->isExternal() ) {
1264 $u = $nt->getFullURL();
1265 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1266 $style = $this->getExternalLinkAttributes( $link, $text );
1269 if ( "" != $trail ) {
1270 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1275 $retVal = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1276 } elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1277 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail );
1278 } elseif ( ( -1 == $nt->getNamespace() ) ||
1279 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1280 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail );
1282 $aid = $nt->getArticleID() ;
1284 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail );
1286 $threshold = $wgUser->getOption("stubthreshold") ;
1287 if ( $threshold > 0 ) {
1288 $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'", DB_READ
) ;
1290 if ( wfNumRows( $res ) > 0 ) {
1291 $s = wfFetchObject( $res );
1293 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
1294 $size = $threshold*2 ; # Really big
1296 wfFreeResult( $res );
1298 $size = $threshold*2 ; # Really big
1303 if ( $size < $threshold ) {
1304 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail );
1306 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail );
1313 # Pass a title object, not a title string
1314 function makeKnownLinkObj( &$nt, $text = "", $query = "", $trail = "" )
1316 global $wgOut, $wgTitle;
1318 $fname = "Skin::makeKnownLinkObj";
1319 wfProfileIn( $fname );
1321 $link = $nt->getPrefixedURL();
1323 if ( "" == $link ) {
1325 if ( "" == $text ) { $text = $nt->getFragment(); }
1327 $u = wfLocalUrlE( $link, $query );
1329 if ( "" != $nt->getFragment() ) {
1330 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
1332 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1333 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1336 if ( "" != $trail ) {
1337 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1342 $r = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1343 wfProfileOut( $fname );
1347 # Pass a title object, not a title string
1348 function makeBrokenLinkObj( &$nt, $text = "", $query = "", $trail = "" )
1350 global $wgOut, $wgUser;
1352 $fname = "Skin::makeBrokenLinkObj";
1353 wfProfileIn( $fname );
1355 $link = $nt->getPrefixedURL();
1357 if ( "" == $query ) { $q = "action=edit"; }
1358 else { $q = "action=edit&{$query}"; }
1359 $u = wfLocalUrlE( $link, $q );
1361 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1362 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1365 if ( "" != $trail ) {
1366 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1371 if ( $wgOut->isPrintable() ||
1372 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1373 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1375 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1378 wfProfileOut( $fname );
1382 # Pass a title object, not a title string
1383 function makeStubLinkObj( &$nt, $text = "", $query = "", $trail = "" )
1385 global $wgOut, $wgUser;
1387 $link = $nt->getPrefixedURL();
1389 $u = wfLocalUrlE( $link, $query );
1391 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1392 $style = $this->getInternalLinkAttributesObj( $nt, $text, "stub" );
1395 if ( "" != $trail ) {
1396 if ( preg_match( wfMsg("linktrail"), $trail, $m ) ) {
1401 if ( $wgOut->isPrintable() ||
1402 ( 1 == $wgUser->getOption( "highlightbroken" ) ) ) {
1403 $s = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1405 $s = "{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1410 function fnamePart( $url )
1412 $basename = strrchr( $url, "/" );
1413 if ( false === $basename ) { $basename = $url; }
1414 else { $basename = substr( $basename, 1 ); }
1415 return wfEscapeHTML( $basename );
1418 function makeImage( $url, $alt = "" )
1422 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1423 $s = "<img src=\"{$url}\" alt=\"{$alt}\">";
1427 function makeImageLink( $name, $url, $alt = "" ) {
1428 $nt = Title
::makeTitle( Namespace::getImage(), $name );
1429 return $this->makeImageLinkObj( $nt, $alt );
1432 function makeImageLinkObj( $nt, $alt = "" ) {
1433 global $wgLang, $wgUseImageResize;
1434 $link = $nt->getPrefixedURL();
1435 $name = $nt->getDBKey();
1436 $url = wfImageUrl( $name );
1439 if ( $wgUseImageResize ) {
1440 # Check if the alt text is of the form "options|alt text"
1442 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1443 # * left no resizing, just left align. label is used for alt= only
1444 # * right same, but right aligned
1445 # * none same, but not aligned
1446 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1448 $part = explode( "|", $alt);
1450 if ( count($part) > 1 ) {
1451 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
1452 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
1453 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
1454 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
1455 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
1456 $alt = $part[count($part)-1];
1460 foreach( $part as $key => $val ) {
1461 if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1463 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1464 # remember to set an alignment, don't render immediately
1466 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1467 # remember to set an alignment, don't render immediately
1469 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1470 # remember to set an alignment, don't render immediately
1472 } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1473 # $match is the image width in pixels
1474 $width = intval($match);
1481 # Create a thumbnail. Alignment depends on language
1482 # writing direction, # right aligned for left-to-right-
1483 # languages ("Western languages"), left-aligned
1484 # for right-to-left-languages ("Semitic languages")
1486 # If thumbnail width has not been provided, it is set
1487 # here to 180 pixels
1488 if ( $align == "" ) {
1489 $align = $wgLang->isRTL() ?
"left" : "right";
1491 if ( ! isset($width) ) {
1494 return $this->makeThumbLinkObj( $nt, $alt, $align, $width );
1496 } elseif ( isset($width) ) {
1498 # Create a resized image, without the additional thumbnail
1500 $url = $this->createThumb( $name, $width );
1502 } # endif $wgUseImageResize
1504 if ( empty( $alt ) ) {
1505 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1507 $alt = htmlspecialchars( $alt );
1509 $u = wfLocalUrlE( $link );
1510 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1511 "<img border=\"0\" src=\"{$url}\" alt=\"{$alt}\"></a>";
1512 if ( "" != $align ) {
1513 $s = "<div class=\"float{$align}\">{$s}</div>";
1518 function createThumb( $name, $width ) {
1519 global $wgUploadDirectory;
1520 global $wgImageMagickConvertCommand;
1521 global $wgUseImageMagick;
1522 $imgPath = wfImagePath( $name );
1523 $thumbName = $width."px-".$icon.$name;
1524 $thumbPath = wfImageArchiveDir( $thumbName, "thumb" )."/".$thumbName;
1525 $thumbUrl = wfImageArchiveUrl( $thumbName, "thumb" );
1527 if ( (! file_exists( $thumbPath ) && file_exists( $imgPath ))
1528 ||
( filemtime($thumbPath) < filemtime($imgPath) ) ) {
1529 if ( $wgUseImageMagick ) {
1531 $cmd = $wgImageMagickConvertCommand .
1532 " -quality 95 -geometry {$width}x ".
1533 escapeshellarg($imgPath) . " " .
1534 escapeshellarg($thumbPath);
1535 $conv = shell_exec( $cmd );
1537 # Use PHP's builtin GD library functions.
1539 # First find out what kind of file this is, and select the correct
1540 # input routine for this.
1541 list($src_width, $src_height, $src_type, $src_attr) = getimagesize( $imgPath );
1542 switch( $src_type ) {
1544 $src_image = imagecreatefromgif( $imgPath );
1547 $src_image = imagecreatefromjpeg( $imgPath );
1550 $src_image = imagecreatefrompng( $imgPath );
1552 case 15: # WBMP for WML
1553 $src_image = imagecreatefromwbmp( $imgPath );
1556 $src_image = imagecreatefromxbm( $imgPath );
1559 return "Image type not supported";
1562 $height = floor( $src_height * ( $width/$src_width ) );
1563 $dst_image = imagecreatetruecolor( $width, $height );
1564 imagecopyresampled( $dst_image, $src_image,
1566 $width, $height, $src_width, $src_height );
1567 switch( $src_type ) {
1572 #$thumbUrl .= ".png";
1573 #$thumbPath .= ".png";
1574 imagepng( $dst_image, $thumbPath );
1577 #$thumbUrl .= ".jpg";
1578 #$thumbPath .= ".jpg";
1579 imageinterlace( $dst_image );
1580 imagejpeg( $dst_image, $thumbPath, 95 );
1585 imagedestroy( $dst_image );
1586 imagedestroy( $src_image );
1595 function makeThumbLinkObj( $nt, $label = "", $align = "right", $boxwidth = 180 ) {
1596 global $wgUploadPath;
1597 $name = $nt->getDBKey();
1598 $image = Title
::makeTitle( Namespace::getImage(), $name );
1599 $link = $image->getPrefixedURL();
1600 $url = wfImageUrl( $name );
1601 $path = wfImagePath( $name );
1603 list($width, $height, $type, $attr) = getimagesize( $path );
1604 $cwidth = $boxwidth;
1605 $cheight = intval( $height/($width/$cwidth) );
1606 if ($cheight > $boxwidth*1.5) {
1607 $cheight = $boxwidth*1.3;
1608 $cwidth = intval( $width/($height/$cheight) );
1610 if ( $cwidth > $width ) {
1615 $thumbUrl = $this->createThumb( $name, $cwidth );
1617 $u = wfLocalUrlE( $link );
1619 $more = wfMsg( "thumbnail-more" );
1621 $s = "<div class=\"thumbnail-{$align}\" style=\"width:{$boxwidth}px;\">" .
1622 "<a href=\"{$u}\" class=\"internal\" title=\"{$label}\">" .
1623 "<img border=\"0\" src=\"{$thumbUrl}\" alt=\"{$label}\" width=\"{$cwidth}\" height=\"{$cheight}\"></a>" .
1624 "<a href=\"{$u}\" class=\"internal\" title=\"{$more}\">" .
1625 "<img border=\"0\" src=\"{$wgUploadPath}/magnify-clip.png\" width=\"26\" height=\"24\" align=\"right\" alt=\"{$more}\"></a>" .
1626 "<p>{$label}</div></p>";
1630 function makeMediaLink( $name, $url, $alt = "" ) {
1631 $nt = Title
::makeTitle( Namespace::getMedia(), $name );
1632 return $this->makeMediaLinkObj( $nt, $alt );
1635 function makeMediaLinkObj( $nt, $alt = "" )
1637 $name = $nt->getDBKey();
1638 $url = wfImageUrl( $name );
1639 if ( empty( $alt ) ) {
1640 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1643 $u = htmlspecialchars( $url );
1644 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1648 function specialLink( $name, $key = "" )
1652 if ( "" == $key ) { $key = strtolower( $name ); }
1653 $pn = $wgLang->ucfirst( $name );
1654 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1658 # Called by history lists and recent changes
1661 # Returns text for the start of the tabular part of RC
1662 function beginRecentChangesList()
1664 $this->rc_cache
= array() ;
1665 $this->rcCacheIndex
= 0 ;
1666 $this->lastdate
= "";
1670 function beginImageHistoryList()
1672 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1673 "<p>" . wfMsg( "imghistlegend" ) . "\n<ul>";
1677 # Returns text for the end of RC
1678 # If enhanced RC is in use, returns pretty much all the text
1679 function endRecentChangesList()
1681 $s = $this->recentChangesBlock() ;
1686 # Enhanced RC ungrouped line
1687 function recentChangesBlockLine ( $rcObj )
1689 global $wgUploadPath ;
1691 # Get rc_xxxx variables
1692 extract( $rcObj->mAttribs
) ;
1693 $curIdEq = "curid=$rc_cur_id";
1697 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>" ; $r .= "<tt>" ;
1699 if ( $rc_type == RC_MOVE
) {
1700 $r .= " ";
1702 # M & N (minor & new)
1703 $M = wfMsg( "minoreditletter" );
1704 $N = wfMsg( "newpageletter" );
1706 if ( $rc_type == RC_NEW
) {
1719 $r .= " ".$rcObj->timestamp
." " ;
1723 $link = $rcObj->link
;
1724 if ( $rcObj->watched
) $link = "<strong>{$link}</strong>" ;
1729 $r .= $rcObj->curlink
;
1733 $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" );
1736 $r .= ") . . ".$rcObj->userlink
;
1737 $r .= $rcObj->usertalklink
;
1740 if ( $rc_comment != "" && $rc_type != RC_MOVE
)
1741 $r .= " <em>(".wfEscapeHTML($rc_comment).")</em>" ;
1747 function recentChangesBlockGroup ( $block )
1749 global $wgUploadPath ;
1752 $M = wfMsg( "minoreditletter" );
1753 $N = wfMsg( "newpageletter" );
1755 # Collate list of users
1757 $userlinks = array () ;
1758 foreach ( $block AS $rcObj ) {
1759 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
1760 if ( $rcObj->mAttribs
['rc_new'] ) $isnew = true ;
1761 $u = $rcObj->userlink
;
1762 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1766 # Sort the list and convert to text
1767 krsort ( $userlinks ) ;
1768 asort ( $userlinks ) ;
1770 foreach ( $userlinks as $userlink => $count) {
1772 if ( $count > 1 ) $text .= " ({$count}×)" ;
1773 array_push ( $users , $text ) ;
1775 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1778 $rci = "RCI{$this->rcCacheIndex}" ;
1779 $rcl = "RCL{$this->rcCacheIndex}" ;
1780 $rcm = "RCM{$this->rcCacheIndex}" ;
1781 $tl = "<a href='javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")'>" ;
1782 $tl .= "<span id='{$rcm}'><img src='{$wgUploadPath}/Arr_r.png' width=12 height=12 border=0></span>" ;
1783 $tl .= "<span id='{$rcl}' style='display:none'><img src='{$wgUploadPath}/Arr_d.png' width=12 height=12 border=0></span>" ;
1790 if ( $isnew ) $r .= $N ;
1791 else $r .= " " ;
1792 $r .= " " ; # Minor
1795 $r .= " ".$block[0]->timestamp
." " ;
1799 $link = $block[0]->link
;
1800 if ( $block[0]->watched
) $link = "<strong>{$link}</strong>" ;
1803 $curIdEq = "curid=" . $block[0]->mAttribs
['rc_cur_id'];
1804 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
1806 $r .= " (".count($block)." " ;
1807 if ( $isnew ) $r .= wfMsg("changes");
1808 else $r .= $this->makeKnownLinkObj( $block[0]->getTitle() , wfMsg("changes") ,
1809 "{$curIdEq}&diff=0&oldid=".$oldid ) ;
1813 $r .= $this->makeKnownLink( $block[0]->getTitle(), wfMsg( "history" ), "{$curIdEq}&action=history" );
1821 $r .= "<div id='{$rci}' style='display:none'>" ;
1822 foreach ( $block AS $rcObj ) {
1823 # Get rc_xxxx variables
1824 extract( $rcObj->mAttribs
);
1826 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 border=0>";
1827 $r .= "<tt> " ;
1828 if ( $rc_new ) $r .= $N ;
1829 else $r .= " " ;
1830 if ( $rc_minor ) $r .= $M ;
1831 else $r .= " " ;
1835 if ( $rc_last_oldid != 0 ) {
1836 $o = "oldid=".$rc_last_oldid ;
1838 if ( $rc_type == RC_LOG
) {
1839 $link = $rcObj->timestamp
;
1841 $link = $this->makeKnownLink( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
1843 $link = "<tt>{$link}</tt>" ;
1847 $r .= $rcObj->curlink
;
1849 $r .= $rcObj->lastlink
;
1850 $r .= ") . . ".$rcObj->userlink
;
1851 $r .= $rcObj->usertalklink
;
1852 if ( $rc_comment != "" )
1853 $r .= " <em>(".wfEscapeHTML($rc_comment).")</em>" ;
1858 $this->rcCacheIndex++
;
1862 # If enhanced RC is in use, this function takes the previously cached
1863 # RC lines, arranges them, and outputs the HTML
1864 function recentChangesBlock ()
1866 global $wgUploadPath ;
1867 if ( count ( $this->rc_cache
) == 0 ) return "" ;
1868 #$k = array_keys ( $this->rc_cache ) ;
1869 foreach ( $this->rc_cache
AS $secureName => $block ) {
1870 if ( count ( $block ) < 2 ) {
1871 $r .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
1873 $r .= $this->recentChangesBlockGroup ( $block ) ;
1877 return "<div align=left>{$r}</div>" ;
1880 # Called in a loop over all displayed RC entries
1881 # Either returns the line, or caches it for later use
1882 function recentChangesLine( &$rc, $watched = false )
1885 $usenew = $wgUser->getOption( "usenewrc" );
1887 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
1889 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
1893 function recentChangesLineOld( &$rc, $watched = false )
1895 global $wgTitle, $wgLang, $wgUser;
1897 # Extract DB fields into local scope
1898 extract( $rc->mAttribs
);
1899 $curIdEq = "curid=" . $rc_cur_id;
1901 # Make date header if necessary
1902 $date = $wgLang->date( $rc_timestamp, true);
1904 if ( $date != $this->lastdate
) {
1905 if ( "" != $this->lastdate
) { $s .= "</ul>\n"; }
1906 $s .= "<h4>{$date}</h4>\n<ul>";
1907 $this->lastdate
= $date;
1911 if ( $rc_type == RC_MOVE
) {
1913 $s .= "(" . wfMsg( "diff" ) . ") (";
1915 $s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), wfMsg( "hist" ), "action=history" ) .
1918 # "[[x]] moved to [[y]]"
1919 $s .= $this->makeKnownLinkObj( $rc->getTitle(), "", "redirect=no" );
1920 $s .= " " . wfMsg( "movedto" ). " ";
1921 $s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), "" );
1924 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
1925 $diffLink = wfMsg( "diff" );
1927 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "diff" ),
1928 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}" );
1930 $s .= "($diffLink) (";
1933 $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" );
1936 # M and N (minor and new)
1937 $M = wfMsg( "minoreditletter" );
1938 $N = wfMsg( "newpageletter" );
1939 if ( $rc_minor ) { $s .= " <strong>{$M}</strong>"; }
1940 if ( $rc_type == RC_NEW
) { $s .= "<strong>{$N}</strong>"; }
1943 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), "" );
1946 $articleLink = "<strong>{$articleLink}</strong>";
1948 $s .= " $articleLink";
1953 $s .= "; " . $wgLang->time( $rc_timestamp, true ) . " . . ";
1955 # User link (or contributions for unregistered users)
1956 if ( 0 == $rc_user ) {
1957 $userLink = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1958 $rc_user_text, "target=" . $rc_user_text );
1960 $userLink = $this->makeLink( $wgLang->getNsText( NS_USER
) . ":{$rc_user_text}", $rc_user_text );
1965 $talkname=$wgLang->getNsText(NS_TALK
); # use the shorter name
1966 global $wgDisableAnonTalk;
1967 if( 0 == $rc_user && $wgDisableAnonTalk ) {
1970 $utns=$wgLang->getNsText(NS_USER_TALK
);
1971 $userTalkLink= $this->makeLink($utns . ":{$rc_user_text}", $talkname );
1975 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
1976 $blockLink = $this->makeKnownLink( $wgLang->specialPage(
1977 "Blockip" ), wfMsg( "blocklink" ), "ip={$rc_user_text}" );
1981 if($userTalkLink) $userTalkLink .= " | ";
1982 $userTalkLink .= $blockLink;
1984 if($userTalkLink) $s.=" ({$userTalkLink})";
1987 if ( "" != $rc_comment && "*" != $rc_comment && $rc_type != RC_MOVE
) {
1988 $s .= " <em>(" . wfEscapeHTML( $rc_comment ) . ")</em>";
1995 # function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
1996 function recentChangesLineNew( &$baseRC, $watched = false )
1998 global $wgTitle, $wgLang, $wgUser;
2000 # Create a specialised object
2001 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
2003 # Extract fields from DB into the function scope (rc_xxxx variables)
2004 extract( $rc->mAttribs
);
2005 $curIdEq = "curid=" . $rc_cur_id;
2007 # If it's a new day, add the headline and flush the cache
2008 $date = $wgLang->date( $rc_timestamp, true);
2010 if ( $date != $this->lastdate
) {
2011 # Process current cache
2012 $ret = $this->recentChangesBlock () ;
2013 $this->rc_cache
= array() ;
2014 $ret .= "<h4>{$date}</h4>\n";
2015 $this->lastdate
= $date;
2019 if ( $rc_type == RC_MOVE
) {
2020 $clink = $this->makeKnownLinkObj( $rc->getTitle(), "", "redirect=no" );
2021 $clink .= " " . wfMsg("movedto") . " ";
2022 $clink .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), "" );
2024 $clink = $this->makeKnownLinkObj( $rc->getTitle(), "" ) ;
2027 $time = $wgLang->time( $rc_timestamp, true );
2028 $rc->watched
= $watched ;
2029 $rc->link
= $clink ;
2030 $rc->timestamp
= $time;
2033 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE
) {
2034 $curLink = wfMsg( "cur" );
2036 $curLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "cur" ),
2037 "{$curIdEq}&diff=0&oldid={$rc_this_oldid}" );
2041 $titleObj = $rc->getTitle();
2042 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE
) {
2043 $lastLink = wfMsg( "last" );
2045 $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "last" ),
2046 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}" );
2049 # Make user link (or user contributions for unregistered users)
2050 if ( 0 == $rc_user ) {
2051 $userLink = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
2052 $rc_user_text, "target=" . $rc_user_text );
2053 } else { $userLink = $this->makeLink( $wgLang->getNsText(
2054 Namespace::getUser() ) . ":{$rc_user_text}", $rc_user_text ); }
2056 $rc->userlink
= $userLink ;
2057 $rc->lastlink
= $lastLink ;
2058 $rc->curlink
= $curLink ;
2060 # Make user talk link
2061 $utns=$wgLang->getNsText(NS_USER_TALK
);
2062 $talkname=$wgLang->getNsText(NS_TALK
); # use the shorter name
2063 $userTalkLink= $this->makeLink($utns . ":{$rc_user_text}", $talkname );
2065 global $wgDisableAnonTalk;
2066 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2067 $blockLink = $this->makeKnownLink( $wgLang->specialPage(
2068 "Blockip" ), wfMsg( "blocklink" ), "ip={$rc_user_text}" );
2069 if( $wgDisableAnonTalk )
2070 $rc->usertalklink
= " ({$blockLink})";
2072 $rc->usertalklink
= " ({$userTalkLink} | {$blockLink})";
2074 if( $wgDisableAnonTalk && ($rc_user == 0) )
2075 $rc->usertalklink
= "";
2077 $rc->usertalklink
= " ({$userTalkLink})";
2080 # Put accumulated information into the cache, for later display
2081 # Page moves go on their own line
2082 $title = $rc->getTitle();
2083 $secureName = $title->getPrefixedDBkey();
2084 if ( $rc_type == RC_MOVE
) {
2085 array_push($this->rc_cache
, array($rc) );
2087 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
2088 array_push ( $this->rc_cache
[$secureName] , $rc ) ;
2093 function endImageHistoryList()
2099 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
2101 global $wgUser, $wgLang, $wgTitle;
2103 $dt = $wgLang->timeanddate( $ts, true );
2104 $del = wfMsg( "deleteimg" );
2105 $cur = wfMsg( "cur" );
2108 $url = wfImageUrl( $img );
2110 if ( $wgUser->isSysop() ) {
2111 $link = wfLocalUrlE( $wgTitle->getPrefixedText(), "image=" . $wgTitle->getURL() .
2113 $style = $this->getInternalLinkAttributes( $link, $del );
2115 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
2120 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
2121 if( $wgUser->getID() != 0 ) {
2122 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2123 wfMsg( "revertimg" ), "action=revert&oldimage=" .
2124 urlencode( $img ) );
2125 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2126 $del, "action=delete&oldimage=" . urlencode( $img ) );
2128 # Having live active links for non-logged in users
2129 # means that bots and spiders crawling our site can
2130 # inadvertently change content. Baaaad idea.
2131 $rlink = wfMsg( "revertimg" );
2135 if ( 0 == $u ) { $ul = $ut; }
2136 else { $ul = $this->makeLink( $wgLang->getNsText(
2137 Namespace::getUser() ) . ":{$ut}", $ut ); }
2139 $nb = wfMsg( "nbytes", $size );
2140 $style = $this->getInternalLinkAttributes( $url, $dt );
2142 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
2143 . " . . {$ul} ({$nb})";
2145 if ( "" != $c && "*" != $c ) {
2146 $s .= " <em>(" . wfEscapeHTML( $c ) . ")</em>";
2152 function tocIndent($level) {
2154 while($level-->0) $rv.="<div style=\"margin-left:2em;\">\n";
2159 function tocUnindent($level) {
2161 while($level-->0) $rv.="</div>\n";
2165 // parameter level defines if we are on an indentation level
2166 function tocLine($anchor,$tocline,$level) {
2170 return "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n";
2173 return "<div style=\"margin-bottom:0px;\">\n".
2174 "<A CLASS=\"internal\" HREF=\"#".$anchor."\">".$tocline."</A><BR>\n".
2180 function tocTable($toc) {
2181 // note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2185 $hideline = " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>";
2188 "<p><table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
2189 "<b>".wfMsg("toc")."</b>" .
2191 "</td></tr><tr id='tocinside'><td align=\"left\">\n".
2192 $toc."</td></tr></table><P>\n";
2195 # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
2196 function editSectionScript($section,$head) {
2198 global $wgTitle,$wgUser,$oldid;
2199 if($oldid) return $head;
2200 $url = wfLocalUrlE(urlencode($wgTitle->getPrefixedText()),"action=edit§ion=$section");
2201 return "<span onContextMenu='document.location=\"".$url."\";return false;'>{$head}</span>";
2204 function editSectionLink($section) {
2207 global $wgTitle,$wgUser,$oldid;
2208 if($oldid) return "";
2209 if ($printable) return "";
2210 $editurl="§ion={$section}";
2211 $url=$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
2212 return "<div style=\"float:right;margin-left:5px;\"><small>[".$url."]</small></div>";
2216 // This function is called by EditPage.php and shows a bulletin board style
2217 // toolbar for common editing functions. It can be disabled in the user preferences.
2218 // The necsesary JavaScript code can be found in style/wikibits.js.
2219 function getEditToolbar() {
2221 global $wgUploadPath;
2223 // toolarray an array of arrays which each include the filename of
2224 // the button image (without path), the opening tag, the closing tag,
2225 // and optionally a sample text that is inserted between the two when no
2226 // selection is highlighted.
2227 // The tip text is shown when the user moves the mouse over the button.
2229 array( "image"=>"button_bold.gif",
2232 "sample"=>wfMsg("bold_sample"),
2233 "tip"=>wfMsg("bold_tip")),
2234 array( "image"=>"button_italic.gif",
2237 "sample"=>wfMsg("italic_sample"),
2238 "tip"=>wfMsg("italic_tip")),
2239 array( "image"=>"button_link.gif",
2242 "sample"=>wfMsg("link_sample"),
2243 "tip"=>wfMsg("link_tip")),
2244 array( "image"=>"button_extlink.gif",
2247 "sample"=>wfMsg("extlink_sample"),
2248 "tip"=>wfMsg("extlink_tip")),
2249 array( "image"=>"button_headline.gif",
2252 "sample"=>wfMsg("headline_sample"),
2253 "tip"=>wfMsg("headline_tip")),
2254 array( "image"=>"button_image.gif",
2257 "sample"=>wfMsg("image_sample"),
2258 "tip"=>wfMsg("image_tip")),
2259 array( "image"=>"button_media.gif",
2262 "sample"=>wfMsg("media_sample"),
2263 "tip"=>wfMsg("media_tip")),
2264 array( "image"=>"button_math.gif",
2265 "open"=>"\\<math\\>",
2266 "close"=>"\\</math\\>",
2267 "sample"=>wfMsg("math_sample"),
2268 "tip"=>wfMsg("math_tip")),
2269 array( "image"=>"button_nowiki.gif",
2270 "open"=>"\\<nowiki\\>",
2271 "close"=>"\\</nowiki\\>",
2272 "sample"=>wfMsg("nowiki_sample"),
2273 "tip"=>wfMsg("nowiki_tip")),
2274 array( "image"=>"button_sig.gif",
2278 "tip"=>wfMsg("sig_tip")),
2279 array( "image"=>"button_hr.gif",
2280 "open"=>"\\n----\\n",
2283 "tip"=>wfMsg("hr_tip"))
2285 $toolbar.="<script type='text/javascript'>\n";
2286 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
2287 foreach($toolarray as $tool) {
2289 $image=$wgUploadPath."/".$tool["image"];
2290 $open=$tool["open"];
2291 $close=$tool["close"];
2292 $sample=$tool["sample"];
2294 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
2295 // Older browsers show a "speedtip" type message only for ALT.
2296 // Ideally these should be different, realistically they
2297 // probably don't need to be.
2299 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
2302 $toolbar.="addInfobox('".wfMsg("infobox")."');\n";
2303 $toolbar.="document.writeln(\"</div>\");\n</script>";
2308 include_once( "SkinStandard.php" );
2309 include_once( "SkinNostalgia.php" );
2310 include_once( "SkinCologneBlue.php" );
2312 #include_once( "SkinSmarty.php" );