3 include_once( "Feed.php" );
4 include_once( "Image.php" );
8 # These are the INTERNAL names, which get mapped
9 # directly to class names. For display purposes, the
10 # Language class has internationalized names
12 /* private */ $wgValidSkinNames = array(
13 'standard' => "Standard",
14 'nostalgia' => "Nostalgia",
15 'cologneblue' => "CologneBlue"
18 #$wgValidSkinNames[] = "PHPTal";
19 #$wgValidSkinNames['davinci'] = "DaVinci";
20 #$wgValidSkinNames['mono'] = "Mono";
21 $wgValidSkinNames['monobook'] = "MonoBook";
22 #$wgValidSkinNames['monobookminimal'] = "MonoBookMinimal";
25 include_once( "RecentChange.php" );
27 class RCCacheEntry
extends RecentChange
29 var $secureName, $link;
30 var $curlink , $lastlink , $usertalklink , $versionlink ;
31 var $userlink, $timestamp, $watched;
33 function newFromParent( $rc )
35 $rc2 = new RCCacheEntry
;
36 $rc2->mAttribs
= $rc->mAttribs
;
37 $rc2->mExtra
= $rc->mExtra
;
44 /* private */ var $lastdate, $lastline;
45 var $linktrail ; # linktrail regexp
46 var $rc_cache ; # Cache for Enhanced Recent Changes
47 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
52 $this->linktrail
= wfMsg("linktrail");
55 function getSkinNames()
57 global $wgValidSkinNames;
58 return $wgValidSkinNames;
61 function getStylesheet()
63 return "wikistandard.css";
68 global $wgOut, $wgUser;
70 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
71 $q = $wgUser->getOption( "quickbar" );
72 if ( "" == $q ) { $q = 0; }
76 function initPage( &$out )
78 $fname = "Skin::initPage";
79 wfProfileIn( $fname );
81 $out->addLink( array( "rel" => "shortcut icon", "href" => "/favicon.ico" ) );
83 $this->addMetadataLinks($out);
85 wfProfileOut( $fname );
88 function addMetadataLinks( &$out ) {
89 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
90 global $wgRightsPage, $wgRightsUrl;
92 if( $out->isArticleRelated() ) {
93 # note: buggy CC software only reads first "meta" link
94 if( $wgEnableCreativeCommonsRdf ) {
95 $out->addMetadataLink( array(
96 'title' => 'Creative Commons',
97 'type' => 'application/rdf+xml',
98 'href' => $wgTitle->getLocalURL( "action=creativecommons") ) );
100 if( $wgEnableDublinCoreRdf ) {
101 $out->addMetadataLink( array(
102 'title' => 'Dublin Core',
103 'type' => 'application/rdf+xml',
104 'href' => $wgTitle->getLocalURL( "action=dublincore" ) ) );
108 if( $wgRightsPage ) {
109 $copy = Title
::newFromText( $wgRightsPage );
111 $copyright = $copy->getLocalURL();
114 if( !$copyright && $wgRightsUrl ) {
115 $copyright = $wgRightsUrl;
118 $out->addLink( array(
119 "rel" => "copyright",
120 "href" => $copyright ) );
124 function outputPage( &$out ) {
125 global $wgDebugComments;
127 wfProfileIn( "Skin::outputPage" );
128 $this->initPage( $out );
129 $out->out( $out->headElement() );
131 $out->out( "\n<body" );
132 $ops = $this->getBodyOptions();
133 foreach ( $ops as $name => $val ) {
134 $out->out( " $name='$val'" );
137 if ( $wgDebugComments ) {
138 $out->out( "<!-- Wiki debugging output:\n" .
139 $out->mDebugtext
. "-->\n" );
141 $out->out( $this->beforeContent() );
143 $out->out( $out->mBodytext
. "\n" );
145 $out->out( $this->afterContent() );
148 $out->out( $out->reportTime() );
150 $out->out( "\n</body></html>" );
153 function getHeadScripts() {
155 $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/wikibits.js\"></script>\n";
159 function getUserStyles()
161 global $wgOut, $wgStylePath;
162 $sheet = $this->getStylesheet();
163 $s = "<style type='text/css'>\n";
164 $s .= "/*/*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
165 $s .= "@import url(\"$wgStylePath/$sheet\");\n";
166 $s .= $this->doGetUserStyles();
172 function doGetUserStyles()
177 if ( 1 == $wgUser->getOption( "underline" ) ) {
178 # Don't override browser settings
183 "text-decoration: none; }\n";
185 if ( 1 == $wgUser->getOption( "highlightbroken" ) ) {
186 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
188 if ( 1 == $wgUser->getOption( "justify" ) ) {
189 $s .= "#article { text-align: justify; }\n";
194 function getBodyOptions()
196 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
198 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
200 if ( 0 != $wgTitle->getNamespace() ) {
201 $a = array( "bgcolor" => "#ffffec" );
203 else $a = array( "bgcolor" => "#FFFFFF" );
204 if($wgOut->isArticle() && $wgUser->getOption("editondblclick") &&
205 (!$wgTitle->isProtected() ||
$wgUser->isSysop()) ) {
206 $t = wfMsg( "editthispage" );
208 if ( !empty($redirect) ) {
209 $red = "&redirect={$redirect}";
211 if ( !empty($oldid) && ! isset( $diff ) ) {
212 $oid = "&oldid={$oldid}";
214 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
215 $s = "document.location = \"" .$s ."\";";
216 $a +
= array ("ondblclick" => $s);
219 $a['onload'] = $wgOut->getOnloadHandler();
223 function getExternalLinkAttributes( $link, $text )
225 global $wgUser, $wgOut, $wgLang;
227 $link = urldecode( $link );
228 $link = $wgLang->checkTitleEncoding( $link );
229 $link = str_replace( "_", " ", $link );
230 $link = wfEscapeHTML( $link );
232 $r = " class='external'";
234 if ( 1 == $wgUser->getOption( "hover" ) ) {
235 $r .= " title=\"{$link}\"";
240 function getInternalLinkAttributes( $link, $text, $broken = false )
242 global $wgUser, $wgOut;
244 $link = urldecode( $link );
245 $link = str_replace( "_", " ", $link );
246 $link = wfEscapeHTML( $link );
248 if ( $broken == "stub" ) {
249 $r = " class='stub'";
250 } else if ( $broken == "yes" ) {
256 if ( 1 == $wgUser->getOption( "hover" ) ) {
257 $r .= " title=\"{$link}\"";
262 function getInternalLinkAttributesObj( &$nt, $text, $broken = false )
264 global $wgUser, $wgOut;
266 if ( $broken == "stub" ) {
267 $r = " class='stub'";
268 } else if ( $broken == "yes" ) {
274 if ( 1 == $wgUser->getOption( "hover" ) ) {
275 $r .= ' title ="' . $nt->getEscapedText() . '"';
286 # This will be called immediately after the <body> tag. Split into
287 # two functions to make it easier to subclass.
289 function beforeContent()
291 global $wgUser, $wgOut, $wgSiteNotice;
293 if( $wgSiteNotice ) {
294 $note = "\n<div id='notice' style='font-weight: bold; color: red; text-align: center'>$wgSiteNotice</div>\n";
298 return $this->doBeforeContent() . $note;
301 function doBeforeContent()
303 global $wgUser, $wgOut, $wgTitle, $wgLang;
304 $fname = "Skin::doBeforeContent";
305 wfProfileIn( $fname );
308 $qb = $this->qbSetting();
310 if( $langlinks = $this->otherLanguages() ) {
316 $borderhack = "class='top'";
319 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
320 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
323 $left = ($qb == 1 ||
$qb == 3);
324 if($wgLang->isRTL()) $left = !$left;
327 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
328 $this->logoText() . "</td>";
330 $s .= $this->getQuickbarCompensator( $rows );
332 $l = $wgLang->isRTL() ?
"right" : "left";
333 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
335 $s .= $this->topLinks() ;
336 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
338 $r = $wgLang->isRTL() ?
"left" : "right";
339 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
340 $s .= $this->nameAndLogin();
341 $s .= "\n<br />" . $this->searchForm() . "</td>";
344 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
347 if ( $shove && !$left ) { # Right
348 $s .= $this->getQuickbarCompensator( $rows );
350 $s .= "</tr>\n</table>\n</div>\n";
351 $s .= "\n<div id='article'>\n";
353 $s .= $this->pageTitle();
354 $s .= $this->pageSubtitle() ;
355 $s .= $this->getCategories();
356 wfProfileOut( $fname );
360 function getCategories () {
361 global $wgOut, $wgTitle, $wgUser, $wgParser;
362 global $wgUseCategoryMagic;
363 if( !$wgUseCategoryMagic ) return "" ;
364 if( count( $wgOut->mCategoryLinks
) == 0 ) return "";
365 if( !$wgOut->isArticle() ) return "";
367 $t = implode ( " | " , $wgOut->mCategoryLinks
) ;
368 $s = $this->makeKnownLink( "Special:Categories",
369 wfMsg( "categories" ), "article=" . urlencode( $wgTitle->getPrefixedDBkey() ) )
371 return "<p class='catlinks'>$s</p>";
374 function getQuickbarCompensator( $rows = 1 )
376 return "<td width='152' rowspan='{$rows}'> </td>";
379 # This gets called immediately before the </body> tag.
381 function afterContent()
383 global $wgUser, $wgOut, $wgServer;
384 global $wgTitle, $wgLang;
386 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
387 return $printfooter . $this->doAfterContent();
390 function printFooter() {
392 $url = htmlspecialchars( $wgTitle->getFullURL() );
393 return "<p>" . wfMsg( "retrievedfrom", "<a href=\"$url\">$url</a>" ) .
394 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
397 function doAfterContent()
399 global $wgUser, $wgOut, $wgLang;
400 $fname = "Skin::doAfterContent";
401 wfProfileIn( $fname );
402 wfProfileIn( "$fname-1" );
404 $s = "\n</div><br clear='all' />\n";
405 $s .= "\n<div id='footer'>";
406 $s .= "<table border='0' cellspacing='0'><tr>";
408 wfProfileOut( "$fname-1" );
409 wfProfileIn( "$fname-2" );
411 $qb = $this->qbSetting();
413 $left = ($qb == 1 ||
$qb == 3);
414 if($wgLang->isRTL()) $left = !$left;
416 if ( $shove && $left ) { # Left
417 $s .= $this->getQuickbarCompensator();
419 wfProfileOut( "$fname-2" );
420 wfProfileIn( "$fname-3" );
421 $l = $wgLang->isRTL() ?
"right" : "left";
422 $s .= "<td class='bottom' align='$l' valign='top'>";
424 $s .= $this->bottomLinks();
425 $s .= "\n<br />" . $this->mainPageLink()
426 . " | " . $this->aboutLink()
427 . " | " . $this->specialLink( "recentchanges" )
428 . " | " . $this->searchForm()
429 . "<br /><span id='pagestats'>" . $this->pageStats() . "</span>";
432 if ( $shove && !$left ) { # Right
433 $s .= $this->getQuickbarCompensator();
435 $s .= "</tr></table>\n</div>\n</div>\n";
437 wfProfileOut( "$fname-3" );
438 wfProfileIn( "$fname-4" );
439 if ( 0 != $qb ) { $s .= $this->quickBar(); }
440 wfProfileOut( "$fname-4" );
441 wfProfileOut( $fname );
445 function pageTitleLinks()
447 global $wgOut, $wgTitle, $wgUser, $wgLang, $wgUseApproval, $wgRequest;
449 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
450 $action = $wgRequest->getText( 'action' );
452 $s = $this->printableLink();
453 if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ;
455 if ( $wgOut->isArticleRelated() ) {
456 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
457 $name = $wgTitle->getDBkey();
458 $link = wfEscapeHTML( Image
::wfImageUrl( $name ) );
459 $style = $this->getInternalLinkAttributes( $link, $name );
460 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
462 # This will show the "Approve" link if $wgUseApproval=true;
463 if ( isset ( $wgUseApproval ) && $wgUseApproval )
465 $t = $wgTitle->getDBkey();
466 $name = "Approve this article" ;
467 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
468 #wfEscapeHTML( wfImageUrl( $name ) );
469 $style = $this->getExternalLinkAttributes( $link, $name );
470 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
473 if ( "history" == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
474 $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
475 wfMsg( "currentrev" ) );
478 if ( $wgUser->getNewtalk() ) {
479 # do not show "You have new messages" text when we are viewing our
482 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
483 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
484 $n =$wgUser->getName();
485 $tl = $this->makeKnownLink( $wgLang->getNsText(
486 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
487 wfMsg("newmessageslink") );
488 $s.=" | <strong>". wfMsg( "newmessages", $tl ) . "</strong>";
491 if( $wgUser->isSysop() &&
492 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
493 ($n = $wgTitle->isDeleted() ) ) {
494 $s .= " | " . wfMsg( "thisisdeleted",
495 $this->makeKnownLink(
496 $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ),
497 wfMsg( "restorelink", $n ) ) );
502 function printableLink()
504 global $wgOut, $wgFeedClasses, $wgRequest;
506 $baseurl = $_SERVER['REQUEST_URI'];
507 if( strpos( "?", $baseurl ) == false ) {
512 $baseurl = htmlspecialchars( $baseurl );
513 $printurl = $wgRequest->escapeAppendQuery( "printable=yes" );
515 $s = "<a href=\"$printurl\">" . wfMsg( "printableversion" ) . "</a>";
516 if( $wgOut->isSyndicated() ) {
517 foreach( $wgFeedClasses as $format => $class ) {
518 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
519 $s .= " | <a href=\"$feedurl\">{$format}</a>";
527 global $wgOut, $wgTitle, $wgUser;
529 $s = "<h1 class='pagetitle'>" . htmlspecialchars( $wgOut->getPageTitle() ) . "</h1>";
530 if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
534 function pageSubtitle()
538 $sub = $wgOut->getSubtitle();
540 global $wgExtraSubtitle;
541 $sub = wfMsg( "fromwikipedia" ) . $wgExtraSubtitle;
543 $subpages = $this->subPageSubtitle();
544 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
545 $s = "<p class='subtitle'>{$sub}</p>\n";
549 function subPageSubtitle()
551 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
553 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
554 $ptext=$wgTitle->getPrefixedText();
555 if(preg_match("/\//",$ptext)) {
556 $links=explode("/",$ptext);
559 foreach($links as $link) {
561 if ($c<count($links)) {
562 $growinglink .= $link;
563 $getlink = $this->makeLink( $growinglink, $link );
564 if(preg_match("/class='new'/i",$getlink)) { break; } # this is a hack, but it saves time
570 $subpages .= $getlink;
579 function nameAndLogin()
581 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader, $wgIP;
583 $li = $wgLang->specialPage( "Userlogin" );
584 $lo = $wgLang->specialPage( "Userlogout" );
587 if ( 0 == $wgUser->getID() ) {
588 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) {
591 $tl = $this->makeKnownLink( $wgLang->getNsText(
592 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
593 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
595 $s .= $n . " (".$tl.")";
597 $s .= wfMsg("notloggedin");
600 $rt = $wgTitle->getPrefixedURL();
601 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
603 } else { $q = "returnto={$rt}"; }
605 $s .= "\n<br />" . $this->makeKnownLink( $li,
606 wfMsg( "login" ), $q );
608 $n = $wgUser->getName();
609 $rt = $wgTitle->getPrefixedURL();
610 $tl = $this->makeKnownLink( $wgLang->getNsText(
611 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
612 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
616 $s .= $this->makeKnownLink( $wgLang->getNsText(
617 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br />" .
618 $this->makeKnownLink( $lo, wfMsg( "logout" ),
619 "returnto={$rt}" ) . " | " .
620 $this->specialLink( "preferences" );
622 $s .= " | " . $this->makeKnownLink( wfMsg( "helppage" ),
628 function getSearchLink() {
629 $searchPage =& Title
::makeTitle( NS_SPECIAL
, "Search" );
630 return $searchPage->getLocalURL();
633 function escapeSearchLink() {
634 return htmlspecialchars( $this->getSearchLink() );
637 function searchForm()
640 $search = $wgRequest->getText( 'search' );
642 $s = "<form name='search' class='inline' method='post' action=\""
643 . $this->escapeSearchLink() . "\">\n"
644 . "<input type='text' name=\"search\" size='19' value=\""
645 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
646 . "<input type='submit' name=\"go\" value=\"" . wfMsg ("go") . "\" /> "
647 . "<input type='submit' name=\"fulltext\" value=\"" . wfMsg ("search") . "\" />\n</form>";
657 $s = $this->mainPageLink() . $sep
658 . $this->specialLink( "recentchanges" );
660 if ( $wgOut->isArticleRelated() ) {
661 $s .= $sep . $this->editThisPage()
662 . $sep . $this->historyLink();
664 # Many people don't like this dropdown box
665 #$s .= $sep . $this->specialPagesList();
670 function bottomLinks()
672 global $wgOut, $wgUser, $wgTitle;
676 if ( $wgOut->isArticleRelated() ) {
677 $s .= "<strong>" . $this->editThisPage() . "</strong>";
678 if ( 0 != $wgUser->getID() ) {
679 $s .= $sep . $this->watchThisPage();
681 $s .= $sep . $this->talkLink()
682 . $sep . $this->historyLink()
683 . $sep . $this->whatLinksHere()
684 . $sep . $this->watchPageLinksLink();
686 if ( $wgTitle->getNamespace() == Namespace::getUser()
687 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
690 $id=User
::idFromName($wgTitle->getText());
691 $ip=User
::isIP($wgTitle->getText());
693 if($id ||
$ip) { # both anons and non-anons have contri list
694 $s .= $sep . $this->userContribsLink();
696 if ( 0 != $wgUser->getID() ) { # show only to signed in users
697 if($id) { # can only email non-anons
698 $s .= $sep . $this->emailUserLink();
702 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
703 $s .= "\n<br />" . $this->deleteThisPage() .
704 $sep . $this->protectThisPage() .
705 $sep . $this->moveThisPage();
707 $s .= "<br />\n" . $this->otherLanguages();
714 global $wgOut, $wgLang, $wgArticle, $wgRequest;
715 global $wgDisableCounters;
717 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
718 if ( ! $wgOut->isArticle() ) { return ""; }
719 if ( isset( $oldid ) ||
isset( $diff ) ) { return ""; }
720 if ( 0 == $wgArticle->getID() ) { return ""; }
723 if ( !$wgDisableCounters ) {
724 $count = $wgLang->formatNum( $wgArticle->getCount() );
726 $s = wfMsg( "viewcount", $count );
730 $s .= " " . $this->getCredits();
732 return $s . " " . $this->getCopyright();
735 function getCredits() {
736 global $wgMaxCredits;
740 if (!isset($wgMaxCredits) ||
$wgMaxCredits == 0) {
741 $s = $this->lastModified();
743 $s = $this->getAuthorCredits();
744 if ($wgMaxCredits > 1) {
745 $s .= " " . $this->getContributorCredits();
752 function getAuthorCredits() {
753 global $wgLang, $wgArticle;
755 $last_author = $wgArticle->getUser();
757 if ($last_author == 0) {
758 $author_credit = wfMsg("anonymous");
760 $real_name = User
::whoIsReal($last_author);
761 if (!empty($real_name)) {
762 $author_credit = $real_name;
764 $author_credit = wfMsg("siteuser", User
::whoIs($last_author));
768 $timestamp = $wgArticle->getTimestamp();
770 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
774 return wfMsg("lastmodifiedby", $d, $author_credit);
777 function getContributorCredits() {
779 global $wgArticle, $wgMaxCredits, $wgLang;
781 # don't count last editor
783 $contributors = $wgArticle->getContributors($wgMaxCredits - 1);
785 $real_names = array();
786 $user_names = array();
788 # Sift for real versus user names
790 foreach ($contributors as $user_id => $user_parts) {
792 if (!empty($user_parts[1])) {
793 $real_names[$user_id] = $user_parts[1];
795 $user_names[$user_id] = $user_parts[0];
800 $real = $wgLang->listToText(array_values($real_names));
801 $user = $wgLang->listToText(array_values($user_names));
804 $user = wfMsg("siteusers", $user);
807 if ($contributors[0] && $contributors[0][0] > 0) {
808 $anon = wfMsg("anonymous");
813 $creds = $wgLang->listToText(array($real, $user, $anon));
815 return wfMsg("othercontribs", $creds);
818 function getCopyright() {
819 global $wgRightsPage, $wgRightsUrl, $wgRightsText;
821 if( $wgRightsPage ) {
822 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
823 } elseif( $wgRightsUrl ) {
824 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
829 $out .= wfMsg( "copyright", $link );
833 function getCopyrightIcon() {
834 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
836 if( $wgRightsIcon ) {
837 $icon = htmlspecialchars( $wgRightsIcon );
839 $url = htmlspecialchars( $wgRightsUrl );
840 $out .= "<a href=\"$url\">";
842 $text = htmlspecialchars( $wgRightsText );
843 $out .= "<img src=\"$icon\" alt='$text' />";
851 function getPoweredBy() {
853 $url = htmlspecialchars( "$wgStylePath/images/poweredby_mediawiki_88x31.png" );
854 $img = "<a href='http://www.mediawiki.org/'><img src='$url' alt='MediaWiki' /></a>";
858 function lastModified()
860 global $wgLang, $wgArticle;
862 $timestamp = $wgArticle->getTimestamp();
864 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
865 $s = " " . wfMsg( "lastmodified", $d );
872 function logoText( $align = "" )
874 if ( "" != $align ) { $a = " align='{$align}'"; }
877 $mp = wfMsg( "mainpage" );
878 $titleObj = Title
::newFromText( $mp );
879 $s = "<a href=\"" . $titleObj->escapeLocalURL()
880 . "\"><img{$a} src=\""
881 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\" /></a>";
887 global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgLang;
888 global $wgDisableUploads, $wgRemoteUploads;
890 $fname = "Skin::quickBar";
891 wfProfileIn( $fname );
893 $action = $wgRequest->getText( 'action' );
894 $wpPreview = $wgRequest->getBool( 'wpPreview' );
895 $tns=$wgTitle->getNamespace();
897 $s = "\n<div id='quickbar'>";
898 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
901 $s .= $this->mainPageLink()
902 . $sep . $this->specialLink( "recentchanges" )
903 . $sep . $this->specialLink( "randompage" );
904 if ($wgUser->getID()) {
905 $s.= $sep . $this->specialLink( "watchlist" ) ;
906 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
907 wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) );
910 // only show watchlist link if logged in
911 if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
912 $s .= "\n<br /><hr class='sep' />";
913 $articleExists = $wgTitle->getArticleId();
914 if ( $wgOut->isArticle() ||
$action =="edit" ||
$action =="history" ||
$wpPreview) {
915 if($wgOut->isArticle()) {
916 $s .= "<strong>" . $this->editThisPage() . "</strong>";
917 } else { # backlink to the article in edit or history mode
918 if($articleExists){ # no backlink if no article
921 $text = wfMsg("articlepage");
924 $text = wfMsg("viewtalkpage");
927 $text = wfMsg("userpage");
930 $text = wfMsg("viewtalkpage");
933 $text = wfMsg("wikipediapage");
936 $text = wfMsg("viewtalkpage");
939 $text = wfMsg("imagepage");
942 $text = wfMsg("viewtalkpage");
945 $text= wfMsg("articlepage");
948 $link = $wgTitle->getText();
949 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
950 $link = $nstext . ":" . $link ;
953 $s .= $this->makeLink( $link, $text );
954 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
955 # we just throw in a "New page" text to tell the user that he's in edit mode,
956 # and to avoid messing with the separator that is prepended to the next item
957 $s .= "<strong>" . wfMsg("newpage") . "</strong>";
963 if( $tns%2
&& $action!="edit" && !$wpPreview) {
964 $s.="<br />".$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("postcomment"),"action=edit§ion=new");
968 watching could cause problems in edit mode:
969 if user edits article, then loads "watch this article" in background and then saves
970 article with "Watch this article" checkbox disabled, the article is transparently
971 unwatched. Therefore we do not show the "Watch this page" link in edit mode
973 if ( 0 != $wgUser->getID() && $articleExists) {
974 if($action!="edit" && $action != "submit" )
976 $s .= $sep . $this->watchThisPage();
978 if ( $wgTitle->userCanEdit() )
979 $s .= $sep . $this->moveThisPage();
981 if ( $wgUser->isSysop() and $articleExists ) {
982 $s .= $sep . $this->deleteThisPage() .
983 $sep . $this->protectThisPage();
985 $s .= $sep . $this->talkLink();
986 if ($articleExists && $action !="history") {
987 $s .= $sep . $this->historyLink();
989 $s.=$sep . $this->whatLinksHere();
991 if($wgOut->isArticleRelated()) {
992 $s .= $sep . $this->watchPageLinksLink();
995 if ( Namespace::getUser() == $wgTitle->getNamespace()
996 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
999 $id=User
::idFromName($wgTitle->getText());
1000 $ip=User
::isIP($wgTitle->getText());
1003 $s .= $sep . $this->userContribsLink();
1005 if ( 0 != $wgUser->getID() ) {
1006 if($id) { # can only email real users
1007 $s .= $sep . $this->emailUserLink();
1011 $s .= "\n<br /><hr class='sep' />";
1014 if ( 0 != $wgUser->getID() && ( !$wgDisableUploads ||
$wgRemoteUploads ) ) {
1015 $s .= $this->specialLink( "upload" ) . $sep;
1017 $s .= $this->specialLink( "specialpages" )
1018 . $sep . $this->bugReportsLink();
1020 global $wgSiteSupportPage;
1021 if( $wgSiteSupportPage ) {
1022 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
1023 "\" class=\"internal\">" . wfMsg( "sitesupport" ) . "</a>";
1026 $s .= "\n<br /></div>\n";
1027 wfProfileOut( $fname );
1031 function specialPagesList()
1033 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
1036 $validSP = $wgLang->getValidSpecialPages();
1038 foreach ( $validSP as $name => $desc ) {
1039 if ( "" == $desc ) { continue; }
1042 if ( $wgUser->isSysop() )
1044 $sysopSP = $wgLang->getSysopSpecialPages();
1046 foreach ( $sysopSP as $name => $desc ) {
1047 if ( "" == $desc ) { continue; }
1051 if ( $wgUser->isDeveloper() )
1053 $devSP = $wgLang->getDeveloperSpecialPages();
1055 foreach ( $devSP as $name => $desc ) {
1056 if ( "" == $desc ) { continue; }
1060 $go = wfMsg( "go" );
1061 $sp = wfMsg( "specialpages" );
1062 $spp = $wgLang->specialPage( "Specialpages" );
1064 $s = "<form id=\"specialpages\" method=\"get\" class=\"inline\" " .
1065 "action=\"" . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1066 $s .= "<select name=\"wpDropdown\">\n";
1067 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1069 foreach ( $a as $name => $desc ) {
1070 $p = $wgLang->specialPage( $name );
1071 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1073 $s .= "</select>\n";
1074 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1079 function mainPageLink()
1081 $mp = wfMsg( "mainpage" );
1082 $s = $this->makeKnownLink( $mp, $mp );
1086 function copyrightLink()
1088 $s = $this->makeKnownLink( wfMsg( "copyrightpage" ),
1089 wfMsg( "copyrightpagename" ) );
1093 function aboutLink()
1095 $s = $this->makeKnownLink( wfMsg( "aboutpage" ),
1096 wfMsg( "aboutwikipedia" ) );
1101 function disclaimerLink()
1103 $s = $this->makeKnownLink( wfMsg( "disclaimerpage" ),
1104 wfMsg( "disclaimers" ) );
1108 function editThisPage()
1110 global $wgOut, $wgTitle, $wgRequest;
1112 $oldid = $wgRequest->getVal( 'oldid' );
1113 $diff = $wgRequest->getVal( 'diff' );
1114 $redirect = $wgRequest->getVal( 'redirect' );
1116 if ( ! $wgOut->isArticleRelated() ) {
1117 $s = wfMsg( "protectedpage" );
1119 $n = $wgTitle->getPrefixedText();
1120 if ( $wgTitle->userCanEdit() ) {
1121 $t = wfMsg( "editthispage" );
1123 #$t = wfMsg( "protectedpage" );
1124 $t = wfMsg( "viewsource" );
1128 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1129 if ( $oldid && ! isset( $diff ) ) {
1130 $oid = "&oldid={$oldid}";
1132 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
1137 function deleteThisPage()
1139 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1141 $diff = $wgRequest->getVal( 'diff' );
1142 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1143 $n = $wgTitle->getPrefixedText();
1144 $t = wfMsg( "deletethispage" );
1146 $s = $this->makeKnownLink( $n, $t, "action=delete" );
1153 function protectThisPage()
1155 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1157 $diff = $wgRequest->getVal( 'diff' );
1158 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1159 $n = $wgTitle->getPrefixedText();
1161 if ( $wgTitle->isProtected() ) {
1162 $t = wfMsg( "unprotectthispage" );
1163 $q = "action=unprotect";
1165 $t = wfMsg( "protectthispage" );
1166 $q = "action=protect";
1168 $s = $this->makeKnownLink( $n, $t, $q );
1175 function watchThisPage()
1177 global $wgUser, $wgOut, $wgTitle;
1179 if ( $wgOut->isArticleRelated() ) {
1180 $n = $wgTitle->getPrefixedText();
1182 if ( $wgTitle->userIsWatching() ) {
1183 $t = wfMsg( "unwatchthispage" );
1184 $q = "action=unwatch";
1186 $t = wfMsg( "watchthispage" );
1187 $q = "action=watch";
1189 $s = $this->makeKnownLink( $n, $t, $q );
1191 $s = wfMsg( "notanarticle" );
1196 function moveThisPage()
1198 global $wgTitle, $wgLang;
1200 if ( $wgTitle->userCanEdit() ) {
1201 $s = $this->makeKnownLink( $wgLang->specialPage( "Movepage" ),
1202 wfMsg( "movethispage" ), "target=" . $wgTitle->getPrefixedURL() );
1203 } // no message if page is protected - would be redundant
1207 function historyLink()
1211 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1212 wfMsg( "history" ), "action=history" );
1216 function whatLinksHere()
1218 global $wgTitle, $wgLang;
1220 $s = $this->makeKnownLink( $wgLang->specialPage( "Whatlinkshere" ),
1221 wfMsg( "whatlinkshere" ), "target=" . $wgTitle->getPrefixedURL() );
1225 function userContribsLink()
1227 global $wgTitle, $wgLang;
1229 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1230 wfMsg( "contributions" ), "target=" . $wgTitle->getPartialURL() );
1234 function emailUserLink()
1236 global $wgTitle, $wgLang;
1238 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
1239 wfMsg( "emailuser" ), "target=" . $wgTitle->getPartialURL() );
1243 function watchPageLinksLink()
1245 global $wgOut, $wgTitle, $wgLang;
1247 if ( ! $wgOut->isArticleRelated() ) {
1248 $s = "(" . wfMsg( "notanarticle" ) . ")";
1250 $s = $this->makeKnownLink( $wgLang->specialPage(
1251 "Recentchangeslinked" ), wfMsg( "recentchangeslinked" ),
1252 "target=" . $wgTitle->getPrefixedURL() );
1257 function otherLanguages()
1259 global $wgOut, $wgLang, $wgTitle, $wgUseNewInterlanguage;
1261 $a = $wgOut->getLanguageLinks();
1262 if ( 0 == count( $a ) ) {
1263 if ( !$wgUseNewInterlanguage ) return "";
1264 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1265 if ( $ns != 0 AND $ns != 1 ) return "" ;
1267 $x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
1268 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1269 wfMsg( "intl" ) , $x );
1272 if ( !$wgUseNewInterlanguage ) {
1273 $s = wfMsg( "otherlanguages" ) . ": ";
1275 global $wgLanguageCode ;
1276 $x = "mode=zoom&xt=".$wgTitle->getDBkey() ;
1277 $x .= "&xl=".$wgLanguageCode ;
1278 $s = $this->makeKnownLink( $wgLang->specialPage( "Intl" ),
1279 wfMsg( "otherlanguages" ) , $x ) . ": " ;
1282 $s = wfMsg( "otherlanguages" ) . ": ";
1284 if($wgLang->isRTL()) $s .= "<span dir='LTR'>";
1285 foreach( $a as $l ) {
1286 if ( ! $first ) { $s .= " | "; }
1289 $nt = Title
::newFromText( $l );
1290 $url = $nt->getFullURL();
1291 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
1293 if ( "" == $text ) { $text = $l; }
1294 $style = $this->getExternalLinkAttributes( $l, $text );
1295 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1297 if($wgLang->isRTL()) $s .= "</span>";
1301 function bugReportsLink()
1303 $s = $this->makeKnownLink( wfMsg( "bugreportspage" ),
1304 wfMsg( "bugreports" ) );
1310 global $wgLinkCache;
1311 $t1 = Title
::newFromText( gmdate( "F j" ) );
1312 $t2 = Title
::newFromText( gmdate( "Y" ) );
1314 $wgLinkCache->suspend();
1315 $id = $t1->getArticleID();
1316 $wgLinkCache->resume();
1319 $s = $this->makeBrokenLink( $t1->getText() );
1321 $s = $this->makeKnownLink( $t1->getText() );
1325 $wgLinkCache->suspend();
1326 $id = $t2->getArticleID();
1327 $wgLinkCache->resume();
1330 $s .= $this->makeBrokenLink( $t2->getText() );
1332 $s .= $this->makeKnownLink( $t2->getText() );
1339 global $wgLang, $wgTitle, $wgLinkCache;
1341 $tns = $wgTitle->getNamespace();
1342 if ( -1 == $tns ) { return ""; }
1344 $pn = $wgTitle->getText();
1345 $tp = wfMsg( "talkpage" );
1346 if ( Namespace::isTalk( $tns ) ) {
1347 $lns = Namespace::getSubject( $tns );
1350 $text = wfMsg("articlepage");
1353 $text = wfMsg("userpage");
1356 $text = wfMsg("wikipediapage");
1359 $text = wfMsg("imagepage");
1362 $text= wfMsg("articlepage");
1366 $lns = Namespace::getTalk( $tns );
1369 $n = $wgLang->getNsText( $lns );
1370 if ( "" == $n ) { $link = $pn; }
1371 else { $link = "{$n}:{$pn}"; }
1373 $wgLinkCache->suspend();
1374 $s = $this->makeLink( $link, $text );
1375 $wgLinkCache->resume();
1380 function commentLink()
1382 global $wgLang, $wgTitle, $wgLinkCache;
1384 $tns = $wgTitle->getNamespace();
1385 if ( -1 == $tns ) { return ""; }
1387 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1389 # assert Namespace::isTalk( $lns )
1391 $n = $wgLang->getNsText( $lns );
1392 $pn = $wgTitle->getText();
1394 $link = "{$n}:{$pn}";
1396 $wgLinkCache->suspend();
1397 $s = $this->makeKnownLink($link, wfMsg("postcomment"), "action=edit§ion=new");
1398 $wgLinkCache->resume();
1403 # After all the page content is transformed into HTML, it makes
1404 # a final pass through here for things like table backgrounds.
1406 function transformContent( $text )
1411 # Note: This function MUST call getArticleID() on the link,
1412 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1414 function makeLink( $title, $text = "", $query = "", $trail = "" ) {
1415 wfProfileIn( "Skin::makeLink" );
1416 $nt = Title
::newFromText( $title );
1418 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1420 wfDebug( "Invalid title passed to Skin::makeLink(): \"$title\"\n" );
1421 $result = $text == "" ?
$title : $text;
1424 wfProfileOut( "Skin::makeLink" );
1428 function makeKnownLink( $title, $text = "", $query = "", $trail = "", $prefix = '',$aprops = '') {
1429 $nt = Title
::newFromText( $title );
1431 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
1433 wfDebug( "Invalid title passed to Skin::makeKnownLink(): \"$title\"\n" );
1434 return $text == "" ?
$title : $text;
1438 function makeBrokenLink( $title, $text = "", $query = "", $trail = "" ) {
1439 $nt = Title
::newFromText( $title );
1441 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1443 wfDebug( "Invalid title passed to Skin::makeBrokenLink(): \"$title\"\n" );
1444 return $text == "" ?
$title : $text;
1448 function makeStubLink( $title, $text = "", $query = "", $trail = "" ) {
1449 $nt = Title
::newFromText( $title );
1451 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1453 wfDebug( "Invalid title passed to Skin::makeStubLink(): \"$title\"\n" );
1454 return $text == "" ?
$title : $text;
1458 # Pass a title object, not a title string
1459 function makeLinkObj( &$nt, $text= "", $query = "", $trail = "", $prefix = "" )
1461 global $wgOut, $wgUser;
1462 if ( $nt->isExternal() ) {
1463 $u = $nt->getFullURL();
1464 $link = $nt->getPrefixedURL();
1465 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
1466 $style = $this->getExternalLinkAttributes( $link, $text );
1469 if ( "" != $trail ) {
1470 if ( preg_match( "/^([a-z]+)(.*)$$/sD", $trail, $m ) ) {
1475 $retVal = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1476 } elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1477 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1478 } elseif ( ( -1 == $nt->getNamespace() ) ||
1479 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1480 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1482 $aid = $nt->getArticleID() ;
1484 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
1486 $threshold = $wgUser->getOption("stubthreshold") ;
1487 if ( $threshold > 0 ) {
1488 $res = wfQuery ( "SELECT LENGTH(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'", DB_READ
) ;
1490 if ( wfNumRows( $res ) > 0 ) {
1491 $s = wfFetchObject( $res );
1493 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
1494 $size = $threshold*2 ; # Really big
1496 wfFreeResult( $res );
1498 $size = $threshold*2 ; # Really big
1503 if ( $size < $threshold ) {
1504 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
1506 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1513 # Pass a title object, not a title string
1514 function makeKnownLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" , $aprops = '')
1516 global $wgOut, $wgTitle;
1518 $fname = "Skin::makeKnownLinkObj";
1519 wfProfileIn( $fname );
1521 $link = $nt->getPrefixedURL();
1523 if ( "" == $link ) {
1525 if ( "" == $text ) {
1526 $text = htmlspecialchars( $nt->getFragment() );
1529 $u = $nt->escapeLocalURL( $query );
1531 if ( "" != $nt->getFragment() ) {
1532 $u .= "#" . htmlspecialchars( $nt->getFragment() );
1534 if ( "" == $text ) {
1535 $text = htmlspecialchars( $nt->getPrefixedText() );
1537 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1540 if ( "" != $trail ) {
1541 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1546 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
1547 wfProfileOut( $fname );
1551 # Pass a title object, not a title string
1552 function makeBrokenLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" )
1554 global $wgOut, $wgUser;
1556 $fname = "Skin::makeBrokenLinkObj";
1557 wfProfileIn( $fname );
1559 if ( "" == $query ) {
1562 $q = "action=edit&{$query}";
1564 $u = $nt->escapeLocalURL( $q );
1566 if ( "" == $text ) {
1567 $text = htmlspecialchars( $nt->getPrefixedText() );
1569 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1572 if ( "" != $trail ) {
1573 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1578 if ( $wgUser->getOption( "highlightbroken" ) ) {
1579 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1581 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1584 wfProfileOut( $fname );
1588 # Pass a title object, not a title string
1589 function makeStubLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" )
1591 global $wgOut, $wgUser;
1593 $link = $nt->getPrefixedURL();
1595 $u = $nt->escapeLocalURL( $query );
1597 if ( "" == $text ) {
1598 $text = htmlspecialchars( $nt->getPrefixedText() );
1600 $style = $this->getInternalLinkAttributesObj( $nt, $text, "stub" );
1603 if ( "" != $trail ) {
1604 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1609 if ( $wgUser->getOption( "highlightbroken" ) ) {
1610 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1612 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1617 function makeSelfLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" )
1619 $u = $nt->escapeLocalURL( $query );
1620 if ( "" == $text ) {
1621 $text = htmlspecialchars( $nt->getPrefixedText() );
1624 if ( "" != $trail ) {
1625 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1630 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
1633 function fnamePart( $url )
1635 $basename = strrchr( $url, "/" );
1636 if ( false === $basename ) { $basename = $url; }
1637 else { $basename = substr( $basename, 1 ); }
1638 return wfEscapeHTML( $basename );
1641 function makeImage( $url, $alt = "" )
1645 if ( "" == $alt ) { $alt = $this->fnamePart( $url ); }
1646 $s = "<img src=\"{$url}\" alt=\"{$alt}\" />";
1650 function makeImageLink( $name, $url, $alt = "" ) {
1651 $nt = Title
::makeTitle( Namespace::getImage(), $name );
1652 return $this->makeImageLinkObj( $nt, $alt );
1655 function makeImageLinkObj( $nt, $alt = "" ) {
1656 global $wgLang, $wgUseImageResize;
1657 $img = Image
::newFromTitle( $nt );
1658 $url = $img->getURL();
1661 $prefix = $postfix = "";
1663 if ( $wgUseImageResize ) {
1664 # Check if the alt text is of the form "options|alt text"
1666 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1667 # * left no resizing, just left align. label is used for alt= only
1668 # * right same, but right aligned
1669 # * none same, but not aligned
1670 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1671 # * center center the image
1672 # * framed Keep original image size, no magnify-button.
1674 $part = explode( "|", $alt);
1676 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
1677 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
1678 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
1679 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
1680 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
1681 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
1682 $mwFramed =& MagicWord
::get( MAG_IMG_FRAMED
);
1683 $alt = $part[count($part)-1];
1685 $framed=$thumb=false;
1687 foreach( $part as $key => $val ) {
1688 if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1690 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1691 # remember to set an alignment, don't render immediately
1693 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1694 # remember to set an alignment, don't render immediately
1696 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
1697 # remember to set an alignment, don't render immediately
1699 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1700 # remember to set an alignment, don't render immediately
1702 } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1703 # $match is the image width in pixels
1704 $width = intval($match);
1705 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
1709 if ( "center" == $align )
1711 $prefix = '<span style="text-align: center">';
1712 $postfix = '</span>';
1716 if ( $thumb ||
$framed ) {
1718 # Create a thumbnail. Alignment depends on language
1719 # writing direction, # right aligned for left-to-right-
1720 # languages ("Western languages"), left-aligned
1721 # for right-to-left-languages ("Semitic languages")
1723 # If thumbnail width has not been provided, it is set
1724 # here to 180 pixels
1725 if ( $align == "" ) {
1726 $align = $wgLang->isRTL() ?
"left" : "right";
1728 if ( ! isset($width) ) {
1731 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $framed ).$postfix;
1733 } elseif ( isset($width) ) {
1735 # Create a resized image, without the additional thumbnail
1737 $url = $img->createThumb( $width );
1739 } # endif $wgUseImageResize
1741 if ( empty( $alt ) ) {
1742 $alt = preg_replace( '/\.(.+?)^/', '', $img->getName() );
1744 $alt = htmlspecialchars( $alt );
1746 $u = $nt->escapeLocalURL();
1749 $s = str_replace( "$1", $img->getName(), wfMsg("missingimage") );
1750 $s .= "<br>{$alt}<br>{$url}<br>\n";
1752 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
1753 "<img src=\"{$url}\" alt=\"{$alt}\" /></a>";
1755 if ( "" != $align ) {
1756 $s = "<div class=\"float{$align}\"><span>{$s}</span>\n</div>";
1758 return $prefix.$s.$postfix;
1762 function makeThumbLinkObj( $img, $label = "", $align = "right", $boxwidth = 180, $framed=false ) {
1763 global $wgStylePath, $wgLang;
1764 # $image = Title::makeTitle( Namespace::getImage(), $name );
1765 $url = $img->getURL();
1767 #$label = htmlspecialchars( $label );
1768 $alt = preg_replace( "/<[^>]*>/", "", $label);
1769 $alt = htmlspecialchars( $alt );
1771 if ( $img->exists() )
1773 $width = $img->getWidth();
1774 $height = $img->getHeight();
1776 $width = $height = 200;
1780 // Use image dimensions, don't scale
1782 $boxheight = $height;
1785 $boxheight = intval( $height/($width/$boxwidth) );
1786 # if ( $boxwidth > $width ) {
1787 # $boxwidth = $width;
1788 # $boxheight = $height;
1790 $thumbUrl = $img->createThumb( $boxwidth );
1792 $oboxwidth = $boxwidth +
2;
1794 $u = $img->getEscapeLocalURL();
1796 $more = htmlspecialchars( wfMsg( "thumbnail-more" ) );
1797 $magnifyalign = $wgLang->isRTL() ?
"left" : "right";
1798 $textalign = $wgLang->isRTL() ?
' style="text-align:right"' : "";
1800 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
1801 if ( $thumbUrl == "" ) {
1802 $s .= str_replace( "$1", $img->getName(), wfMsg("missingimage") );
1805 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1806 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1807 'width="'.$boxwidth.'" height="'.$boxheight.'" /></a>';
1811 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1812 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1813 '<img src="'.$wgStylePath.'/images/magnify-clip.png" ' .
1814 'width="15" height="11" alt="'.$more.'" /></a></div>';
1817 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div>\n</div>";
1821 function makeMediaLink( $name, $url, $alt = "" ) {
1822 $nt = Title
::makeTitle( Namespace::getMedia(), $name );
1823 return $this->makeMediaLinkObj( $nt, $alt );
1826 function makeMediaLinkObj( $nt, $alt = "" )
1828 $name = $nt->getDBKey();
1829 $url = Image
::wfImageUrl( $name );
1830 if ( empty( $alt ) ) {
1831 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1834 $u = htmlspecialchars( $url );
1835 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1839 function specialLink( $name, $key = "" )
1843 if ( "" == $key ) { $key = strtolower( $name ); }
1844 $pn = $wgLang->ucfirst( $name );
1845 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1849 function makeExternalLink( $url, $text, $escape = true ) {
1850 $style = $this->getExternalLinkAttributes( $url, $text );
1851 $url = htmlspecialchars( $url );
1853 $text = htmlspecialchars( $text );
1855 return "<a href=\"$url\"$style>$text</a>";
1858 # Called by history lists and recent changes
1861 # Returns text for the start of the tabular part of RC
1862 function beginRecentChangesList()
1864 $this->rc_cache
= array() ;
1865 $this->rcMoveIndex
= 0;
1866 $this->rcCacheIndex
= 0 ;
1867 $this->lastdate
= "";
1868 $this->rclistOpen
= false;
1872 function beginImageHistoryList()
1874 $s = "\n<h2>" . wfMsg( "imghistory" ) . "</h2>\n" .
1875 "<p>" . wfMsg( "imghistlegend" ) . "</p>\n<ul class='special'>";
1879 # Returns text for the end of RC
1880 # If enhanced RC is in use, returns pretty much all the text
1881 function endRecentChangesList()
1883 $s = $this->recentChangesBlock() ;
1884 if( $this->rclistOpen
) {
1890 # Enhanced RC ungrouped line
1891 function recentChangesBlockLine ( $rcObj )
1893 global $wgStylePath, $wgLang ;
1895 # Get rc_xxxx variables
1896 extract( $rcObj->mAttribs
) ;
1897 $curIdEq = "curid=$rc_cur_id";
1902 $r .= "<img src='{$wgStylePath}/images/Arr_.png' width='12' height='12' border='0' />" ; $r .= "<tt>" ;
1904 if ( $rc_type == RC_MOVE
) {
1905 $r .= " ";
1907 # M & N (minor & new)
1908 $M = wfMsg( "minoreditletter" );
1909 $N = wfMsg( "newpageletter" );
1911 if ( $rc_type == RC_NEW
) {
1924 $r .= " ".$rcObj->timestamp
." " ;
1928 $link = $rcObj->link
;
1929 if ( $rcObj->watched
) $link = "<strong>{$link}</strong>" ;
1934 $r .= $rcObj->curlink
;
1938 $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" );
1941 $r .= ") . . ".$rcObj->userlink
;
1942 $r .= $rcObj->usertalklink
;
1945 if ( $rc_comment != "" && $rc_type != RC_MOVE
) {
1946 $rc_comment=$this->formatComment($rc_comment);
1947 $r .= $wgLang->emphasize( " (".$rc_comment.")" );
1955 function recentChangesBlockGroup ( $block )
1957 global $wgStylePath, $wgLang ;
1960 $M = wfMsg( "minoreditletter" );
1961 $N = wfMsg( "newpageletter" );
1963 # Collate list of users
1965 $userlinks = array () ;
1966 foreach ( $block AS $rcObj ) {
1967 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
1968 if ( $rcObj->mAttribs
['rc_new'] ) $isnew = true ;
1969 $u = $rcObj->userlink
;
1970 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
1974 # Sort the list and convert to text
1975 krsort ( $userlinks ) ;
1976 asort ( $userlinks ) ;
1978 foreach ( $userlinks as $userlink => $count) {
1980 if ( $count > 1 ) $text .= " ({$count}×)" ;
1981 array_push ( $users , $text ) ;
1983 $users = " <font size='-1'>[".implode("; ",$users)."]</font>" ;
1986 $rci = "RCI{$this->rcCacheIndex}" ;
1987 $rcl = "RCL{$this->rcCacheIndex}" ;
1988 $rcm = "RCM{$this->rcCacheIndex}" ;
1989 $toggleLink = "javascript:toggleVisibility(\"{$rci}\",\"{$rcm}\",\"{$rcl}\")" ;
1990 $arrowdir = $wgLang->isRTL() ?
"l" : "r";
1991 $tl = "<span id='{$rcm}'><a href='$toggleLink'><img src='{$wgStylePath}/images/Arr_{$arrowdir}.png' width='12' height='12' /></a></span>" ;
1992 $tl .= "<span id='{$rcl}' style='display:none'><a href='$toggleLink'><img src='{$wgStylePath}/images/Arr_d.png' width='12' height='12' /></a></span>" ;
1998 if ( $isnew ) $r .= $N ;
1999 else $r .= " " ;
2000 $r .= " " ; # Minor
2003 $r .= " ".$block[0]->timestamp
." " ;
2007 $link = $block[0]->link
;
2008 if ( $block[0]->watched
) $link = "<strong>{$link}</strong>" ;
2011 $curIdEq = "curid=" . $block[0]->mAttribs
['rc_cur_id'];
2012 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
2014 $r .= " (".count($block)." " ;
2015 if ( $isnew ) $r .= wfMsg("changes");
2016 else $r .= $this->makeKnownLinkObj( $block[0]->getTitle() , wfMsg("changes") ,
2017 "{$curIdEq}&diff=0&oldid=".$oldid ) ;
2021 $r .= $this->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( "history" ), "{$curIdEq}&action=history" );
2029 $r .= "<div id='{$rci}' style='display:none'>" ;
2030 foreach ( $block AS $rcObj ) {
2031 # Get rc_xxxx variables
2032 extract( $rcObj->mAttribs
);
2034 $r .= "<img src='{$wgStylePath}/images/Arr_.png' width=12 height=12 />";
2035 $r .= "<tt> " ;
2036 if ( $rc_new ) $r .= $N ;
2037 else $r .= " " ;
2038 if ( $rc_minor ) $r .= $M ;
2039 else $r .= " " ;
2043 if ( $rc_last_oldid != 0 ) {
2044 $o = "oldid=".$rc_last_oldid ;
2046 if ( $rc_type == RC_LOG
) {
2047 $link = $rcObj->timestamp
;
2049 $link = $this->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
2051 $link = "<tt>{$link}</tt>" ;
2055 $r .= $rcObj->curlink
;
2057 $r .= $rcObj->lastlink
;
2058 $r .= ") . . ".$rcObj->userlink
;
2059 $r .= $rcObj->usertalklink
;
2060 if ( $rc_comment != "" ) {
2061 $rc_comment=$this->formatComment($rc_comment);
2062 $r .= $wgLang->emphasize( " (".$rc_comment.")" ) ;
2068 $this->rcCacheIndex++
;
2072 # If enhanced RC is in use, this function takes the previously cached
2073 # RC lines, arranges them, and outputs the HTML
2074 function recentChangesBlock ()
2076 global $wgStylePath ;
2077 if ( count ( $this->rc_cache
) == 0 ) return "" ;
2079 foreach ( $this->rc_cache
AS $secureName => $block ) {
2080 if ( count ( $block ) < 2 ) {
2081 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
2083 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
2087 return "<div>{$blockOut}</div>" ;
2090 # Called in a loop over all displayed RC entries
2091 # Either returns the line, or caches it for later use
2092 function recentChangesLine( &$rc, $watched = false )
2095 $usenew = $wgUser->getOption( "usenewrc" );
2097 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
2099 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
2103 function recentChangesLineOld( &$rc, $watched = false )
2105 global $wgTitle, $wgLang, $wgUser, $wgRCSeconds;
2107 # Extract DB fields into local scope
2108 extract( $rc->mAttribs
);
2109 $curIdEq = "curid=" . $rc_cur_id;
2111 # Make date header if necessary
2112 $date = $wgLang->date( $rc_timestamp, true);
2114 if ( $date != $this->lastdate
) {
2115 if ( "" != $this->lastdate
) { $s .= "</ul>\n"; }
2116 $s .= "<h4>{$date}</h4>\n<ul class='special'>";
2117 $this->lastdate
= $date;
2118 $this->rclistOpen
= true;
2122 if ( $rc_type == RC_MOVE
) {
2124 $s .= "(" . wfMsg( "diff" ) . ") (";
2126 $s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), wfMsg( "hist" ), "action=history" ) .
2129 # "[[x]] moved to [[y]]"
2131 $s .= wfMsg( "1movedto2", $this->makeKnownLinkObj( $rc->getTitle(), "", "redirect=no" ),
2132 $this->makeKnownLinkObj( $rc->getMovedToTitle(), "" ) );
2136 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
2137 $diffLink = wfMsg( "diff" );
2139 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "diff" ),
2140 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}" ,'' ,'' , ' tabindex="'.$rc->counter
.'"');
2142 $s .= "($diffLink) (";
2145 $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" );
2148 # M and N (minor and new)
2149 $M = wfMsg( "minoreditletter" );
2150 $N = wfMsg( "newpageletter" );
2151 if ( $rc_minor ) { $s .= " <strong>{$M}</strong>"; }
2152 if ( $rc_type == RC_NEW
) { $s .= "<strong>{$N}</strong>"; }
2155 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), "" );
2158 $articleLink = "<strong>{$articleLink}</strong>";
2160 $s .= " $articleLink";
2165 $s .= "; " . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . " . . ";
2167 # User link (or contributions for unregistered users)
2168 if ( 0 == $rc_user ) {
2169 $userLink = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
2170 $rc_user_text, "target=" . $rc_user_text );
2172 $userLink = $this->makeLink( $wgLang->getNsText( NS_USER
) . ":{$rc_user_text}", $rc_user_text );
2177 $talkname=$wgLang->getNsText(NS_TALK
); # use the shorter name
2178 global $wgDisableAnonTalk;
2179 if( 0 == $rc_user && $wgDisableAnonTalk ) {
2182 $utns=$wgLang->getNsText(NS_USER_TALK
);
2183 $userTalkLink= $this->makeLink($utns . ":{$rc_user_text}", $talkname );
2187 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2188 $blockLink = $this->makeKnownLink( $wgLang->specialPage(
2189 "Blockip" ), wfMsg( "blocklink" ), "ip={$rc_user_text}" );
2193 if($userTalkLink) $userTalkLink .= " | ";
2194 $userTalkLink .= $blockLink;
2196 if($userTalkLink) $s.=" ({$userTalkLink})";
2199 if ( "" != $rc_comment && "*" != $rc_comment && $rc_type != RC_MOVE
) {
2200 $rc_comment=$this->formatComment($rc_comment);
2201 $s .= $wgLang->emphasize(" (" . $rc_comment . ")");
2208 # function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
2209 function recentChangesLineNew( &$baseRC, $watched = false )
2211 global $wgTitle, $wgLang, $wgUser, $wgRCSeconds;
2213 # Create a specialised object
2214 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
2216 # Extract fields from DB into the function scope (rc_xxxx variables)
2217 extract( $rc->mAttribs
);
2218 $curIdEq = "curid=" . $rc_cur_id;
2220 # If it's a new day, add the headline and flush the cache
2221 $date = $wgLang->date( $rc_timestamp, true);
2223 if ( $date != $this->lastdate
) {
2224 # Process current cache
2225 $ret = $this->recentChangesBlock () ;
2226 $this->rc_cache
= array() ;
2227 $ret .= "<h4>{$date}</h4>\n";
2228 $this->lastdate
= $date;
2232 if ( $rc_type == RC_MOVE
) {
2233 $clink = $this->makeKnownLinkObj( $rc->getTitle(), "", "redirect=no" );
2234 $clink .= " " . wfMsg("movedto") . " ";
2235 $clink .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), "" );
2237 $clink = $this->makeKnownLinkObj( $rc->getTitle(), "" ) ;
2240 $time = $wgLang->time( $rc_timestamp, true, $wgRCSeconds );
2241 $rc->watched
= $watched ;
2242 $rc->link
= $clink ;
2243 $rc->timestamp
= $time;
2246 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE
) {
2247 $curLink = wfMsg( "cur" );
2249 $curLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "cur" ),
2250 "{$curIdEq}&diff=0&oldid={$rc_this_oldid}" ,'' ,'' , ' tabindex="'.$baseRC->counter
.'"' );
2254 $titleObj = $rc->getTitle();
2255 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE
) {
2256 $lastLink = wfMsg( "last" );
2258 $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "last" ),
2259 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}" );
2262 # Make user link (or user contributions for unregistered users)
2263 if ( 0 == $rc_user ) {
2264 $userLink = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
2265 $rc_user_text, "target=" . $rc_user_text );
2267 $userLink = $this->makeLink( $wgLang->getNsText(
2268 Namespace::getUser() ) . ":{$rc_user_text}", $rc_user_text );
2271 $rc->userlink
= $userLink ;
2272 $rc->lastlink
= $lastLink ;
2273 $rc->curlink
= $curLink ;
2275 # Make user talk link
2276 $utns=$wgLang->getNsText(NS_USER_TALK
);
2277 $talkname=$wgLang->getNsText(NS_TALK
); # use the shorter name
2278 $userTalkLink= $this->makeLink($utns . ":{$rc_user_text}", $talkname );
2280 global $wgDisableAnonTalk;
2281 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2282 $blockLink = $this->makeKnownLink( $wgLang->specialPage(
2283 "Blockip" ), wfMsg( "blocklink" ), "ip={$rc_user_text}" );
2284 if( $wgDisableAnonTalk )
2285 $rc->usertalklink
= " ({$blockLink})";
2287 $rc->usertalklink
= " ({$userTalkLink} | {$blockLink})";
2289 if( $wgDisableAnonTalk && ($rc_user == 0) )
2290 $rc->usertalklink
= "";
2292 $rc->usertalklink
= " ({$userTalkLink})";
2295 # Put accumulated information into the cache, for later display
2296 # Page moves go on their own line
2297 $title = $rc->getTitle();
2298 $secureName = $title->getPrefixedDBkey();
2299 if ( $rc_type == RC_MOVE
) {
2300 # Use an @ character to prevent collision with page names
2301 $this->rc_cache
["@@" . ($this->rcMoveIndex++
)] = array($rc);
2303 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
2304 array_push ( $this->rc_cache
[$secureName] , $rc ) ;
2309 function endImageHistoryList()
2315 /* This function is called by all recent changes variants, by the page history,
2316 and by the user contributions list. It is responsible for formatting edit
2317 comments. It escapes any HTML in the comment, but adds some CSS to format
2318 auto-generated comments (from section editing) and formats [[wikilinks]].
2319 Main author: Erik Möller (moeller@scireview.de)
2321 function formatComment($comment)
2324 $comment=wfEscapeHTML($comment);
2326 # The pattern for autogen comments is / * foo * /, which makes for
2328 # We look for all comments, match any text before and after the comment,
2329 # add a separator where needed and format the comment itself with CSS
2330 while (preg_match("/(.*)\/\*\s*(.*?)\s*\*\/(.*)/", $comment,$match)) {
2335 if($pre) { $auto="$sep ".$auto; }
2336 if($post) { $auto.=" $sep"; }
2337 $auto="<span class=\"autocomment\">".$auto."</span>";
2338 $comment=$pre.$auto.$post;
2341 # format regular and media links - all other wiki formatting
2343 while(preg_match("/\[\[(.*?)(\|(.*?))*\]\]/",$comment,$match)) {
2345 $medians = $wgLang->getNsText(Namespace::getMedia());
2347 if(preg_match("/^".$medians."/i",$match[1])) {
2348 $func="makeMediaLink";
2350 if(isset($match[3]) ) {
2352 preg_replace("/\[\[(.*?)\]\]/",
2353 $this->$func($match[1],$match[3]),$comment,1);
2356 preg_replace("/\[\[(.*?)\]\]/",
2357 $this->$func($match[1],$match[1]),$comment,1);
2365 function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c )
2367 global $wgUser, $wgLang, $wgTitle;
2369 $dt = $wgLang->timeanddate( $ts, true );
2370 $del = wfMsg( "deleteimg" );
2371 $cur = wfMsg( "cur" );
2374 $url = Image
::wfImageUrl( $img );
2376 if ( $wgUser->isSysop() ) {
2377 $link = $wgTitle->escapeLocalURL( "image=" . $wgTitle->getPartialURL() .
2379 $style = $this->getInternalLinkAttributes( $link, $del );
2381 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
2386 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
2387 if( $wgUser->getID() != 0 ) {
2388 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2389 wfMsg( "revertimg" ), "action=revert&oldimage=" .
2390 urlencode( $img ) );
2391 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2392 $del, "action=delete&oldimage=" . urlencode( $img ) );
2394 # Having live active links for non-logged in users
2395 # means that bots and spiders crawling our site can
2396 # inadvertently change content. Baaaad idea.
2397 $rlink = wfMsg( "revertimg" );
2401 if ( 0 == $u ) { $ul = $ut; }
2402 else { $ul = $this->makeLink( $wgLang->getNsText(
2403 Namespace::getUser() ) . ":{$ut}", $ut ); }
2405 $nb = wfMsg( "nbytes", $size );
2406 $style = $this->getInternalLinkAttributes( $url, $dt );
2408 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$dt}</a>"
2409 . " . . {$ul} ({$nb})";
2411 if ( "" != $c && "*" != $c ) {
2412 $sk=$wgUser->getSkin();
2413 $s .= $wgLang->emphasize(" (" . $sk->formatComment($c) . ")");
2419 function tocIndent($level) {
2420 return str_repeat( "<div class='tocindent'>\n", $level>0 ?
$level : 0 );
2423 function tocUnindent($level) {
2424 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
2427 # parameter level defines if we are on an indentation level
2428 function tocLine( $anchor, $tocline, $level ) {
2429 $link = "<a href=\"#$anchor\">$tocline</a><br />";
2433 return "<div class='tocline'>$link</div>\n";
2438 function tocTable($toc) {
2439 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2440 # try min-width & co when somebody gets a chance
2441 $hideline = " <script type='text/javascript'>showTocToggle(\"" . addslashes( wfMsg("showtoc") ) . "\",\"" . addslashes( wfMsg("hidetoc") ) . "\")</script>";
2443 "<table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
2444 "<b>".wfMsg("toc")."</b>" .
2446 "</td></tr><tr id='tocinside'><td>\n".
2447 $toc."</td></tr></table>\n";
2450 # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
2451 function editSectionScript( $section, $head ) {
2452 global $wgTitle, $wgRequest;
2453 if( $wgRequest->getInt( "oldid" ) && ( $wgRequest->getVal( "diff" ) != "0" ) ) {
2456 $url = $wgTitle->escapeLocalURL( "action=edit§ion=$section" );
2457 return "<span oncontextmenu='document.location=\"$url\";return false;'>{$head}</span>";
2460 function editSectionLink( $section ) {
2462 global $wgTitle, $wgUser, $wgLang;
2464 if( $wgRequest->getInt( "oldid" ) && ( $wgRequest->getVal( "diff" ) != "0" ) ) {
2465 # Section edit links would be out of sync on an old page.
2466 # But, if we're diffing to the current page, they'll be
2471 $editurl = "§ion={$section}";
2472 $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
2474 if( $wgLang->isRTL() ) {
2476 $nearside = "right";
2481 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2485 // This function is called by EditPage.php and shows a bulletin board style
2486 // toolbar for common editing functions. It can be disabled in the user preferences.
2487 // The necsesary JavaScript code can be found in style/wikibits.js.
2488 function getEditToolbar() {
2489 global $wgStylePath, $wgLang, $wgMimeType;
2491 // toolarray an array of arrays which each include the filename of
2492 // the button image (without path), the opening tag, the closing tag,
2493 // and optionally a sample text that is inserted between the two when no
2494 // selection is highlighted.
2495 // The tip text is shown when the user moves the mouse over the button.
2497 // Already here are accesskeys (key), which are not used yet until someone
2498 // can figure out a way to make them work in IE. However, we should make
2499 // sure these keys are not defined on the edit page.
2501 array( "image"=>"button_bold.png",
2504 "sample"=>wfMsg("bold_sample"),
2505 "tip"=>wfMsg("bold_tip"),
2508 array( "image"=>"button_italic.png",
2511 "sample"=>wfMsg("italic_sample"),
2512 "tip"=>wfMsg("italic_tip"),
2515 array( "image"=>"button_link.png",
2518 "sample"=>wfMsg("link_sample"),
2519 "tip"=>wfMsg("link_tip"),
2522 array( "image"=>"button_extlink.png",
2525 "sample"=>wfMsg("extlink_sample"),
2526 "tip"=>wfMsg("extlink_tip"),
2529 array( "image"=>"button_headline.png",
2532 "sample"=>wfMsg("headline_sample"),
2533 "tip"=>wfMsg("headline_tip"),
2536 array( "image"=>"button_image.png",
2537 "open"=>"[[".$wgLang->getNsText(NS_IMAGE
).":",
2539 "sample"=>wfMsg("image_sample"),
2540 "tip"=>wfMsg("image_tip"),
2543 array( "image"=>"button_media.png",
2544 "open"=>"[[".$wgLang->getNsText(NS_MEDIA
).":",
2546 "sample"=>wfMsg("media_sample"),
2547 "tip"=>wfMsg("media_tip"),
2550 array( "image"=>"button_math.png",
2551 "open"=>"\\<math\\>",
2552 "close"=>"\\</math\\>",
2553 "sample"=>wfMsg("math_sample"),
2554 "tip"=>wfMsg("math_tip"),
2557 array( "image"=>"button_nowiki.png",
2558 "open"=>"\\<nowiki\\>",
2559 "close"=>"\\</nowiki\\>",
2560 "sample"=>wfMsg("nowiki_sample"),
2561 "tip"=>wfMsg("nowiki_tip"),
2564 array( "image"=>"button_sig.png",
2568 "tip"=>wfMsg("sig_tip"),
2571 array( "image"=>"button_hr.png",
2572 "open"=>"\\n----\\n",
2575 "tip"=>wfMsg("hr_tip"),
2579 $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
2581 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
2582 foreach($toolarray as $tool) {
2584 $image=$wgStylePath."/images/".$tool["image"];
2585 $open=$tool["open"];
2586 $close=$tool["close"];
2587 $sample = addslashes( $tool["sample"] );
2589 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
2590 // Older browsers show a "speedtip" type message only for ALT.
2591 // Ideally these should be different, realistically they
2592 // probably don't need to be.
2593 $tip = addslashes( $tool["tip"] );
2595 #$key = $tool["key"];
2597 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
2600 $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
2601 $toolbar.="document.writeln(\"</div>\");\n";
2603 $toolbar.="/*]]>*/\n</script>";
2608 include_once( "SkinStandard.php" );
2609 include_once( "SkinNostalgia.php" );
2610 include_once( "SkinCologneBlue.php" );
2612 if( $wgUsePHPTal ) {
2613 include_once( "SkinPHPTal.php" );