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;
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 $r.= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/sorttable.js\"></script>\n";
180 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
181 $userpage = $wgUser->getUserPage();
182 $userjs = htmlspecialchars( $this->makeUrl(
183 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
184 'action=raw&ctype='.$wgJsMimeType));
185 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
191 * To make it harder for someone to slip a user a fake
192 * user-JavaScript or user-CSS preview, a random token
193 * is associated with the login session. If it's not
194 * passed back with the preview request, we won't render
197 * @param string $action
201 function userCanPreview( $action ) {
202 global $wgTitle, $wgRequest, $wgUser;
204 if( $action != 'submit' )
206 if( !$wgRequest->wasPosted() )
208 if( !$wgTitle->userCanEditCssJsSubpage() )
210 return $wgUser->matchEditToken(
211 $wgRequest->getVal( 'wpEditToken' ) );
214 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
215 function getUserStylesheet() {
216 global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
217 $sheet = $this->getStylesheet();
218 $action = $wgRequest->getText('action');
219 $s = "@import \"$wgStylePath/$sheet\";\n";
220 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
221 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
222 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
223 $s .= $wgRequest->getText('wpTextbox1');
225 $userpage = $wgUser->getUserPage();
226 $s.= '@import "'.$this->makeUrl(
227 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
228 'action=raw&ctype=text/css').'";'."\n";
231 $s .= $this->doGetUserStyles();
236 * placeholder, returns generated js in monobook
238 function getUserJs() { return; }
241 * Return html code that include User stylesheets
243 function getUserStyles() {
244 global $wgOut, $wgStylePath, $wgLang;
245 $s = "<style type='text/css'>\n";
246 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
247 $s .= $this->getUserStylesheet();
248 $s .= "/*]]>*/ /* */\n";
254 * Some styles that are set by user through the user settings interface.
256 function doGetUserStyles() {
257 global $wgUser, $wgContLang;
259 $csspage = $wgContLang->getNsText( NS_MEDIAWIKI
) . ':' . $this->getSkinName() . '.css';
260 $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n";
262 return $s . $this->reallyDoGetUserStyles();
265 function reallyDoGetUserStyles() {
268 if (($undopt = $wgUser->getOption("underline")) != 2) {
269 $underline = $undopt ?
'underline' : 'none';
270 $s .= "a { text-decoration: $underline; }\n";
272 if( $wgUser->getOption( 'highlightbroken' ) ) {
273 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
276 a.new, #quickbar a.new,
277 a.stub, #quickbar a.stub {
279 text-decoration: inherit;
281 a.new:after, #quickbar a.new:after {
284 text-decoration: $underline;
286 a.stub:after, #quickbar a.stub:after {
289 text-decoration: $underline;
293 if( $wgUser->getOption( 'justify' ) ) {
294 $s .= "#article, #bodyContent { text-align: justify; }\n";
296 if( !$wgUser->getOption( 'showtoc' ) ) {
297 $s .= "#toc { display: none; }\n";
299 if( !$wgUser->getOption( 'editsection' ) ) {
300 $s .= ".editsection { display: none; }\n";
305 function getBodyOptions() {
306 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
308 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
310 if ( 0 != $wgTitle->getNamespace() ) {
311 $a = array( 'bgcolor' => '#ffffec' );
313 else $a = array( 'bgcolor' => '#FFFFFF' );
314 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
315 (!$wgTitle->isProtected() ||
$wgUser->isAllowed('protect')) ) {
316 $t = wfMsg( 'editthispage' );
318 if ( !empty($redirect) && $redirect == 'no' ) {
319 $red = "&redirect={$redirect}";
321 if ( !empty($oldid) && ! isset( $diff ) ) {
322 $oid = "&oldid=" . IntVal( $oldid );
324 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
325 $s = 'document.location = "' .$s .'";';
326 $a +
= array ('ondblclick' => $s);
329 $a['onload'] = $wgOut->getOnloadHandler();
330 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
331 if( $a['onload'] != '' ) {
334 $a['onload'] .= 'setupRightClickEdit()';
348 * This will be called immediately after the <body> tag. Split into
349 * two functions to make it easier to subclass.
351 function beforeContent() {
352 return $this->doBeforeContent();
355 function doBeforeContent() {
356 global $wgOut, $wgTitle, $wgContLang;
357 $fname = 'Skin::doBeforeContent';
358 wfProfileIn( $fname );
361 $qb = $this->qbSetting();
363 if( $langlinks = $this->otherLanguages() ) {
369 $borderhack = 'class="top"';
372 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
373 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
376 $left = ($qb == 1 ||
$qb == 3);
377 if($wgContLang->isRTL()) $left = !$left;
380 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
381 $this->logoText() . '</td>';
383 $s .= $this->getQuickbarCompensator( $rows );
385 $l = $wgContLang->isRTL() ?
'right' : 'left';
386 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
388 $s .= $this->topLinks() ;
389 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
391 $r = $wgContLang->isRTL() ?
"left" : "right";
392 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
393 $s .= $this->nameAndLogin();
394 $s .= "\n<br />" . $this->searchForm() . "</td>";
397 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
400 if ( $shove && !$left ) { # Right
401 $s .= $this->getQuickbarCompensator( $rows );
403 $s .= "</tr>\n</table>\n</div>\n";
404 $s .= "\n<div id='article'>\n";
406 $notice = wfGetSiteNotice();
408 $s .= "\n<div id='siteNotice'>$notice</div>\n";
410 $s .= $this->pageTitle();
411 $s .= $this->pageSubtitle() ;
412 $s .= $this->getCategories();
413 wfProfileOut( $fname );
418 function getCategoryLinks () {
419 global $wgOut, $wgTitle, $wgParser;
420 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
422 if( !$wgUseCategoryMagic ) return '' ;
423 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
425 # Taken out so that they will be displayed in previews -- TS
426 #if( !$wgOut->isArticle() ) return '';
428 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
429 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
430 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
433 # optional 'dmoz-like' category browser. Will be shown under the list
434 # of categories an article belong to
435 if($wgUseCategoryBrowser) {
436 $s .= '<br /><hr />';
438 # get a big array of the parents tree
439 $parenttree = $wgTitle->getParentCategoryTree();
441 # Skin object passed by reference cause it can not be
442 # accessed under the method subfunction walkThrough.
443 $s .= Skin
::drawCategoryBrowser($parenttree, $this);
449 # Render the array as a serie of links
450 function drawCategoryBrowser ($tree, &$skin) {
452 foreach ($tree as $element => $parent) {
453 if (empty($parent)) {
454 # element start a new list
457 # grab the others elements
458 $return .= Skin
::drawCategoryBrowser($parent, $skin);
460 # add our current element to the list
461 $eltitle = Title
::NewFromText($element);
462 if (!empty($parent)) $return .= ' > ';
463 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
468 function getCategories() {
469 $catlinks=$this->getCategoryLinks();
470 if(!empty($catlinks)) {
471 return "<p class='catlinks'>{$catlinks}</p>";
475 function getQuickbarCompensator( $rows = 1 ) {
476 return "<td width='152' rowspan='{$rows}'> </td>";
480 * This gets called immediately before the </body> tag.
481 * @return string HTML to be put after </body> ???
483 function afterContent() {
484 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
485 return $printfooter . $this->doAfterContent();
488 /** @return string Retrievied from HTML text */
489 function printSource() {
491 $url = htmlspecialchars( $wgTitle->getFullURL() );
492 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
495 function printFooter() {
496 return "<p>" . $this->printSource() .
497 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
500 /** overloaded by derived classes */
501 function doAfterContent() { }
503 function pageTitleLinks() {
504 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
506 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
507 $action = $wgRequest->getText( 'action' );
509 $s = $this->printableLink();
510 $disclaimer = $this->disclaimerLink(); # may be empty
512 $s .= ' | ' . $disclaimer;
515 if ( $wgOut->isArticleRelated() ) {
516 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
517 $name = $wgTitle->getDBkey();
518 $image = new Image( $wgTitle );
519 if( $image->exists() ) {
520 $link = htmlspecialchars( $image->getURL() );
521 $style = $this->getInternalLinkAttributes( $link, $name );
522 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
526 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
527 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
528 wfMsg( 'currentrev' ) );
531 if ( $wgUser->getNewtalk() ) {
532 # do not show "You have new messages" text when we are viewing our
535 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
536 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
537 wfMsg('newmessageslink') );
538 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
540 $wgOut->setSquidMaxage(0);
541 $wgOut->enableClientCache(false);
545 $undelete = $this->getUndeleteLink();
546 if( !empty( $undelete ) ) {
547 $s .= ' | '.$undelete;
552 function getUndeleteLink() {
553 global $wgUser, $wgTitle, $wgContLang, $action;
554 if( $wgUser->isAllowed('rollback') &&
555 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
556 ($n = $wgTitle->isDeleted() ) ) {
557 return wfMsg( 'thisisdeleted',
558 $this->makeKnownLink(
559 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
560 wfMsg( 'restorelink', $n ) ) );
565 function printableLink() {
566 global $wgOut, $wgFeedClasses, $wgRequest;
568 $baseurl = $_SERVER['REQUEST_URI'];
569 if( strpos( '?', $baseurl ) == false ) {
574 $baseurl = htmlspecialchars( $baseurl );
575 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
577 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
578 if( $wgOut->isSyndicated() ) {
579 foreach( $wgFeedClasses as $format => $class ) {
580 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
581 $s .= " | <a href=\"$feedurl\">{$format}</a>";
587 function pageTitle() {
588 global $wgOut, $wgTitle, $wgUser;
590 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
594 function pageSubtitle() {
597 $sub = $wgOut->getSubtitle();
599 global $wgExtraSubtitle;
600 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
602 $subpages = $this->subPageSubtitle();
603 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
604 $s = "<p class='subtitle'>{$sub}</p>\n";
608 function subPageSubtitle() {
609 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
611 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
612 $ptext=$wgTitle->getPrefixedText();
613 if(preg_match('/\//',$ptext)) {
614 $links = explode('/',$ptext);
617 foreach($links as $link) {
619 if ($c<count($links)) {
620 $growinglink .= $link;
621 $getlink = $this->makeLink( $growinglink, $link );
622 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
626 $subpages .= '< ';
628 $subpages .= $getlink;
637 function nameAndLogin() {
638 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
640 $li = $wgContLang->specialPage( 'Userlogin' );
641 $lo = $wgContLang->specialPage( 'Userlogout' );
644 if ( $wgUser->isAnon() ) {
645 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
648 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
649 $wgContLang->getNsText( NS_TALK
) );
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->makeKnownLinkObj(
662 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
663 wfMsg( 'login' ), $q );
665 $n = $wgUser->getName();
666 $rt = $wgTitle->getPrefixedURL();
667 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
668 $wgContLang->getNsText( NS_TALK
) );
672 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
673 $n ) . "{$tl}<br />" .
674 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
675 "returnto={$rt}" ) . ' | ' .
676 $this->specialLink( 'preferences' );
678 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( '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() {
695 $search = $wgRequest->getText( 'search' );
697 $s = '<form name="search" class="inline" method="post" action="'
698 . $this->escapeSearchLink() . "\">\n"
699 . '<input type="text" name="search" size="19" value="'
700 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
701 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
702 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
707 function topLinks() {
711 $s = $this->mainPageLink() . $sep
712 . $this->specialLink( 'recentchanges' );
714 if ( $wgOut->isArticleRelated() ) {
715 $s .= $sep . $this->editThisPage()
716 . $sep . $this->historyLink();
718 # Many people don't like this dropdown box
719 #$s .= $sep . $this->specialPagesList();
721 /* show links to different language variants */
722 global $wgDisableLangConversion, $wgContLang, $wgTitle;
723 $variants = $wgContLang->getVariants();
724 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
725 foreach( $variants as $code ) {
726 $varname = $wgContLang->getVariantname( $code );
727 if( $varname == 'disable' )
729 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
736 function bottomLinks() {
737 global $wgOut, $wgUser, $wgTitle;
741 if ( $wgOut->isArticleRelated() ) {
742 $s .= '<strong>' . $this->editThisPage() . '</strong>';
743 if ( $wgUser->isLoggedIn() ) {
744 $s .= $sep . $this->watchThisPage();
746 $s .= $sep . $this->talkLink()
747 . $sep . $this->historyLink()
748 . $sep . $this->whatLinksHere()
749 . $sep . $this->watchPageLinksLink();
751 if ( $wgTitle->getNamespace() == NS_USER
752 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
755 $id=User
::idFromName($wgTitle->getText());
756 $ip=User
::isIP($wgTitle->getText());
758 if($id ||
$ip) { # both anons and non-anons have contri list
759 $s .= $sep . $this->userContribsLink();
761 if( $this->showEmailUser( $id ) ) {
762 $s .= $sep . $this->emailUserLink();
765 if ( $wgTitle->getArticleId() ) {
767 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
768 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
769 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
771 $s .= "<br />\n" . $this->otherLanguages();
776 function pageStats() {
777 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
778 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
780 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
781 if ( ! $wgOut->isArticle() ) { return ''; }
782 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
783 if ( 0 == $wgArticle->getID() ) { return ''; }
786 if ( !$wgDisableCounters ) {
787 $count = $wgLang->formatNum( $wgArticle->getCount() );
789 $s = wfMsg( 'viewcount', $count );
793 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
794 require_once('Credits.php');
795 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
797 $s .= $this->lastModified();
800 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
801 $dbr =& wfGetDB( DB_SLAVE
);
802 extract( $dbr->tableNames( 'watchlist' ) );
803 $sql = "SELECT COUNT(*) AS n FROM $watchlist
804 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
805 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
806 $res = $dbr->query( $sql, 'Skin::pageStats');
807 $x = $dbr->fetchObject( $res );
808 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
811 return $s . ' ' . $this->getCopyright();
814 function getCopyright() {
815 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
818 $oldid = $wgRequest->getVal( 'oldid' );
819 $diff = $wgRequest->getVal( 'diff' );
821 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
822 $msg = 'history_copyright';
828 if( $wgRightsPage ) {
829 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
830 } elseif( $wgRightsUrl ) {
831 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
836 $out .= wfMsgForContent( $msg, $link );
840 function getCopyrightIcon() {
841 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
843 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
844 $out = $wgCopyrightIcon;
845 } else if ( $wgRightsIcon ) {
846 $icon = htmlspecialchars( $wgRightsIcon );
847 if ( $wgRightsUrl ) {
848 $url = htmlspecialchars( $wgRightsUrl );
849 $out .= '<a href="'.$url.'">';
851 $text = htmlspecialchars( $wgRightsText );
852 $out .= "<img src=\"$icon\" alt='$text' />";
853 if ( $wgRightsUrl ) {
860 function getPoweredBy() {
862 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
863 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
867 function lastModified() {
868 global $wgLang, $wgArticle, $wgLoadBalancer;
870 $timestamp = $wgArticle->getTimestamp();
872 $d = $wgLang->timeanddate( $timestamp, true );
873 $s = ' ' . wfMsg( 'lastmodified', $d );
877 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
878 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
883 function logoText( $align = '' ) {
884 if ( '' != $align ) { $a = " align='{$align}'"; }
887 $mp = wfMsg( 'mainpage' );
888 $titleObj = Title
::newFromText( $mp );
889 if ( is_object( $titleObj ) ) {
890 $url = $titleObj->escapeLocalURL();
895 $logourl = $this->getLogo();
896 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
901 * show a drop-down box of special pages
902 * @TODO crash bug913. Need to be rewrote completly.
904 function specialPagesList() {
905 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
906 require_once('SpecialPage.php');
908 $pages = SpecialPage
::getPages();
910 // special pages without access restriction
911 foreach ( $pages[''] as $name => $page ) {
912 $a[$name] = $page->getDescription();
915 // Other special pages that are restricted.
916 // Copied from SpecialSpecialpages.php
917 foreach($wgAvailableRights as $right) {
918 if( $wgUser->isAllowed($right) ) {
919 /** Add all pages for this right */
920 if(isset($pages[$right])) {
921 foreach($pages[$right] as $name => $page) {
922 $a[$name] = $page->getDescription();
929 $sp = wfMsg( 'specialpages' );
930 $spp = $wgContLang->specialPage( 'Specialpages' );
932 $s = '<form id="specialpages" method="get" class="inline" ' .
933 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
934 $s .= "<select name=\"wpDropdown\">\n";
935 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
938 foreach ( $a as $name => $desc ) {
939 $p = $wgContLang->specialPage( $name );
940 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
943 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
948 function mainPageLink() {
949 $mp = wfMsgForContent( 'mainpage' );
950 $mptxt = wfMsg( 'mainpage');
951 $s = $this->makeKnownLink( $mp, $mptxt );
955 function copyrightLink() {
956 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
957 wfMsg( 'copyrightpagename' ) );
961 function aboutLink() {
962 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
963 wfMsg( 'aboutsite' ) );
968 function disclaimerLink() {
969 $disclaimers = wfMsg( 'disclaimers' );
970 if ($disclaimers == '-') {
973 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
978 function editThisPage() {
979 global $wgOut, $wgTitle, $wgRequest;
981 $oldid = $wgRequest->getVal( 'oldid' );
982 $diff = $wgRequest->getVal( 'diff' );
983 $redirect = $wgRequest->getVal( 'redirect' );
985 if ( ! $wgOut->isArticleRelated() ) {
986 $s = wfMsg( 'protectedpage' );
988 if ( $wgTitle->userCanEdit() ) {
989 $t = wfMsg( 'editthispage' );
991 $t = wfMsg( 'viewsource' );
995 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
996 if ( $oldid && ! isset( $diff ) ) {
997 $oid = '&oldid='.$oldid;
999 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1004 function deleteThisPage() {
1005 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1007 $diff = $wgRequest->getVal( 'diff' );
1008 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1009 $t = wfMsg( 'deletethispage' );
1011 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1018 function protectThisPage() {
1019 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1021 $diff = $wgRequest->getVal( 'diff' );
1022 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1023 if ( $wgTitle->isProtected() ) {
1024 $t = wfMsg( 'unprotectthispage' );
1025 $q = 'action=unprotect';
1027 $t = wfMsg( 'protectthispage' );
1028 $q = 'action=protect';
1030 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1037 function watchThisPage() {
1038 global $wgUser, $wgOut, $wgTitle;
1040 if ( $wgOut->isArticleRelated() ) {
1041 if ( $wgTitle->userIsWatching() ) {
1042 $t = wfMsg( 'unwatchthispage' );
1043 $q = 'action=unwatch';
1045 $t = wfMsg( 'watchthispage' );
1046 $q = 'action=watch';
1048 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1050 $s = wfMsg( 'notanarticle' );
1055 function moveThisPage() {
1058 if ( $wgTitle->userCanMove() ) {
1059 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1060 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1062 // no message if page is protected - would be redundant
1067 function historyLink() {
1070 return $this->makeKnownLinkObj( $wgTitle,
1071 wfMsg( 'history' ), 'action=history' );
1074 function whatLinksHere() {
1077 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1078 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1081 function userContribsLink() {
1084 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1085 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1088 function showEmailUser( $id ) {
1089 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1090 return $wgEnableEmail &&
1091 $wgEnableUserEmail &&
1092 $wgUser->isLoggedIn() && # show only to signed in users
1093 0 != $id; # we can only email to non-anons ..
1094 # '' != $id->getEmail() && # who must have an email address stored ..
1095 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1096 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1099 function emailUserLink() {
1102 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1103 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1106 function watchPageLinksLink() {
1107 global $wgOut, $wgTitle;
1109 if ( ! $wgOut->isArticleRelated() ) {
1110 return '(' . wfMsg( 'notanarticle' ) . ')';
1112 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1113 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1114 'target=' . $wgTitle->getPrefixedURL() );
1118 function otherLanguages() {
1119 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1121 if ( $wgHideInterlanguageLinks ) {
1125 $a = $wgOut->getLanguageLinks();
1126 if ( 0 == count( $a ) ) {
1130 $s = wfMsg( 'otherlanguages' ) . ': ';
1132 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1133 foreach( $a as $l ) {
1134 if ( ! $first ) { $s .= ' | '; }
1137 $nt = Title
::newFromText( $l );
1138 $url = $nt->escapeFullURL();
1139 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1141 if ( '' == $text ) { $text = $l; }
1142 $style = $this->getExternalLinkAttributes( $l, $text );
1143 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1145 if($wgContLang->isRTL()) $s .= '</span>';
1149 function bugReportsLink() {
1150 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1151 wfMsg( 'bugreports' ) );
1155 function dateLink() {
1156 global $wgLinkCache;
1157 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1158 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1160 $wgLinkCache->suspend();
1161 $id = $t1->getArticleID();
1162 $wgLinkCache->resume();
1165 $s = $this->makeBrokenLink( $t1->getText() );
1167 $s = $this->makeKnownLink( $t1->getText() );
1171 $wgLinkCache->suspend();
1172 $id = $t2->getArticleID();
1173 $wgLinkCache->resume();
1176 $s .= $this->makeBrokenLink( $t2->getText() );
1178 $s .= $this->makeKnownLink( $t2->getText() );
1183 function talkLink() {
1184 global $wgTitle, $wgLinkCache;
1186 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1187 # No discussion links for special pages
1191 if( $wgTitle->isTalkPage() ) {
1192 $link = $wgTitle->getSubjectPage();
1193 switch( $link->getNamespace() ) {
1195 $text = wfMsg('articlepage');
1198 $text = wfMsg('userpage');
1201 $text = wfMsg('wikipediapage');
1204 $text = wfMsg('imagepage');
1207 $text= wfMsg('articlepage');
1210 $link = $wgTitle->getTalkPage();
1211 $text = wfMsg( 'talkpage' );
1214 $wgLinkCache->suspend();
1215 $s = $this->makeLinkObj( $link, $text );
1216 $wgLinkCache->resume();
1221 function commentLink() {
1222 global $wgContLang, $wgTitle, $wgLinkCache;
1224 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1227 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1228 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1231 /* these are used extensively in SkinPHPTal, but also some other places */
1232 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1233 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1234 return $title->getLocalURL( $urlaction );
1237 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1238 $title = Title
::newFromText( wfMsgForContent($name) );
1239 $this->checkTitle($title, $name);
1240 return $title->getLocalURL( $urlaction );
1243 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1244 $title = Title
::newFromText( $name );
1245 $this->checkTitle($title, $name);
1246 return $title->getLocalURL( $urlaction );
1249 # If url string starts with http, consider as external URL, else
1251 /*static*/ function makeInternalOrExternalUrl( $name ) {
1252 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1255 return $this->makeUrl( $name );
1259 # this can be passed the NS number as defined in Language.php
1260 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1261 $title = Title
::makeTitleSafe( $namespace, $name );
1262 $this->checkTitle($title, $name);
1263 return $title->getLocalURL( $urlaction );
1266 /* these return an array with the 'href' and boolean 'exists' */
1267 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1268 $title = Title
::newFromText( $name );
1269 $this->checkTitle($title, $name);
1271 'href' => $title->getLocalURL( $urlaction ),
1272 'exists' => $title->getArticleID() != 0?
true:false
1276 # make sure we have some title to operate on
1277 /*static*/ function checkTitle ( &$title, &$name ) {
1278 if(!is_object($title)) {
1279 $title = Title
::newFromText( $name );
1280 if(!is_object($title)) {
1281 $title = Title
::newFromText( '--error: link target missing--' );
1287 * Build an array that represents the sidebar(s), the navigation bar among them
1292 function buildSidebar() {
1293 $fname = 'SkinTemplate::buildSidebar';
1294 wfProfileIn( $fname );
1297 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1298 foreach ($lines as $line) {
1299 if (strpos($line, '*') !== 0)
1301 if (strpos($line, '**') !== 0) {
1302 $line = trim($line, '* ');
1305 if (strpos($line, '|') !== false) { // sanity check
1306 $line = explode( '|' , trim($line, '* '), 2 );
1307 $link = wfMsgForContent( $line[0] );
1310 $bar[$heading][] = array(
1311 'text' => wfMsg( $line[1] ),
1312 'href' => $this->makeInternalOrExternalUrl( $link ),
1313 'id' => 'n-' . strtr($line[1], ' ', '-'),
1315 } else { continue; }
1319 wfProfileOut( $fname );