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 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( $wgUser->isAllowed('rollback') &&
553 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
554 ($n = $wgTitle->isDeleted() ) ) {
555 return wfMsg( 'thisisdeleted',
556 $this->makeKnownLink(
557 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
558 wfMsg( 'restorelink', $n ) ) );
563 function printableLink() {
564 global $wgOut, $wgFeedClasses, $wgRequest;
566 $baseurl = $_SERVER['REQUEST_URI'];
567 if( strpos( '?', $baseurl ) == false ) {
572 $baseurl = htmlspecialchars( $baseurl );
573 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
575 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
576 if( $wgOut->isSyndicated() ) {
577 foreach( $wgFeedClasses as $format => $class ) {
578 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
579 $s .= " | <a href=\"$feedurl\">{$format}</a>";
585 function pageTitle() {
586 global $wgOut, $wgTitle, $wgUser;
588 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
592 function pageSubtitle() {
595 $sub = $wgOut->getSubtitle();
597 global $wgExtraSubtitle;
598 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
600 $subpages = $this->subPageSubtitle();
601 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
602 $s = "<p class='subtitle'>{$sub}</p>\n";
606 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() {
636 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
638 $li = $wgContLang->specialPage( 'Userlogin' );
639 $lo = $wgContLang->specialPage( 'Userlogout' );
642 if ( $wgUser->isAnon() ) {
643 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
646 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
647 $wgContLang->getNsText( NS_TALK
) );
649 $s .= $n . ' ('.$tl.')';
651 $s .= wfMsg('notloggedin');
654 $rt = $wgTitle->getPrefixedURL();
655 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
657 } else { $q = "returnto={$rt}"; }
659 $s .= "\n<br />" . $this->makeKnownLinkObj(
660 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
661 wfMsg( 'login' ), $q );
663 $n = $wgUser->getName();
664 $rt = $wgTitle->getPrefixedURL();
665 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
666 $wgContLang->getNsText( NS_TALK
) );
670 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
671 $n ) . "{$tl}<br />" .
672 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
673 "returnto={$rt}" ) . ' | ' .
674 $this->specialLink( 'preferences' );
676 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
682 function getSearchLink() {
683 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
684 return $searchPage->getLocalURL();
687 function escapeSearchLink() {
688 return htmlspecialchars( $this->getSearchLink() );
691 function searchForm() {
693 $search = $wgRequest->getText( 'search' );
695 $s = '<form name="search" class="inline" method="post" action="'
696 . $this->escapeSearchLink() . "\">\n"
697 . '<input type="text" name="search" size="19" value="'
698 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
699 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
700 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
705 function topLinks() {
709 $s = $this->mainPageLink() . $sep
710 . $this->specialLink( 'recentchanges' );
712 if ( $wgOut->isArticleRelated() ) {
713 $s .= $sep . $this->editThisPage()
714 . $sep . $this->historyLink();
716 # Many people don't like this dropdown box
717 #$s .= $sep . $this->specialPagesList();
719 /* show links to different language variants */
720 global $wgDisableLangConversion, $wgContLang, $wgTitle;
721 $variants = $wgContLang->getVariants();
722 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
723 foreach( $variants as $code ) {
724 $varname = $wgContLang->getVariantname( $code );
725 if( $varname == 'disable' )
727 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
734 function bottomLinks() {
735 global $wgOut, $wgUser, $wgTitle;
739 if ( $wgOut->isArticleRelated() ) {
740 $s .= '<strong>' . $this->editThisPage() . '</strong>';
741 if ( $wgUser->isLoggedIn() ) {
742 $s .= $sep . $this->watchThisPage();
744 $s .= $sep . $this->talkLink()
745 . $sep . $this->historyLink()
746 . $sep . $this->whatLinksHere()
747 . $sep . $this->watchPageLinksLink();
749 if ( $wgTitle->getNamespace() == NS_USER
750 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
753 $id=User
::idFromName($wgTitle->getText());
754 $ip=User
::isIP($wgTitle->getText());
756 if($id ||
$ip) { # both anons and non-anons have contri list
757 $s .= $sep . $this->userContribsLink();
759 if( $this->showEmailUser( $id ) ) {
760 $s .= $sep . $this->emailUserLink();
763 if ( $wgTitle->getArticleId() ) {
765 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
766 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
767 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
769 $s .= "<br />\n" . $this->otherLanguages();
774 function pageStats() {
775 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
776 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
778 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
779 if ( ! $wgOut->isArticle() ) { return ''; }
780 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
781 if ( 0 == $wgArticle->getID() ) { return ''; }
784 if ( !$wgDisableCounters ) {
785 $count = $wgLang->formatNum( $wgArticle->getCount() );
787 $s = wfMsg( 'viewcount', $count );
791 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
792 require_once('Credits.php');
793 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
795 $s .= $this->lastModified();
798 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
799 $dbr =& wfGetDB( DB_SLAVE
);
800 extract( $dbr->tableNames( 'watchlist' ) );
801 $sql = "SELECT COUNT(*) AS n FROM $watchlist
802 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
803 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
804 $res = $dbr->query( $sql, 'Skin::pageStats');
805 $x = $dbr->fetchObject( $res );
806 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
809 return $s . ' ' . $this->getCopyright();
812 function getCopyright() {
813 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
816 $oldid = $wgRequest->getVal( 'oldid' );
817 $diff = $wgRequest->getVal( 'diff' );
819 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
820 $msg = 'history_copyright';
826 if( $wgRightsPage ) {
827 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
828 } elseif( $wgRightsUrl ) {
829 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
834 $out .= wfMsgForContent( $msg, $link );
838 function getCopyrightIcon() {
839 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
841 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
842 $out = $wgCopyrightIcon;
843 } else if ( $wgRightsIcon ) {
844 $icon = htmlspecialchars( $wgRightsIcon );
845 if ( $wgRightsUrl ) {
846 $url = htmlspecialchars( $wgRightsUrl );
847 $out .= '<a href="'.$url.'">';
849 $text = htmlspecialchars( $wgRightsText );
850 $out .= "<img src=\"$icon\" alt='$text' />";
851 if ( $wgRightsUrl ) {
858 function getPoweredBy() {
860 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
861 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
865 function lastModified() {
866 global $wgLang, $wgArticle, $wgLoadBalancer;
868 $timestamp = $wgArticle->getTimestamp();
870 $d = $wgLang->timeanddate( $timestamp, true );
871 $s = ' ' . wfMsg( 'lastmodified', $d );
875 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
876 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
881 function logoText( $align = '' ) {
882 if ( '' != $align ) { $a = " align='{$align}'"; }
885 $mp = wfMsg( 'mainpage' );
886 $titleObj = Title
::newFromText( $mp );
887 if ( is_object( $titleObj ) ) {
888 $url = $titleObj->escapeLocalURL();
893 $logourl = $this->getLogo();
894 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
899 * show a drop-down box of special pages
900 * @TODO crash bug913. Need to be rewrote completly.
902 function specialPagesList() {
903 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
904 require_once('SpecialPage.php');
906 $pages = SpecialPage
::getPages();
908 // special pages without access restriction
909 foreach ( $pages[''] as $name => $page ) {
910 $a[$name] = $page->getDescription();
913 // Other special pages that are restricted.
914 // Copied from SpecialSpecialpages.php
915 foreach($wgAvailableRights as $right) {
916 if( $wgUser->isAllowed($right) ) {
917 /** Add all pages for this right */
918 if(isset($pages[$right])) {
919 foreach($pages[$right] as $name => $page) {
920 $a[$name] = $page->getDescription();
927 $sp = wfMsg( 'specialpages' );
928 $spp = $wgContLang->specialPage( 'Specialpages' );
930 $s = '<form id="specialpages" method="get" class="inline" ' .
931 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
932 $s .= "<select name=\"wpDropdown\">\n";
933 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
936 foreach ( $a as $name => $desc ) {
937 $p = $wgContLang->specialPage( $name );
938 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
941 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
946 function mainPageLink() {
947 $mp = wfMsgForContent( 'mainpage' );
948 $mptxt = wfMsg( 'mainpage');
949 $s = $this->makeKnownLink( $mp, $mptxt );
953 function copyrightLink() {
954 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
955 wfMsg( 'copyrightpagename' ) );
959 function aboutLink() {
960 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
961 wfMsg( 'aboutsite' ) );
966 function disclaimerLink() {
967 $disclaimers = wfMsg( 'disclaimers' );
968 if ($disclaimers == '-') {
971 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
976 function editThisPage() {
977 global $wgOut, $wgTitle, $wgRequest;
979 $oldid = $wgRequest->getVal( 'oldid' );
980 $diff = $wgRequest->getVal( 'diff' );
981 $redirect = $wgRequest->getVal( 'redirect' );
983 if ( ! $wgOut->isArticleRelated() ) {
984 $s = wfMsg( 'protectedpage' );
986 if ( $wgTitle->userCanEdit() ) {
987 $t = wfMsg( 'editthispage' );
989 $t = wfMsg( 'viewsource' );
993 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
994 if ( $oldid && ! isset( $diff ) ) {
995 $oid = '&oldid='.$oldid;
997 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1002 function deleteThisPage() {
1003 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1005 $diff = $wgRequest->getVal( 'diff' );
1006 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1007 $t = wfMsg( 'deletethispage' );
1009 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1016 function protectThisPage() {
1017 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1019 $diff = $wgRequest->getVal( 'diff' );
1020 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1021 if ( $wgTitle->isProtected() ) {
1022 $t = wfMsg( 'unprotectthispage' );
1023 $q = 'action=unprotect';
1025 $t = wfMsg( 'protectthispage' );
1026 $q = 'action=protect';
1028 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1035 function watchThisPage() {
1036 global $wgUser, $wgOut, $wgTitle;
1038 if ( $wgOut->isArticleRelated() ) {
1039 if ( $wgTitle->userIsWatching() ) {
1040 $t = wfMsg( 'unwatchthispage' );
1041 $q = 'action=unwatch';
1043 $t = wfMsg( 'watchthispage' );
1044 $q = 'action=watch';
1046 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1048 $s = wfMsg( 'notanarticle' );
1053 function moveThisPage() {
1056 if ( $wgTitle->userCanMove() ) {
1057 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1058 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1060 // no message if page is protected - would be redundant
1065 function historyLink() {
1068 return $this->makeKnownLinkObj( $wgTitle,
1069 wfMsg( 'history' ), 'action=history' );
1072 function whatLinksHere() {
1075 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1076 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1079 function userContribsLink() {
1082 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1083 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1086 function showEmailUser( $id ) {
1087 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1088 return $wgEnableEmail &&
1089 $wgEnableUserEmail &&
1090 $wgUser->isLoggedIn() && # show only to signed in users
1091 0 != $id; # we can only email to non-anons ..
1092 # '' != $id->getEmail() && # who must have an email address stored ..
1093 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1094 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1097 function emailUserLink() {
1100 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1101 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1104 function watchPageLinksLink() {
1105 global $wgOut, $wgTitle;
1107 if ( ! $wgOut->isArticleRelated() ) {
1108 return '(' . wfMsg( 'notanarticle' ) . ')';
1110 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1111 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1112 'target=' . $wgTitle->getPrefixedURL() );
1116 function otherLanguages() {
1117 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1119 if ( $wgHideInterlanguageLinks ) {
1123 $a = $wgOut->getLanguageLinks();
1124 if ( 0 == count( $a ) ) {
1128 $s = wfMsg( 'otherlanguages' ) . ': ';
1130 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1131 foreach( $a as $l ) {
1132 if ( ! $first ) { $s .= ' | '; }
1135 $nt = Title
::newFromText( $l );
1136 $url = $nt->escapeFullURL();
1137 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1139 if ( '' == $text ) { $text = $l; }
1140 $style = $this->getExternalLinkAttributes( $l, $text );
1141 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1143 if($wgContLang->isRTL()) $s .= '</span>';
1147 function bugReportsLink() {
1148 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1149 wfMsg( 'bugreports' ) );
1153 function dateLink() {
1154 global $wgLinkCache;
1155 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1156 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1158 $wgLinkCache->suspend();
1159 $id = $t1->getArticleID();
1160 $wgLinkCache->resume();
1163 $s = $this->makeBrokenLink( $t1->getText() );
1165 $s = $this->makeKnownLink( $t1->getText() );
1169 $wgLinkCache->suspend();
1170 $id = $t2->getArticleID();
1171 $wgLinkCache->resume();
1174 $s .= $this->makeBrokenLink( $t2->getText() );
1176 $s .= $this->makeKnownLink( $t2->getText() );
1181 function talkLink() {
1182 global $wgTitle, $wgLinkCache;
1184 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1185 # No discussion links for special pages
1189 if( $wgTitle->isTalkPage() ) {
1190 $link = $wgTitle->getSubjectPage();
1191 switch( $link->getNamespace() ) {
1193 $text = wfMsg('articlepage');
1196 $text = wfMsg('userpage');
1199 $text = wfMsg('wikipediapage');
1202 $text = wfMsg('imagepage');
1205 $text= wfMsg('articlepage');
1208 $link = $wgTitle->getTalkPage();
1209 $text = wfMsg( 'talkpage' );
1212 $wgLinkCache->suspend();
1213 $s = $this->makeLinkObj( $link, $text );
1214 $wgLinkCache->resume();
1219 function commentLink() {
1220 global $wgContLang, $wgTitle, $wgLinkCache;
1222 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1225 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1226 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1229 /* these are used extensively in SkinPHPTal, but also some other places */
1230 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1231 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1232 return $title->getLocalURL( $urlaction );
1235 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1236 $title = Title
::newFromText( wfMsgForContent($name) );
1237 $this->checkTitle($title, $name);
1238 return $title->getLocalURL( $urlaction );
1241 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1242 $title = Title
::newFromText( $name );
1243 $this->checkTitle($title, $name);
1244 return $title->getLocalURL( $urlaction );
1247 # If url string starts with http, consider as external URL, else
1249 /*static*/ function makeInternalOrExternalUrl( $name ) {
1250 global $wgUrlProtcols;
1251 if ( preg_match( '/^(?:' . $wgUrlProtcols . ')/', $name ) ) {
1254 return $this->makeUrl( $name );
1258 # this can be passed the NS number as defined in Language.php
1259 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1260 $title = Title
::makeTitleSafe( $namespace, $name );
1261 $this->checkTitle($title, $name);
1262 return $title->getLocalURL( $urlaction );
1265 /* these return an array with the 'href' and boolean 'exists' */
1266 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1267 $title = Title
::newFromText( $name );
1268 $this->checkTitle($title, $name);
1270 'href' => $title->getLocalURL( $urlaction ),
1271 'exists' => $title->getArticleID() != 0?
true:false
1275 # make sure we have some title to operate on
1276 /*static*/ function checkTitle ( &$title, &$name ) {
1277 if(!is_object($title)) {
1278 $title = Title
::newFromText( $name );
1279 if(!is_object($title)) {
1280 $title = Title
::newFromText( '--error: link target missing--' );
1286 * Build an array that represents the sidebar(s), the navigation bar among them
1291 function buildSidebar() {
1292 $fname = 'SkinTemplate::buildSidebar';
1293 wfProfileIn( $fname );
1296 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1297 foreach ($lines as $line) {
1298 if (strpos($line, '*') !== 0)
1300 if (strpos($line, '**') !== 0) {
1301 $line = trim($line, '* ');
1304 if (strpos($line, '|') !== false) { // sanity check
1305 $line = explode( '|' , trim($line, '* '), 2 );
1306 $link = wfMsgForContent( $line[0] );
1309 $bar[$heading][] = array(
1310 'text' => wfMsg( $line[1] ),
1311 'href' => $this->makeInternalOrExternalUrl( $link ),
1312 'id' => 'n-' . strtr($line[1], ' ', '-'),
1314 } else { continue; }
1318 wfProfileOut( $fname );