3 include_once( "Feed.php" );
7 # These are the INTERNAL names, which get mapped
8 # directly to class names. For display purposes, the
9 # Language class has internationalized names
11 /* private */ $wgValidSkinNames = array(
12 'standard' => "Standard",
13 'nostalgia' => "Nostalgia",
14 'cologneblue' => "CologneBlue"
17 #$wgValidSkinNames[] = "PHPTal";
18 #$wgValidSkinNames['davinci'] = "DaVinci";
19 #$wgValidSkinNames['mono'] = "Mono";
20 $wgValidSkinNames['monobook'] = "MonoBook";
21 #$wgValidSkinNames['monobookminimal'] = "MonoBookMinimal";
24 include_once( "RecentChange.php" );
26 # For some odd PHP bug, this function can't be part of a class
27 function getCategories ()
29 global $wgOut , $wgTitle , $wgUseCategoryMagic , $wgUser , $wgParser ;
30 if ( !isset ( $wgUseCategoryMagic ) ||
!$wgUseCategoryMagic ) return "" ;
31 if ( count ( $wgOut->mCategoryLinks
) == 0 ) return "" ;
32 if ( !$wgOut->isArticle() ) return "" ;
33 $sk = $wgUser->getSkin() ;
35 $s .= $sk->makeKnownLink ( "Special:Categories" , "Categories" , "article=".$wgTitle->getDBkey() ) ;
36 $t = implode ( " | " , $wgOut->mCategoryLinks
) ;
37 if ( $t != "" ) $s .= ": " ;
39 return "<p class='catlinks'>$s</p>";
42 class RCCacheEntry
extends RecentChange
44 var $secureName, $link;
45 var $curlink , $lastlink , $usertalklink , $versionlink ;
46 var $userlink, $timestamp, $watched;
48 function newFromParent( $rc )
50 $rc2 = new RCCacheEntry
;
51 $rc2->mAttribs
= $rc->mAttribs
;
52 $rc2->mExtra
= $rc->mExtra
;
59 /* private */ var $lastdate, $lastline;
60 var $linktrail ; # linktrail regexp
61 var $rc_cache ; # Cache for Enhanced Recent Changes
62 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
67 $this->linktrail
= wfMsg("linktrail");
70 function getSkinNames()
72 global $wgValidSkinNames;
73 return $wgValidSkinNames;
76 function getStylesheet()
78 return "wikistandard.css";
83 global $wgOut, $wgUser;
85 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
86 $q = $wgUser->getOption( "quickbar" );
87 if ( "" == $q ) { $q = 0; }
91 function initPage( &$out )
93 $fname = "Skin::initPage";
94 wfProfileIn( $fname );
96 $out->addLink( array( "rel" => "shortcut icon", "href" => "/favicon.ico" ) );
98 $this->addMetadataLinks($out);
100 wfProfileOut( $fname );
103 function addMetadataLinks( &$out ) {
104 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
105 global $wgRightsPage, $wgRightsUrl;
107 if( $out->isArticleRelated() ) {
108 # note: buggy CC software only reads first "meta" link
109 if( $wgEnableCreativeCommonsRdf ) {
110 $out->addMetadataLink( array(
111 'title' => 'Creative Commons',
112 'type' => 'application/rdf+xml',
113 'href' => $wgTitle->getLocalURL( "action=creativecommons") ) );
115 if( $wgEnableDublinCoreRdf ) {
116 $out->addMetadataLink( array(
117 'title' => 'Dublin Core',
118 'type' => 'application/rdf+xml',
119 'href' => $wgTitle->getLocalURL( "action=dublincore" ) ) );
123 if( $wgRightsPage ) {
124 $copy = Title
::newFromText( $wgRightsPage );
126 $copyright = $copy->getLocalURL();
129 if( !$copyright && $wgRightsUrl ) {
130 $copyright = $wgRightsUrl;
133 $out->addLink( array(
134 "rel" => "copyright",
135 "href" => $copyright ) );
139 function outputPage( &$out ) {
140 global $wgDebugComments;
142 wfProfileIn( "Skin::outputPage" );
143 $this->initPage( $out );
144 $out->out( $out->headElement() );
146 $out->out( "\n<body" );
147 $ops = $this->getBodyOptions();
148 foreach ( $ops as $name => $val ) {
149 $out->out( " $name='$val'" );
152 if ( $wgDebugComments ) {
153 $out->out( "<!-- Wiki debugging output:\n" .
154 $out->mDebugtext
. "-->\n" );
156 $out->out( $this->beforeContent() );
158 $out->out( $out->mBodytext
. "\n" );
160 $out->out( $this->afterContent() );
163 $out->out( $out->reportTime() );
165 $out->out( "\n</body></html>" );
168 function getHeadScripts() {
169 global $wgStyleSheetPath;
170 $r = "<script type=\"text/javascript\" src=\"{$wgStyleSheetPath}/wikibits.js\"></script>\n";
174 function getUserStyles()
176 global $wgOut, $wgStyleSheetPath;
177 $sheet = $this->getStylesheet();
178 $s = "<style type='text/css'>\n";
179 $s .= "/*/*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
180 $s .= "@import url(\"$wgStyleSheetPath/$sheet\");\n";
181 $s .= $this->doGetUserStyles();
187 function doGetUserStyles()
192 if ( 1 == $wgUser->getOption( "underline" ) ) {
193 # Don't override browser settings
198 "text-decoration: none; }\n";
200 if ( 1 == $wgUser->getOption( "highlightbroken" ) ) {
201 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
203 if ( 1 == $wgUser->getOption( "justify" ) ) {
204 $s .= "#article { text-align: justify; }\n";
209 function getBodyOptions()
211 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
213 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
215 if ( 0 != $wgTitle->getNamespace() ) {
216 $a = array( "bgcolor" => "#ffffec" );
218 else $a = array( "bgcolor" => "#FFFFFF" );
219 if($wgOut->isArticle() && $wgUser->getOption("editondblclick") &&
220 (!$wgTitle->isProtected() ||
$wgUser->isSysop()) ) {
221 $t = wfMsg( "editthispage" );
223 if ( !empty($redirect) ) {
224 $red = "&redirect={$redirect}";
226 if ( !empty($oldid) && ! isset( $diff ) ) {
227 $oid = "&oldid={$oldid}";
229 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
230 $s = "document.location = \"" .$s ."\";";
231 $a +
= array ("ondblclick" => $s);
234 $a['onload'] = $wgOut->getOnloadHandler();
238 function getExternalLinkAttributes( $link, $text )
240 global $wgUser, $wgOut, $wgLang;
242 $link = urldecode( $link );
243 $link = $wgLang->checkTitleEncoding( $link );
244 $link = str_replace( "_", " ", $link );
245 $link = wfEscapeHTML( $link );
247 $r = " class='external'";
249 if ( 1 == $wgUser->getOption( "hover" ) ) {
250 $r .= " title=\"{$link}\"";
255 function getInternalLinkAttributes( $link, $text, $broken = false )
257 global $wgUser, $wgOut;
259 $link = urldecode( $link );
260 $link = str_replace( "_", " ", $link );
261 $link = wfEscapeHTML( $link );
263 if ( $broken == "stub" ) {
264 $r = " class='stub'";
265 } else if ( $broken == "yes" ) {
271 if ( 1 == $wgUser->getOption( "hover" ) ) {
272 $r .= " title=\"{$link}\"";
277 function getInternalLinkAttributesObj( &$nt, $text, $broken = false )
279 global $wgUser, $wgOut;
281 if ( $broken == "stub" ) {
282 $r = " class='stub'";
283 } else if ( $broken == "yes" ) {
289 if ( 1 == $wgUser->getOption( "hover" ) ) {
290 $r .= ' title ="' . $nt->getEscapedText() . '"';
301 # This will be called immediately after the <body> tag. Split into
302 # two functions to make it easier to subclass.
304 function beforeContent()
306 global $wgUser, $wgOut, $wgSiteNotice;
308 if( $wgSiteNotice ) {
309 $note = "\n<div id='notice' style='font-weight: bold; color: red; text-align: center'>$wgSiteNotice</div>\n";
313 return $this->doBeforeContent() . $note;
316 function doBeforeContent()
318 global $wgUser, $wgOut, $wgTitle, $wgLang;
319 $fname = "Skin::doBeforeContent";
320 wfProfileIn( $fname );
323 $qb = $this->qbSetting();
325 if( $langlinks = $this->otherLanguages() ) {
331 $borderhack = "class='top'";
334 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
335 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
338 $left = ($qb == 1 ||
$qb == 3);
339 if($wgLang->isRTL()) $left = !$left;
342 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
343 $this->logoText() . "</td>";
345 $s .= $this->getQuickbarCompensator( $rows );
347 $l = $wgLang->isRTL() ?
"right" : "left";
348 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
350 $s .= $this->topLinks() ;
351 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
353 $r = $wgLang->isRTL() ?
"left" : "right";
354 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
355 $s .= $this->nameAndLogin();
356 $s .= "\n<br />" . $this->searchForm() . "</td>";
359 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
362 if ( $shove && !$left ) { # Right
363 $s .= $this->getQuickbarCompensator( $rows );
365 $s .= "</tr>\n</table>\n</div>\n";
366 $s .= "\n<div id='article'>\n";
368 $s .= $this->pageTitle();
369 $s .= $this->pageSubtitle() ;
370 $s .= getCategories(); // For some odd reason, zhis can't be a function of the object
371 wfProfileOut( $fname );
375 function getQuickbarCompensator( $rows = 1 )
377 return "<td width='152' rowspan='{$rows}'> </td>";
380 # This gets called immediately before the </body> tag.
382 function afterContent()
384 global $wgUser, $wgOut, $wgServer;
385 global $wgTitle, $wgLang;
387 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
388 return $printfooter . $this->doAfterContent();
391 function printFooter() {
393 $url = htmlspecialchars( $wgTitle->getFullURL() );
394 return "<p>" . wfMsg( "retrievedfrom", "<a href=\"$url\">$url</a>" ) .
395 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
398 function doAfterContent()
400 global $wgUser, $wgOut, $wgLang;
401 $fname = "Skin::doAfterContent";
402 wfProfileIn( $fname );
403 wfProfileIn( "$fname-1" );
405 $s = "\n</div><br clear='all' />\n";
406 $s .= "\n<div id='footer'>";
407 $s .= "<table border='0' cellspacing='0'><tr>";
409 wfProfileOut( "$fname-1" );
410 wfProfileIn( "$fname-2" );
412 $qb = $this->qbSetting();
414 $left = ($qb == 1 ||
$qb == 3);
415 if($wgLang->isRTL()) $left = !$left;
417 if ( $shove && $left ) { # Left
418 $s .= $this->getQuickbarCompensator();
420 wfProfileOut( "$fname-2" );
421 wfProfileIn( "$fname-3" );
422 $l = $wgLang->isRTL() ?
"right" : "left";
423 $s .= "<td class='bottom' align='$l' valign='top'>";
425 $s .= $this->bottomLinks();
426 $s .= "\n<br />" . $this->mainPageLink()
427 . " | " . $this->aboutLink()
428 . " | " . $this->specialLink( "recentchanges" )
429 . " | " . $this->searchForm()
430 . "<br /><span id='pagestats'>" . $this->pageStats() . "</span>";
433 if ( $shove && !$left ) { # Right
434 $s .= $this->getQuickbarCompensator();
436 $s .= "</tr></table>\n</div>\n</div>\n";
438 wfProfileOut( "$fname-3" );
439 wfProfileIn( "$fname-4" );
440 if ( 0 != $qb ) { $s .= $this->quickBar(); }
441 wfProfileOut( "$fname-4" );
442 wfProfileOut( $fname );
446 function pageTitleLinks()
448 global $wgOut, $wgTitle, $wgUser, $wgLang, $wgUseApproval, $wgRequest;
450 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
451 $action = $wgRequest->getText( 'action' );
453 $s = $this->printableLink();
454 if ( wfMsg ( "disclaimers" ) != "" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ;
456 if ( $wgOut->isArticleRelated() ) {
457 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
458 $name = $wgTitle->getDBkey();
459 $link = wfEscapeHTML( wfImageUrl( $name ) );
460 $style = $this->getInternalLinkAttributes( $link, $name );
461 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
463 # This will show the "Approve" link if $wgUseApproval=true;
464 if ( isset ( $wgUseApproval ) && $wgUseApproval )
466 $t = $wgTitle->getDBkey();
467 $name = "Approve this article" ;
468 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
469 #wfEscapeHTML( wfImageUrl( $name ) );
470 $style = $this->getExternalLinkAttributes( $link, $name );
471 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
474 if ( "history" == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
475 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
476 wfMsg( "currentrev" ) );
479 if ( $wgUser->getNewtalk() ) {
480 # do not show "You have new messages" text when we are viewing our
483 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
484 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
485 $n =$wgUser->getName();
486 $tl = $this->makeKnownLink( $wgLang->getNsText(
487 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
488 wfMsg("newmessageslink") );
489 $s.=" | <strong>". wfMsg( "newmessages", $tl ) . "</strong>";
492 if( $wgUser->isSysop() &&
493 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
494 ($n = $wgTitle->isDeleted() ) ) {
495 $s .= " | " . wfMsg( "thisisdeleted",
496 $this->makeKnownLink(
497 $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ),
498 wfMsg( "restorelink", $n ) ) );
503 function printableLink()
505 global $wgOut, $wgFeedClasses, $wgRequest;
507 $baseurl = $_SERVER['REQUEST_URI'];
508 if( strpos( "?", $baseurl ) == false ) {
513 $baseurl = htmlspecialchars( $baseurl );
514 $printurl = $wgRequest->escapeAppendQuery( "printable=yes" );
516 $s = "<a href=\"$printurl\">" . wfMsg( "printableversion" ) . "</a>";
517 if( $wgOut->isSyndicated() ) {
518 foreach( $wgFeedClasses as $format => $class ) {
519 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
520 $s .= " | <a href=\"$feedurl\">{$format}</a>";
528 global $wgOut, $wgTitle, $wgUser;
530 $s = "<h1 class='pagetitle'>" . htmlspecialchars( $wgOut->getPageTitle() ) . "</h1>";
531 if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
535 function pageSubtitle()
537 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
539 $sub = $wgOut->getSubtitle();
541 global $wgExtraSubtitle;
542 $sub = wfMsg( "fromwikipedia" ) . $wgExtraSubtitle;
544 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
545 $ptext=$wgTitle->getPrefixedText();
546 if(preg_match("/\//",$ptext)) {
547 $sub.="</p><p class='subpages'>";
548 $links=explode("/",$ptext);
551 foreach($links as $link) {
553 if ($c<count($links)) {
554 $growinglink .= $link;
555 $getlink = $this->makeLink( $growinglink, $link );
556 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
569 $s = "<p class='subtitle'>{$sub}</p>\n";
573 function nameAndLogin()
575 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader, $wgIP;
577 $li = $wgLang->specialPage( "Userlogin" );
578 $lo = $wgLang->specialPage( "Userlogout" );
581 if ( 0 == $wgUser->getID() ) {
582 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) {
585 $tl = $this->makeKnownLink( $wgLang->getNsText(
586 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
587 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
589 $s .= $n . " (".$tl.")";
591 $s .= wfMsg("notloggedin");
594 $rt = $wgTitle->getPrefixedURL();
595 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
597 } else { $q = "returnto={$rt}"; }
599 $s .= "\n<br />" . $this->makeKnownLink( $li,
600 wfMsg( "login" ), $q );
602 $n = $wgUser->getName();
603 $rt = $wgTitle->getPrefixedURL();
604 $tl = $this->makeKnownLink( $wgLang->getNsText(
605 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
606 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
610 $s .= $this->makeKnownLink( $wgLang->getNsText(
611 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br />" .
612 $this->makeKnownLink( $lo, wfMsg( "logout" ),
613 "returnto={$rt}" ) . " | " .
614 $this->specialLink( "preferences" );
616 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
622 function searchForm()
626 $search = $wgRequest->getText( 'search' );;
628 $s = "<form name='search' class='inline' method='post' action=\""
629 . wfLocalUrl( "" ) . "\">\n"
630 . "<input type='text' name=\"search\" size='19' value=\""
631 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
632 . "<input type='submit' name=\"go\" value=\"" . wfMsg ("go") . "\" /> "
633 . "<input type='submit' name=\"fulltext\" value=\"" . wfMsg ("search") . "\" />\n</form>";
643 $s = $this->mainPageLink() . $sep
644 . $this->specialLink( "recentchanges" );
646 if ( $wgOut->isArticleRelated() ) {
647 $s .= $sep . $this->editThisPage()
648 . $sep . $this->historyLink();
650 # Many people don't like this dropdown box
651 #$s .= $sep . $this->specialPagesList();
656 function bottomLinks()
658 global $wgOut, $wgUser, $wgTitle;
662 if ( $wgOut->isArticleRelated() ) {
663 $s .= "<strong>" . $this->editThisPage() . "</strong>";
664 if ( 0 != $wgUser->getID() ) {
665 $s .= $sep . $this->watchThisPage();
667 $s .= $sep . $this->talkLink()
668 . $sep . $this->historyLink()
669 . $sep . $this->whatLinksHere()
670 . $sep . $this->watchPageLinksLink();
672 if ( $wgTitle->getNamespace() == Namespace::getUser()
673 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
676 $id=User
::idFromName($wgTitle->getText());
677 $ip=User
::isIP($wgTitle->getText());
679 if($id ||
$ip) { # both anons and non-anons have contri list
680 $s .= $sep . $this->userContribsLink();
682 if ( 0 != $wgUser->getID() ) { # show only to signed in users
683 if($id) { # can only email non-anons
684 $s .= $sep . $this->emailUserLink();
688 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
689 $s .= "\n<br />" . $this->deleteThisPage() .
690 $sep . $this->protectThisPage() .
691 $sep . $this->moveThisPage();
693 $s .= "<br />\n" . $this->otherLanguages();
700 global $wgOut, $wgLang, $wgArticle, $wgRequest;
701 global $wgDisableCounters;
703 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
704 if ( ! $wgOut->isArticle() ) { return ""; }
705 if ( isset( $oldid ) ||
isset( $diff ) ) { return ""; }
706 if ( 0 == $wgArticle->getID() ) { return ""; }
709 if ( !$wgDisableCounters ) {
710 $count = $wgLang->formatNum( $wgArticle->getCount() );
712 $s = wfMsg( "viewcount", $count );
715 $s .= $this->lastModified();
716 return $s . " " . $this->getCopyright();
719 function getCopyright() {
720 global $wgRightsPage, $wgRightsUrl, $wgRightsText;
722 if( $wgRightsPage ) {
723 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
724 } elseif( $wgRightsUrl ) {
725 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
730 $out .= wfMsg( "copyright", $link );
734 function getCopyrightIcon() {
735 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
737 if( $wgRightsIcon ) {
738 $icon = htmlspecialchars( $wgRightsIcon );
740 $url = htmlspecialchars( $wgRightsUrl );
741 $out .= "<a href=\"$url\">";
743 $text = htmlspecialchars( $wgRightsText );
744 $out .= "<img src=\"$icon\" alt='$text' />";
752 function getPoweredBy() {
753 global $wgUploadPath;
754 $url = htmlspecialchars( "$wgUploadPath/poweredby_mediawiki_88x31.png" );
755 $img = "<a href='http://www.mediawiki.org/'><img src='$url' alt='MediaWiki' /></a>";
759 function lastModified()
761 global $wgLang, $wgArticle;
763 $timestamp = $wgArticle->getTimestamp();
765 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
766 $s = " " . wfMsg( "lastmodified", $d );
773 function logoText( $align = "" )
775 if ( "" != $align ) { $a = " align='{$align}'"; }
778 $mp = wfMsg( "mainpage" );
779 $titleObj = Title
::newFromText( $mp );
780 $s = "<a href=\"" . $titleObj->escapeLocalURL()
781 . "\"><img{$a} src=\""
782 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\" /></a>";
788 global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgLang;
789 global $wgDisableUploads, $wgRemoteUploads;
791 $fname = "Skin::quickBar";
792 wfProfileIn( $fname );
794 $action = $wgRequest->getText( 'action' );
795 $wpPreview = $wgRequest->getBool( 'wpPreview' );
796 $tns=$wgTitle->getNamespace();
798 $s = "\n<div id='quickbar'>";
799 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
802 $s .= $this->mainPageLink()
803 . $sep . $this->specialLink( "recentchanges" )
804 . $sep . $this->specialLink( "randompage" );
805 if ($wgUser->getID()) {
806 $s.= $sep . $this->specialLink( "watchlist" ) ;
807 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
808 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
811 // only show watchlist link if logged in
812 if ( wfMsg ( "currentevents" ) != "" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
813 $s .= "\n<br /><hr class='sep' />";
814 $articleExists = $wgTitle->getArticleId();
815 if ( $wgOut->isArticle() ||
$action =="edit" ||
$action =="history" ||
$wpPreview) {
816 if($wgOut->isArticle()) {
817 $s .= "<strong>" . $this->editThisPage() . "</strong>";
818 } else { # backlink to the article in edit or history mode
819 if($articleExists){ # no backlink if no article
822 $text = wfMsg("articlepage");
825 $text = wfMsg("viewtalkpage");
828 $text = wfMsg("userpage");
831 $text = wfMsg("viewtalkpage");
834 $text = wfMsg("wikipediapage");
837 $text = wfMsg("viewtalkpage");
840 $text = wfMsg("imagepage");
843 $text = wfMsg("viewtalkpage");
846 $text= wfMsg("articlepage");
849 $link = $wgTitle->getText();
850 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
851 $link = $nstext . ":" . $link ;
854 $s .= $this->makeLink( $link, $text );
855 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
856 # we just throw in a "New page" text to tell the user that he's in edit mode,
857 # and to avoid messing with the separator that is prepended to the next item
858 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
864 if( $tns%2
&& $action!="edit" && !$wpPreview) {
865 $s.="<br />".$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("postcomment"),"action=edit§ion=new");
869 watching could cause problems in edit mode:
870 if user edits article, then loads "watch this article" in background and then saves
871 article with "Watch this article" checkbox disabled, the article is transparently
872 unwatched. Therefore we do not show the "Watch this page" link in edit mode
874 if ( 0 != $wgUser->getID() && $articleExists) {
875 if($action!="edit" && $action != "submit" )
877 $s .= $sep . $this->watchThisPage();
879 if ( $wgTitle->userCanEdit() )
880 $s .= $sep . $this->moveThisPage();
882 if ( $wgUser->isSysop() and $articleExists ) {
883 $s .= $sep . $this->deleteThisPage() .
884 $sep . $this->protectThisPage();
886 $s .= $sep . $this->talkLink();
887 if ($articleExists && $action !="history") {
888 $s .= $sep . $this->historyLink();
890 $s.=$sep . $this->whatLinksHere();
892 if($wgOut->isArticleRelated()) {
893 $s .= $sep . $this->watchPageLinksLink();
896 if ( Namespace::getUser() == $wgTitle->getNamespace()
897 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
900 $id=User
::idFromName($wgTitle->getText());
901 $ip=User
::isIP($wgTitle->getText());
904 $s .= $sep . $this->userContribsLink();
906 if ( 0 != $wgUser->getID() ) {
907 if($id) { # can only email real users
908 $s .= $sep . $this->emailUserLink();
912 $s .= "\n<br /><hr class='sep' />";
915 if ( 0 != $wgUser->getID() && ( !$wgDisableUploads ||
$wgRemoteUploads ) ) {
916 $s .= $this->specialLink( "upload" ) . $sep;
918 $s .= $this->specialLink( "specialpages" )
919 . $sep . $this->bugReportsLink();
921 global $wgSiteSupportPage;
922 if( $wgSiteSupportPage ) {
923 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
924 "\" class=\"internal\">" . wfMsg( "sitesupport" ) . "</a>";
927 $s .= "\n<br /></div>\n";
928 wfProfileOut( $fname );
932 function specialPagesList()
934 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
937 $validSP = $wgLang->getValidSpecialPages();
939 foreach ( $validSP as $name => $desc ) {
940 if ( "" == $desc ) { continue; }
943 if ( $wgUser->isSysop() )
945 $sysopSP = $wgLang->getSysopSpecialPages();
947 foreach ( $sysopSP as $name => $desc ) {
948 if ( "" == $desc ) { continue; }
952 if ( $wgUser->isDeveloper() )
954 $devSP = $wgLang->getDeveloperSpecialPages();
956 foreach ( $devSP as $name => $desc ) {
957 if ( "" == $desc ) { continue; }
962 $sp = wfMsg( "specialpages" );
963 $spp = $wgLang->specialPage( "Specialpages" );
965 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
966 "action=\"" . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
967 $s .= "<select name=\"wpDropdown\">\n";
968 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
970 foreach ( $a as $name => $desc ) {
971 $p = $wgLang->specialPage( $name );
972 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
975 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
980 function mainPageLink()
982 $mp = wfMsg( "mainpage" );
983 $s = $this->makeKnownLink( $mp, $mp );
987 function copyrightLink()
989 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
990 wfMsg( "copyrightpagename" ) );
996 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
997 wfMsg( "aboutwikipedia" ) );
1002 function disclaimerLink()
1004 $s = $this->makeKnownLink( wfMsg( "disclaimerpage" ),
1005 wfMsg( "disclaimers" ) );
1009 function editThisPage()
1011 global $wgOut, $wgTitle, $wgRequest;
1013 $oldid = $wgRequest->getVal( 'oldid' );
1014 $diff = $wgRequest->getVal( 'diff' );
1015 $redirect = $wgRequest->getVal( 'redirect' );
1017 if ( ! $wgOut->isArticleRelated() ) {
1018 $s = wfMsg( "protectedpage" );
1020 $n = $wgTitle->getPrefixedText();
1021 if ( $wgTitle->userCanEdit() ) {
1022 $t = wfMsg( "editthispage" );
1024 #$t = wfMsg( "protectedpage" );
1025 $t = wfMsg( "viewsource" );
1029 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1030 if ( $oldid && ! isset( $diff ) ) {
1031 $oid = "&oldid={$oldid}";
1033 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
1038 function deleteThisPage()
1040 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1042 $diff = $wgRequest->getVal( 'diff' );
1043 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1044 $n = $wgTitle->getPrefixedText();
1045 $t = wfMsg( "deletethispage" );
1047 $s = $this->makeKnownLink( $n, $t, "action=delete" );
1054 function protectThisPage()
1056 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1058 $diff = $wgRequest->getVal( 'diff' );
1059 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1060 $n = $wgTitle->getPrefixedText();
1062 if ( $wgTitle->isProtected() ) {
1063 $t = wfMsg( "unprotectthispage" );
1064 $q = "action=unprotect";
1066 $t = wfMsg( "protectthispage" );
1067 $q = "action=protect";
1069 $s = $this->makeKnownLink( $n, $t, $q );
1076 function watchThisPage()
1078 global $wgUser, $wgOut, $wgTitle;
1080 if ( $wgOut->isArticleRelated() ) {
1081 $n = $wgTitle->getPrefixedText();
1083 if ( $wgTitle->userIsWatching() ) {
1084 $t = wfMsg( "unwatchthispage" );
1085 $q = "action=unwatch";
1087 $t = wfMsg( "watchthispage" );
1088 $q = "action=watch";
1090 $s = $this->makeKnownLink( $n, $t, $q );
1092 $s = wfMsg( "notanarticle" );
1097 function moveThisPage()
1099 global $wgTitle, $wgLang;
1101 if ( $wgTitle->userCanEdit() ) {
1102 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
1103 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
1104 } // no message if page is protected - would be redundant
1108 function historyLink()
1112 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1113 wfMsg( "history" ), "action=history" );
1117 function whatLinksHere()
1119 global $wgTitle, $wgLang;
1121 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
1122 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
1126 function userContribsLink()
1128 global $wgTitle, $wgLang;
1130 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1131 wfMsg( "contributions" ), "target=" . $wgTitle->getPartialURL() );
1135 function emailUserLink()
1137 global $wgTitle, $wgLang;
1139 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
1140 wfMsg( "emailuser" ), "target=" . $wgTitle->getPartialURL() );
1144 function watchPageLinksLink()
1146 global $wgOut, $wgTitle, $wgLang;
1148 if ( ! $wgOut->isArticleRelated() ) {
1149 $s = "(" . wfMsg( "notanarticle" ) . ")";
1151 $s = $this->makeKnownLink( $wgLang->specialPage(
1152 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
1153 "target=" . $wgTitle->getPrefixedURL() );
1158 function otherLanguages()
1160 global $wgOut, $wgLang, $wgTitle, $wgUseNewInterlanguage;
1162 $a = $wgOut->getLanguageLinks();
1163 if ( 0 == count( $a ) ) {
1164 if ( !$wgUseNewInterlanguage ) return "";
1165 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1166 if ( $ns != 0 AND $ns != 1 ) return "" ;
1168 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
1169 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1170 wfMsg( "intl" ) , $x );
1173 if ( !$wgUseNewInterlanguage ) {
1174 $s = wfMsg( "otherlanguages" ) . ": ";
1176 global $wgLanguageCode ;
1177 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
1178 $x .= "&xl=".$wgLanguageCode ;
1179 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
1180 wfMsg( "otherlanguages" ) , $x ) . ": " ;
1183 $s = wfMsg( "otherlanguages" ) . ": ";
1185 if($wgLang->isRTL()) $s .= "<span dir='LTR'>";
1186 foreach( $a as $l ) {
1187 if ( ! $first ) { $s .= " | "; }
1190 $nt = Title
::newFromText( $l );
1191 $url = $nt->getFullURL();
1192 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
1194 if ( "" == $text ) { $text = $l; }
1195 $style = $this->getExternalLinkAttributes( $l, $text );
1196 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1198 if($wgLang->isRTL()) $s .= "</span>";
1202 function bugReportsLink()
1204 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
1205 wfMsg( "bugreports" ) );
1211 global $wgLinkCache;
1212 $t1 = Title
::newFromText( gmdate( "F j" ) );
1213 $t2 = Title
::newFromText( gmdate( "Y" ) );
1215 $wgLinkCache->suspend();
1216 $id = $t1->getArticleID();
1217 $wgLinkCache->resume();
1220 $s = $this->makeBrokenLink( $t1->getText() );
1222 $s = $this->makeKnownLink( $t1->getText() );
1226 $wgLinkCache->suspend();
1227 $id = $t2->getArticleID();
1228 $wgLinkCache->resume();
1231 $s .= $this->makeBrokenLink( $t2->getText() );
1233 $s .= $this->makeKnownLink( $t2->getText() );
1240 global $wgLang, $wgTitle, $wgLinkCache;
1242 $tns = $wgTitle->getNamespace();
1243 if ( -1 == $tns ) { return ""; }
1245 $pn = $wgTitle->getText();
1246 $tp = wfMsg( "talkpage" );
1247 if ( Namespace::isTalk( $tns ) ) {
1248 $lns = Namespace::getSubject( $tns );
1251 $text = wfMsg("articlepage");
1254 $text = wfMsg("userpage");
1257 $text = wfMsg("wikipediapage");
1260 $text = wfMsg("imagepage");
1263 $text= wfMsg("articlepage");
1267 $lns = Namespace::getTalk( $tns );
1270 $n = $wgLang->getNsText( $lns );
1271 if ( "" == $n ) { $link = $pn; }
1272 else { $link = "{$n}:{$pn}"; }
1274 $wgLinkCache->suspend();
1275 $s = $this->makeLink( $link, $text );
1276 $wgLinkCache->resume();
1281 function commentLink()
1283 global $wgLang, $wgTitle, $wgLinkCache;
1285 $tns = $wgTitle->getNamespace();
1286 if ( -1 == $tns ) { return ""; }
1288 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1290 # assert Namespace::isTalk( $lns )
1292 $n = $wgLang->getNsText( $lns );
1293 $pn = $wgTitle->getText();
1295 $link = "{$n}:{$pn}";
1297 $wgLinkCache->suspend();
1298 $s = $this->makeKnownLink($link, wfMsg("postcomment"), "action=edit§ion=new");
1299 $wgLinkCache->resume();
1304 # After all the page content is transformed into HTML, it makes
1305 # a final pass through here for things like table backgrounds.
1307 function transformContent( $text )
1312 # Note: This function MUST call getArticleID() on the link,
1313 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1315 function makeLink( $title, $text = "", $query = "", $trail = "" ) {
1316 wfProfileIn( "Skin::makeLink" );
1317 $nt = Title
::newFromText( $title );
1319 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1321 wfDebug( "Invalid title passed to Skin::makeLink(): \"$title\"\n" );
1322 $result = $text == "" ?
$title : $text;
1325 wfProfileOut( "Skin::makeLink" );
1329 function makeKnownLink( $title, $text = "", $query = "", $trail = "", $prefix = '',$aprops = '') {
1330 $nt = Title
::newFromText( $title );
1332 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
1334 wfDebug( "Invalid title passed to Skin::makeKnownLink(): \"$title\"\n" );
1335 return $text == "" ?
$title : $text;
1339 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" ) {
1340 $nt = Title
::newFromText( $title );
1342 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1344 wfDebug( "Invalid title passed to Skin::makeBrokenLink(): \"$title\"\n" );
1345 return $text == "" ?
$title : $text;
1349 function makeStubLink( $title, $text = "", $query = "", $trail = "" ) {
1350 $nt = Title
::newFromText( $title );
1352 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1354 wfDebug( "Invalid title passed to Skin::makeStubLink(): \"$title\"\n" );
1355 return $text == "" ?
$title : $text;
1359 # Pass a title object, not a title string
1360 function makeLinkObj( &$nt, $text= "", $query = "", $trail = "", $prefix = "" )
1362 global $wgOut, $wgUser;
1363 if ( $nt->isExternal() ) {
1364 $u = $nt->getFullURL();
1365 $link = $nt->getPrefixedURL();
1366 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1367 $style = $this->getExternalLinkAttributes( $link, $text );
1370 if ( "" != $trail ) {
1371 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1376 $retVal = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1377 } elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1378 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1379 } elseif ( ( -1 == $nt->getNamespace() ) ||
1380 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1381 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1383 $aid = $nt->getArticleID() ;
1385 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
1387 $threshold = $wgUser->getOption("stubthreshold") ;
1388 if ( $threshold > 0 ) {
1389 $res = wfQuery ( "SELECT LENGTH(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'", DB_READ
) ;
1391 if ( wfNumRows( $res ) > 0 ) {
1392 $s = wfFetchObject( $res );
1394 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
1395 $size = $threshold*2 ; # Really big
1397 wfFreeResult( $res );
1399 $size = $threshold*2 ; # Really big
1404 if ( $size < $threshold ) {
1405 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
1407 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1414 # Pass a title object, not a title string
1415 function makeKnownLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" , $aprops = '')
1417 global $wgOut, $wgTitle;
1419 $fname = "Skin::makeKnownLinkObj";
1420 wfProfileIn( $fname );
1422 $link = $nt->getPrefixedURL();
1424 if ( "" == $link ) {
1426 if ( "" == $text ) {
1427 $text = htmlspecialchars( $nt->getFragment() );
1430 $u = $nt->escapeLocalURL( $query );
1432 if ( "" != $nt->getFragment() ) {
1433 $u .= "#" . htmlspecialchars( $nt->getFragment() );
1435 if ( "" == $text ) {
1436 $text = htmlspecialchars( $nt->getPrefixedText() );
1438 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1441 if ( "" != $trail ) {
1442 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1447 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
1448 wfProfileOut( $fname );
1452 # Pass a title object, not a title string
1453 function makeBrokenLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" )
1455 global $wgOut, $wgUser;
1457 $fname = "Skin::makeBrokenLinkObj";
1458 wfProfileIn( $fname );
1460 if ( "" == $query ) {
1463 $q = "action=edit&{$query}";
1465 $u = $nt->escapeLocalURL( $q );
1467 if ( "" == $text ) {
1468 $text = htmlspecialchars( $nt->getPrefixedText() );
1470 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1473 if ( "" != $trail ) {
1474 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1479 if ( $wgUser->getOption( "highlightbroken" ) ) {
1480 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1482 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1485 wfProfileOut( $fname );
1489 # Pass a title object, not a title string
1490 function makeStubLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" )
1492 global $wgOut, $wgUser;
1494 $link = $nt->getPrefixedURL();
1496 $u = $nt->escapeLocalURL( $query );
1498 if ( "" == $text ) {
1499 $text = htmlspecialchars( $nt->getPrefixedText() );
1501 $style = $this->getInternalLinkAttributesObj( $nt, $text, "stub" );
1504 if ( "" != $trail ) {
1505 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1510 if ( $wgUser->getOption( "highlightbroken" ) ) {
1511 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1513 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1518 function makeSelfLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" )
1520 $u = $nt->escapeLocalURL( $query );
1521 if ( "" == $text ) {
1522 $text = htmlspecialchars( $nt->getPrefixedText() );
1525 if ( "" != $trail ) {
1526 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1531 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
1534 function fnamePart( $url )
1536 $basename = strrchr( $url, "/" );
1537 if ( false === $basename ) { $basename = $url; }
1538 else { $basename = substr( $basename, 1 ); }
1539 return wfEscapeHTML( $basename );
1542 function makeImage( $url, $alt = "" )
1546 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1547 $s = "<img src=\"{$url}\" alt=\"{$alt}\" />";
1551 function makeImageLink( $name, $url, $alt = "" ) {
1552 $nt = Title
::makeTitle( Namespace::getImage(), $name );
1553 return $this->makeImageLinkObj( $nt, $alt );
1556 function makeImageLinkObj( $nt, $alt = "" ) {
1557 global $wgLang, $wgUseImageResize;
1558 $name = $nt->getDBKey();
1559 $url = wfImageUrl( $name );
1561 $prefix = $postfix = "";
1563 if ( $wgUseImageResize ) {
1564 # Check if the alt text is of the form "options|alt text"
1566 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1567 # * left no resizing, just left align. label is used for alt= only
1568 # * right same, but right aligned
1569 # * none same, but not aligned
1570 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1572 $part = explode( "|", $alt);
1574 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
1575 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
1576 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
1577 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
1578 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
1579 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
1580 $alt = $part[count($part)-1];
1584 foreach( $part as $key => $val ) {
1585 if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1587 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1588 # remember to set an alignment, don't render immediately
1590 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1591 # remember to set an alignment, don't render immediately
1593 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
1594 # remember to set an alignment, don't render immediately
1596 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1597 # remember to set an alignment, don't render immediately
1599 } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1600 # $match is the image width in pixels
1601 $width = intval($match);
1604 if ( "center" == $align )
1606 $prefix = '<span style="text-align: center">';
1607 $postfix = '</span>';
1613 # Create a thumbnail. Alignment depends on language
1614 # writing direction, # right aligned for left-to-right-
1615 # languages ("Western languages"), left-aligned
1616 # for right-to-left-languages ("Semitic languages")
1618 # If thumbnail width has not been provided, it is set
1619 # here to 180 pixels
1620 if ( $align == "" ) {
1621 $align = $wgLang->isRTL() ?
"left" : "right";
1623 if ( ! isset($width) ) {
1626 return $prefix.$this->makeThumbLinkObj( $nt, $alt, $align, $width ).$postfix;
1628 } elseif ( isset($width) ) {
1630 # Create a resized image, without the additional thumbnail
1632 $url = $this->createThumb( $name, $width );
1634 } # endif $wgUseImageResize
1636 if ( empty( $alt ) ) {
1637 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1639 $alt = htmlspecialchars( $alt );
1641 $u = $nt->escapeLocalURL();
1644 $s = str_replace( "$1", $name, wfMsg("missingimage") );
1646 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1647 "<img src=\"{$url}\" alt=\"{$alt}\" /></a>";
1649 if ( "" != $align ) {
1650 $s = "<div class=\"float{$align}\"><span>{$s}</span>\n</div>";
1652 return $prefix.$s.$postfix;
1655 function createThumb( $name, $width ) {
1656 global $wgUploadDirectory;
1657 global $wgImageMagickConvertCommand;
1658 global $wgUseImageMagick;
1659 global $wgUseSquid, $wgInternalServer;
1660 $imgPath = wfImagePath( $name );
1661 $thumbName = $width."px-".$name;
1662 $thumbPath = wfImageThumbDir( $thumbName )."/".$thumbName;
1663 $thumbUrl = wfImageThumbUrl( $thumbName );
1665 if ( ! file_exists( $imgPath ) )
1667 # If there is no image, there will be no thumbnail
1671 if ( (! file_exists( $thumbPath ) )
1672 ||
( filemtime($thumbPath) < filemtime($imgPath) ) ) {
1674 if ( $wgUseSquid ) {
1676 $wgInternalServer.$thumbUrl
1678 wfPurgeSquidServers($urlArr);
1681 if ( $wgUseImageMagick ) {
1683 $cmd = $wgImageMagickConvertCommand .
1684 " -quality 85 -geometry {$width} ".
1685 escapeshellarg($imgPath) . " " .
1686 escapeshellarg($thumbPath);
1687 $conv = shell_exec( $cmd );
1689 # Use PHP's builtin GD library functions.
1691 # First find out what kind of file this is, and select the correct
1692 # input routine for this.
1693 list($src_width, $src_height, $src_type, $src_attr) = getimagesize( $imgPath );
1694 switch( $src_type ) {
1696 $src_image = imagecreatefromgif( $imgPath );
1699 $src_image = imagecreatefromjpeg( $imgPath );
1702 $src_image = imagecreatefrompng( $imgPath );
1704 case 15: # WBMP for WML
1705 $src_image = imagecreatefromwbmp( $imgPath );
1708 $src_image = imagecreatefromxbm( $imgPath );
1711 return "Image type not supported";
1714 $height = floor( $src_height * ( $width/$src_width ) );
1715 $dst_image = imagecreatetruecolor( $width, $height );
1716 imagecopyresampled( $dst_image, $src_image,
1718 $width, $height, $src_width, $src_height );
1719 switch( $src_type ) {
1724 #$thumbUrl .= ".png";
1725 #$thumbPath .= ".png";
1726 imagepng( $dst_image, $thumbPath );
1729 #$thumbUrl .= ".jpg";
1730 #$thumbPath .= ".jpg";
1731 imageinterlace( $dst_image );
1732 imagejpeg( $dst_image, $thumbPath, 95 );
1737 imagedestroy( $dst_image );
1738 imagedestroy( $src_image );
1743 # Check for zero-sized thumbnails. Those can be generated when
1744 # no disk space is available or some other error occurs
1746 $thumbstat = stat( $thumbPath );
1747 $imgstat = stat( $imgPath );
1748 if( $thumbstat["size"] == 0 )
1750 unlink( $thumbPath );
1757 function makeThumbLinkObj( $nt, $label = "", $align = "right", $boxwidth = 180 ) {
1758 global $wgUploadPath, $wgLang;
1759 $name = $nt->getDBKey();
1760 $image = Title
::makeTitle( Namespace::getImage(), $name );
1761 $url = wfImageUrl( $name );
1762 $path = wfImagePath( $name );
1764 #$label = htmlspecialchars( $label );
1765 $alt = preg_replace( "/<[^>]*>/", "", $label);
1766 $alt = htmlspecialchars( $alt );
1768 if ( file_exists( $path ) )
1770 list($width, $height, $type, $attr) = getimagesize( $path );
1772 $width = $height = 200;
1774 $boxheight = intval( $height/($width/$boxwidth) );
1775 if ( $boxwidth > $width ) {
1777 $boxheight = $height;
1779 $oboxwidth = $boxwidth +
2;
1780 $thumbUrl = $this->createThumb( $name, $boxwidth );
1782 $u = $nt->escapeLocalURL();
1784 $more = htmlspecialchars( wfMsg( "thumbnail-more" ) );
1785 $magnifyalign = $wgLang->isRTL() ?
"left" : "right";
1786 $textalign = $wgLang->isRTL() ?
' style="text-align:right"' : "";
1788 $s = "<div class=\"thumb t{$align}\"\"><div style=\"width:{$oboxwidth}px;\">";
1789 if ( $thumbUrl == "" ) {
1790 $s .= str_replace( "$1", $name, wfMsg("missingimage") );
1793 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1794 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1795 'width="'.$boxwidth.'" height="'.$boxheight.'" /></a>';
1796 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1797 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1798 '<img src="'.$wgUploadPath.'/magnify-clip.png" ' .
1799 'width="15" height="11" alt="'.$more.'" /></a></div>';
1802 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div>\n</div>";
1806 function makeMediaLink( $name, $url, $alt = "" ) {
1807 $nt = Title
::makeTitle( Namespace::getMedia(), $name );
1808 return $this->makeMediaLinkObj( $nt, $alt );
1811 function makeMediaLinkObj( $nt, $alt = "" )
1813 $name = $nt->getDBKey();
1814 $url = wfImageUrl( $name );
1815 if ( empty( $alt ) ) {
1816 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1819 $u = htmlspecialchars( $url );
1820 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1824 function specialLink( $name, $key = "" )
1828 if ( "" == $key ) { $key = strtolower( $name ); }
1829 $pn = $wgLang->ucfirst( $name );
1830 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1834 function makeExternalLink( $url, $text, $escape = true ) {
1835 $style = $this->getExternalLinkAttributes( $url, $text );
1836 $url = htmlspecialchars( $url );
1838 $text = htmlspecialchars( $text );
1840 return "<a href=\"$url\"$style>$text</a>";
1843 # Called by history lists and recent changes
1846 # Returns text for the start of the tabular part of RC
1847 function beginRecentChangesList()
1849 $this->rc_cache
= array() ;
1850 $this->rcMoveIndex
= 0;
1851 $this->rcCacheIndex
= 0 ;
1852 $this->lastdate
= "";
1853 $this->rclistOpen
= false;
1857 function beginImageHistoryList()
1859 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1860 "<p>" . wfMsg( "imghistlegend" ) . "</p>\n<ul class='special'>";
1864 # Returns text for the end of RC
1865 # If enhanced RC is in use, returns pretty much all the text
1866 function endRecentChangesList()
1868 $s = $this->recentChangesBlock() ;
1869 if( $this->rclistOpen
) {
1875 # Enhanced RC ungrouped line
1876 function recentChangesBlockLine ( $rcObj )
1878 global $wgUploadPath, $wgLang ;
1880 # Get rc_xxxx variables
1881 extract( $rcObj->mAttribs
) ;
1882 $curIdEq = "curid=$rc_cur_id";
1887 $r .= "<img src='{$wgUploadPath}/Arr_.png' width='12' height='12' border='0' />" ; $r .= "<tt>" ;
1889 if ( $rc_type == RC_MOVE
) {
1890 $r .= " ";
1892 # M & N (minor & new)
1893 $M = wfMsg( "minoreditletter" );
1894 $N = wfMsg( "newpageletter" );
1896 if ( $rc_type == RC_NEW
) {
1909 $r .= " ".$rcObj->timestamp
." " ;
1913 $link = $rcObj->link
;
1914 if ( $rcObj->watched
) $link = "<strong>{$link}</strong>" ;
1919 $r .= $rcObj->curlink
;
1923 $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" );
1926 $r .= ") . . ".$rcObj->userlink
;
1927 $r .= $rcObj->usertalklink
;
1930 if ( $rc_comment != "" && $rc_type != RC_MOVE
) {
1931 $rc_comment=$this->formatComment($rc_comment);
1932 $r .= $wgLang->emphasize( " (".$rc_comment.")" );
1940 function recentChangesBlockGroup ( $block )
1942 global $wgUploadPath, $wgLang ;
1945 $M = wfMsg( "minoreditletter" );
1946 $N = wfMsg( "newpageletter" );
1948 # Collate list of users
1950 $userlinks = array () ;
1951 foreach ( $block AS $rcObj ) {
1952 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
1953 if ( $rcObj->mAttribs
['rc_new'] ) $isnew = true ;
1954 $u = $rcObj->userlink
;
1955 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1959 # Sort the list and convert to text
1960 krsort ( $userlinks ) ;
1961 asort ( $userlinks ) ;
1963 foreach ( $userlinks as $userlink => $count) {
1965 if ( $count > 1 ) $text .= " ({$count}×)" ;
1966 array_push ( $users , $text ) ;
1968 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1971 $rci = "RCI{$this->rcCacheIndex}" ;
1972 $rcl = "RCL{$this->rcCacheIndex}" ;
1973 $rcm = "RCM{$this->rcCacheIndex}" ;
1974 $toggleLink = "javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")" ;
1975 $arrowdir = $wgLang->isRTL() ?
"l" : "r";
1976 $tl = "<span id='{$rcm}'><a href='$toggleLink'><img src='{$wgUploadPath}/Arr_{$arrowdir}.png' width='12' height='12' /></a></span>" ;
1977 $tl .= "<span id='{$rcl}' style='display:none'><a href='$toggleLink'><img src='{$wgUploadPath}/Arr_d.png' width='12' height='12' /></a></span>" ;
1983 if ( $isnew ) $r .= $N ;
1984 else $r .= " " ;
1985 $r .= " " ; # Minor
1988 $r .= " ".$block[0]->timestamp
." " ;
1992 $link = $block[0]->link
;
1993 if ( $block[0]->watched
) $link = "<strong>{$link}</strong>" ;
1996 $curIdEq = "curid=" . $block[0]->mAttribs
['rc_cur_id'];
1997 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
1999 $r .= " (".count($block)." " ;
2000 if ( $isnew ) $r .= wfMsg("changes");
2001 else $r .= $this->makeKnownLinkObj( $block[0]->getTitle() , wfMsg("changes") ,
2002 "{$curIdEq}&diff=0&oldid=".$oldid ) ;
2006 $r .= $this->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( "history" ), "{$curIdEq}&action=history" );
2014 $r .= "<div id='{$rci}' style='display:none'>" ;
2015 foreach ( $block AS $rcObj ) {
2016 # Get rc_xxxx variables
2017 extract( $rcObj->mAttribs
);
2019 $r .= "<img src='{$wgUploadPath}/Arr_.png' width=12 height=12 />";
2020 $r .= "<tt> " ;
2021 if ( $rc_new ) $r .= $N ;
2022 else $r .= " " ;
2023 if ( $rc_minor ) $r .= $M ;
2024 else $r .= " " ;
2028 if ( $rc_last_oldid != 0 ) {
2029 $o = "oldid=".$rc_last_oldid ;
2031 if ( $rc_type == RC_LOG
) {
2032 $link = $rcObj->timestamp
;
2034 $link = $this->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
2036 $link = "<tt>{$link}</tt>" ;
2040 $r .= $rcObj->curlink
;
2042 $r .= $rcObj->lastlink
;
2043 $r .= ") . . ".$rcObj->userlink
;
2044 $r .= $rcObj->usertalklink
;
2045 if ( $rc_comment != "" ) {
2046 $rc_comment=$this->formatComment($rc_comment);
2047 $r .= $wgLang->emphasize( " (".$rc_comment.")" ) ;
2053 $this->rcCacheIndex++
;
2057 # If enhanced RC is in use, this function takes the previously cached
2058 # RC lines, arranges them, and outputs the HTML
2059 function recentChangesBlock ()
2061 global $wgUploadPath ;
2062 if ( count ( $this->rc_cache
) == 0 ) return "" ;
2064 foreach ( $this->rc_cache
AS $secureName => $block ) {
2065 if ( count ( $block ) < 2 ) {
2066 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
2068 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
2072 return "<div>{$blockOut}</div>" ;
2075 # Called in a loop over all displayed RC entries
2076 # Either returns the line, or caches it for later use
2077 function recentChangesLine( &$rc, $watched = false )
2080 $usenew = $wgUser->getOption( "usenewrc" );
2082 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
2084 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
2088 function recentChangesLineOld( &$rc, $watched = false )
2090 global $wgTitle, $wgLang, $wgUser, $wgRCSeconds;
2092 # Extract DB fields into local scope
2093 extract( $rc->mAttribs
);
2094 $curIdEq = "curid=" . $rc_cur_id;
2096 # Make date header if necessary
2097 $date = $wgLang->date( $rc_timestamp, true);
2099 if ( $date != $this->lastdate
) {
2100 if ( "" != $this->lastdate
) { $s .= "</ul>\n"; }
2101 $s .= "<h4>{$date}</h4>\n<ul class='special'>";
2102 $this->lastdate
= $date;
2103 $this->rclistOpen
= true;
2107 if ( $rc_type == RC_MOVE
) {
2109 $s .= "(" . wfMsg( "diff" ) . ") (";
2111 $s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), wfMsg( "hist" ), "action=history" ) .
2114 # "[[x]] moved to [[y]]"
2116 $s .= wfMsg( "1movedto2", $this->makeKnownLinkObj( $rc->getTitle(), "", "redirect=no" ),
2117 $this->makeKnownLinkObj( $rc->getMovedToTitle(), "" ) );
2121 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
2122 $diffLink = wfMsg( "diff" );
2124 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "diff" ),
2125 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}" ,'' ,'' , ' tabindex="'.$rc->counter
.'"');
2127 $s .= "($diffLink) (";
2130 $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" );
2133 # M and N (minor and new)
2134 $M = wfMsg( "minoreditletter" );
2135 $N = wfMsg( "newpageletter" );
2136 if ( $rc_minor ) { $s .= " <strong>{$M}</strong>"; }
2137 if ( $rc_type == RC_NEW
) { $s .= "<strong>{$N}</strong>"; }
2140 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), "" );
2143 $articleLink = "<strong>{$articleLink}</strong>";
2145 $s .= " $articleLink";
2150 $s .= "; " . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . " . . ";
2152 # User link (or contributions for unregistered users)
2153 if ( 0 == $rc_user ) {
2154 $userLink = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
2155 $rc_user_text, "target=" . $rc_user_text );
2157 $userLink = $this->makeLink( $wgLang->getNsText( NS_USER
) . ":{$rc_user_text}", $rc_user_text );
2162 $talkname=$wgLang->getNsText(NS_TALK
); # use the shorter name
2163 global $wgDisableAnonTalk;
2164 if( 0 == $rc_user && $wgDisableAnonTalk ) {
2167 $utns=$wgLang->getNsText(NS_USER_TALK
);
2168 $userTalkLink= $this->makeLink($utns . ":{$rc_user_text}", $talkname );
2172 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2173 $blockLink = $this->makeKnownLink( $wgLang->specialPage(
2174 "Blockip" ), wfMsg( "blocklink" ), "ip={$rc_user_text}" );
2178 if($userTalkLink) $userTalkLink .= " | ";
2179 $userTalkLink .= $blockLink;
2181 if($userTalkLink) $s.=" ({$userTalkLink})";
2184 if ( "" != $rc_comment && "*" != $rc_comment && $rc_type != RC_MOVE
) {
2185 $rc_comment=$this->formatComment($rc_comment);
2186 $s .= $wgLang->emphasize(" (" . $rc_comment . ")");
2193 # function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
2194 function recentChangesLineNew( &$baseRC, $watched = false )
2196 global $wgTitle, $wgLang, $wgUser, $wgRCSeconds;
2198 # Create a specialised object
2199 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
2201 # Extract fields from DB into the function scope (rc_xxxx variables)
2202 extract( $rc->mAttribs
);
2203 $curIdEq = "curid=" . $rc_cur_id;
2205 # If it's a new day, add the headline and flush the cache
2206 $date = $wgLang->date( $rc_timestamp, true);
2208 if ( $date != $this->lastdate
) {
2209 # Process current cache
2210 $ret = $this->recentChangesBlock () ;
2211 $this->rc_cache
= array() ;
2212 $ret .= "<h4>{$date}</h4>\n";
2213 $this->lastdate
= $date;
2217 if ( $rc_type == RC_MOVE
) {
2218 $clink = $this->makeKnownLinkObj( $rc->getTitle(), "", "redirect=no" );
2219 $clink .= " " . wfMsg("movedto") . " ";
2220 $clink .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), "" );
2222 $clink = $this->makeKnownLinkObj( $rc->getTitle(), "" ) ;
2225 $time = $wgLang->time( $rc_timestamp, true, $wgRCSeconds );
2226 $rc->watched
= $watched ;
2227 $rc->link
= $clink ;
2228 $rc->timestamp
= $time;
2231 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE
) {
2232 $curLink = wfMsg( "cur" );
2234 $curLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "cur" ),
2235 "{$curIdEq}&diff=0&oldid={$rc_this_oldid}" ,'' ,'' , ' tabindex="'.$baseRC->counter
.'"' );
2239 $titleObj = $rc->getTitle();
2240 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE
) {
2241 $lastLink = wfMsg( "last" );
2243 $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "last" ),
2244 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}" );
2247 # Make user link (or user contributions for unregistered users)
2248 if ( 0 == $rc_user ) {
2249 $userLink = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
2250 $rc_user_text, "target=" . $rc_user_text );
2252 $userLink = $this->makeLink( $wgLang->getNsText(
2253 Namespace::getUser() ) . ":{$rc_user_text}", $rc_user_text );
2256 $rc->userlink
= $userLink ;
2257 $rc->lastlink
= $lastLink ;
2258 $rc->curlink
= $curLink ;
2260 # Make user talk link
2261 $utns=$wgLang->getNsText(NS_USER_TALK
);
2262 $talkname=$wgLang->getNsText(NS_TALK
); # use the shorter name
2263 $userTalkLink= $this->makeLink($utns . ":{$rc_user_text}", $talkname );
2265 global $wgDisableAnonTalk;
2266 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2267 $blockLink = $this->makeKnownLink( $wgLang->specialPage(
2268 "Blockip" ), wfMsg( "blocklink" ), "ip={$rc_user_text}" );
2269 if( $wgDisableAnonTalk )
2270 $rc->usertalklink
= " ({$blockLink})";
2272 $rc->usertalklink
= " ({$userTalkLink} | {$blockLink})";
2274 if( $wgDisableAnonTalk && ($rc_user == 0) )
2275 $rc->usertalklink
= "";
2277 $rc->usertalklink
= " ({$userTalkLink})";
2280 # Put accumulated information into the cache, for later display
2281 # Page moves go on their own line
2282 $title = $rc->getTitle();
2283 $secureName = $title->getPrefixedDBkey();
2284 if ( $rc_type == RC_MOVE
) {
2285 # Use an @ character to prevent collision with page names
2286 $this->rc_cache
["@@" . ($this->rcMoveIndex++
)] = array($rc);
2288 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
2289 array_push ( $this->rc_cache
[$secureName] , $rc ) ;
2294 function endImageHistoryList()
2300 /* This function is called by all recent changes variants, by the page history,
2301 and by the user contributions list. It is responsible for formatting edit
2302 comments. It escapes any HTML in the comment, but adds some CSS to format
2303 auto-generated comments (from section editing) and formats [[wikilinks]].
2304 Main author: Erik Möller (moeller@scireview.de)
2306 function formatComment($comment)
2309 $comment=wfEscapeHTML($comment);
2311 # The pattern for autogen comments is / * foo * /, which makes for
2313 # We look for all comments, match any text before and after the comment,
2314 # add a separator where needed and format the comment itself with CSS
2315 while (preg_match("/(.*)\/\*\s*(.*?)\s*\*\/(.*)/", $comment,$match)) {
2320 if($pre) { $auto="$sep ".$auto; }
2321 if($post) { $auto.=" $sep"; }
2322 $auto="<span class=\"autocomment\">".$auto."</span>";
2323 $comment=$pre.$auto.$post;
2326 # format regular and media links - all other wiki formatting
2328 while(preg_match("/\[\[(.*?)(\|(.*?))*\]\]/",$comment,$match)) {
2330 $medians = $wgLang->getNsText(Namespace::getMedia());
2332 if(preg_match("/^".$medians."/i",$match[1])) {
2333 $func="makeMediaLink";
2335 if(isset($match[3]) ) {
2337 preg_replace("/\[\[(.*?)\]\]/",
2338 $this->$func($match[1],$match[3]),$comment,1);
2341 preg_replace("/\[\[(.*?)\]\]/",
2342 $this->$func($match[1],$match[1]),$comment,1);
2350 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
2352 global $wgUser, $wgLang, $wgTitle;
2354 $dt = $wgLang->timeanddate( $ts, true );
2355 $del = wfMsg( "deleteimg" );
2356 $cur = wfMsg( "cur" );
2359 $url = wfImageUrl( $img );
2361 if ( $wgUser->isSysop() ) {
2362 $link = $wgTitle->escapeLocalURL( "image=" . $wgTitle->getPartialURL() .
2364 $style = $this->getInternalLinkAttributes( $link, $del );
2366 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
2371 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
2372 if( $wgUser->getID() != 0 ) {
2373 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2374 wfMsg( "revertimg" ), "action=revert&oldimage=" .
2375 urlencode( $img ) );
2376 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2377 $del, "action=delete&oldimage=" . urlencode( $img ) );
2379 # Having live active links for non-logged in users
2380 # means that bots and spiders crawling our site can
2381 # inadvertently change content. Baaaad idea.
2382 $rlink = wfMsg( "revertimg" );
2386 if ( 0 == $u ) { $ul = $ut; }
2387 else { $ul = $this->makeLink( $wgLang->getNsText(
2388 Namespace::getUser() ) . ":{$ut}", $ut ); }
2390 $nb = wfMsg( "nbytes", $size );
2391 $style = $this->getInternalLinkAttributes( $url, $dt );
2393 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
2394 . " . . {$ul} ({$nb})";
2396 if ( "" != $c && "*" != $c ) {
2397 $sk=$wgUser->getSkin();
2398 $s .= $wgLang->emphasize(" (" . $sk->formatComment($c) . ")");
2404 function tocIndent($level) {
2405 return str_repeat( "<div class='tocindent'>\n", $level>0 ?
$level : 0 );
2408 function tocUnindent($level) {
2409 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
2412 # parameter level defines if we are on an indentation level
2413 function tocLine( $anchor, $tocline, $level ) {
2414 $link = "<a href=\"#$anchor\">$tocline</a><br />";
2418 return "<div class='tocline'>$link</div>\n";
2423 function tocTable($toc) {
2424 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2425 # try min-width & co when somebody gets a chance
2426 $hideline = " <script type='text/javascript'>showTocToggle(\"" . addslashes( wfMsg("showtoc") ) . "\",\"" . addslashes( wfMsg("hidetoc") ) . "\")</script>";
2428 "<table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
2429 "<b>".wfMsg("toc")."</b>" .
2431 "</td></tr><tr id='tocinside'><td>\n".
2432 $toc."</td></tr></table>\n";
2435 # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
2436 function editSectionScript( $section, $head ) {
2437 global $wgTitle, $wgRequest;
2438 if( $wgRequest->getInt( "oldid" ) && ( $wgRequest->getVal( "diff" ) != "0" ) ) {
2441 $url = $wgTitle->escapeLocalURL( "action=edit§ion=$section" );
2442 return "<span oncontextmenu='document.location=\"$url\";return false;'>{$head}</span>";
2445 function editSectionLink( $section ) {
2447 global $wgTitle, $wgUser, $wgLang;
2449 if( $wgRequest->getInt( "oldid" ) && ( $wgRequest->getVal( "diff" ) != "0" ) ) {
2450 # Section edit links would be out of sync on an old page.
2451 # But, if we're diffing to the current page, they'll be
2456 $editurl = "§ion={$section}";
2457 $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
2459 if( $wgLang->isRTL() ) {
2461 $nearside = "right";
2466 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2470 // This function is called by EditPage.php and shows a bulletin board style
2471 // toolbar for common editing functions. It can be disabled in the user preferences.
2472 // The necsesary JavaScript code can be found in style/wikibits.js.
2473 function getEditToolbar() {
2474 global $wgUploadPath, $wgLang, $wgMimeType;
2476 // toolarray an array of arrays which each include the filename of
2477 // the button image (without path), the opening tag, the closing tag,
2478 // and optionally a sample text that is inserted between the two when no
2479 // selection is highlighted.
2480 // The tip text is shown when the user moves the mouse over the button.
2482 // Already here are accesskeys (key), which are not used yet until someone
2483 // can figure out a way to make them work in IE. However, we should make
2484 // sure these keys are not defined on the edit page.
2486 array( "image"=>"button_bold.png",
2489 "sample"=>wfMsg("bold_sample"),
2490 "tip"=>wfMsg("bold_tip"),
2493 array( "image"=>"button_italic.png",
2496 "sample"=>wfMsg("italic_sample"),
2497 "tip"=>wfMsg("italic_tip"),
2500 array( "image"=>"button_link.png",
2503 "sample"=>wfMsg("link_sample"),
2504 "tip"=>wfMsg("link_tip"),
2507 array( "image"=>"button_extlink.png",
2510 "sample"=>wfMsg("extlink_sample"),
2511 "tip"=>wfMsg("extlink_tip"),
2514 array( "image"=>"button_headline.png",
2517 "sample"=>wfMsg("headline_sample"),
2518 "tip"=>wfMsg("headline_tip"),
2521 array( "image"=>"button_image.png",
2522 "open"=>"[[".$wgLang->getNsText(NS_IMAGE
).":",
2524 "sample"=>wfMsg("image_sample"),
2525 "tip"=>wfMsg("image_tip"),
2528 array( "image"=>"button_media.png",
2529 "open"=>"[[".$wgLang->getNsText(NS_MEDIA
).":",
2531 "sample"=>wfMsg("media_sample"),
2532 "tip"=>wfMsg("media_tip"),
2535 array( "image"=>"button_math.png",
2536 "open"=>"\\<math\\>",
2537 "close"=>"\\</math\\>",
2538 "sample"=>wfMsg("math_sample"),
2539 "tip"=>wfMsg("math_tip"),
2542 array( "image"=>"button_nowiki.png",
2543 "open"=>"\\<nowiki\\>",
2544 "close"=>"\\</nowiki\\>",
2545 "sample"=>wfMsg("nowiki_sample"),
2546 "tip"=>wfMsg("nowiki_tip"),
2549 array( "image"=>"button_sig.png",
2553 "tip"=>wfMsg("sig_tip"),
2556 array( "image"=>"button_hr.png",
2557 "open"=>"\\n----\\n",
2560 "tip"=>wfMsg("hr_tip"),
2564 $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
2566 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
2567 foreach($toolarray as $tool) {
2569 $image=$wgUploadPath."/".$tool["image"];
2570 $open=$tool["open"];
2571 $close=$tool["close"];
2572 $sample = addslashes( $tool["sample"] );
2574 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
2575 // Older browsers show a "speedtip" type message only for ALT.
2576 // Ideally these should be different, realistically they
2577 // probably don't need to be.
2578 $tip = addslashes( $tool["tip"] );
2580 #$key = $tool["key"];
2582 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
2585 $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
2586 $toolbar.="document.writeln(\"</div>\");\n";
2588 $toolbar.="/*]]>*/\n</script>";
2593 include_once( "SkinStandard.php" );
2594 include_once( "SkinNostalgia.php" );
2595 include_once( "SkinCologneBlue.php" );
2597 if( $wgUsePHPTal ) {
2598 include_once( "SkinPHPTal.php" );