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?1'; }
84 /** @return string skin name */
85 function getSkinName() {
89 function qbSetting() {
90 global $wgOut, $wgUser;
92 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
93 $q = $wgUser->getOption( 'quickbar' );
94 if ( '' == $q ) { $q = 0; }
98 function initPage( &$out ) {
99 $fname = 'Skin::initPage';
100 wfProfileIn( $fname );
102 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
104 $this->addMetadataLinks($out);
106 wfProfileOut( $fname );
109 function addMetadataLinks( &$out ) {
110 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
111 global $wgRightsPage, $wgRightsUrl, $wgUseTrackbacks;
113 if( $out->isArticleRelated() ) {
114 # note: buggy CC software only reads first "meta" link
115 if( $wgEnableCreativeCommonsRdf ) {
116 $out->addMetadataLink( array(
117 'title' => 'Creative Commons',
118 'type' => 'application/rdf+xml',
119 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
121 if( $wgEnableDublinCoreRdf ) {
122 $out->addMetadataLink( array(
123 'title' => 'Dublin Core',
124 'type' => 'application/rdf+xml',
125 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
129 if( $wgRightsPage ) {
130 $copy = Title
::newFromText( $wgRightsPage );
132 $copyright = $copy->getLocalURL();
135 if( !$copyright && $wgRightsUrl ) {
136 $copyright = $wgRightsUrl;
139 $out->addLink( array(
140 'rel' => 'copyright',
141 'href' => $copyright ) );
145 function outputPage( &$out ) {
146 global $wgDebugComments;
148 wfProfileIn( 'Skin::outputPage' );
149 $this->initPage( $out );
151 $out->out( $out->headElement() );
153 $out->out( "\n<body" );
154 $ops = $this->getBodyOptions();
155 foreach ( $ops as $name => $val ) {
156 $out->out( " $name='$val'" );
159 if ( $wgDebugComments ) {
160 $out->out( "<!-- Wiki debugging output:\n" .
161 $out->mDebugtext
. "-->\n" );
164 $out->out( $this->beforeContent() );
166 $out->out( $out->mBodytext
. "\n" );
168 $out->out( $this->afterContent() );
171 $out->out( $out->reportTime() );
173 $out->out( "\n</body></html>" );
176 function getHeadScripts() {
177 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs, $wgJsMimeType;
178 $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
179 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
180 $userpage = $wgUser->getUserPage();
181 $userjs = htmlspecialchars( $this->makeUrl(
182 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
183 'action=raw&ctype='.$wgJsMimeType));
184 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
190 * To make it harder for someone to slip a user a fake
191 * user-JavaScript or user-CSS preview, a random token
192 * is associated with the login session. If it's not
193 * passed back with the preview request, we won't render
196 * @param string $action
200 function userCanPreview( $action ) {
201 global $wgTitle, $wgRequest, $wgUser;
203 if( $action != 'submit' )
205 if( !$wgRequest->wasPosted() )
207 if( !$wgTitle->userCanEditCssJsSubpage() )
209 return $wgUser->matchEditToken(
210 $wgRequest->getVal( 'wpEditToken' ) );
213 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
214 function getUserStylesheet() {
215 global $wgOut, $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage;
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";
221 $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
222 $s .= '@import "' . $this->makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
223 '@import "'.$this->makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
225 $s .= $this->doGetUserStyles();
230 * placeholder, returns generated js in monobook
232 function getUserJs() { return; }
235 * Return html code that include User stylesheets
237 function getUserStyles() {
238 global $wgOut, $wgStylePath, $wgLang;
239 $s = "<style type='text/css'>\n";
240 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
241 $s .= $this->getUserStylesheet();
242 $s .= "/*]]>*/ /* */\n";
248 * Some styles that are set by user through the user settings interface.
250 function doGetUserStyles() {
251 global $wgUser, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
255 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
256 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
257 $s .= $wgRequest->getText('wpTextbox1');
259 $userpage = $wgUser->getUserPage();
260 $s.= '@import "'.$this->makeUrl(
261 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
262 'action=raw&ctype=text/css').'";'."\n";
266 return $s . $this->reallyDoGetUserStyles();
269 function reallyDoGetUserStyles() {
272 if (($undopt = $wgUser->getOption("underline")) != 2) {
273 $underline = $undopt ?
'underline' : 'none';
274 $s .= "a { text-decoration: $underline; }\n";
276 if( $wgUser->getOption( 'highlightbroken' ) ) {
277 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
280 a.new, #quickbar a.new,
281 a.stub, #quickbar a.stub {
283 text-decoration: inherit;
285 a.new:after, #quickbar a.new:after {
288 text-decoration: $underline;
290 a.stub:after, #quickbar a.stub:after {
293 text-decoration: $underline;
297 if( $wgUser->getOption( 'justify' ) ) {
298 $s .= "#article, #bodyContent { text-align: justify; }\n";
300 if( !$wgUser->getOption( 'showtoc' ) ) {
301 $s .= "#toc { display: none; }\n";
303 if( !$wgUser->getOption( 'editsection' ) ) {
304 $s .= ".editsection { display: none; }\n";
309 function getBodyOptions() {
310 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
312 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
314 if ( 0 != $wgTitle->getNamespace() ) {
315 $a = array( 'bgcolor' => '#ffffec' );
317 else $a = array( 'bgcolor' => '#FFFFFF' );
318 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
319 $wgTitle->userCanEdit() ) {
320 $t = wfMsg( 'editthispage' );
322 if ( !empty($redirect) && $redirect == 'no' ) {
323 $red = "&redirect={$redirect}";
325 if ( !empty($oldid) && ! isset( $diff ) ) {
326 $oid = "&oldid=" . intval( $oldid );
328 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
329 $s = 'document.location = "' .$s .'";';
330 $a +
= array ('ondblclick' => $s);
333 $a['onload'] = $wgOut->getOnloadHandler();
334 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
335 if( $a['onload'] != '' ) {
338 $a['onload'] .= 'setupRightClickEdit()';
352 * This will be called immediately after the <body> tag. Split into
353 * two functions to make it easier to subclass.
355 function beforeContent() {
356 return $this->doBeforeContent();
359 function doBeforeContent() {
360 global $wgOut, $wgTitle, $wgContLang;
361 $fname = 'Skin::doBeforeContent';
362 wfProfileIn( $fname );
365 $qb = $this->qbSetting();
367 if( $langlinks = $this->otherLanguages() ) {
373 $borderhack = 'class="top"';
376 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
377 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
380 $left = ($qb == 1 ||
$qb == 3);
381 if($wgContLang->isRTL()) $left = !$left;
384 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
385 $this->logoText() . '</td>';
387 $s .= $this->getQuickbarCompensator( $rows );
389 $l = $wgContLang->isRTL() ?
'right' : 'left';
390 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
392 $s .= $this->topLinks() ;
393 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
395 $r = $wgContLang->isRTL() ?
"left" : "right";
396 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
397 $s .= $this->nameAndLogin();
398 $s .= "\n<br />" . $this->searchForm() . "</td>";
401 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
404 if ( $shove && !$left ) { # Right
405 $s .= $this->getQuickbarCompensator( $rows );
407 $s .= "</tr>\n</table>\n</div>\n";
408 $s .= "\n<div id='article'>\n";
410 $notice = wfGetSiteNotice();
412 $s .= "\n<div id='siteNotice'>$notice</div>\n";
414 $s .= $this->pageTitle();
415 $s .= $this->pageSubtitle() ;
416 $s .= $this->getCategories();
417 wfProfileOut( $fname );
422 function getCategoryLinks () {
423 global $wgOut, $wgTitle, $wgParser;
424 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgContLang;
426 if( !$wgUseCategoryMagic ) return '' ;
427 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
429 // Use Unicode bidi embedding override characters,
430 // to make sure links don't smash each other up in ugly ways.
431 $embed = "<span dir='" . ($wgContLang->isRTL() ?
'rtl' : 'ltr') . "'>";
433 $t = $embed . implode ( "$pop | $embed" , $wgOut->mCategoryLinks
) . $pop;
435 $msg = count( $wgOut->mCategoryLinks
) === 1 ?
'categories1' : 'categories';
436 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
437 wfMsg( $msg ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
440 # optional 'dmoz-like' category browser. Will be shown under the list
441 # of categories an article belong to
442 if($wgUseCategoryBrowser) {
443 $s .= '<br /><hr />';
445 # get a big array of the parents tree
446 $parenttree = $wgTitle->getParentCategoryTree();
447 # Skin object passed by reference cause it can not be
448 # accessed under the method subfunction drawCategoryBrowser
449 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
450 # Clean out bogus first entry and sort them
453 # Output one per line
454 $s .= implode("<br />\n", $tempout);
460 /** Render the array as a serie of links.
461 * @param array $tree Categories tree returned by Title::getParentCategoryTree
462 * @param object &skin Skin passed by reference
463 * @return string separated by >, terminate with "\n"
465 function drawCategoryBrowser($tree, &$skin) {
467 foreach ($tree as $element => $parent) {
468 if (empty($parent)) {
469 # element start a new list
472 # grab the others elements
473 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
475 # add our current element to the list
476 $eltitle = Title
::NewFromText($element);
477 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
482 function getCategories() {
483 $catlinks=$this->getCategoryLinks();
484 if(!empty($catlinks)) {
485 return "<p class='catlinks'>{$catlinks}</p>";
489 function getQuickbarCompensator( $rows = 1 ) {
490 return "<td width='152' rowspan='{$rows}'> </td>";
494 * This gets called immediately before the </body> tag.
495 * @return string HTML to be put after </body> ???
497 function afterContent() {
498 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
499 return $printfooter . $this->doAfterContent();
502 /** @return string Retrievied from HTML text */
503 function printSource() {
505 $url = htmlspecialchars( $wgTitle->getFullURL() );
506 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
509 function printFooter() {
510 return "<p>" . $this->printSource() .
511 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
514 /** overloaded by derived classes */
515 function doAfterContent() { }
517 function pageTitleLinks() {
518 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
520 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
521 $action = $wgRequest->getText( 'action' );
523 $s = $this->printableLink();
524 $disclaimer = $this->disclaimerLink(); # may be empty
526 $s .= ' | ' . $disclaimer;
528 $privacy = $this->privacyLink(); # may be empty too
530 $s .= ' | ' . $privacy;
533 if ( $wgOut->isArticleRelated() ) {
534 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
535 $name = $wgTitle->getDBkey();
536 $image = new Image( $wgTitle );
537 if( $image->exists() ) {
538 $link = htmlspecialchars( $image->getURL() );
539 $style = $this->getInternalLinkAttributes( $link, $name );
540 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
544 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
545 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
546 wfMsg( 'currentrev' ) );
549 if ( $wgUser->getNewtalk() ) {
550 # do not show "You have new messages" text when we are viewing our
553 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
554 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
555 wfMsg('newmessageslink') );
556 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
558 $wgOut->setSquidMaxage(0);
559 $wgOut->enableClientCache(false);
563 $undelete = $this->getUndeleteLink();
564 if( !empty( $undelete ) ) {
565 $s .= ' | '.$undelete;
570 function getUndeleteLink() {
571 global $wgUser, $wgTitle, $wgContLang, $action;
572 if( (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
573 ($n = $wgTitle->isDeleted() ) )
575 if ( $wgUser->isAllowed( 'delete' ) ) {
576 $msg = 'thisisdeleted';
578 $msg = 'viewdeleted';
581 $this->makeKnownLink(
582 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
583 wfMsg( 'restorelink' . ($n == 1 ?
'1' : ''), $n ) ) );
588 function printableLink() {
589 global $wgOut, $wgFeedClasses, $wgRequest;
591 $baseurl = $_SERVER['REQUEST_URI'];
592 if( strpos( '?', $baseurl ) == false ) {
597 $baseurl = htmlspecialchars( $baseurl );
598 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
600 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
601 if( $wgOut->isSyndicated() ) {
602 foreach( $wgFeedClasses as $format => $class ) {
603 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
604 $s .= " | <a href=\"$feedurl\">{$format}</a>";
610 function pageTitle() {
611 global $wgOut, $wgTitle, $wgUser;
613 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
617 function pageSubtitle() {
620 $sub = $wgOut->getSubtitle();
622 global $wgExtraSubtitle;
623 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
625 $subpages = $this->subPageSubtitle();
626 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
627 $s = "<p class='subtitle'>{$sub}</p>\n";
631 function subPageSubtitle() {
632 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
634 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
635 $ptext=$wgTitle->getPrefixedText();
636 if(preg_match('/\//',$ptext)) {
637 $links = explode('/',$ptext);
640 foreach($links as $link) {
642 if ($c<count($links)) {
643 $growinglink .= $link;
644 $getlink = $this->makeLink( $growinglink, $link );
645 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
649 $subpages .= '< ';
651 $subpages .= $getlink;
660 function nameAndLogin() {
661 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
663 $li = $wgContLang->specialPage( 'Userlogin' );
664 $lo = $wgContLang->specialPage( 'Userlogout' );
667 if ( $wgUser->isAnon() ) {
668 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
671 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
672 $wgLang->getNsText( NS_TALK
) );
674 $s .= $n . ' ('.$tl.')';
676 $s .= wfMsg('notloggedin');
679 $rt = $wgTitle->getPrefixedURL();
680 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
682 } else { $q = "returnto={$rt}"; }
684 $s .= "\n<br />" . $this->makeKnownLinkObj(
685 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
686 wfMsg( 'login' ), $q );
688 $n = $wgUser->getName();
689 $rt = $wgTitle->getPrefixedURL();
690 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
691 $wgLang->getNsText( NS_TALK
) );
695 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
696 $n ) . "{$tl}<br />" .
697 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
698 "returnto={$rt}" ) . ' | ' .
699 $this->specialLink( 'preferences' );
701 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
707 function getSearchLink() {
708 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
709 return $searchPage->getLocalURL();
712 function escapeSearchLink() {
713 return htmlspecialchars( $this->getSearchLink() );
716 function searchForm() {
718 $search = $wgRequest->getText( 'search' );
720 $s = '<form name="search" class="inline" method="post" action="'
721 . $this->escapeSearchLink() . "\">\n"
722 . '<input type="text" name="search" size="19" value="'
723 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
724 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
725 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
730 function topLinks() {
734 $s = $this->mainPageLink() . $sep
735 . $this->specialLink( 'recentchanges' );
737 if ( $wgOut->isArticleRelated() ) {
738 $s .= $sep . $this->editThisPage()
739 . $sep . $this->historyLink();
741 # Many people don't like this dropdown box
742 #$s .= $sep . $this->specialPagesList();
744 /* show links to different language variants */
745 global $wgDisableLangConversion, $wgContLang, $wgTitle;
746 $variants = $wgContLang->getVariants();
747 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
748 foreach( $variants as $code ) {
749 $varname = $wgContLang->getVariantname( $code );
750 if( $varname == 'disable' )
752 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
759 function bottomLinks() {
760 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
764 if ( $wgOut->isArticleRelated() ) {
765 $s .= '<strong>' . $this->editThisPage() . '</strong>';
766 if ( $wgUser->isLoggedIn() ) {
767 $s .= $sep . $this->watchThisPage();
769 $s .= $sep . $this->talkLink()
770 . $sep . $this->historyLink()
771 . $sep . $this->whatLinksHere()
772 . $sep . $this->watchPageLinksLink();
774 if ($wgUseTrackbacks)
775 $s .= $sep . $this->trackbackLink();
777 if ( $wgTitle->getNamespace() == NS_USER
778 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
781 $id=User
::idFromName($wgTitle->getText());
782 $ip=User
::isIP($wgTitle->getText());
784 if($id ||
$ip) { # both anons and non-anons have contri list
785 $s .= $sep . $this->userContribsLink();
787 if( $this->showEmailUser( $id ) ) {
788 $s .= $sep . $this->emailUserLink();
791 if ( $wgTitle->getArticleId() ) {
793 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
794 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
795 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
797 $s .= "<br />\n" . $this->otherLanguages();
802 function pageStats() {
803 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
804 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
806 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
807 if ( ! $wgOut->isArticle() ) { return ''; }
808 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
809 if ( 0 == $wgArticle->getID() ) { return ''; }
812 if ( !$wgDisableCounters ) {
813 $count = $wgLang->formatNum( $wgArticle->getCount() );
815 $s = wfMsg( 'viewcount', $count );
819 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
820 require_once('Credits.php');
821 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
823 $s .= $this->lastModified();
826 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
827 $dbr =& wfGetDB( DB_SLAVE
);
828 extract( $dbr->tableNames( 'watchlist' ) );
829 $sql = "SELECT COUNT(*) AS n FROM $watchlist
830 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
831 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
832 $res = $dbr->query( $sql, 'Skin::pageStats');
833 $x = $dbr->fetchObject( $res );
834 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
837 return $s . ' ' . $this->getCopyright();
840 function getCopyright() {
841 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
844 $oldid = $wgRequest->getVal( 'oldid' );
845 $diff = $wgRequest->getVal( 'diff' );
847 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
848 $msg = 'history_copyright';
854 if( $wgRightsPage ) {
855 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
856 } elseif( $wgRightsUrl ) {
857 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
862 $out .= wfMsgForContent( $msg, $link );
866 function getCopyrightIcon() {
867 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
869 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
870 $out = $wgCopyrightIcon;
871 } else if ( $wgRightsIcon ) {
872 $icon = htmlspecialchars( $wgRightsIcon );
873 if ( $wgRightsUrl ) {
874 $url = htmlspecialchars( $wgRightsUrl );
875 $out .= '<a href="'.$url.'">';
877 $text = htmlspecialchars( $wgRightsText );
878 $out .= "<img src=\"$icon\" alt='$text' />";
879 if ( $wgRightsUrl ) {
886 function getPoweredBy() {
888 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
889 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
893 function lastModified() {
894 global $wgLang, $wgArticle, $wgLoadBalancer;
896 $timestamp = $wgArticle->getTimestamp();
898 $d = $wgLang->timeanddate( $timestamp, true );
899 $s = ' ' . wfMsg( 'lastmodified', $d );
903 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
904 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
909 function logoText( $align = '' ) {
910 if ( '' != $align ) { $a = " align='{$align}'"; }
913 $mp = wfMsg( 'mainpage' );
914 $titleObj = Title
::newFromText( $mp );
915 if ( is_object( $titleObj ) ) {
916 $url = $titleObj->escapeLocalURL();
921 $logourl = $this->getLogo();
922 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
927 * show a drop-down box of special pages
928 * @TODO crash bug913. Need to be rewrote completly.
930 function specialPagesList() {
931 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
932 require_once('SpecialPage.php');
934 $pages = SpecialPage
::getPages();
936 // special pages without access restriction
937 foreach ( $pages[''] as $name => $page ) {
938 $a[$name] = $page->getDescription();
941 // Other special pages that are restricted.
942 // Copied from SpecialSpecialpages.php
943 foreach($wgAvailableRights as $right) {
944 if( $wgUser->isAllowed($right) ) {
945 /** Add all pages for this right */
946 if(isset($pages[$right])) {
947 foreach($pages[$right] as $name => $page) {
948 $a[$name] = $page->getDescription();
955 $sp = wfMsg( 'specialpages' );
956 $spp = $wgContLang->specialPage( 'Specialpages' );
958 $s = '<form id="specialpages" method="get" class="inline" ' .
959 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
960 $s .= "<select name=\"wpDropdown\">\n";
961 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
964 foreach ( $a as $name => $desc ) {
965 $p = $wgContLang->specialPage( $name );
966 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
969 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
974 function mainPageLink() {
975 $mp = wfMsgForContent( 'mainpage' );
976 $mptxt = wfMsg( 'mainpage');
977 $s = $this->makeKnownLink( $mp, $mptxt );
981 function copyrightLink() {
982 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
983 wfMsg( 'copyrightpagename' ) );
987 function privacyLink() {
988 $privacy = wfMsg( 'privacy' );
989 if ($privacy == '-') {
992 return $this->makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy);
996 function aboutLink() {
997 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
998 wfMsg( 'aboutsite' ) );
1002 function disclaimerLink() {
1003 $disclaimers = wfMsg( 'disclaimers' );
1004 if ($disclaimers == '-') {
1007 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
1012 function editThisPage() {
1013 global $wgOut, $wgTitle, $wgRequest;
1015 $oldid = $wgRequest->getVal( 'oldid' );
1016 $diff = $wgRequest->getVal( 'diff' );
1017 $redirect = $wgRequest->getVal( 'redirect' );
1019 if ( ! $wgOut->isArticleRelated() ) {
1020 $s = wfMsg( 'protectedpage' );
1022 if ( $wgTitle->userCanEdit() ) {
1023 $t = wfMsg( 'editthispage' );
1025 $t = wfMsg( 'viewsource' );
1029 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1030 if ( $oldid && ! isset( $diff ) ) {
1031 $oid = '&oldid='.$oldid;
1033 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1038 function deleteThisPage() {
1039 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1041 $diff = $wgRequest->getVal( 'diff' );
1042 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1043 $t = wfMsg( 'deletethispage' );
1045 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1052 function protectThisPage() {
1053 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1055 $diff = $wgRequest->getVal( 'diff' );
1056 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1057 if ( $wgTitle->isProtected() ) {
1058 $t = wfMsg( 'unprotectthispage' );
1059 $q = 'action=unprotect';
1061 $t = wfMsg( 'protectthispage' );
1062 $q = 'action=protect';
1064 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1071 function watchThisPage() {
1072 global $wgUser, $wgOut, $wgTitle;
1074 if ( $wgOut->isArticleRelated() ) {
1075 if ( $wgTitle->userIsWatching() ) {
1076 $t = wfMsg( 'unwatchthispage' );
1077 $q = 'action=unwatch';
1079 $t = wfMsg( 'watchthispage' );
1080 $q = 'action=watch';
1082 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1084 $s = wfMsg( 'notanarticle' );
1089 function moveThisPage() {
1092 if ( $wgTitle->userCanMove() ) {
1093 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1094 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1096 // no message if page is protected - would be redundant
1101 function historyLink() {
1104 return $this->makeKnownLinkObj( $wgTitle,
1105 wfMsg( 'history' ), 'action=history' );
1108 function whatLinksHere() {
1111 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1112 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1115 function userContribsLink() {
1118 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1119 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1122 function showEmailUser( $id ) {
1123 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1124 return $wgEnableEmail &&
1125 $wgEnableUserEmail &&
1126 $wgUser->isLoggedIn() && # show only to signed in users
1127 0 != $id; # we can only email to non-anons ..
1128 # '' != $id->getEmail() && # who must have an email address stored ..
1129 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1130 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1133 function emailUserLink() {
1136 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1137 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1140 function watchPageLinksLink() {
1141 global $wgOut, $wgTitle;
1143 if ( ! $wgOut->isArticleRelated() ) {
1144 return '(' . wfMsg( 'notanarticle' ) . ')';
1146 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1147 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1148 'target=' . $wgTitle->getPrefixedURL() );
1152 function trackbackLink() {
1155 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1156 . wfMsg('trackbacklink') . "</a>";
1159 function otherLanguages() {
1160 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1162 if ( $wgHideInterlanguageLinks ) {
1166 $a = $wgOut->getLanguageLinks();
1167 if ( 0 == count( $a ) ) {
1171 $s = wfMsg( 'otherlanguages' ) . ': ';
1173 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1174 foreach( $a as $l ) {
1175 if ( ! $first ) { $s .= ' | '; }
1178 $nt = Title
::newFromText( $l );
1179 $url = $nt->escapeFullURL();
1180 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1182 if ( '' == $text ) { $text = $l; }
1183 $style = $this->getExternalLinkAttributes( $l, $text );
1184 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1186 if($wgContLang->isRTL()) $s .= '</span>';
1190 function bugReportsLink() {
1191 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1192 wfMsg( 'bugreports' ) );
1196 function dateLink() {
1197 global $wgLinkCache;
1198 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1199 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1201 $wgLinkCache->suspend();
1202 $id = $t1->getArticleID();
1203 $wgLinkCache->resume();
1206 $s = $this->makeBrokenLink( $t1->getText() );
1208 $s = $this->makeKnownLink( $t1->getText() );
1212 $wgLinkCache->suspend();
1213 $id = $t2->getArticleID();
1214 $wgLinkCache->resume();
1217 $s .= $this->makeBrokenLink( $t2->getText() );
1219 $s .= $this->makeKnownLink( $t2->getText() );
1224 function talkLink() {
1225 global $wgTitle, $wgLinkCache;
1227 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1228 # No discussion links for special pages
1232 if( $wgTitle->isTalkPage() ) {
1233 $link = $wgTitle->getSubjectPage();
1234 switch( $link->getNamespace() ) {
1236 $text = wfMsg('articlepage');
1239 $text = wfMsg('userpage');
1242 $text = wfMsg('wikipediapage');
1245 $text = wfMsg('imagepage');
1248 $text= wfMsg('articlepage');
1251 $link = $wgTitle->getTalkPage();
1252 $text = wfMsg( 'talkpage' );
1255 $wgLinkCache->suspend();
1256 $s = $this->makeLinkObj( $link, $text );
1257 $wgLinkCache->resume();
1262 function commentLink() {
1263 global $wgContLang, $wgTitle, $wgLinkCache;
1265 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1268 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1269 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1272 /* these are used extensively in SkinPHPTal, but also some other places */
1273 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1274 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1275 return $title->getLocalURL( $urlaction );
1278 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1279 $title = Title
::newFromText( wfMsgForContent($name) );
1280 $this->checkTitle($title, $name);
1281 return $title->getLocalURL( $urlaction );
1284 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1285 $title = Title
::newFromText( $name );
1286 $this->checkTitle($title, $name);
1287 return $title->getLocalURL( $urlaction );
1290 # If url string starts with http, consider as external URL, else
1292 /*static*/ function makeInternalOrExternalUrl( $name ) {
1293 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1296 return $this->makeUrl( $name );
1300 # this can be passed the NS number as defined in Language.php
1301 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1302 $title = Title
::makeTitleSafe( $namespace, $name );
1303 $this->checkTitle($title, $name);
1304 return $title->getLocalURL( $urlaction );
1307 /* these return an array with the 'href' and boolean 'exists' */
1308 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1309 $title = Title
::newFromText( $name );
1310 $this->checkTitle($title, $name);
1312 'href' => $title->getLocalURL( $urlaction ),
1313 'exists' => $title->getArticleID() != 0?
true:false
1318 * Make URL details where the article exists (or at least it's convenient to think so)
1320 function makeKnownUrlDetails( $name, $urlaction='' ) {
1321 $title = Title
::newFromText( $name );
1322 $this->checkTitle($title, $name);
1324 'href' => $title->getLocalURL( $urlaction ),
1329 # make sure we have some title to operate on
1330 /*static*/ function checkTitle ( &$title, &$name ) {
1331 if(!is_object($title)) {
1332 $title = Title
::newFromText( $name );
1333 if(!is_object($title)) {
1334 $title = Title
::newFromText( '--error: link target missing--' );
1340 * Build an array that represents the sidebar(s), the navigation bar among them
1345 function buildSidebar() {
1346 global $wgTitle, $action;
1348 $fname = 'SkinTemplate::buildSidebar';
1349 $pageurl = $wgTitle->getLocalURL();
1350 wfProfileIn( $fname );
1353 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1354 foreach ($lines as $line) {
1355 if (strpos($line, '*') !== 0)
1357 if (strpos($line, '**') !== 0) {
1358 $line = trim($line, '* ');
1361 if (strpos($line, '|') !== false) { // sanity check
1362 $line = explode( '|' , trim($line, '* '), 2 );
1363 $link = wfMsgForContent( $line[0] );
1366 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1368 if (wfEmptyMsg($line[0], $link))
1370 $href = $this->makeInternalOrExternalUrl( $link );
1371 $bar[$heading][] = array(
1374 'id' => 'n-' . strtr($line[1], ' ', '-'),
1375 'active' => $pageurl == $href
1377 } else { continue; }
1381 wfProfileOut( $fname );