10 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
12 if( defined( "MEDIAWIKI" ) ) {
15 require_once( 'Linker.php' );
16 require_once( 'Image.php' );
18 # Get a list of all skins available in /skins/
19 # Build using the regular expression '^(.*).php$'
20 # Array keys are all lower case, array value keep the case used by filename
23 $skinDir = dir($IP.'/skins');
25 # while code from www.php.net
26 while (false !== ($file = $skinDir->read())) {
27 if(preg_match('/^([^.].*)\.php$/',$file, $matches)) {
29 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
35 require_once( 'RecentChange.php' );
41 class RCCacheEntry
extends RecentChange
43 var $secureName, $link;
44 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
45 var $userlink, $timestamp, $watched;
47 function newFromParent( $rc )
49 $rc2 = new RCCacheEntry
;
50 $rc2->mAttribs
= $rc->mAttribs
;
51 $rc2->mExtra
= $rc->mExtra
;
58 * The main skin class that provide methods and properties for all other skins
59 * including PHPTal skins.
60 * This base class is also the "Standard" skin.
63 class Skin
extends Linker
{
67 var $lastdate, $lastline;
68 var $rc_cache ; # Cache for Enhanced Recent Changes
69 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
73 /** Constructor, call parent constructor */
74 function Skin() { parent
::Linker(); }
76 function getSkinNames() {
77 global $wgValidSkinNames;
78 return $wgValidSkinNames;
81 /** @return string path to the skin stylesheet */
82 function getStylesheet() { return 'common/wikistandard.css'; }
84 /** @return string skin name */
85 function getSkinName() {
89 function qbSetting() {
90 global $wgOut, $wgUser;
92 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
93 $q = $wgUser->getOption( 'quickbar' );
94 if ( '' == $q ) { $q = 0; }
98 function initPage( &$out ) {
99 $fname = 'Skin::initPage';
100 wfProfileIn( $fname );
102 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
104 $this->addMetadataLinks($out);
106 wfProfileOut( $fname );
109 function addMetadataLinks( &$out ) {
110 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
111 global $wgRightsPage, $wgRightsUrl, $wgUseTrackbacks;
113 if( $out->isArticleRelated() ) {
114 # note: buggy CC software only reads first "meta" link
115 if( $wgEnableCreativeCommonsRdf ) {
116 $out->addMetadataLink( array(
117 'title' => 'Creative Commons',
118 'type' => 'application/rdf+xml',
119 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
121 if( $wgEnableDublinCoreRdf ) {
122 $out->addMetadataLink( array(
123 'title' => 'Dublin Core',
124 'type' => 'application/rdf+xml',
125 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
129 if( $wgRightsPage ) {
130 $copy = Title
::newFromText( $wgRightsPage );
132 $copyright = $copy->getLocalURL();
135 if( !$copyright && $wgRightsUrl ) {
136 $copyright = $wgRightsUrl;
139 $out->addLink( array(
140 'rel' => 'copyright',
141 'href' => $copyright ) );
145 function outputPage( &$out ) {
146 global $wgDebugComments;
148 wfProfileIn( 'Skin::outputPage' );
149 $this->initPage( $out );
151 $out->out( $out->headElement() );
153 $out->out( "\n<body" );
154 $ops = $this->getBodyOptions();
155 foreach ( $ops as $name => $val ) {
156 $out->out( " $name='$val'" );
159 if ( $wgDebugComments ) {
160 $out->out( "<!-- Wiki debugging output:\n" .
161 $out->mDebugtext
. "-->\n" );
164 $out->out( $this->beforeContent() );
166 $out->out( $out->mBodytext
. "\n" );
168 $out->out( $this->afterContent() );
171 $out->out( $out->reportTime() );
173 $out->out( "\n</body></html>" );
176 function getHeadScripts() {
177 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs, $wgJsMimeType;
178 $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
179 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
180 $userpage = $wgUser->getUserPage();
181 $userjs = htmlspecialchars( $this->makeUrl(
182 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
183 'action=raw&ctype='.$wgJsMimeType));
184 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
190 * To make it harder for someone to slip a user a fake
191 * user-JavaScript or user-CSS preview, a random token
192 * is associated with the login session. If it's not
193 * passed back with the preview request, we won't render
196 * @param string $action
200 function userCanPreview( $action ) {
201 global $wgTitle, $wgRequest, $wgUser;
203 if( $action != 'submit' )
205 if( !$wgRequest->wasPosted() )
207 if( !$wgTitle->userCanEditCssJsSubpage() )
209 return $wgUser->matchEditToken(
210 $wgRequest->getVal( 'wpEditToken' ) );
213 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
214 function getUserStylesheet() {
215 global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
216 $sheet = $this->getStylesheet();
217 $action = $wgRequest->getText('action');
218 $s = "@import \"$wgStylePath/$sheet\";\n";
219 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
220 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
221 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
222 $s .= $wgRequest->getText('wpTextbox1');
224 $userpage = $wgUser->getUserPage();
225 $s.= '@import "'.$this->makeUrl(
226 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
227 'action=raw&ctype=text/css').'";'."\n";
230 $s .= $this->doGetUserStyles();
235 * placeholder, returns generated js in monobook
237 function getUserJs() { return; }
240 * Return html code that include User stylesheets
242 function getUserStyles() {
243 global $wgOut, $wgStylePath, $wgLang;
244 $s = "<style type='text/css'>\n";
245 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
246 $s .= $this->getUserStylesheet();
247 $s .= "/*]]>*/ /* */\n";
253 * Some styles that are set by user through the user settings interface.
255 function doGetUserStyles() {
256 global $wgUser, $wgContLang;
258 $csspage = $wgContLang->getNsText( NS_MEDIAWIKI
) . ':' . $this->getSkinName() . '.css';
259 $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n";
261 return $s . $this->reallyDoGetUserStyles();
264 function reallyDoGetUserStyles() {
267 if (($undopt = $wgUser->getOption("underline")) != 2) {
268 $underline = $undopt ?
'underline' : 'none';
269 $s .= "a { text-decoration: $underline; }\n";
271 if( $wgUser->getOption( 'highlightbroken' ) ) {
272 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
275 a.new, #quickbar a.new,
276 a.stub, #quickbar a.stub {
278 text-decoration: inherit;
280 a.new:after, #quickbar a.new:after {
283 text-decoration: $underline;
285 a.stub:after, #quickbar a.stub:after {
288 text-decoration: $underline;
292 if( $wgUser->getOption( 'justify' ) ) {
293 $s .= "#article, #bodyContent { text-align: justify; }\n";
295 if( !$wgUser->getOption( 'showtoc' ) ) {
296 $s .= "#toc { display: none; }\n";
298 if( !$wgUser->getOption( 'editsection' ) ) {
299 $s .= ".editsection { display: none; }\n";
304 function getBodyOptions() {
305 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
307 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
309 if ( 0 != $wgTitle->getNamespace() ) {
310 $a = array( 'bgcolor' => '#ffffec' );
312 else $a = array( 'bgcolor' => '#FFFFFF' );
313 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
314 (!$wgTitle->isProtected() ||
$wgUser->isAllowed('protect')) ) {
315 $t = wfMsg( 'editthispage' );
317 if ( !empty($redirect) && $redirect == 'no' ) {
318 $red = "&redirect={$redirect}";
320 if ( !empty($oldid) && ! isset( $diff ) ) {
321 $oid = "&oldid=" . IntVal( $oldid );
323 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
324 $s = 'document.location = "' .$s .'";';
325 $a +
= array ('ondblclick' => $s);
328 $a['onload'] = $wgOut->getOnloadHandler();
329 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
330 if( $a['onload'] != '' ) {
333 $a['onload'] .= 'setupRightClickEdit()';
347 * This will be called immediately after the <body> tag. Split into
348 * two functions to make it easier to subclass.
350 function beforeContent() {
351 return $this->doBeforeContent();
354 function doBeforeContent() {
355 global $wgOut, $wgTitle, $wgContLang;
356 $fname = 'Skin::doBeforeContent';
357 wfProfileIn( $fname );
360 $qb = $this->qbSetting();
362 if( $langlinks = $this->otherLanguages() ) {
368 $borderhack = 'class="top"';
371 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
372 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
375 $left = ($qb == 1 ||
$qb == 3);
376 if($wgContLang->isRTL()) $left = !$left;
379 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
380 $this->logoText() . '</td>';
382 $s .= $this->getQuickbarCompensator( $rows );
384 $l = $wgContLang->isRTL() ?
'right' : 'left';
385 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
387 $s .= $this->topLinks() ;
388 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
390 $r = $wgContLang->isRTL() ?
"left" : "right";
391 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
392 $s .= $this->nameAndLogin();
393 $s .= "\n<br />" . $this->searchForm() . "</td>";
396 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
399 if ( $shove && !$left ) { # Right
400 $s .= $this->getQuickbarCompensator( $rows );
402 $s .= "</tr>\n</table>\n</div>\n";
403 $s .= "\n<div id='article'>\n";
405 $notice = wfGetSiteNotice();
407 $s .= "\n<div id='siteNotice'>$notice</div>\n";
409 $s .= $this->pageTitle();
410 $s .= $this->pageSubtitle() ;
411 $s .= $this->getCategories();
412 wfProfileOut( $fname );
417 function getCategoryLinks () {
418 global $wgOut, $wgTitle, $wgParser;
419 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
421 if( !$wgUseCategoryMagic ) return '' ;
422 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
424 # Taken out so that they will be displayed in previews -- TS
425 #if( !$wgOut->isArticle() ) return '';
427 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
428 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
429 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
432 # optional 'dmoz-like' category browser. Will be shown under the list
433 # of categories an article belong to
434 if($wgUseCategoryBrowser) {
435 $s .= '<br /><hr />';
437 # get a big array of the parents tree
438 $parenttree = $wgTitle->getParentCategoryTree();
440 # Skin object passed by reference cause it can not be
441 # accessed under the method subfunction walkThrough.
442 $s .= Skin
::drawCategoryBrowser($parenttree, $this);
448 # Render the array as a serie of links
449 function drawCategoryBrowser ($tree, &$skin) {
451 foreach ($tree as $element => $parent) {
452 if (empty($parent)) {
453 # element start a new list
456 # grab the others elements
457 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
459 # add our current element to the list
460 $eltitle = Title
::NewFromText($element);
461 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
466 function getCategories() {
467 $catlinks=$this->getCategoryLinks();
468 if(!empty($catlinks)) {
469 return "<p class='catlinks'>{$catlinks}</p>";
473 function getQuickbarCompensator( $rows = 1 ) {
474 return "<td width='152' rowspan='{$rows}'> </td>";
478 * This gets called immediately before the </body> tag.
479 * @return string HTML to be put after </body> ???
481 function afterContent() {
482 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
483 return $printfooter . $this->doAfterContent();
486 /** @return string Retrievied from HTML text */
487 function printSource() {
489 $url = htmlspecialchars( $wgTitle->getFullURL() );
490 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
493 function printFooter() {
494 return "<p>" . $this->printSource() .
495 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
498 /** overloaded by derived classes */
499 function doAfterContent() { }
501 function pageTitleLinks() {
502 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
504 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
505 $action = $wgRequest->getText( 'action' );
507 $s = $this->printableLink();
508 $disclaimer = $this->disclaimerLink(); # may be empty
510 $s .= ' | ' . $disclaimer;
513 if ( $wgOut->isArticleRelated() ) {
514 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
515 $name = $wgTitle->getDBkey();
516 $image = new Image( $wgTitle );
517 if( $image->exists() ) {
518 $link = htmlspecialchars( $image->getURL() );
519 $style = $this->getInternalLinkAttributes( $link, $name );
520 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
524 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
525 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
526 wfMsg( 'currentrev' ) );
529 if ( $wgUser->getNewtalk() ) {
530 # do not show "You have new messages" text when we are viewing our
533 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
534 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
535 wfMsg('newmessageslink') );
536 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
538 $wgOut->setSquidMaxage(0);
539 $wgOut->enableClientCache(false);
543 $undelete = $this->getUndeleteLink();
544 if( !empty( $undelete ) ) {
545 $s .= ' | '.$undelete;
550 function getUndeleteLink() {
551 global $wgUser, $wgTitle, $wgContLang, $action;
552 if( (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
553 ($n = $wgTitle->isDeleted() ) )
555 if ( $wgUser->isAllowed( 'delete' ) ) {
556 $msg = 'thisisdeleted';
558 $msg = 'viewdeleted';
561 $this->makeKnownLink(
562 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
563 wfMsg( 'restorelink' . ($n == 1 ?
'1' : ''), $n ) ) );
568 function printableLink() {
569 global $wgOut, $wgFeedClasses, $wgRequest;
571 $baseurl = $_SERVER['REQUEST_URI'];
572 if( strpos( '?', $baseurl ) == false ) {
577 $baseurl = htmlspecialchars( $baseurl );
578 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
580 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
581 if( $wgOut->isSyndicated() ) {
582 foreach( $wgFeedClasses as $format => $class ) {
583 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
584 $s .= " | <a href=\"$feedurl\">{$format}</a>";
590 function pageTitle() {
591 global $wgOut, $wgTitle, $wgUser;
593 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
597 function pageSubtitle() {
600 $sub = $wgOut->getSubtitle();
602 global $wgExtraSubtitle;
603 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
605 $subpages = $this->subPageSubtitle();
606 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
607 $s = "<p class='subtitle'>{$sub}</p>\n";
611 function subPageSubtitle() {
612 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
614 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
615 $ptext=$wgTitle->getPrefixedText();
616 if(preg_match('/\//',$ptext)) {
617 $links = explode('/',$ptext);
620 foreach($links as $link) {
622 if ($c<count($links)) {
623 $growinglink .= $link;
624 $getlink = $this->makeLink( $growinglink, $link );
625 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
629 $subpages .= '< ';
631 $subpages .= $getlink;
640 function nameAndLogin() {
641 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
643 $li = $wgContLang->specialPage( 'Userlogin' );
644 $lo = $wgContLang->specialPage( 'Userlogout' );
647 if ( $wgUser->isAnon() ) {
648 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
651 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
652 $wgLang->getNsText( NS_TALK
) );
654 $s .= $n . ' ('.$tl.')';
656 $s .= wfMsg('notloggedin');
659 $rt = $wgTitle->getPrefixedURL();
660 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
662 } else { $q = "returnto={$rt}"; }
664 $s .= "\n<br />" . $this->makeKnownLinkObj(
665 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
666 wfMsg( 'login' ), $q );
668 $n = $wgUser->getName();
669 $rt = $wgTitle->getPrefixedURL();
670 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
671 $wgLang->getNsText( NS_TALK
) );
675 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
676 $n ) . "{$tl}<br />" .
677 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
678 "returnto={$rt}" ) . ' | ' .
679 $this->specialLink( 'preferences' );
681 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
687 function getSearchLink() {
688 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
689 return $searchPage->getLocalURL();
692 function escapeSearchLink() {
693 return htmlspecialchars( $this->getSearchLink() );
696 function searchForm() {
698 $search = $wgRequest->getText( 'search' );
700 $s = '<form name="search" class="inline" method="post" action="'
701 . $this->escapeSearchLink() . "\">\n"
702 . '<input type="text" name="search" size="19" value="'
703 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
704 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
705 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
710 function topLinks() {
714 $s = $this->mainPageLink() . $sep
715 . $this->specialLink( 'recentchanges' );
717 if ( $wgOut->isArticleRelated() ) {
718 $s .= $sep . $this->editThisPage()
719 . $sep . $this->historyLink();
721 # Many people don't like this dropdown box
722 #$s .= $sep . $this->specialPagesList();
724 /* show links to different language variants */
725 global $wgDisableLangConversion, $wgContLang, $wgTitle;
726 $variants = $wgContLang->getVariants();
727 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
728 foreach( $variants as $code ) {
729 $varname = $wgContLang->getVariantname( $code );
730 if( $varname == 'disable' )
732 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
739 function bottomLinks() {
740 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
744 if ( $wgOut->isArticleRelated() ) {
745 $s .= '<strong>' . $this->editThisPage() . '</strong>';
746 if ( $wgUser->isLoggedIn() ) {
747 $s .= $sep . $this->watchThisPage();
749 $s .= $sep . $this->talkLink()
750 . $sep . $this->historyLink()
751 . $sep . $this->whatLinksHere()
752 . $sep . $this->watchPageLinksLink();
754 if ($wgUseTrackbacks)
755 $s .= $sep . $this->trackbackLink();
757 if ( $wgTitle->getNamespace() == NS_USER
758 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
761 $id=User
::idFromName($wgTitle->getText());
762 $ip=User
::isIP($wgTitle->getText());
764 if($id ||
$ip) { # both anons and non-anons have contri list
765 $s .= $sep . $this->userContribsLink();
767 if( $this->showEmailUser( $id ) ) {
768 $s .= $sep . $this->emailUserLink();
771 if ( $wgTitle->getArticleId() ) {
773 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
774 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
775 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
777 $s .= "<br />\n" . $this->otherLanguages();
782 function pageStats() {
783 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
784 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
786 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
787 if ( ! $wgOut->isArticle() ) { return ''; }
788 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
789 if ( 0 == $wgArticle->getID() ) { return ''; }
792 if ( !$wgDisableCounters ) {
793 $count = $wgLang->formatNum( $wgArticle->getCount() );
795 $s = wfMsg( 'viewcount', $count );
799 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
800 require_once('Credits.php');
801 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
803 $s .= $this->lastModified();
806 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
807 $dbr =& wfGetDB( DB_SLAVE
);
808 extract( $dbr->tableNames( 'watchlist' ) );
809 $sql = "SELECT COUNT(*) AS n FROM $watchlist
810 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
811 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
812 $res = $dbr->query( $sql, 'Skin::pageStats');
813 $x = $dbr->fetchObject( $res );
814 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
817 return $s . ' ' . $this->getCopyright();
820 function getCopyright() {
821 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
824 $oldid = $wgRequest->getVal( 'oldid' );
825 $diff = $wgRequest->getVal( 'diff' );
827 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
828 $msg = 'history_copyright';
834 if( $wgRightsPage ) {
835 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
836 } elseif( $wgRightsUrl ) {
837 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
842 $out .= wfMsgForContent( $msg, $link );
846 function getCopyrightIcon() {
847 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
849 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
850 $out = $wgCopyrightIcon;
851 } else if ( $wgRightsIcon ) {
852 $icon = htmlspecialchars( $wgRightsIcon );
853 if ( $wgRightsUrl ) {
854 $url = htmlspecialchars( $wgRightsUrl );
855 $out .= '<a href="'.$url.'">';
857 $text = htmlspecialchars( $wgRightsText );
858 $out .= "<img src=\"$icon\" alt='$text' />";
859 if ( $wgRightsUrl ) {
866 function getPoweredBy() {
868 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
869 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
873 function lastModified() {
874 global $wgLang, $wgArticle, $wgLoadBalancer;
876 $timestamp = $wgArticle->getTimestamp();
878 $d = $wgLang->timeanddate( $timestamp, true );
879 $s = ' ' . wfMsg( 'lastmodified', $d );
883 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
884 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
889 function logoText( $align = '' ) {
890 if ( '' != $align ) { $a = " align='{$align}'"; }
893 $mp = wfMsg( 'mainpage' );
894 $titleObj = Title
::newFromText( $mp );
895 if ( is_object( $titleObj ) ) {
896 $url = $titleObj->escapeLocalURL();
901 $logourl = $this->getLogo();
902 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
907 * show a drop-down box of special pages
908 * @TODO crash bug913. Need to be rewrote completly.
910 function specialPagesList() {
911 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
912 require_once('SpecialPage.php');
914 $pages = SpecialPage
::getPages();
916 // special pages without access restriction
917 foreach ( $pages[''] as $name => $page ) {
918 $a[$name] = $page->getDescription();
921 // Other special pages that are restricted.
922 // Copied from SpecialSpecialpages.php
923 foreach($wgAvailableRights as $right) {
924 if( $wgUser->isAllowed($right) ) {
925 /** Add all pages for this right */
926 if(isset($pages[$right])) {
927 foreach($pages[$right] as $name => $page) {
928 $a[$name] = $page->getDescription();
935 $sp = wfMsg( 'specialpages' );
936 $spp = $wgContLang->specialPage( 'Specialpages' );
938 $s = '<form id="specialpages" method="get" class="inline" ' .
939 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
940 $s .= "<select name=\"wpDropdown\">\n";
941 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
944 foreach ( $a as $name => $desc ) {
945 $p = $wgContLang->specialPage( $name );
946 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
949 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
954 function mainPageLink() {
955 $mp = wfMsgForContent( 'mainpage' );
956 $mptxt = wfMsg( 'mainpage');
957 $s = $this->makeKnownLink( $mp, $mptxt );
961 function copyrightLink() {
962 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
963 wfMsg( 'copyrightpagename' ) );
967 function aboutLink() {
968 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
969 wfMsg( 'aboutsite' ) );
974 function disclaimerLink() {
975 $disclaimers = wfMsg( 'disclaimers' );
976 if ($disclaimers == '-') {
979 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
984 function editThisPage() {
985 global $wgOut, $wgTitle, $wgRequest;
987 $oldid = $wgRequest->getVal( 'oldid' );
988 $diff = $wgRequest->getVal( 'diff' );
989 $redirect = $wgRequest->getVal( 'redirect' );
991 if ( ! $wgOut->isArticleRelated() ) {
992 $s = wfMsg( 'protectedpage' );
994 if ( $wgTitle->userCanEdit() ) {
995 $t = wfMsg( 'editthispage' );
997 $t = wfMsg( 'viewsource' );
1001 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1002 if ( $oldid && ! isset( $diff ) ) {
1003 $oid = '&oldid='.$oldid;
1005 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1010 function deleteThisPage() {
1011 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1013 $diff = $wgRequest->getVal( 'diff' );
1014 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1015 $t = wfMsg( 'deletethispage' );
1017 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1024 function protectThisPage() {
1025 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1027 $diff = $wgRequest->getVal( 'diff' );
1028 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1029 if ( $wgTitle->isProtected() ) {
1030 $t = wfMsg( 'unprotectthispage' );
1031 $q = 'action=unprotect';
1033 $t = wfMsg( 'protectthispage' );
1034 $q = 'action=protect';
1036 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1043 function watchThisPage() {
1044 global $wgUser, $wgOut, $wgTitle;
1046 if ( $wgOut->isArticleRelated() ) {
1047 if ( $wgTitle->userIsWatching() ) {
1048 $t = wfMsg( 'unwatchthispage' );
1049 $q = 'action=unwatch';
1051 $t = wfMsg( 'watchthispage' );
1052 $q = 'action=watch';
1054 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1056 $s = wfMsg( 'notanarticle' );
1061 function moveThisPage() {
1064 if ( $wgTitle->userCanMove() ) {
1065 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1066 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1068 // no message if page is protected - would be redundant
1073 function historyLink() {
1076 return $this->makeKnownLinkObj( $wgTitle,
1077 wfMsg( 'history' ), 'action=history' );
1080 function whatLinksHere() {
1083 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1084 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1087 function userContribsLink() {
1090 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1091 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1094 function showEmailUser( $id ) {
1095 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1096 return $wgEnableEmail &&
1097 $wgEnableUserEmail &&
1098 $wgUser->isLoggedIn() && # show only to signed in users
1099 0 != $id; # we can only email to non-anons ..
1100 # '' != $id->getEmail() && # who must have an email address stored ..
1101 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1102 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1105 function emailUserLink() {
1108 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1109 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1112 function watchPageLinksLink() {
1113 global $wgOut, $wgTitle;
1115 if ( ! $wgOut->isArticleRelated() ) {
1116 return '(' . wfMsg( 'notanarticle' ) . ')';
1118 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1119 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1120 'target=' . $wgTitle->getPrefixedURL() );
1124 function trackbackLink() {
1127 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1128 . wfMsg('trackbacklink') . "</a>";
1131 function otherLanguages() {
1132 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1134 if ( $wgHideInterlanguageLinks ) {
1138 $a = $wgOut->getLanguageLinks();
1139 if ( 0 == count( $a ) ) {
1143 $s = wfMsg( 'otherlanguages' ) . ': ';
1145 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1146 foreach( $a as $l ) {
1147 if ( ! $first ) { $s .= ' | '; }
1150 $nt = Title
::newFromText( $l );
1151 $url = $nt->escapeFullURL();
1152 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1154 if ( '' == $text ) { $text = $l; }
1155 $style = $this->getExternalLinkAttributes( $l, $text );
1156 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1158 if($wgContLang->isRTL()) $s .= '</span>';
1162 function bugReportsLink() {
1163 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1164 wfMsg( 'bugreports' ) );
1168 function dateLink() {
1169 global $wgLinkCache;
1170 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1171 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1173 $wgLinkCache->suspend();
1174 $id = $t1->getArticleID();
1175 $wgLinkCache->resume();
1178 $s = $this->makeBrokenLink( $t1->getText() );
1180 $s = $this->makeKnownLink( $t1->getText() );
1184 $wgLinkCache->suspend();
1185 $id = $t2->getArticleID();
1186 $wgLinkCache->resume();
1189 $s .= $this->makeBrokenLink( $t2->getText() );
1191 $s .= $this->makeKnownLink( $t2->getText() );
1196 function talkLink() {
1197 global $wgTitle, $wgLinkCache;
1199 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1200 # No discussion links for special pages
1204 if( $wgTitle->isTalkPage() ) {
1205 $link = $wgTitle->getSubjectPage();
1206 switch( $link->getNamespace() ) {
1208 $text = wfMsg('articlepage');
1211 $text = wfMsg('userpage');
1214 $text = wfMsg('wikipediapage');
1217 $text = wfMsg('imagepage');
1220 $text= wfMsg('articlepage');
1223 $link = $wgTitle->getTalkPage();
1224 $text = wfMsg( 'talkpage' );
1227 $wgLinkCache->suspend();
1228 $s = $this->makeLinkObj( $link, $text );
1229 $wgLinkCache->resume();
1234 function commentLink() {
1235 global $wgContLang, $wgTitle, $wgLinkCache;
1237 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1240 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1241 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1244 /* these are used extensively in SkinPHPTal, but also some other places */
1245 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1246 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1247 return $title->getLocalURL( $urlaction );
1250 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1251 $title = Title
::newFromText( wfMsgForContent($name) );
1252 $this->checkTitle($title, $name);
1253 return $title->getLocalURL( $urlaction );
1256 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1257 $title = Title
::newFromText( $name );
1258 $this->checkTitle($title, $name);
1259 return $title->getLocalURL( $urlaction );
1262 # If url string starts with http, consider as external URL, else
1264 /*static*/ function makeInternalOrExternalUrl( $name ) {
1265 global $wgUrlProtocols;
1266 if ( preg_match( '/^(?:' . $wgUrlProtocols . ')/', $name ) ) {
1269 return $this->makeUrl( $name );
1273 # this can be passed the NS number as defined in Language.php
1274 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1275 $title = Title
::makeTitleSafe( $namespace, $name );
1276 $this->checkTitle($title, $name);
1277 return $title->getLocalURL( $urlaction );
1280 /* these return an array with the 'href' and boolean 'exists' */
1281 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1282 $title = Title
::newFromText( $name );
1283 $this->checkTitle($title, $name);
1285 'href' => $title->getLocalURL( $urlaction ),
1286 'exists' => $title->getArticleID() != 0?
true:false
1290 # make sure we have some title to operate on
1291 /*static*/ function checkTitle ( &$title, &$name ) {
1292 if(!is_object($title)) {
1293 $title = Title
::newFromText( $name );
1294 if(!is_object($title)) {
1295 $title = Title
::newFromText( '--error: link target missing--' );
1301 * Build an array that represents the sidebar(s), the navigation bar among them
1306 function buildSidebar() {
1307 $fname = 'SkinTemplate::buildSidebar';
1308 wfProfileIn( $fname );
1311 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1312 foreach ($lines as $line) {
1313 if (strpos($line, '*') !== 0)
1315 if (strpos($line, '**') !== 0) {
1316 $line = trim($line, '* ');
1319 if (strpos($line, '|') !== false) { // sanity check
1320 $line = explode( '|' , trim($line, '* '), 2 );
1321 $link = wfMsgForContent( $line[0] );
1324 if (wfNoMsg($line[1], $text = wfMsg($line[1])))
1326 if (wfNoMsg($line[0], $link))
1328 $bar[$heading][] = array(
1330 'href' => $this->makeInternalOrExternalUrl( $link ),
1331 'id' => 'n-' . strtr($line[1], ' ', '-'),
1333 } else { continue; }
1337 wfProfileOut( $fname );