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 $underline = $wgUser->getOption( "underline" ) ?
'underline' : 'none';
268 $s .= "a { text-decoration: $underline; }\n";
269 if( $wgUser->getOption( 'highlightbroken' ) ) {
270 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
273 a.new, #quickbar a.new,
274 a.stub, #quickbar a.stub {
276 text-decoration: inherit;
278 a.new:after, #quickbar a.new:after {
281 text-decoration: $underline;
283 a.stub:after, #quickbar a.stub:after {
286 text-decoration: $underline;
290 if( $wgUser->getOption( 'justify' ) ) {
291 $s .= "#article, #bodyContent { text-align: justify; }\n";
293 if( !$wgUser->getOption( 'showtoc' ) ) {
294 $s .= "#toc { display: none; }\n";
299 function getBodyOptions() {
300 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
302 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
304 if ( 0 != $wgTitle->getNamespace() ) {
305 $a = array( 'bgcolor' => '#ffffec' );
307 else $a = array( 'bgcolor' => '#FFFFFF' );
308 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
309 (!$wgTitle->isProtected() ||
$wgUser->isAllowed('protect')) ) {
310 $t = wfMsg( 'editthispage' );
312 if ( !empty($redirect) && $redirect == 'no' ) {
313 $red = "&redirect={$redirect}";
315 if ( !empty($oldid) && ! isset( $diff ) ) {
316 $oid = "&oldid=" . IntVal( $oldid );
318 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
319 $s = 'document.location = "' .$s .'";';
320 $a +
= array ('ondblclick' => $s);
323 $a['onload'] = $wgOut->getOnloadHandler();
324 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
325 if( $a['onload'] != '' ) {
328 $a['onload'] .= 'setupRightClickEdit()';
342 * This will be called immediately after the <body> tag. Split into
343 * two functions to make it easier to subclass.
345 function beforeContent() {
346 return $this->doBeforeContent();
349 function doBeforeContent() {
350 global $wgOut, $wgTitle, $wgContLang;
351 $fname = 'Skin::doBeforeContent';
352 wfProfileIn( $fname );
355 $qb = $this->qbSetting();
357 if( $langlinks = $this->otherLanguages() ) {
363 $borderhack = 'class="top"';
366 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
367 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
370 $left = ($qb == 1 ||
$qb == 3);
371 if($wgContLang->isRTL()) $left = !$left;
374 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
375 $this->logoText() . '</td>';
377 $s .= $this->getQuickbarCompensator( $rows );
379 $l = $wgContLang->isRTL() ?
'right' : 'left';
380 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
382 $s .= $this->topLinks() ;
383 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
385 $r = $wgContLang->isRTL() ?
"left" : "right";
386 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
387 $s .= $this->nameAndLogin();
388 $s .= "\n<br />" . $this->searchForm() . "</td>";
391 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
394 if ( $shove && !$left ) { # Right
395 $s .= $this->getQuickbarCompensator( $rows );
397 $s .= "</tr>\n</table>\n</div>\n";
398 $s .= "\n<div id='article'>\n";
400 $notice = wfGetSiteNotice();
402 $s .= "\n<div id='siteNotice'>$notice</div>\n";
404 $s .= $this->pageTitle();
405 $s .= $this->pageSubtitle() ;
406 $s .= $this->getCategories();
407 wfProfileOut( $fname );
412 function getCategoryLinks () {
413 global $wgOut, $wgTitle, $wgParser;
414 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
416 if( !$wgUseCategoryMagic ) return '' ;
417 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
419 # Taken out so that they will be displayed in previews -- TS
420 #if( !$wgOut->isArticle() ) return '';
422 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
423 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
424 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
427 # optional 'dmoz-like' category browser. Will be shown under the list
428 # of categories an article belong to
429 if($wgUseCategoryBrowser) {
430 $s .= '<br /><hr />';
432 # get a big array of the parents tree
433 $parenttree = $wgTitle->getParentCategoryTree();
435 # Skin object passed by reference cause it can not be
436 # accessed under the method subfunction walkThrough.
437 $s .= Skin
::drawCategoryBrowser($parenttree, $this);
443 # Render the array as a serie of links
444 function drawCategoryBrowser ($tree, &$skin) {
446 foreach ($tree as $element => $parent) {
447 if (empty($parent)) {
448 # element start a new list
451 # grab the others elements
452 $return .= Skin
::drawCategoryBrowser($parent, $skin);
454 # add our current element to the list
455 $eltitle = Title
::NewFromText($element);
456 if (!empty($parent)) $return .= ' > ';
457 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
462 function getCategories() {
463 $catlinks=$this->getCategoryLinks();
464 if(!empty($catlinks)) {
465 return "<p class='catlinks'>{$catlinks}</p>";
469 function getQuickbarCompensator( $rows = 1 ) {
470 return "<td width='152' rowspan='{$rows}'> </td>";
474 * This gets called immediately before the </body> tag.
475 * @return string HTML to be put after </body> ???
477 function afterContent() {
478 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
479 return $printfooter . $this->doAfterContent();
482 /** @return string Retrievied from HTML text */
483 function printSource() {
485 $url = htmlspecialchars( $wgTitle->getFullURL() );
486 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
489 function printFooter() {
490 return "<p>" . $this->printSource() .
491 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
494 /** overloaded by derived classes */
495 function doAfterContent() { }
497 function pageTitleLinks() {
498 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgUseApproval, $wgRequest;
500 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
501 $action = $wgRequest->getText( 'action' );
503 $s = $this->printableLink();
504 $disclaimer = $this->disclaimerLink(); # may be empty
506 $s .= ' | ' . $disclaimer;
509 if ( $wgOut->isArticleRelated() ) {
510 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
511 $name = $wgTitle->getDBkey();
512 $image = new Image( $wgTitle );
513 if( $image->exists() ) {
514 $link = htmlspecialchars( $image->getURL() );
515 $style = $this->getInternalLinkAttributes( $link, $name );
516 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
519 # This will show the "Approve" link if $wgUseApproval=true;
520 if ( isset ( $wgUseApproval ) && $wgUseApproval )
522 $t = $wgTitle->getDBkey();
523 $name = 'Approve this article' ;
524 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
525 #htmlspecialchars( wfImageUrl( $name ) );
526 $style = $this->getExternalLinkAttributes( $link, $name );
527 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
530 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
531 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
532 wfMsg( 'currentrev' ) );
535 if ( $wgUser->getNewtalk() ) {
536 # do not show "You have new messages" text when we are viewing our
539 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
540 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
541 wfMsg('newmessageslink') );
542 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
544 $wgOut->setSquidMaxage(0);
545 $wgOut->enableClientCache(false);
549 $undelete = $this->getUndeleteLink();
550 if( !empty( $undelete ) ) {
551 $s .= ' | '.$undelete;
556 function getUndeleteLink() {
557 global $wgUser, $wgTitle, $wgContLang, $action;
558 if( $wgUser->isAllowed('rollback') &&
559 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
560 ($n = $wgTitle->isDeleted() ) ) {
561 return wfMsg( 'thisisdeleted',
562 $this->makeKnownLink(
563 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
564 wfMsg( 'restorelink', $n ) ) );
569 function printableLink() {
570 global $wgOut, $wgFeedClasses, $wgRequest;
572 $baseurl = $_SERVER['REQUEST_URI'];
573 if( strpos( '?', $baseurl ) == false ) {
578 $baseurl = htmlspecialchars( $baseurl );
579 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
581 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
582 if( $wgOut->isSyndicated() ) {
583 foreach( $wgFeedClasses as $format => $class ) {
584 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
585 $s .= " | <a href=\"$feedurl\">{$format}</a>";
591 function pageTitle() {
592 global $wgOut, $wgTitle, $wgUser;
594 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
598 function pageSubtitle() {
601 $sub = $wgOut->getSubtitle();
603 global $wgExtraSubtitle;
604 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
606 $subpages = $this->subPageSubtitle();
607 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
608 $s = "<p class='subtitle'>{$sub}</p>\n";
612 function subPageSubtitle() {
613 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
615 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
616 $ptext=$wgTitle->getPrefixedText();
617 if(preg_match('/\//',$ptext)) {
618 $links = explode('/',$ptext);
621 foreach($links as $link) {
623 if ($c<count($links)) {
624 $growinglink .= $link;
625 $getlink = $this->makeLink( $growinglink, $link );
626 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
630 $subpages .= '< ';
632 $subpages .= $getlink;
641 function nameAndLogin() {
642 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
644 $li = $wgContLang->specialPage( 'Userlogin' );
645 $lo = $wgContLang->specialPage( 'Userlogout' );
648 if ( $wgUser->isAnon() ) {
649 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
652 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
653 $wgContLang->getNsText( NS_TALK
) );
655 $s .= $n . ' ('.$tl.')';
657 $s .= wfMsg('notloggedin');
660 $rt = $wgTitle->getPrefixedURL();
661 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
663 } else { $q = "returnto={$rt}"; }
665 $s .= "\n<br />" . $this->makeKnownLinkObj(
666 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
667 wfMsg( 'login' ), $q );
669 $n = $wgUser->getName();
670 $rt = $wgTitle->getPrefixedURL();
671 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
672 $wgContLang->getNsText( NS_TALK
) );
676 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
677 $n ) . "{$tl}<br />" .
678 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
679 "returnto={$rt}" ) . ' | ' .
680 $this->specialLink( 'preferences' );
682 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
688 function getSearchLink() {
689 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
690 return $searchPage->getLocalURL();
693 function escapeSearchLink() {
694 return htmlspecialchars( $this->getSearchLink() );
697 function searchForm() {
699 $search = $wgRequest->getText( 'search' );
701 $s = '<form name="search" class="inline" method="post" action="'
702 . $this->escapeSearchLink() . "\">\n"
703 . '<input type="text" name="search" size="19" value="'
704 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
705 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
706 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
711 function topLinks() {
715 $s = $this->mainPageLink() . $sep
716 . $this->specialLink( 'recentchanges' );
718 if ( $wgOut->isArticleRelated() ) {
719 $s .= $sep . $this->editThisPage()
720 . $sep . $this->historyLink();
722 # Many people don't like this dropdown box
723 #$s .= $sep . $this->specialPagesList();
725 /* show links to different language variants */
726 global $wgDisableLangConversion, $wgContLang, $wgTitle;
727 $variants = $wgContLang->getVariants();
728 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
729 foreach( $variants as $code ) {
730 $varname = $wgContLang->getVariantname( $code );
731 if( $varname == 'disable' )
733 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
740 function bottomLinks() {
741 global $wgOut, $wgUser, $wgTitle;
745 if ( $wgOut->isArticleRelated() ) {
746 $s .= '<strong>' . $this->editThisPage() . '</strong>';
747 if ( $wgUser->isLoggedIn() ) {
748 $s .= $sep . $this->watchThisPage();
750 $s .= $sep . $this->talkLink()
751 . $sep . $this->historyLink()
752 . $sep . $this->whatLinksHere()
753 . $sep . $this->watchPageLinksLink();
755 if ( $wgTitle->getNamespace() == NS_USER
756 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
759 $id=User
::idFromName($wgTitle->getText());
760 $ip=User
::isIP($wgTitle->getText());
762 if($id ||
$ip) { # both anons and non-anons have contri list
763 $s .= $sep . $this->userContribsLink();
765 if( $this->showEmailUser( $id ) ) {
766 $s .= $sep . $this->emailUserLink();
769 if ( $wgTitle->getArticleId() ) {
771 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
772 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
773 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
775 $s .= "<br />\n" . $this->otherLanguages();
780 function pageStats() {
781 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
782 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
784 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
785 if ( ! $wgOut->isArticle() ) { return ''; }
786 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
787 if ( 0 == $wgArticle->getID() ) { return ''; }
790 if ( !$wgDisableCounters ) {
791 $count = $wgLang->formatNum( $wgArticle->getCount() );
793 $s = wfMsg( 'viewcount', $count );
797 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
798 require_once('Credits.php');
799 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
801 $s .= $this->lastModified();
804 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
805 $dbr =& wfGetDB( DB_SLAVE
);
806 extract( $dbr->tableNames( 'watchlist' ) );
807 $sql = "SELECT COUNT(*) AS n FROM $watchlist
808 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
809 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
810 $res = $dbr->query( $sql, 'Skin::pageStats');
811 $x = $dbr->fetchObject( $res );
812 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
815 return $s . ' ' . $this->getCopyright();
818 function getCopyright() {
819 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
822 $oldid = $wgRequest->getVal( 'oldid' );
823 $diff = $wgRequest->getVal( 'diff' );
825 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
826 $msg = 'history_copyright';
832 if( $wgRightsPage ) {
833 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
834 } elseif( $wgRightsUrl ) {
835 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
840 $out .= wfMsgForContent( $msg, $link );
844 function getCopyrightIcon() {
845 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
847 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
848 $out = $wgCopyrightIcon;
849 } else if ( $wgRightsIcon ) {
850 $icon = htmlspecialchars( $wgRightsIcon );
851 if ( $wgRightsUrl ) {
852 $url = htmlspecialchars( $wgRightsUrl );
853 $out .= '<a href="'.$url.'">';
855 $text = htmlspecialchars( $wgRightsText );
856 $out .= "<img src=\"$icon\" alt='$text' />";
857 if ( $wgRightsUrl ) {
864 function getPoweredBy() {
866 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
867 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
871 function lastModified() {
872 global $wgLang, $wgArticle, $wgLoadBalancer;
874 $timestamp = $wgArticle->getTimestamp();
876 $d = $wgLang->timeanddate( $timestamp, true );
877 $s = ' ' . wfMsg( 'lastmodified', $d );
881 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
882 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
887 function logoText( $align = '' ) {
888 if ( '' != $align ) { $a = " align='{$align}'"; }
891 $mp = wfMsg( 'mainpage' );
892 $titleObj = Title
::newFromText( $mp );
893 if ( is_object( $titleObj ) ) {
894 $url = $titleObj->escapeLocalURL();
899 $logourl = $this->getLogo();
900 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
905 * show a drop-down box of special pages
906 * @TODO crash bug913. Need to be rewrote completly.
908 function specialPagesList() {
909 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
910 require_once('SpecialPage.php');
912 $pages = SpecialPage
::getPages();
914 // special pages without access restriction
915 foreach ( $pages[''] as $name => $page ) {
916 $a[$name] = $page->getDescription();
919 // Other special pages that are restricted.
920 // Copied from SpecialSpecialpages.php
921 foreach($wgAvailableRights as $right) {
922 if( $wgUser->isAllowed($right) ) {
923 /** Add all pages for this right */
924 if(isset($pages[$right])) {
925 foreach($pages[$right] as $name => $page) {
926 $a[$name] = $page->getDescription();
933 $sp = wfMsg( 'specialpages' );
934 $spp = $wgContLang->specialPage( 'Specialpages' );
936 $s = '<form id="specialpages" method="get" class="inline" ' .
937 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
938 $s .= "<select name=\"wpDropdown\">\n";
939 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
942 foreach ( $a as $name => $desc ) {
943 $p = $wgContLang->specialPage( $name );
944 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
947 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
952 function mainPageLink() {
953 $mp = wfMsgForContent( 'mainpage' );
954 $mptxt = wfMsg( 'mainpage');
955 $s = $this->makeKnownLink( $mp, $mptxt );
959 function copyrightLink() {
960 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
961 wfMsg( 'copyrightpagename' ) );
965 function aboutLink() {
966 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
967 wfMsg( 'aboutsite' ) );
972 function disclaimerLink() {
973 $disclaimers = wfMsg( 'disclaimers' );
974 if ($disclaimers == '-') {
977 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
982 function editThisPage() {
983 global $wgOut, $wgTitle, $wgRequest;
985 $oldid = $wgRequest->getVal( 'oldid' );
986 $diff = $wgRequest->getVal( 'diff' );
987 $redirect = $wgRequest->getVal( 'redirect' );
989 if ( ! $wgOut->isArticleRelated() ) {
990 $s = wfMsg( 'protectedpage' );
992 if ( $wgTitle->userCanEdit() ) {
993 $t = wfMsg( 'editthispage' );
995 $t = wfMsg( 'viewsource' );
999 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1000 if ( $oldid && ! isset( $diff ) ) {
1001 $oid = '&oldid='.$oldid;
1003 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1008 function deleteThisPage() {
1009 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1011 $diff = $wgRequest->getVal( 'diff' );
1012 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1013 $t = wfMsg( 'deletethispage' );
1015 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1022 function protectThisPage() {
1023 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1025 $diff = $wgRequest->getVal( 'diff' );
1026 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1027 if ( $wgTitle->isProtected() ) {
1028 $t = wfMsg( 'unprotectthispage' );
1029 $q = 'action=unprotect';
1031 $t = wfMsg( 'protectthispage' );
1032 $q = 'action=protect';
1034 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1041 function watchThisPage() {
1042 global $wgUser, $wgOut, $wgTitle;
1044 if ( $wgOut->isArticleRelated() ) {
1045 if ( $wgTitle->userIsWatching() ) {
1046 $t = wfMsg( 'unwatchthispage' );
1047 $q = 'action=unwatch';
1049 $t = wfMsg( 'watchthispage' );
1050 $q = 'action=watch';
1052 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1054 $s = wfMsg( 'notanarticle' );
1059 function moveThisPage() {
1062 if ( $wgTitle->userCanMove() ) {
1063 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1064 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1066 // no message if page is protected - would be redundant
1071 function historyLink() {
1074 return $this->makeKnownLinkObj( $wgTitle,
1075 wfMsg( 'history' ), 'action=history' );
1078 function whatLinksHere() {
1081 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1082 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1085 function userContribsLink() {
1088 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1089 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1092 function showEmailUser( $id ) {
1093 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1094 return $wgEnableEmail &&
1095 $wgEnableUserEmail &&
1096 $wgUser->isLoggedIn() && # show only to signed in users
1097 0 != $id; # we can only email to non-anons ..
1098 # '' != $id->getEmail() && # who must have an email address stored ..
1099 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1100 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1103 function emailUserLink() {
1106 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1107 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1110 function watchPageLinksLink() {
1111 global $wgOut, $wgTitle;
1113 if ( ! $wgOut->isArticleRelated() ) {
1114 return '(' . wfMsg( 'notanarticle' ) . ')';
1116 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1117 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1118 'target=' . $wgTitle->getPrefixedURL() );
1122 function otherLanguages() {
1123 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1125 if ( $wgHideInterlanguageLinks ) {
1129 $a = $wgOut->getLanguageLinks();
1130 if ( 0 == count( $a ) ) {
1134 $s = wfMsg( 'otherlanguages' ) . ': ';
1136 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1137 foreach( $a as $l ) {
1138 if ( ! $first ) { $s .= ' | '; }
1141 $nt = Title
::newFromText( $l );
1142 $url = $nt->escapeFullURL();
1143 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1145 if ( '' == $text ) { $text = $l; }
1146 $style = $this->getExternalLinkAttributes( $l, $text );
1147 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1149 if($wgContLang->isRTL()) $s .= '</span>';
1153 function bugReportsLink() {
1154 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1155 wfMsg( 'bugreports' ) );
1159 function dateLink() {
1160 global $wgLinkCache;
1161 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1162 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1164 $wgLinkCache->suspend();
1165 $id = $t1->getArticleID();
1166 $wgLinkCache->resume();
1169 $s = $this->makeBrokenLink( $t1->getText() );
1171 $s = $this->makeKnownLink( $t1->getText() );
1175 $wgLinkCache->suspend();
1176 $id = $t2->getArticleID();
1177 $wgLinkCache->resume();
1180 $s .= $this->makeBrokenLink( $t2->getText() );
1182 $s .= $this->makeKnownLink( $t2->getText() );
1187 function talkLink() {
1188 global $wgTitle, $wgLinkCache;
1190 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1191 # No discussion links for special pages
1195 if( $wgTitle->isTalkPage() ) {
1196 $link = $wgTitle->getSubjectPage();
1197 switch( $link->getNamespace() ) {
1199 $text = wfMsg('articlepage');
1202 $text = wfMsg('userpage');
1205 $text = wfMsg('wikipediapage');
1208 $text = wfMsg('imagepage');
1211 $text= wfMsg('articlepage');
1214 $link = $wgTitle->getTalkPage();
1215 $text = wfMsg( 'talkpage' );
1218 $wgLinkCache->suspend();
1219 $s = $this->makeLinkObj( $link, $text );
1220 $wgLinkCache->resume();
1225 function commentLink() {
1226 global $wgContLang, $wgTitle, $wgLinkCache;
1228 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1231 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1232 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1235 /* these are used extensively in SkinPHPTal, but also some other places */
1236 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1237 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1238 return $title->getLocalURL( $urlaction );
1241 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1242 $title = Title
::newFromText( wfMsgForContent($name) );
1243 $this->checkTitle($title, $name);
1244 return $title->getLocalURL( $urlaction );
1247 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1248 $title = Title
::newFromText( $name );
1249 $this->checkTitle($title, $name);
1250 return $title->getLocalURL( $urlaction );
1253 # If url string starts with http, consider as external URL, else
1255 /*static*/ function makeInternalOrExternalUrl( $name ) {
1256 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1259 return $this->makeUrl( $name );
1263 # this can be passed the NS number as defined in Language.php
1264 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1265 $title = Title
::makeTitleSafe( $namespace, $name );
1266 $this->checkTitle($title, $name);
1267 return $title->getLocalURL( $urlaction );
1270 /* these return an array with the 'href' and boolean 'exists' */
1271 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1272 $title = Title
::newFromText( $name );
1273 $this->checkTitle($title, $name);
1275 'href' => $title->getLocalURL( $urlaction ),
1276 'exists' => $title->getArticleID() != 0?
true:false
1280 # make sure we have some title to operate on
1281 /*static*/ function checkTitle ( &$title, &$name ) {
1282 if(!is_object($title)) {
1283 $title = Title
::newFromText( $name );
1284 if(!is_object($title)) {
1285 $title = Title
::newFromText( '--error: link target missing--' );
1291 * Build an array that represents the sidebar(s), the navigation bar among them
1296 function buildSidebar() {
1297 $fname = 'SkinTemplate::buildSidebar';
1298 wfProfileIn( $fname );
1301 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1302 foreach ($lines as $line) {
1303 if (strpos($line, '*') !== 0)
1305 if (strpos($line, '**') !== 0) {
1306 $line = trim($line, '* ');
1309 if (strpos($line, '|') !== false) { // sanity check
1310 $line = explode( '|' , trim($line, '* '), 2 );
1311 $link = wfMsgForContent( $line[0] );
1314 $bar[$heading][] = array(
1315 'text' => wfMsg( $line[1] ),
1316 'href' => $this->makeInternalOrExternalUrl( $link ),
1317 'id' => 'n-' . $line[1],
1319 } else { continue; }
1323 wfProfileOut( $fname );