4 require_once( 'Feed.php' ); // should not be called if the actual page isn't feed enabled
5 require_once( 'Image.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['myskin'] = 'MySkin';
22 #$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal';
25 require_once( 'RecentChange.php' );
27 class RCCacheEntry
extends RecentChange
29 var $secureName, $link;
30 var $curlink , $difflink, $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';
65 function getSkinName() {
71 global $wgOut, $wgUser;
73 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
74 $q = $wgUser->getOption( 'quickbar' );
75 if ( '' == $q ) { $q = 0; }
79 function initPage( &$out )
81 $fname = 'Skin::initPage';
82 wfProfileIn( $fname );
84 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
86 $this->addMetadataLinks($out);
88 wfProfileOut( $fname );
91 function addMetadataLinks( &$out ) {
92 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
93 global $wgRightsPage, $wgRightsUrl;
95 if( $out->isArticleRelated() ) {
96 # note: buggy CC software only reads first "meta" link
97 if( $wgEnableCreativeCommonsRdf ) {
98 $out->addMetadataLink( array(
99 'title' => 'Creative Commons',
100 'type' => 'application/rdf+xml',
101 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
103 if( $wgEnableDublinCoreRdf ) {
104 $out->addMetadataLink( array(
105 'title' => 'Dublin Core',
106 'type' => 'application/rdf+xml',
107 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
111 if( $wgRightsPage ) {
112 $copy = Title
::newFromText( $wgRightsPage );
114 $copyright = $copy->getLocalURL();
117 if( !$copyright && $wgRightsUrl ) {
118 $copyright = $wgRightsUrl;
121 $out->addLink( array(
122 'rel' => 'copyright',
123 'href' => $copyright ) );
127 function outputPage( &$out ) {
128 global $wgDebugComments;
130 wfProfileIn( 'Skin::outputPage' );
131 $this->initPage( $out );
132 $out->out( $out->headElement() );
134 $out->out( "\n<body" );
135 $ops = $this->getBodyOptions();
136 foreach ( $ops as $name => $val ) {
137 $out->out( " $name='$val'" );
140 if ( $wgDebugComments ) {
141 $out->out( "<!-- Wiki debugging output:\n" .
142 $out->mDebugtext
. "-->\n" );
144 $out->out( $this->beforeContent() );
146 $out->out( $out->mBodytext
. "\n" );
148 $out->out( $this->afterContent() );
151 $out->out( $out->reportTime() );
153 $out->out( "\n</body></html>" );
156 function getHeadScripts() {
157 global $wgStylePath, $wgUser, $wgLang, $wgAllowUserJs;
158 $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/wikibits.js\"></script>\n";
159 if( $wgAllowUserJs && $wgUser->getID() != 0 ) { # logged in
160 $userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
161 $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript'));
162 $r .= '<script type="text/javascript" src="'.$userjs."\"></script>\n";
167 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
168 function getUserStylesheet() {
169 global $wgOut, $wgStylePath, $wgLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
170 $sheet = $this->getStylesheet();
171 $action = $wgRequest->getText('action');
172 $s = "@import \"$wgStylePath/$sheet\";\n";
173 if($wgLang->isRTL()) $s .= "@import \"$wgStylePath/common_rtl.css\";\n";
174 if( $wgAllowUserCss && $wgUser->getID() != 0 ) { # logged in
175 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
176 $s .= $wgRequest->getText('wpTextbox1');
178 $userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
179 $s.= '@import "'.$this->makeUrl($userpage.'/'.$this->getSkinName().'.css', 'action=raw&ctype=text/css').'";'."\n";
182 $s .= $this->doGetUserStyles();
185 # placeholder, returns generated js in monobook
186 function getUserJs() {
190 function getUserStyles()
192 global $wgOut, $wgStylePath, $wgLang;
193 $s = "<style type='text/css'>\n";
194 $s .= "/*/*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
195 $s .= $this->getUserStylesheet();
201 function doGetUserStyles()
206 if ( 1 == $wgUser->getOption( 'underline' ) ) {
207 # Don't override browser settings
212 "text-decoration: none; }\n";
214 if ( 1 == $wgUser->getOption( 'highlightbroken' ) ) {
215 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
217 if ( 1 == $wgUser->getOption( 'justify' ) ) {
218 $s .= "#article { text-align: justify; }\n";
223 function getBodyOptions()
225 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
227 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
229 if ( 0 != $wgTitle->getNamespace() ) {
230 $a = array( 'bgcolor' => '#ffffec' );
232 else $a = array( 'bgcolor' => '#FFFFFF' );
233 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
234 (!$wgTitle->isProtected() ||
$wgUser->isSysop()) ) {
235 $t = wfMsg( 'editthispage' );
237 if ( !empty($redirect) ) {
238 $red = "&redirect={$redirect}";
240 if ( !empty($oldid) && ! isset( $diff ) ) {
241 $oid = "&oldid={$oldid}";
243 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
244 $s = 'document.location = "' .$s .'";';
245 $a +
= array ('ondblclick' => $s);
248 $a['onload'] = $wgOut->getOnloadHandler();
252 function getExternalLinkAttributes( $link, $text, $class='' )
254 global $wgUser, $wgOut, $wgLang;
256 $link = urldecode( $link );
257 $link = $wgLang->checkTitleEncoding( $link );
258 $link = str_replace( '_', ' ', $link );
259 $link = wfEscapeHTML( $link );
261 $r = ($class != '') ?
" class='$class'" : " class='external'";
263 if ( 1 == $wgUser->getOption( 'hover' ) ) {
264 $r .= " title=\"{$link}\"";
269 function getInternalLinkAttributes( $link, $text, $broken = false )
271 global $wgUser, $wgOut;
273 $link = urldecode( $link );
274 $link = str_replace( '_', ' ', $link );
275 $link = wfEscapeHTML( $link );
277 if ( $broken == 'stub' ) {
278 $r = ' class="stub"';
279 } else if ( $broken == 'yes' ) {
285 if ( 1 == $wgUser->getOption( 'hover' ) ) {
286 $r .= " title=\"{$link}\"";
291 function getInternalLinkAttributesObj( &$nt, $text, $broken = false )
293 global $wgUser, $wgOut;
295 if ( $broken == 'stub' ) {
296 $r = ' class="stub"';
297 } else if ( $broken == 'yes' ) {
303 if ( 1 == $wgUser->getOption( 'hover' ) ) {
304 $r .= ' title ="' . $nt->getEscapedText() . '"';
315 # This will be called immediately after the <body> tag. Split into
316 # two functions to make it easier to subclass.
318 function beforeContent()
320 global $wgUser, $wgOut, $wgSiteNotice;
322 if( $wgSiteNotice ) {
323 $note = "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
327 return $this->doBeforeContent() . $note;
330 function doBeforeContent()
332 global $wgUser, $wgOut, $wgTitle, $wgLang;
333 $fname = 'Skin::doBeforeContent';
334 wfProfileIn( $fname );
337 $qb = $this->qbSetting();
339 if( $langlinks = $this->otherLanguages() ) {
345 $borderhack = 'class="top"';
348 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
349 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
352 $left = ($qb == 1 ||
$qb == 3);
353 if($wgLang->isRTL()) $left = !$left;
356 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
357 $this->logoText() . '</td>';
359 $s .= $this->getQuickbarCompensator( $rows );
361 $l = $wgLang->isRTL() ?
'right' : 'left';
362 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
364 $s .= $this->topLinks() ;
365 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
367 $r = $wgLang->isRTL() ?
"left" : "right";
368 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
369 $s .= $this->nameAndLogin();
370 $s .= "\n<br />" . $this->searchForm() . "</td>";
373 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
376 if ( $shove && !$left ) { # Right
377 $s .= $this->getQuickbarCompensator( $rows );
379 $s .= "</tr>\n</table>\n</div>\n";
380 $s .= "\n<div id='article'>\n";
382 $s .= $this->pageTitle();
383 $s .= $this->pageSubtitle() ;
384 $s .= $this->getCategories();
385 wfProfileOut( $fname );
389 function getCategoryLinks () {
390 global $wgOut, $wgTitle, $wgUser, $wgParser;
391 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
393 if( !$wgUseCategoryMagic ) return '' ;
394 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
396 # Taken out so that they will be displayed in previews -- TS
397 #if( !$wgOut->isArticle() ) return '';
399 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
400 $s = $this->makeKnownLink( 'Special:Categories',
401 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
404 if($wgUseCategoryBrowser) {
407 $s.= $wgTitle->getAllParentCategories($catstack);
413 function getCategories() {
414 $catlinks=$this->getCategoryLinks();
415 if(!empty($catlinks)) {
416 return "<p class='catlinks'>{$catlinks}</p>";
420 function getQuickbarCompensator( $rows = 1 )
422 return "<td width='152' rowspan='{$rows}'> </td>";
425 # This gets called immediately before the </body> tag.
427 function afterContent()
429 global $wgUser, $wgOut, $wgServer;
430 global $wgTitle, $wgLang;
432 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
433 return $printfooter . $this->doAfterContent();
436 function printFooter() {
438 $url = htmlspecialchars( $wgTitle->getFullURL() );
439 return "<p>" . wfMsg( "retrievedfrom", "<a href=\"$url\">$url</a>" ) .
440 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
443 function doAfterContent()
445 global $wgUser, $wgOut, $wgLang;
446 $fname = 'Skin::doAfterContent';
447 wfProfileIn( $fname );
448 wfProfileIn( $fname.'-1' );
450 $s = "\n</div><br style=\"clear:both\" />\n";
451 $s .= "\n<div id='footer'>";
452 $s .= '<table border="0" cellspacing="0"><tr>';
454 wfProfileOut( $fname.'-1' );
455 wfProfileIn( $fname.'-2' );
457 $qb = $this->qbSetting();
459 $left = ($qb == 1 ||
$qb == 3);
460 if($wgLang->isRTL()) $left = !$left;
462 if ( $shove && $left ) { # Left
463 $s .= $this->getQuickbarCompensator();
465 wfProfileOut( $fname.'-2' );
466 wfProfileIn( $fname.'-3' );
467 $l = $wgLang->isRTL() ?
'right' : 'left';
468 $s .= "<td class='bottom' align='$l' valign='top'>";
470 $s .= $this->bottomLinks();
471 $s .= "\n<br />" . $this->mainPageLink()
472 . ' | ' . $this->aboutLink()
473 . ' | ' . $this->specialLink( 'recentchanges' )
474 . ' | ' . $this->searchForm()
475 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
478 if ( $shove && !$left ) { # Right
479 $s .= $this->getQuickbarCompensator();
481 $s .= "</tr></table>\n</div>\n</div>\n";
483 wfProfileOut( $fname.'-3' );
484 wfProfileIn( $fname.'-4' );
485 if ( 0 != $qb ) { $s .= $this->quickBar(); }
486 wfProfileOut( $fname.'-4' );
487 wfProfileOut( $fname );
491 function pageTitleLinks()
493 global $wgOut, $wgTitle, $wgUser, $wgLang, $wgUseApproval, $wgRequest;
495 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
496 $action = $wgRequest->getText( 'action' );
498 $s = $this->printableLink();
499 if ( wfMsg ( 'disclaimers' ) != '-' ) $s .= ' | ' . $this->makeKnownLink( wfMsg( 'disclaimerpage' ), wfMsg( 'disclaimers' ) ) ;
501 if ( $wgOut->isArticleRelated() ) {
502 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
503 $name = $wgTitle->getDBkey();
504 $link = wfEscapeHTML( Image
::wfImageUrl( $name ) );
505 $style = $this->getInternalLinkAttributes( $link, $name );
506 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
508 # This will show the "Approve" link if $wgUseApproval=true;
509 if ( isset ( $wgUseApproval ) && $wgUseApproval )
511 $t = $wgTitle->getDBkey();
512 $name = 'Approve this article' ;
513 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
514 #wfEscapeHTML( wfImageUrl( $name ) );
515 $style = $this->getExternalLinkAttributes( $link, $name );
516 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
519 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
520 $s .= ' | ' . $this->makeKnownLink( $wgTitle->getPrefixedText(),
521 wfMsg( 'currentrev' ) );
524 if ( $wgUser->getNewtalk() ) {
525 # do not show "You have new messages" text when we are viewing our
528 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
529 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
530 $n =$wgUser->getName();
531 $tl = $this->makeKnownLink( $wgLang->getNsText(
532 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
533 wfMsg('newmessageslink') );
534 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
538 $undelete = $this->getUndeleteLink();
539 if( !empty( $undelete ) ) {
540 $s .= ' | '.$undelete;
545 function getUndeleteLink() {
546 global $wgUser, $wgTitle, $wgLang, $action;
547 if( $wgUser->isSysop() &&
548 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
549 ($n = $wgTitle->isDeleted() ) ) {
550 return wfMsg( 'thisisdeleted',
551 $this->makeKnownLink(
552 $wgLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
553 wfMsg( 'restorelink', $n ) ) );
558 function printableLink()
560 global $wgOut, $wgFeedClasses, $wgRequest;
562 $baseurl = $_SERVER['REQUEST_URI'];
563 if( strpos( '?', $baseurl ) == false ) {
568 $baseurl = htmlspecialchars( $baseurl );
569 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
571 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
572 if( $wgOut->isSyndicated() ) {
573 foreach( $wgFeedClasses as $format => $class ) {
574 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
575 $s .= " | <a href=\"$feedurl\">{$format}</a>";
583 global $wgOut, $wgTitle, $wgUser;
585 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
586 if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
590 function pageSubtitle()
594 $sub = $wgOut->getSubtitle();
596 global $wgExtraSubtitle;
597 $sub = wfMsg( 'fromwikipedia' ) . $wgExtraSubtitle;
599 $subpages = $this->subPageSubtitle();
600 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
601 $s = "<p class='subtitle'>{$sub}</p>\n";
605 function subPageSubtitle()
607 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
609 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
610 $ptext=$wgTitle->getPrefixedText();
611 if(preg_match('/\//',$ptext)) {
612 $links = explode('/',$ptext);
615 foreach($links as $link) {
617 if ($c<count($links)) {
618 $growinglink .= $link;
619 $getlink = $this->makeLink( $growinglink, $link );
620 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
624 $subpages .= '< ';
626 $subpages .= $getlink;
635 function nameAndLogin()
637 global $wgUser, $wgTitle, $wgLang, $wgShowIPinHeader, $wgIP;
639 $li = $wgLang->specialPage( 'Userlogin' );
640 $lo = $wgLang->specialPage( 'Userlogout' );
643 if ( 0 == $wgUser->getID() ) {
644 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
647 $tl = $this->makeKnownLink( $wgLang->getNsText(
648 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
649 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
651 $s .= $n . ' ('.$tl.')';
653 $s .= wfMsg('notloggedin');
656 $rt = $wgTitle->getPrefixedURL();
657 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
659 } else { $q = "returnto={$rt}"; }
661 $s .= "\n<br />" . $this->makeKnownLink( $li,
662 wfMsg( 'login' ), $q );
664 $n = $wgUser->getName();
665 $rt = $wgTitle->getPrefixedURL();
666 $tl = $this->makeKnownLink( $wgLang->getNsText(
667 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
668 $wgLang->getNsText( Namespace::getTalk( 0 ) ) );
672 $s .= $this->makeKnownLink( $wgLang->getNsText(
673 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br />" .
674 $this->makeKnownLink( $lo, wfMsg( 'logout' ),
675 "returnto={$rt}" ) . ' | ' .
676 $this->specialLink( 'preferences' );
678 $s .= ' | ' . $this->makeKnownLink( wfMsg( 'helppage' ),
684 function getSearchLink() {
685 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
686 return $searchPage->getLocalURL();
689 function escapeSearchLink() {
690 return htmlspecialchars( $this->getSearchLink() );
693 function searchForm()
696 $search = $wgRequest->getText( 'search' );
698 $s = '<form name="search" class="inline" method="post" action="'
699 . $this->escapeSearchLink() . "\">\n"
700 . '<input type="text" name="search" size="19" value="'
701 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
702 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
703 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
713 $s = $this->mainPageLink() . $sep
714 . $this->specialLink( 'recentchanges' );
716 if ( $wgOut->isArticleRelated() ) {
717 $s .= $sep . $this->editThisPage()
718 . $sep . $this->historyLink();
720 # Many people don't like this dropdown box
721 #$s .= $sep . $this->specialPagesList();
726 function bottomLinks()
728 global $wgOut, $wgUser, $wgTitle;
732 if ( $wgOut->isArticleRelated() ) {
733 $s .= '<strong>' . $this->editThisPage() . '</strong>';
734 if ( 0 != $wgUser->getID() ) {
735 $s .= $sep . $this->watchThisPage();
737 $s .= $sep . $this->talkLink()
738 . $sep . $this->historyLink()
739 . $sep . $this->whatLinksHere()
740 . $sep . $this->watchPageLinksLink();
742 if ( $wgTitle->getNamespace() == Namespace::getUser()
743 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
746 $id=User
::idFromName($wgTitle->getText());
747 $ip=User
::isIP($wgTitle->getText());
749 if($id ||
$ip) { # both anons and non-anons have contri list
750 $s .= $sep . $this->userContribsLink();
752 if ( 0 != $wgUser->getID() ) { # show only to signed in users
753 if($id) { # can only email non-anons
754 $s .= $sep . $this->emailUserLink();
758 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
759 $s .= "\n<br />" . $this->deleteThisPage() .
760 $sep . $this->protectThisPage() .
761 $sep . $this->moveThisPage();
763 $s .= "<br />\n" . $this->otherLanguages();
770 global $wgOut, $wgLang, $wgArticle, $wgRequest;
771 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax;
773 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
774 if ( ! $wgOut->isArticle() ) { return ''; }
775 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
776 if ( 0 == $wgArticle->getID() ) { return ''; }
779 if ( !$wgDisableCounters ) {
780 $count = $wgLang->formatNum( $wgArticle->getCount() );
782 $s = wfMsg( 'viewcount', $count );
786 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
787 require_once("Credits.php");
788 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
790 $s .= $this->lastModified();
793 return $s . ' ' . $this->getCopyright();
796 function getCopyright() {
797 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
800 $oldid = $wgRequest->getVal( 'oldid' );
801 $diff = $wgRequest->getVal( 'diff' );
803 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsg( 'history_copyright' ) !== '-' ) {
804 $msg = 'history_copyright';
810 if( $wgRightsPage ) {
811 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
812 } elseif( $wgRightsUrl ) {
813 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
818 $out .= wfMsg( $msg, $link );
822 function getCopyrightIcon() {
823 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
825 if( $wgRightsIcon ) {
826 $icon = htmlspecialchars( $wgRightsIcon );
828 $url = htmlspecialchars( $wgRightsUrl );
829 $out .= '<a href="'.$url.'">';
831 $text = htmlspecialchars( $wgRightsText );
832 $out .= "<img src=\"$icon\" alt='$text' />";
840 function getPoweredBy() {
842 $url = htmlspecialchars( "$wgStylePath/images/poweredby_mediawiki_88x31.png" );
843 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
847 function lastModified()
849 global $wgLang, $wgArticle;
851 $timestamp = $wgArticle->getTimestamp();
853 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
854 $s = ' ' . wfMsg( 'lastmodified', $d );
861 function logoText( $align = '' )
863 if ( '' != $align ) { $a = ' align="'.$align.'"'; }
866 $mp = wfMsg( 'mainpage' );
867 $titleObj = Title
::newFromText( $mp );
868 $s = '<a href="' . $titleObj->escapeLocalURL()
869 . '"><img'.$a.' src="'
870 . $this->getLogo() . '" alt="' . "[{$mp}]\" /></a>";
876 global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgLang;
877 global $wgDisableUploads, $wgRemoteUploads;
879 $fname = 'Skin::quickBar';
880 wfProfileIn( $fname );
882 $action = $wgRequest->getText( 'action' );
883 $wpPreview = $wgRequest->getBool( 'wpPreview' );
884 $tns=$wgTitle->getNamespace();
886 $s = "\n<div id='quickbar'>";
887 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
890 $s .= $this->mainPageLink()
891 . $sep . $this->specialLink( 'recentchanges' )
892 . $sep . $this->specialLink( 'randompage' );
893 if ($wgUser->getID()) {
894 $s.= $sep . $this->specialLink( 'watchlist' ) ;
895 $s .= $sep .$this->makeKnownLink( $wgLang->specialPage( 'Contributions' ),
896 wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) );
899 // only show watchlist link if logged in
900 if ( wfMsg ( 'currentevents' ) != '-' ) $s .= $sep . $this->makeKnownLink( wfMsg( 'currentevents' ), '' ) ;
901 $s .= "\n<br /><hr class='sep' />";
902 $articleExists = $wgTitle->getArticleId();
903 if ( $wgOut->isArticle() ||
$action =='edit' ||
$action =='history' ||
$wpPreview) {
904 if($wgOut->isArticle()) {
905 $s .= '<strong>' . $this->editThisPage() . '</strong>';
906 } else { # backlink to the article in edit or history mode
907 if($articleExists){ # no backlink if no article
910 $text = wfMsg('articlepage');
913 $text = wfMsg('viewtalkpage');
916 $text = wfMsg('userpage');
919 $text = wfMsg('viewtalkpage');
922 $text = wfMsg('wikipediapage');
925 $text = wfMsg('viewtalkpage');
928 $text = wfMsg('imagepage');
931 $text = wfMsg('viewtalkpage');
934 $text= wfMsg('articlepage');
937 $link = $wgTitle->getText();
938 if ($nstext = $wgLang->getNsText($tns) ) { # add namespace if necessary
939 $link = $nstext . ':' . $link ;
942 $s .= $this->makeLink( $link, $text );
943 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
944 # we just throw in a "New page" text to tell the user that he's in edit mode,
945 # and to avoid messing with the separator that is prepended to the next item
946 $s .= '<strong>' . wfMsg('newpage') . '</strong>';
952 if( $tns%2
&& $action!='edit' && !$wpPreview) {
953 $s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit§ion=new');
957 watching could cause problems in edit mode:
958 if user edits article, then loads "watch this article" in background and then saves
959 article with "Watch this article" checkbox disabled, the article is transparently
960 unwatched. Therefore we do not show the "Watch this page" link in edit mode
962 if ( 0 != $wgUser->getID() && $articleExists) {
963 if($action!='edit' && $action != 'submit' )
965 $s .= $sep . $this->watchThisPage();
967 if ( $wgTitle->userCanEdit() )
968 $s .= $sep . $this->moveThisPage();
970 if ( $wgUser->isSysop() and $articleExists ) {
971 $s .= $sep . $this->deleteThisPage() .
972 $sep . $this->protectThisPage();
974 $s .= $sep . $this->talkLink();
975 if ($articleExists && $action !='history') {
976 $s .= $sep . $this->historyLink();
978 $s.=$sep . $this->whatLinksHere();
980 if($wgOut->isArticleRelated()) {
981 $s .= $sep . $this->watchPageLinksLink();
984 if ( Namespace::getUser() == $wgTitle->getNamespace()
985 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
988 $id=User
::idFromName($wgTitle->getText());
989 $ip=User
::isIP($wgTitle->getText());
992 $s .= $sep . $this->userContribsLink();
994 if ( 0 != $wgUser->getID() ) {
995 if($id) { # can only email real users
996 $s .= $sep . $this->emailUserLink();
1000 $s .= "\n<br /><hr class='sep' />";
1003 if ( 0 != $wgUser->getID() && ( !$wgDisableUploads ||
$wgRemoteUploads ) ) {
1004 $s .= $this->specialLink( 'upload' ) . $sep;
1006 $s .= $this->specialLink( 'specialpages' )
1007 . $sep . $this->bugReportsLink();
1009 global $wgSiteSupportPage;
1010 if( $wgSiteSupportPage ) {
1011 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
1012 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
1015 $s .= "\n<br /></div>\n";
1016 wfProfileOut( $fname );
1020 function specialPagesList()
1022 global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
1023 require_once('SpecialPage.php');
1025 $pages = SpecialPage
::getPages();
1027 foreach ( $pages[''] as $name => $page ) {
1028 $a[$name] = $page->getDescription();
1030 if ( $wgUser->isSysop() )
1032 foreach ( $pages['sysop'] as $name => $page ) {
1033 $a[$name] = $page->getDescription();
1036 if ( $wgUser->isDeveloper() )
1038 foreach ( $pages['developer'] as $name => $page ) {
1039 $a[$name] = $page->getDescription() ;
1042 $go = wfMsg( 'go' );
1043 $sp = wfMsg( 'specialpages' );
1044 $spp = $wgLang->specialPage( 'Specialpages' );
1046 $s = '<form id="specialpages" method="get" class="inline" ' .
1047 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1048 $s .= "<select name=\"wpDropdown\">\n";
1049 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1051 foreach ( $a as $name => $desc ) {
1052 $p = $wgLang->specialPage( $name );
1053 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1055 $s .= "</select>\n";
1056 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1061 function mainPageLink()
1063 $mp = wfMsg( 'mainpage' );
1064 $s = $this->makeKnownLink( $mp, $mp );
1068 function copyrightLink()
1070 $s = $this->makeKnownLink( wfMsg( 'copyrightpage' ),
1071 wfMsg( 'copyrightpagename' ) );
1075 function aboutLink()
1077 $s = $this->makeKnownLink( wfMsg( 'aboutpage' ),
1078 wfMsg( 'aboutwikipedia' ) );
1083 function disclaimerLink()
1085 $s = $this->makeKnownLink( wfMsg( 'disclaimerpage' ),
1086 wfMsg( 'disclaimers' ) );
1090 function editThisPage()
1092 global $wgOut, $wgTitle, $wgRequest;
1094 $oldid = $wgRequest->getVal( 'oldid' );
1095 $diff = $wgRequest->getVal( 'diff' );
1096 $redirect = $wgRequest->getVal( 'redirect' );
1098 if ( ! $wgOut->isArticleRelated() ) {
1099 $s = wfMsg( 'protectedpage' );
1101 $n = $wgTitle->getPrefixedText();
1102 if ( $wgTitle->userCanEdit() ) {
1103 $t = wfMsg( 'editthispage' );
1105 #$t = wfMsg( "protectedpage" );
1106 $t = wfMsg( 'viewsource' );
1110 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1111 if ( $oldid && ! isset( $diff ) ) {
1112 $oid = "&oldid={$oldid}";
1114 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
1119 function deleteThisPage()
1121 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1123 $diff = $wgRequest->getVal( 'diff' );
1124 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1125 $n = $wgTitle->getPrefixedText();
1126 $t = wfMsg( 'deletethispage' );
1128 $s = $this->makeKnownLink( $n, $t, 'action=delete' );
1135 function protectThisPage()
1137 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1139 $diff = $wgRequest->getVal( 'diff' );
1140 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1141 $n = $wgTitle->getPrefixedText();
1143 if ( $wgTitle->isProtected() ) {
1144 $t = wfMsg( 'unprotectthispage' );
1145 $q = 'action=unprotect';
1147 $t = wfMsg( 'protectthispage' );
1148 $q = 'action=protect';
1150 $s = $this->makeKnownLink( $n, $t, $q );
1157 function watchThisPage()
1159 global $wgUser, $wgOut, $wgTitle;
1161 if ( $wgOut->isArticleRelated() ) {
1162 $n = $wgTitle->getPrefixedText();
1164 if ( $wgTitle->userIsWatching() ) {
1165 $t = wfMsg( 'unwatchthispage' );
1166 $q = 'action=unwatch';
1168 $t = wfMsg( 'watchthispage' );
1169 $q = 'action=watch';
1171 $s = $this->makeKnownLink( $n, $t, $q );
1173 $s = wfMsg( 'notanarticle' );
1178 function moveThisPage()
1180 global $wgTitle, $wgLang;
1182 if ( $wgTitle->userCanEdit() ) {
1183 $s = $this->makeKnownLink( $wgLang->specialPage( 'Movepage' ),
1184 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1185 } // no message if page is protected - would be redundant
1189 function historyLink()
1193 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1194 wfMsg( 'history' ), 'action=history' );
1198 function whatLinksHere()
1200 global $wgTitle, $wgLang;
1202 $s = $this->makeKnownLink( $wgLang->specialPage( 'Whatlinkshere' ),
1203 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1207 function userContribsLink()
1209 global $wgTitle, $wgLang;
1211 $s = $this->makeKnownLink( $wgLang->specialPage( 'Contributions' ),
1212 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1216 function emailUserLink()
1218 global $wgTitle, $wgLang;
1220 $s = $this->makeKnownLink( $wgLang->specialPage( 'Emailuser' ),
1221 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1225 function watchPageLinksLink()
1227 global $wgOut, $wgTitle, $wgLang;
1229 if ( ! $wgOut->isArticleRelated() ) {
1230 $s = '(' . wfMsg( 'notanarticle' ) . ')';
1232 $s = $this->makeKnownLink( $wgLang->specialPage(
1233 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1234 'target=' . $wgTitle->getPrefixedURL() );
1239 function otherLanguages()
1241 global $wgOut, $wgLang, $wgTitle, $wgUseNewInterlanguage;
1243 $a = $wgOut->getLanguageLinks();
1244 if ( 0 == count( $a ) ) {
1245 if ( !$wgUseNewInterlanguage ) return '';
1246 $ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1247 if ( $ns != 0 AND $ns != 1 ) return '' ;
1249 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
1250 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1251 wfMsg( 'intl' ) , $x );
1254 if ( !$wgUseNewInterlanguage ) {
1255 $s = wfMsg( 'otherlanguages' ) . ': ';
1257 global $wgLanguageCode ;
1258 $x = 'mode=zoom&xt='.$wgTitle->getDBkey() ;
1259 $x .= '&xl='.$wgLanguageCode ;
1260 $s = $this->makeKnownLink( $wgLang->specialPage( 'Intl' ),
1261 wfMsg( 'otherlanguages' ) , $x ) . ': ' ;
1264 $s = wfMsg( 'otherlanguages' ) . ': ';
1266 if($wgLang->isRTL()) $s .= '<span dir="LTR">';
1267 foreach( $a as $l ) {
1268 if ( ! $first ) { $s .= ' | '; }
1271 $nt = Title
::newFromText( $l );
1272 $url = $nt->getFullURL();
1273 $text = $wgLang->getLanguageName( $nt->getInterwiki() );
1275 if ( '' == $text ) { $text = $l; }
1276 $style = $this->getExternalLinkAttributes( $l, $text );
1277 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1279 if($wgLang->isRTL()) $s .= '</span>';
1283 function bugReportsLink()
1285 $s = $this->makeKnownLink( wfMsg( 'bugreportspage' ),
1286 wfMsg( 'bugreports' ) );
1292 global $wgLinkCache;
1293 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1294 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1296 $wgLinkCache->suspend();
1297 $id = $t1->getArticleID();
1298 $wgLinkCache->resume();
1301 $s = $this->makeBrokenLink( $t1->getText() );
1303 $s = $this->makeKnownLink( $t1->getText() );
1307 $wgLinkCache->suspend();
1308 $id = $t2->getArticleID();
1309 $wgLinkCache->resume();
1312 $s .= $this->makeBrokenLink( $t2->getText() );
1314 $s .= $this->makeKnownLink( $t2->getText() );
1321 global $wgLang, $wgTitle, $wgLinkCache;
1323 $tns = $wgTitle->getNamespace();
1324 if ( -1 == $tns ) { return ''; }
1326 $pn = $wgTitle->getText();
1327 $tp = wfMsg( 'talkpage' );
1328 if ( Namespace::isTalk( $tns ) ) {
1329 $lns = Namespace::getSubject( $tns );
1332 $text = wfMsg('articlepage');
1335 $text = wfMsg('userpage');
1338 $text = wfMsg('wikipediapage');
1341 $text = wfMsg('imagepage');
1344 $text= wfMsg('articlepage');
1348 $lns = Namespace::getTalk( $tns );
1351 $n = $wgLang->getNsText( $lns );
1352 if ( '' == $n ) { $link = $pn; }
1353 else { $link = $n.':'.$pn; }
1355 $wgLinkCache->suspend();
1356 $s = $this->makeLink( $link, $text );
1357 $wgLinkCache->resume();
1362 function commentLink()
1364 global $wgLang, $wgTitle, $wgLinkCache;
1366 $tns = $wgTitle->getNamespace();
1367 if ( -1 == $tns ) { return ''; }
1369 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1371 # assert Namespace::isTalk( $lns )
1373 $n = $wgLang->getNsText( $lns );
1374 $pn = $wgTitle->getText();
1378 $wgLinkCache->suspend();
1379 $s = $this->makeKnownLink($link, wfMsg('postcomment'), 'action=edit§ion=new');
1380 $wgLinkCache->resume();
1385 # After all the page content is transformed into HTML, it makes
1386 # a final pass through here for things like table backgrounds.
1388 function transformContent( $text )
1393 # Note: This function MUST call getArticleID() on the link,
1394 # otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1396 function makeLink( $title, $text = '', $query = '', $trail = '' ) {
1397 wfProfileIn( 'Skin::makeLink' );
1398 $nt = Title
::newFromText( $title );
1400 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1402 wfDebug( 'Invalid title passed to Skin::makeLink(): "'.$title."\"\n" );
1403 $result = $text == "" ?
$title : $text;
1406 wfProfileOut( 'Skin::makeLink' );
1410 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
1411 $nt = Title
::newFromText( $title );
1413 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
1415 wfDebug( 'Invalid title passed to Skin::makeKnownLink(): "'.$title."\"\n" );
1416 return $text == '' ?
$title : $text;
1420 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
1421 $nt = Title
::newFromText( $title );
1423 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1425 wfDebug( 'Invalid title passed to Skin::makeBrokenLink(): "'.$title."\"\n" );
1426 return $text == '' ?
$title : $text;
1430 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
1431 $nt = Title
::newFromText( $title );
1433 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1435 wfDebug( 'Invalid title passed to Skin::makeStubLink(): "'.$title."\"\n" );
1436 return $text == '' ?
$title : $text;
1440 # Pass a title object, not a title string
1441 function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' )
1443 global $wgOut, $wgUser;
1444 $fname = 'Skin::makeLinkObj';
1446 if ( $nt->isExternal() ) {
1447 $u = $nt->getFullURL();
1448 $link = $nt->getPrefixedURL();
1449 if ( '' == $text ) { $text = $nt->getPrefixedText(); }
1450 $style = $this->getExternalLinkAttributes( $link, $text, 'extiw' );
1453 if ( '' != $trail ) {
1454 if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
1459 $retVal = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
1460 } elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1461 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1462 } elseif ( ( -1 == $nt->getNamespace() ) ||
1463 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1464 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1466 $aid = $nt->getArticleID() ;
1468 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
1470 $threshold = $wgUser->getOption('stubthreshold') ;
1471 if ( $threshold > 0 ) {
1472 $s = $dbr->getArray( 'cur',
1473 array( 'LENGTH(cur_text) AS x', 'cur_namespace', 'cur_is_redirect' ),
1474 array( 'cur_id' => $aid ),
1478 if ( $s !== false ) {
1480 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
1481 $size = $threshold*2 ; # Really big
1484 $size = $threshold*2 ; # Really big
1489 if ( $size < $threshold ) {
1490 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
1492 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1499 # Pass a title object, not a title string
1500 function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '')
1502 global $wgOut, $wgTitle, $wgInputEncoding;
1504 $fname = 'Skin::makeKnownLinkObj';
1505 wfProfileIn( $fname );
1507 if ( !is_object( $nt ) ) {
1510 $link = $nt->getPrefixedURL();
1512 if ( '' == $link ) {
1514 if ( '' == $text ) {
1515 $text = htmlspecialchars( $nt->getFragment() );
1518 $u = $nt->escapeLocalURL( $query );
1520 if ( '' != $nt->getFragment() ) {
1521 $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT
, $wgInputEncoding ) );
1522 $replacearray = array(
1526 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
1528 if ( '' == $text ) {
1529 $text = htmlspecialchars( $nt->getPrefixedText() );
1531 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1534 if ( '' != $trail ) {
1535 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1540 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
1541 wfProfileOut( $fname );
1545 # Pass a title object, not a title string
1546 function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' )
1548 global $wgOut, $wgUser;
1550 $fname = 'Skin::makeBrokenLinkObj';
1551 wfProfileIn( $fname );
1553 if ( '' == $query ) {
1556 $q = 'action=edit&'.$query;
1558 $u = $nt->escapeLocalURL( $q );
1560 if ( '' == $text ) {
1561 $text = htmlspecialchars( $nt->getPrefixedText() );
1563 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1566 if ( '' != $trail ) {
1567 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1572 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1573 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1575 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1578 wfProfileOut( $fname );
1582 # Pass a title object, not a title string
1583 function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' )
1585 global $wgOut, $wgUser;
1587 $link = $nt->getPrefixedURL();
1589 $u = $nt->escapeLocalURL( $query );
1591 if ( '' == $text ) {
1592 $text = htmlspecialchars( $nt->getPrefixedText() );
1594 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
1597 if ( '' != $trail ) {
1598 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1603 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1604 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1606 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1611 function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' )
1613 $u = $nt->escapeLocalURL( $query );
1614 if ( '' == $text ) {
1615 $text = htmlspecialchars( $nt->getPrefixedText() );
1618 if ( '' != $trail ) {
1619 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1624 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
1627 /* these are used extensively in SkinPHPTal, but also some other places */
1628 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1629 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1630 $this->checkTitle($title, $name);
1631 return $title->getLocalURL( $urlaction );
1633 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1634 $title = Title
::newFromText( $name );
1635 $title = $title->getTalkPage();
1636 $this->checkTitle($title, $name);
1637 return $title->getLocalURL( $urlaction );
1639 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1640 $title = Title
::newFromText( $name );
1641 $title= $title->getSubjectPage();
1642 $this->checkTitle($title, $name);
1643 return $title->getLocalURL( $urlaction );
1645 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1646 $title = Title
::newFromText( wfMsg($name) );
1647 $this->checkTitle($title, $name);
1648 return $title->getLocalURL( $urlaction );
1650 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1651 $title = Title
::newFromText( $name );
1652 $this->checkTitle($title, $name);
1653 return $title->getLocalURL( $urlaction );
1655 # this can be passed the NS number as defined in Language.php
1656 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
1657 $title = Title
::makeTitle( $namespace, $name );
1658 $this->checkTitle($title, $name);
1659 return $title->getLocalURL( $urlaction );
1662 /* these return an array with the 'href' and boolean 'exists' */
1663 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1664 $title = Title
::newFromText( $name );
1665 $this->checkTitle($title, $name);
1667 'href' => $title->getLocalURL( $urlaction ),
1668 'exists' => $title->getArticleID() != 0?
true:false
1671 /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) {
1672 $title = Title
::newFromText( $name );
1673 $title = $title->getTalkPage();
1674 $this->checkTitle($title, $name);
1676 'href' => $title->getLocalURL( $urlaction ),
1677 'exists' => $title->getArticleID() != 0?
true:false
1680 /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) {
1681 $title = Title
::newFromText( $name );
1682 $title= $title->getSubjectPage();
1683 $this->checkTitle($title, $name);
1685 'href' => $title->getLocalURL( $urlaction ),
1686 'exists' => $title->getArticleID() != 0?
true:false
1689 /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
1690 $title = Title
::newFromText( wfMsg($name) );
1691 $this->checkTitle($title, $name);
1693 'href' => $title->getLocalURL( $urlaction ),
1694 'exists' => $title->getArticleID() != 0?
true:false
1698 # make sure we have some title to operate on
1699 /*static*/ function checkTitle ( &$title, &$name ) {
1700 if(!is_object($title)) {
1701 $title = Title
::newFromText( $name );
1702 if(!is_object($title)) {
1703 $title = Title
::newFromText( '--error: link target missing--' );
1708 function fnamePart( $url )
1710 $basename = strrchr( $url, '/' );
1711 if ( false === $basename ) { $basename = $url; }
1712 else { $basename = substr( $basename, 1 ); }
1713 return wfEscapeHTML( $basename );
1716 function makeImage( $url, $alt = '' )
1720 if ( '' == $alt ) { $alt = $this->fnamePart( $url ); }
1721 $s = '<img src="'.$url.'" alt="'.$alt.'" />';
1725 function makeImageLink( $name, $url, $alt = '' ) {
1726 $nt = Title
::makeTitle( Namespace::getImage(), $name );
1727 return $this->makeImageLinkObj( $nt, $alt );
1730 function makeImageLinkObj( $nt, $alt = '' ) {
1731 global $wgLang, $wgUseImageResize;
1732 $img = Image
::newFromTitle( $nt );
1733 $url = $img->getURL();
1736 $prefix = $postfix = '';
1738 if ( $wgUseImageResize ) {
1739 # Check if the alt text is of the form "options|alt text"
1741 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1742 # * left no resizing, just left align. label is used for alt= only
1743 # * right same, but right aligned
1744 # * none same, but not aligned
1745 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1746 # * center center the image
1747 # * framed Keep original image size, no magnify-button.
1749 $part = explode( '|', $alt);
1751 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
1752 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
1753 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
1754 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
1755 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
1756 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
1757 $mwFramed =& MagicWord
::get( MAG_IMG_FRAMED
);
1758 $alt = $part[count($part)-1];
1760 $height = $framed = $thumb = false;
1762 foreach( $part as $key => $val ) {
1763 if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1765 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1766 # remember to set an alignment, don't render immediately
1768 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1769 # remember to set an alignment, don't render immediately
1771 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
1772 # remember to set an alignment, don't render immediately
1774 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1775 # remember to set an alignment, don't render immediately
1777 } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1778 # $match is the image width in pixels
1779 if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
1780 $width = intval( $m[1] );
1781 $height = intval( $m[2] );
1783 $width = intval($match);
1785 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
1789 if ( 'center' == $align )
1791 $prefix = '<span style="text-align: center">';
1792 $postfix = '</span>';
1796 if ( $thumb ||
$framed ) {
1798 # Create a thumbnail. Alignment depends on language
1799 # writing direction, # right aligned for left-to-right-
1800 # languages ("Western languages"), left-aligned
1801 # for right-to-left-languages ("Semitic languages")
1803 # If thumbnail width has not been provided, it is set
1804 # here to 180 pixels
1805 if ( $align == '' ) {
1806 $align = $wgLang->isRTL() ?
'left' : 'right';
1808 if ( ! isset($width) ) {
1811 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed ).$postfix;
1813 } elseif ( isset($width) ) {
1815 # Create a resized image, without the additional thumbnail
1818 if ( ( ! $height === false )
1819 && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
1820 print "height=$height<br>\nimg->getHeight() = ".$img->getHeight()."<br>\n";
1821 print 'rescaling by factor '. $height / $img->getHeight() . "<br>\n";
1822 $width = $img->getWidth() * $height / $img->getHeight();
1824 $url = $img->createThumb( $width );
1826 } # endif $wgUseImageResize
1828 if ( empty( $alt ) ) {
1829 $alt = preg_replace( '/\.(.+?)^/', '', $img->getName() );
1831 $alt = htmlspecialchars( $alt );
1833 $u = $nt->escapeLocalURL();
1836 $s = str_replace( "$1", $img->getName(), wfMsg('missingimage') );
1837 $s .= "<br>{$alt}<br>{$url}<br>\n";
1839 $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
1840 '<img src="'.$url.'" alt="'.$alt.'" /></a>';
1842 if ( '' != $align ) {
1843 $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
1845 return str_replace("\n", ' ',$prefix.$s.$postfix);
1849 function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false ) {
1850 global $wgStylePath, $wgLang;
1851 # $image = Title::makeTitle( Namespace::getImage(), $name );
1852 $url = $img->getURL();
1854 #$label = htmlspecialchars( $label );
1855 $alt = preg_replace( '/<[^>]*>/', '', $label);
1856 $alt = htmlspecialchars( $alt );
1858 if ( $img->exists() )
1860 $width = $img->getWidth();
1861 $height = $img->getHeight();
1863 $width = $height = 200;
1867 // Use image dimensions, don't scale
1869 $oboxwidth = $boxwidth +
2;
1870 $boxheight = $height;
1873 $h = intval( $height/($width/$boxwidth) );
1874 $oboxwidth = $boxwidth +
2;
1875 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
1877 $boxwidth *= $boxheight/$h;
1881 $thumbUrl = $img->createThumb( $boxwidth );
1884 $u = $img->getEscapeLocalURL();
1886 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
1887 $magnifyalign = $wgLang->isRTL() ?
'left' : 'right';
1888 $textalign = $wgLang->isRTL() ?
' style="text-align:right"' : '';
1890 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
1891 if ( $thumbUrl == '' ) {
1892 $s .= str_replace( "$1", $img->getName(), wfMsg('missingimage') );
1895 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1896 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1897 'width="'.$boxwidth.'" height="'.$boxheight.'" /></a>';
1901 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1902 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1903 '<img src="'.$wgStylePath.'/images/magnify-clip.png" ' .
1904 'width="15" height="11" alt="'.$more.'" /></a></div>';
1907 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
1908 return str_replace("\n", ' ', $s);
1911 function makeMediaLink( $name, $url, $alt = "" ) {
1912 $nt = Title
::makeTitle( Namespace::getMedia(), $name );
1913 return $this->makeMediaLinkObj( $nt, $alt );
1916 function makeMediaLinkObj( $nt, $alt = "" )
1918 if ( ! isset( $nt ) )
1920 ### HOTFIX. Instead of breaking, return empry string.
1923 $name = $nt->getDBKey();
1924 $url = Image
::wfImageUrl( $name );
1925 if ( empty( $alt ) ) {
1926 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1929 $u = htmlspecialchars( $url );
1930 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1935 function specialLink( $name, $key = "" )
1939 if ( '' == $key ) { $key = strtolower( $name ); }
1940 $pn = $wgLang->ucfirst( $name );
1941 return $this->makeKnownLink( $wgLang->specialPage( $pn ),
1945 function makeExternalLink( $url, $text, $escape = true ) {
1946 $style = $this->getExternalLinkAttributes( $url, $text );
1947 $url = htmlspecialchars( $url );
1949 $text = htmlspecialchars( $text );
1951 return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
1954 # Called by history lists and recent changes
1957 # Returns text for the start of the tabular part of RC
1958 function beginRecentChangesList()
1960 $this->rc_cache
= array() ;
1961 $this->rcMoveIndex
= 0;
1962 $this->rcCacheIndex
= 0 ;
1963 $this->lastdate
= '';
1964 $this->rclistOpen
= false;
1968 function beginImageHistoryList()
1970 $s = "\n<h2>" . wfMsg( 'imghistory' ) . "</h2>\n" .
1971 "<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
1975 # Returns text for the end of RC
1976 # If enhanced RC is in use, returns pretty much all the text
1977 function endRecentChangesList()
1979 $s = $this->recentChangesBlock() ;
1980 if( $this->rclistOpen
) {
1986 # Enhanced RC ungrouped line
1987 function recentChangesBlockLine ( $rcObj )
1989 global $wgStylePath, $wgLang ;
1991 # Get rc_xxxx variables
1992 extract( $rcObj->mAttribs
) ;
1993 $curIdEq = 'curid='.$rc_cur_id;
1998 $r .= '<img src="'.$wgStylePath.'/images/Arr_.png" width="12" height="12" border="0" />' ;
2001 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2002 $r .= ' ';
2004 # M & N (minor & new)
2005 $M = wfMsg( 'minoreditletter' );
2006 $N = wfMsg( 'newpageletter' );
2008 if ( $rc_type == RC_NEW
) {
2021 $r .= ' '.$rcObj->timestamp
.' ' ;
2025 $link = $rcObj->link
;
2026 if ( $rcObj->watched
) $link = '<strong>'.$link.'</strong>' ;
2031 $r .= $rcObj->difflink
;
2035 $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
2038 $r .= ') . . '.$rcObj->userlink
;
2039 $r .= $rcObj->usertalklink
;
2042 if ( $rc_comment != '' && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2043 $rc_comment=$this->formatComment($rc_comment);
2044 $r .= $wgLang->emphasize( ' ('.$rc_comment.')' );
2052 function recentChangesBlockGroup ( $block )
2054 global $wgStylePath, $wgLang ;
2057 $M = wfMsg( 'minoreditletter' );
2058 $N = wfMsg( 'newpageletter' );
2060 # Collate list of users
2062 $userlinks = array () ;
2063 foreach ( $block AS $rcObj ) {
2064 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
2065 if ( $rcObj->mAttribs
['rc_new'] ) $isnew = true ;
2066 $u = $rcObj->userlink
;
2067 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
2071 # Sort the list and convert to text
2072 krsort ( $userlinks ) ;
2073 asort ( $userlinks ) ;
2075 foreach ( $userlinks as $userlink => $count) {
2077 if ( $count > 1 ) $text .= " ({$count}×)" ;
2078 array_push ( $users , $text ) ;
2080 $users = ' <font size="-1">['.implode('; ',$users).']</font>' ;
2083 $rci = 'RCI'.$this->rcCacheIndex
;
2084 $rcl = 'RCL'.$this->rcCacheIndex
;
2085 $rcm = 'RCM'.$this->rcCacheIndex
;
2086 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
2087 $arrowdir = $wgLang->isRTL() ?
'l' : 'r';
2088 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/images/Arr_'.$arrowdir.'.png" width="12" height="12" /></a></span>' ;
2089 $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/images/Arr_d.png" width="12" height="12" /></a></span>' ;
2095 if ( $isnew ) $r .= $N ;
2096 else $r .= ' ' ;
2097 $r .= ' ' ; # Minor
2100 $r .= ' '.$block[0]->timestamp
.' ' ;
2104 $link = $block[0]->link
;
2105 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
2108 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
2109 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
2111 $r .= ' ('.count($block).' ' ;
2112 if ( $isnew ) $r .= wfMsg('changes');
2113 else $r .= $this->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
2114 $curIdEq.'&diff=0&oldid='.$oldid ) ;
2118 $r .= $this->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
2126 $r .= '<div id="'.$rci.'" style="display:none">' ;
2127 foreach ( $block AS $rcObj ) {
2128 # Get rc_xxxx variables
2129 extract( $rcObj->mAttribs
);
2131 $r .= '<img src="'.$wgStylePath.'/images/Arr_.png" width="12" height="12" />';
2132 $r .= '<tt> ' ;
2133 if ( $rc_new ) $r .= $N ;
2134 else $r .= ' ' ;
2135 if ( $rc_minor ) $r .= $M ;
2136 else $r .= ' ' ;
2140 if ( $rc_last_oldid != 0 ) {
2141 $o = 'oldid='.$rc_last_oldid ;
2143 if ( $rc_type == RC_LOG
) {
2144 $link = $rcObj->timestamp
;
2146 $link = $this->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
2148 $link = '<tt>'.$link.'</tt>' ;
2152 $r .= $rcObj->curlink
;
2154 $r .= $rcObj->lastlink
;
2155 $r .= ') . . '.$rcObj->userlink
;
2156 $r .= $rcObj->usertalklink
;
2157 if ( $rc_comment != '' ) {
2158 $rc_comment=$this->formatComment($rc_comment);
2159 $r .= $wgLang->emphasize( ' ('.$rc_comment.')' ) ;
2165 $this->rcCacheIndex++
;
2169 # If enhanced RC is in use, this function takes the previously cached
2170 # RC lines, arranges them, and outputs the HTML
2171 function recentChangesBlock ()
2173 global $wgStylePath ;
2174 if ( count ( $this->rc_cache
) == 0 ) return '' ;
2176 foreach ( $this->rc_cache
AS $secureName => $block ) {
2177 if ( count ( $block ) < 2 ) {
2178 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
2180 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
2184 return '<div>'.$blockOut.'</div>' ;
2187 # Called in a loop over all displayed RC entries
2188 # Either returns the line, or caches it for later use
2189 function recentChangesLine( &$rc, $watched = false )
2192 $usenew = $wgUser->getOption( 'usenewrc' );
2194 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
2196 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
2200 function recentChangesLineOld( &$rc, $watched = false )
2202 global $wgTitle, $wgLang, $wgUser, $wgRCSeconds;
2204 # Extract DB fields into local scope
2205 extract( $rc->mAttribs
);
2206 $curIdEq = 'curid=' . $rc_cur_id;
2208 # Make date header if necessary
2209 $date = $wgLang->date( $rc_timestamp, true);
2211 if ( $date != $this->lastdate
) {
2212 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
2213 $s .= "<h4>{$date}</h4>\n<ul class='special'>";
2214 $this->lastdate
= $date;
2215 $this->rclistOpen
= true;
2219 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2221 $s .= '(' . wfMsg( 'diff' ) . ') (';
2223 $s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), wfMsg( 'hist' ), 'action=history' ) .
2226 # "[[x]] moved to [[y]]"
2227 if ( $rc_type == RC_MOVE
) {
2230 $msg = '1movedto2_redir';
2232 $s .= wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2233 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2236 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
2237 $diffLink = wfMsg( 'diff' );
2239 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'diff' ),
2240 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid ,'' ,'' , ' tabindex="'.$rc->counter
.'"');
2242 $s .= '('.$diffLink.') (';
2245 $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
2248 # M and N (minor and new)
2249 $M = wfMsg( 'minoreditletter' );
2250 $N = wfMsg( 'newpageletter' );
2251 if ( $rc_minor ) { $s .= ' <strong>'.$M.'</strong>'; }
2252 if ( $rc_type == RC_NEW
) { $s .= '<strong>'.$N.'</strong>'; }
2255 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '' );
2258 $articleLink = '<strong>'.$articleLink.'</strong>';
2260 $s .= ' '.$articleLink;
2265 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
2267 # User link (or contributions for unregistered users)
2268 if ( 0 == $rc_user ) {
2269 $userLink = $this->makeKnownLink( $wgLang->specialPage( 'Contributions' ),
2270 $rc_user_text, 'target=' . $rc_user_text );
2272 $userLink = $this->makeLink( $wgLang->getNsText( NS_USER
) . ':'.$rc_user_text, $rc_user_text );
2277 $talkname=$wgLang->getNsText(NS_TALK
); # use the shorter name
2278 global $wgDisableAnonTalk;
2279 if( 0 == $rc_user && $wgDisableAnonTalk ) {
2282 $utns=$wgLang->getNsText(NS_USER_TALK
);
2283 $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
2287 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2288 $blockLink = $this->makeKnownLink( $wgLang->specialPage(
2289 'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
2293 if($userTalkLink) $userTalkLink .= ' | ';
2294 $userTalkLink .= $blockLink;
2296 if($userTalkLink) $s.=' ('.$userTalkLink.')';
2299 if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2300 $rc_comment=$this->formatComment($rc_comment);
2301 $s .= $wgLang->emphasize(' (' . $rc_comment . ')');
2308 # function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 )
2309 function recentChangesLineNew( &$baseRC, $watched = false )
2311 global $wgTitle, $wgLang, $wgUser, $wgRCSeconds;
2313 # Create a specialised object
2314 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
2316 # Extract fields from DB into the function scope (rc_xxxx variables)
2317 extract( $rc->mAttribs
);
2318 $curIdEq = 'curid=' . $rc_cur_id;
2320 # If it's a new day, add the headline and flush the cache
2321 $date = $wgLang->date( $rc_timestamp, true);
2323 if ( $date != $this->lastdate
) {
2324 # Process current cache
2325 $ret = $this->recentChangesBlock () ;
2326 $this->rc_cache
= array() ;
2327 $ret .= "<h4>{$date}</h4>\n";
2328 $this->lastdate
= $date;
2332 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2333 if ( $rc_type == RC_MOVE
) {
2336 $msg = "1movedto2_redir";
2338 $clink = wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2339 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2341 $clink = $this->makeKnownLinkObj( $rc->getTitle(), '' ) ;
2344 $time = $wgLang->time( $rc_timestamp, true, $wgRCSeconds );
2345 $rc->watched
= $watched ;
2346 $rc->link
= $clink ;
2347 $rc->timestamp
= $time;
2349 # Make "cur" and "diff" links
2350 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2351 $curLink = wfMsg( 'cur' );
2352 $diffLink = wfMsg( 'diff' );
2354 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
2355 $aprops = ' tabindex="'.$baseRC->counter
.'"';
2356 $curLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'cur' ), $query, '' ,'' , $aprops );
2357 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'diff'), $query, '' ,'' , $aprops );
2361 $titleObj = $rc->getTitle();
2362 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2363 $lastLink = wfMsg( 'last' );
2365 $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'last' ),
2366 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid );
2369 # Make user link (or user contributions for unregistered users)
2370 if ( 0 == $rc_user ) {
2371 $userLink = $this->makeKnownLink( $wgLang->specialPage( 'Contributions' ),
2372 $rc_user_text, 'target=' . $rc_user_text );
2374 $userLink = $this->makeLink( $wgLang->getNsText(
2375 Namespace::getUser() ) . ':'.$rc_user_text, $rc_user_text );
2378 $rc->userlink
= $userLink ;
2379 $rc->lastlink
= $lastLink ;
2380 $rc->curlink
= $curLink ;
2381 $rc->difflink
= $diffLink;
2384 # Make user talk link
2385 $utns=$wgLang->getNsText(NS_USER_TALK
);
2386 $talkname=$wgLang->getNsText(NS_TALK
); # use the shorter name
2387 $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
2389 global $wgDisableAnonTalk;
2390 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2391 $blockLink = $this->makeKnownLink( $wgLang->specialPage(
2392 'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
2393 if( $wgDisableAnonTalk )
2394 $rc->usertalklink
= ' ('.$blockLink.')';
2396 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
2398 if( $wgDisableAnonTalk && ($rc_user == 0) )
2399 $rc->usertalklink
= '';
2401 $rc->usertalklink
= ' ('.$userTalkLink.')';
2404 # Put accumulated information into the cache, for later display
2405 # Page moves go on their own line
2406 $title = $rc->getTitle();
2407 $secureName = $title->getPrefixedDBkey();
2408 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2409 # Use an @ character to prevent collision with page names
2410 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
2412 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
2413 array_push ( $this->rc_cache
[$secureName] , $rc ) ;
2418 function endImageHistoryList()
2424 /* This function is called by all recent changes variants, by the page history,
2425 and by the user contributions list. It is responsible for formatting edit
2426 comments. It escapes any HTML in the comment, but adds some CSS to format
2427 auto-generated comments (from section editing) and formats [[wikilinks]].
2428 Main author: Erik Möller (moeller@scireview.de)
2430 function formatComment($comment)
2433 $comment=wfEscapeHTML($comment);
2435 # The pattern for autogen comments is / * foo * /, which makes for
2437 # We look for all comments, match any text before and after the comment,
2438 # add a separator where needed and format the comment itself with CSS
2439 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
2444 if($pre) { $auto = $sep.' '.$auto; }
2445 if($post) { $auto .= ' '.$sep; }
2446 $auto='<span class="autocomment">'.$auto.'</span>';
2447 $comment=$pre.$auto.$post;
2450 # format regular and media links - all other wiki formatting
2452 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\]/',$comment,$match)) {
2454 $medians = $wgLang->getNsText(Namespace::getMedia()).':';
2456 if(preg_match('/^'.$medians.'/i',$match[1])) {
2457 $func='makeMediaLink';
2459 # Handle link renaming [[foo|text]] will show link as "text"
2460 if(isset($match[3]) ) {
2462 preg_replace('/\[\[(.*?)\]\]/',
2463 $this->$func($match[1],$match[3]),$comment,1);
2466 preg_replace('/\[\[(.*?)\]\]/',
2467 $this->$func($match[1],$match[1]),$comment,1);
2475 function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description )
2477 global $wgUser, $wgLang, $wgTitle;
2479 $datetime = $wgLang->timeanddate( $timestamp, true );
2480 $del = wfMsg( 'deleteimg' );
2481 $cur = wfMsg( 'cur' );
2484 $url = Image
::wfImageUrl( $img );
2486 if ( $wgUser->isSysop() ) {
2487 $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
2489 $style = $this->getInternalLinkAttributes( $link, $del );
2491 $dlink = '<a href="'.$link.'"'.$style.'>'.$del.'</a>';
2496 $url = wfEscapeHTML( wfImageArchiveUrl( $img ) );
2497 if( $wgUser->getID() != 0 ) {
2498 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2499 wfMsg( 'revertimg' ), 'action=revert&oldimage=' .
2500 urlencode( $img ) );
2501 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2502 $del, 'action=delete&oldimage=' . urlencode( $img ) );
2504 # Having live active links for non-logged in users
2505 # means that bots and spiders crawling our site can
2506 # inadvertently change content. Baaaad idea.
2507 $rlink = wfMsg( 'revertimg' );
2512 $userlink = $usertext;
2514 $userlink = $this->makeLink( $wgLang->getNsText( Namespace::getUser() ) .
2515 ':'.$usertext, $usertext );
2517 $nbytes = wfMsg( 'nbytes', $size );
2518 $style = $this->getInternalLinkAttributes( $url, $datetime );
2520 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a>"
2521 . " . . {$userlink} ({$nbytes})";
2523 if ( '' != $description && '*' != $description ) {
2524 $sk=$wgUser->getSkin();
2525 $s .= $wgLang->emphasize(' (' . $sk->formatComment($description) . ')');
2531 function tocIndent($level) {
2532 return str_repeat( '<div class="tocindent">'."\n", $level>0 ?
$level : 0 );
2535 function tocUnindent($level) {
2536 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
2539 # parameter level defines if we are on an indentation level
2540 function tocLine( $anchor, $tocline, $level ) {
2541 $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
2545 return '<div class="tocline">'.$link."</div>\n";
2550 function tocTable($toc) {
2551 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2552 # try min-width & co when somebody gets a chance
2553 $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
2555 '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
2556 '<b>'.wfMsg('toc').'</b>' .
2558 '</td></tr><tr id="tocinside"><td>'."\n".
2559 $toc."</td></tr></table>\n";
2562 # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
2563 function editSectionScript( $section, $head ) {
2564 global $wgTitle, $wgRequest;
2565 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2568 $url = $wgTitle->escapeLocalURL( 'action=edit§ion='.$section );
2569 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2572 function editSectionLink( $section ) {
2574 global $wgTitle, $wgUser, $wgLang;
2576 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2577 # Section edit links would be out of sync on an old page.
2578 # But, if we're diffing to the current page, they'll be
2583 $editurl = '§ion='.$section;
2584 $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2586 if( $wgLang->isRTL() ) {
2588 $nearside = 'right';
2593 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2597 // This function is called by EditPage.php and shows a bulletin board style
2598 // toolbar for common editing functions. It can be disabled in the user preferences.
2599 // The necsesary JavaScript code can be found in style/wikibits.js.
2600 function getEditToolbar() {
2601 global $wgStylePath, $wgLang, $wgMimeType;
2603 // toolarray an array of arrays which each include the filename of
2604 // the button image (without path), the opening tag, the closing tag,
2605 // and optionally a sample text that is inserted between the two when no
2606 // selection is highlighted.
2607 // The tip text is shown when the user moves the mouse over the button.
2609 // Already here are accesskeys (key), which are not used yet until someone
2610 // can figure out a way to make them work in IE. However, we should make
2611 // sure these keys are not defined on the edit page.
2613 array( 'image'=>'button_bold.png',
2616 'sample'=>wfMsg('bold_sample'),
2617 'tip'=>wfMsg('bold_tip'),
2620 array( "image"=>"button_italic.png",
2623 "sample"=>wfMsg("italic_sample"),
2624 "tip"=>wfMsg("italic_tip"),
2627 array( "image"=>"button_link.png",
2630 "sample"=>wfMsg("link_sample"),
2631 "tip"=>wfMsg("link_tip"),
2634 array( "image"=>"button_extlink.png",
2637 "sample"=>wfMsg("extlink_sample"),
2638 "tip"=>wfMsg("extlink_tip"),
2641 array( "image"=>"button_headline.png",
2644 "sample"=>wfMsg("headline_sample"),
2645 "tip"=>wfMsg("headline_tip"),
2648 array( "image"=>"button_image.png",
2649 "open"=>"[[".$wgLang->getNsText(NS_IMAGE
).":",
2651 "sample"=>wfMsg("image_sample"),
2652 "tip"=>wfMsg("image_tip"),
2655 array( "image"=>"button_media.png",
2656 "open"=>"[[".$wgLang->getNsText(NS_MEDIA
).":",
2658 "sample"=>wfMsg("media_sample"),
2659 "tip"=>wfMsg("media_tip"),
2662 array( "image"=>"button_math.png",
2663 "open"=>"\\<math\\>",
2664 "close"=>"\\</math\\>",
2665 "sample"=>wfMsg("math_sample"),
2666 "tip"=>wfMsg("math_tip"),
2669 array( "image"=>"button_nowiki.png",
2670 "open"=>"\\<nowiki\\>",
2671 "close"=>"\\</nowiki\\>",
2672 "sample"=>wfMsg("nowiki_sample"),
2673 "tip"=>wfMsg("nowiki_tip"),
2676 array( "image"=>"button_sig.png",
2680 "tip"=>wfMsg("sig_tip"),
2683 array( "image"=>"button_hr.png",
2684 "open"=>"\\n----\\n",
2687 "tip"=>wfMsg("hr_tip"),
2691 $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
2693 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
2694 foreach($toolarray as $tool) {
2696 $image=$wgStylePath.'/images/'.$tool['image'];
2697 $open=$tool['open'];
2698 $close=$tool['close'];
2699 $sample = addslashes( $tool['sample'] );
2701 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
2702 // Older browsers show a "speedtip" type message only for ALT.
2703 // Ideally these should be different, realistically they
2704 // probably don't need to be.
2705 $tip = addslashes( $tool['tip'] );
2707 #$key = $tool["key"];
2709 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
2712 $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
2713 $toolbar.="document.writeln(\"</div>\");\n";
2715 $toolbar.="/*]]>*/\n</script>";