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 $this->mRevisionId
= $out->mRevisionId
;
108 wfProfileOut( $fname );
111 function addMetadataLinks( &$out ) {
112 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
113 global $wgRightsPage, $wgRightsUrl;
115 if( $out->isArticleRelated() ) {
116 # note: buggy CC software only reads first "meta" link
117 if( $wgEnableCreativeCommonsRdf ) {
118 $out->addMetadataLink( array(
119 'title' => 'Creative Commons',
120 'type' => 'application/rdf+xml',
121 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
123 if( $wgEnableDublinCoreRdf ) {
124 $out->addMetadataLink( array(
125 'title' => 'Dublin Core',
126 'type' => 'application/rdf+xml',
127 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
131 if( $wgRightsPage ) {
132 $copy = Title
::newFromText( $wgRightsPage );
134 $copyright = $copy->getLocalURL();
137 if( !$copyright && $wgRightsUrl ) {
138 $copyright = $wgRightsUrl;
141 $out->addLink( array(
142 'rel' => 'copyright',
143 'href' => $copyright ) );
147 function outputPage( &$out ) {
148 global $wgDebugComments;
150 wfProfileIn( 'Skin::outputPage' );
151 $this->initPage( $out );
153 $out->out( $out->headElement() );
155 $out->out( "\n<body" );
156 $ops = $this->getBodyOptions();
157 foreach ( $ops as $name => $val ) {
158 $out->out( " $name='$val'" );
161 if ( $wgDebugComments ) {
162 $out->out( "<!-- Wiki debugging output:\n" .
163 $out->mDebugtext
. "-->\n" );
166 $out->out( $this->beforeContent() );
168 $out->out( $out->mBodytext
. "\n" );
170 $out->out( $this->afterContent() );
173 $out->out( $out->reportTime() );
175 $out->out( "\n</body></html>" );
178 function getHeadScripts() {
179 global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType;
180 $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
181 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
182 $userpage = $wgUser->getUserPage();
183 $userjs = htmlspecialchars( $this->makeUrl(
184 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
185 'action=raw&ctype='.$wgJsMimeType));
186 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
192 * To make it harder for someone to slip a user a fake
193 * user-JavaScript or user-CSS preview, a random token
194 * is associated with the login session. If it's not
195 * passed back with the preview request, we won't render
198 * @param string $action
202 function userCanPreview( $action ) {
203 global $wgTitle, $wgRequest, $wgUser;
205 if( $action != 'submit' )
207 if( !$wgRequest->wasPosted() )
209 if( !$wgTitle->userCanEditCssJsSubpage() )
211 return $wgUser->matchEditToken(
212 $wgRequest->getVal( 'wpEditToken' ) );
215 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
216 function getUserStylesheet() {
217 global $wgOut, $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage;
218 $sheet = $this->getStylesheet();
219 $action = $wgRequest->getText('action');
220 $s = "@import \"$wgStylePath/$sheet\";\n";
221 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
223 $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
224 $s .= '@import "' . $this->makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
225 '@import "'.$this->makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
227 $s .= $this->doGetUserStyles();
232 * placeholder, returns generated js in monobook
234 function getUserJs() { return; }
237 * Return html code that include User stylesheets
239 function getUserStyles() {
240 global $wgOut, $wgStylePath;
241 $s = "<style type='text/css'>\n";
242 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
243 $s .= $this->getUserStylesheet();
244 $s .= "/*]]>*/ /* */\n";
250 * Some styles that are set by user through the user settings interface.
252 function doGetUserStyles() {
253 global $wgUser, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
257 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
258 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
259 $s .= $wgRequest->getText('wpTextbox1');
261 $userpage = $wgUser->getUserPage();
262 $s.= '@import "'.$this->makeUrl(
263 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
264 'action=raw&ctype=text/css').'";'."\n";
268 return $s . $this->reallyDoGetUserStyles();
271 function reallyDoGetUserStyles() {
274 if (($undopt = $wgUser->getOption("underline")) != 2) {
275 $underline = $undopt ?
'underline' : 'none';
276 $s .= "a { text-decoration: $underline; }\n";
278 if( $wgUser->getOption( 'highlightbroken' ) ) {
279 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
282 a.new, #quickbar a.new,
283 a.stub, #quickbar a.stub {
285 text-decoration: inherit;
287 a.new:after, #quickbar a.new:after {
290 text-decoration: $underline;
292 a.stub:after, #quickbar a.stub:after {
295 text-decoration: $underline;
299 if( $wgUser->getOption( 'justify' ) ) {
300 $s .= "#article, #bodyContent { text-align: justify; }\n";
302 if( !$wgUser->getOption( 'showtoc' ) ) {
303 $s .= "#toc { display: none; }\n";
305 if( !$wgUser->getOption( 'editsection' ) ) {
306 $s .= ".editsection { display: none; }\n";
311 function getBodyOptions() {
312 global $wgUser, $wgTitle, $wgOut, $wgRequest;
314 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
316 if ( 0 != $wgTitle->getNamespace() ) {
317 $a = array( 'bgcolor' => '#ffffec' );
319 else $a = array( 'bgcolor' => '#FFFFFF' );
320 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
321 $wgTitle->userCanEdit() ) {
322 $t = wfMsg( 'editthispage' );
323 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
324 $s = 'document.location = "' .wfEscapeJSString( $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, $wgUseCategoryMagic, $wgUseCategoryBrowser;
421 if( !$wgUseCategoryMagic ) return '' ;
422 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
424 // Use Unicode bidi embedding override characters,
425 // to make sure links don't smash each other up in ugly ways.
426 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
427 $embed = "<span dir='$dir'>";
429 $t = $embed . implode ( "$pop | $embed" , $wgOut->mCategoryLinks
) . $pop;
431 $msg = count( $wgOut->mCategoryLinks
) === 1 ?
'categories1' : 'categories';
432 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
433 wfMsg( $msg ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
436 # optional 'dmoz-like' category browser. Will be shown under the list
437 # of categories an article belong to
438 if($wgUseCategoryBrowser) {
439 $s .= '<br /><hr />';
441 # get a big array of the parents tree
442 $parenttree = $wgTitle->getParentCategoryTree();
443 # Skin object passed by reference cause it can not be
444 # accessed under the method subfunction drawCategoryBrowser
445 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
446 # Clean out bogus first entry and sort them
449 # Output one per line
450 $s .= implode("<br />\n", $tempout);
456 /** Render the array as a serie of links.
457 * @param array $tree Categories tree returned by Title::getParentCategoryTree
458 * @param object &skin Skin passed by reference
459 * @return string separated by >, terminate with "\n"
461 function drawCategoryBrowser($tree, &$skin) {
463 foreach ($tree as $element => $parent) {
464 if (empty($parent)) {
465 # element start a new list
468 # grab the others elements
469 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
471 # add our current element to the list
472 $eltitle = Title
::NewFromText($element);
473 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
478 function getCategories() {
479 $catlinks=$this->getCategoryLinks();
480 if(!empty($catlinks)) {
481 return "<p class='catlinks'>{$catlinks}</p>";
485 function getQuickbarCompensator( $rows = 1 ) {
486 return "<td width='152' rowspan='{$rows}'> </td>";
490 * This gets called immediately before the </body> tag.
491 * @return string HTML to be put after </body> ???
493 function afterContent() {
494 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
495 return $printfooter . $this->doAfterContent();
498 /** @return string Retrievied from HTML text */
499 function printSource() {
501 $url = htmlspecialchars( $wgTitle->getFullURL() );
502 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
505 function printFooter() {
506 return "<p>" . $this->printSource() .
507 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
510 /** overloaded by derived classes */
511 function doAfterContent() { }
513 function pageTitleLinks() {
514 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
516 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
517 $action = $wgRequest->getText( 'action' );
519 $s = $this->printableLink();
520 $disclaimer = $this->disclaimerLink(); # may be empty
522 $s .= ' | ' . $disclaimer;
524 $privacy = $this->privacyLink(); # may be empty too
526 $s .= ' | ' . $privacy;
529 if ( $wgOut->isArticleRelated() ) {
530 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
531 $name = $wgTitle->getDBkey();
532 $image = new Image( $wgTitle );
533 if( $image->exists() ) {
534 $link = htmlspecialchars( $image->getURL() );
535 $style = $this->getInternalLinkAttributes( $link, $name );
536 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
540 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
541 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
542 wfMsg( 'currentrev' ) );
545 if ( $wgUser->getNewtalk() ) {
546 # do not show "You have new messages" text when we are viewing our
549 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
550 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
551 wfMsg('newmessageslink') );
552 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
554 $wgOut->setSquidMaxage(0);
555 $wgOut->enableClientCache(false);
559 $undelete = $this->getUndeleteLink();
560 if( !empty( $undelete ) ) {
561 $s .= ' | '.$undelete;
566 function getUndeleteLink() {
567 global $wgUser, $wgTitle, $wgContLang, $action;
568 if( (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
569 ($n = $wgTitle->isDeleted() ) )
571 if ( $wgUser->isAllowed( 'delete' ) ) {
572 $msg = 'thisisdeleted';
574 $msg = 'viewdeleted';
577 $this->makeKnownLink(
578 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
579 wfMsg( 'restorelink' . ($n == 1 ?
'1' : ''), $n ) ) );
584 function printableLink() {
585 global $wgOut, $wgFeedClasses, $wgRequest;
587 $baseurl = $_SERVER['REQUEST_URI'];
588 if( strpos( '?', $baseurl ) == false ) {
593 $baseurl = htmlspecialchars( $baseurl );
594 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
596 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
597 if( $wgOut->isSyndicated() ) {
598 foreach( $wgFeedClasses as $format => $class ) {
599 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
600 $s .= " | <a href=\"$feedurl\">{$format}</a>";
606 function pageTitle() {
607 global $wgOut, $wgTitle, $wgUser;
609 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
613 function pageSubtitle() {
616 $sub = $wgOut->getSubtitle();
618 global $wgExtraSubtitle;
619 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
621 $subpages = $this->subPageSubtitle();
622 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
623 $s = "<p class='subtitle'>{$sub}</p>\n";
627 function subPageSubtitle() {
628 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
630 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
631 $ptext=$wgTitle->getPrefixedText();
632 if(preg_match('/\//',$ptext)) {
633 $links = explode('/',$ptext);
636 foreach($links as $link) {
638 if ($c<count($links)) {
639 $growinglink .= $link;
640 $getlink = $this->makeLink( $growinglink, $link );
641 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
645 $subpages .= '< ';
647 $subpages .= $getlink;
656 function nameAndLogin() {
657 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
659 $li = $wgContLang->specialPage( 'Userlogin' );
660 $lo = $wgContLang->specialPage( 'Userlogout' );
663 if ( $wgUser->isAnon() ) {
664 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
667 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
668 $wgLang->getNsText( NS_TALK
) );
670 $s .= $n . ' ('.$tl.')';
672 $s .= wfMsg('notloggedin');
675 $rt = $wgTitle->getPrefixedURL();
676 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
678 } else { $q = "returnto={$rt}"; }
680 $s .= "\n<br />" . $this->makeKnownLinkObj(
681 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
682 wfMsg( 'login' ), $q );
684 $n = $wgUser->getName();
685 $rt = $wgTitle->getPrefixedURL();
686 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
687 $wgLang->getNsText( NS_TALK
) );
691 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
692 $n ) . "{$tl}<br />" .
693 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
694 "returnto={$rt}" ) . ' | ' .
695 $this->specialLink( 'preferences' );
697 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
703 function getSearchLink() {
704 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
705 return $searchPage->getLocalURL();
708 function escapeSearchLink() {
709 return htmlspecialchars( $this->getSearchLink() );
712 function searchForm() {
714 $search = $wgRequest->getText( 'search' );
716 $s = '<form name="search" class="inline" method="post" action="'
717 . $this->escapeSearchLink() . "\">\n"
718 . '<input type="text" name="search" size="19" value="'
719 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
720 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
721 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
726 function topLinks() {
730 $s = $this->mainPageLink() . $sep
731 . $this->specialLink( 'recentchanges' );
733 if ( $wgOut->isArticleRelated() ) {
734 $s .= $sep . $this->editThisPage()
735 . $sep . $this->historyLink();
737 # Many people don't like this dropdown box
738 #$s .= $sep . $this->specialPagesList();
740 /* show links to different language variants */
741 global $wgDisableLangConversion, $wgContLang, $wgTitle;
742 $variants = $wgContLang->getVariants();
743 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
744 foreach( $variants as $code ) {
745 $varname = $wgContLang->getVariantname( $code );
746 if( $varname == 'disable' )
748 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
755 function bottomLinks() {
756 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
760 if ( $wgOut->isArticleRelated() ) {
761 $s .= '<strong>' . $this->editThisPage() . '</strong>';
762 if ( $wgUser->isLoggedIn() ) {
763 $s .= $sep . $this->watchThisPage();
765 $s .= $sep . $this->talkLink()
766 . $sep . $this->historyLink()
767 . $sep . $this->whatLinksHere()
768 . $sep . $this->watchPageLinksLink();
770 if ($wgUseTrackbacks)
771 $s .= $sep . $this->trackbackLink();
773 if ( $wgTitle->getNamespace() == NS_USER
774 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
777 $id=User
::idFromName($wgTitle->getText());
778 $ip=User
::isIP($wgTitle->getText());
780 if($id ||
$ip) { # both anons and non-anons have contri list
781 $s .= $sep . $this->userContribsLink();
783 if( $this->showEmailUser( $id ) ) {
784 $s .= $sep . $this->emailUserLink();
787 if ( $wgTitle->getArticleId() ) {
789 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
790 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
791 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
793 $s .= "<br />\n" . $this->otherLanguages();
798 function pageStats() {
799 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
800 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
802 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
803 if ( ! $wgOut->isArticle() ) { return ''; }
804 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
805 if ( 0 == $wgArticle->getID() ) { return ''; }
808 if ( !$wgDisableCounters ) {
809 $count = $wgLang->formatNum( $wgArticle->getCount() );
811 $s = wfMsg( 'viewcount', $count );
815 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
816 require_once('Credits.php');
817 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
819 $s .= $this->lastModified();
822 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
823 $dbr =& wfGetDB( DB_SLAVE
);
824 extract( $dbr->tableNames( 'watchlist' ) );
825 $sql = "SELECT COUNT(*) AS n FROM $watchlist
826 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
827 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
828 $res = $dbr->query( $sql, 'Skin::pageStats');
829 $x = $dbr->fetchObject( $res );
830 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
833 return $s . ' ' . $this->getCopyright();
836 function getCopyright() {
837 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
840 $oldid = $wgRequest->getVal( 'oldid' );
841 $diff = $wgRequest->getVal( 'diff' );
843 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
844 $msg = 'history_copyright';
850 if( $wgRightsPage ) {
851 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
852 } elseif( $wgRightsUrl ) {
853 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
858 $out .= wfMsgForContent( $msg, $link );
862 function getCopyrightIcon() {
863 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
865 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
866 $out = $wgCopyrightIcon;
867 } else if ( $wgRightsIcon ) {
868 $icon = htmlspecialchars( $wgRightsIcon );
869 if ( $wgRightsUrl ) {
870 $url = htmlspecialchars( $wgRightsUrl );
871 $out .= '<a href="'.$url.'">';
873 $text = htmlspecialchars( $wgRightsText );
874 $out .= "<img src=\"$icon\" alt='$text' />";
875 if ( $wgRightsUrl ) {
882 function getPoweredBy() {
884 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
885 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
889 function lastModified() {
890 global $wgLang, $wgArticle, $wgLoadBalancer;
892 $timestamp = $wgArticle->getTimestamp();
894 $d = $wgLang->timeanddate( $timestamp, true );
895 $s = ' ' . wfMsg( 'lastmodified', $d );
899 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
900 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
905 function logoText( $align = '' ) {
906 if ( '' != $align ) { $a = " align='{$align}'"; }
909 $mp = wfMsg( 'mainpage' );
910 $titleObj = Title
::newFromText( $mp );
911 if ( is_object( $titleObj ) ) {
912 $url = $titleObj->escapeLocalURL();
917 $logourl = $this->getLogo();
918 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
923 * show a drop-down box of special pages
924 * @TODO crash bug913. Need to be rewrote completly.
926 function specialPagesList() {
927 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
928 require_once('SpecialPage.php');
930 $pages = SpecialPage
::getPages();
932 // special pages without access restriction
933 foreach ( $pages[''] as $name => $page ) {
934 $a[$name] = $page->getDescription();
937 // Other special pages that are restricted.
938 // Copied from SpecialSpecialpages.php
939 foreach($wgAvailableRights as $right) {
940 if( $wgUser->isAllowed($right) ) {
941 /** Add all pages for this right */
942 if(isset($pages[$right])) {
943 foreach($pages[$right] as $name => $page) {
944 $a[$name] = $page->getDescription();
951 $sp = wfMsg( 'specialpages' );
952 $spp = $wgContLang->specialPage( 'Specialpages' );
954 $s = '<form id="specialpages" method="get" class="inline" ' .
955 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
956 $s .= "<select name=\"wpDropdown\">\n";
957 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
960 foreach ( $a as $name => $desc ) {
961 $p = $wgContLang->specialPage( $name );
962 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
965 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
970 function mainPageLink() {
971 $mp = wfMsgForContent( 'mainpage' );
972 $mptxt = wfMsg( 'mainpage');
973 $s = $this->makeKnownLink( $mp, $mptxt );
977 function copyrightLink() {
978 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
979 wfMsg( 'copyrightpagename' ) );
983 function privacyLink() {
984 $privacy = wfMsg( 'privacy' );
985 if ($privacy == '-') {
988 return $this->makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy);
992 function aboutLink() {
993 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
994 wfMsg( 'aboutsite' ) );
998 function disclaimerLink() {
999 $disclaimers = wfMsg( 'disclaimers' );
1000 if ($disclaimers == '-') {
1003 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
1008 function editThisPage() {
1009 global $wgOut, $wgTitle, $wgRequest;
1011 if ( ! $wgOut->isArticleRelated() ) {
1012 $s = wfMsg( 'protectedpage' );
1014 if ( $wgTitle->userCanEdit() ) {
1015 $t = wfMsg( 'editthispage' );
1017 $t = wfMsg( 'viewsource' );
1020 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1026 * Return URL options for the 'edit page' link.
1027 * This may include an 'oldid' specifier, if the current page view is such.
1032 function editUrlOptions() {
1035 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1036 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1038 return "action=edit";
1042 function deleteThisPage() {
1043 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1045 $diff = $wgRequest->getVal( 'diff' );
1046 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1047 $t = wfMsg( 'deletethispage' );
1049 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1056 function protectThisPage() {
1057 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1059 $diff = $wgRequest->getVal( 'diff' );
1060 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1061 if ( $wgTitle->isProtected() ) {
1062 $t = wfMsg( 'unprotectthispage' );
1063 $q = 'action=unprotect';
1065 $t = wfMsg( 'protectthispage' );
1066 $q = 'action=protect';
1068 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1075 function watchThisPage() {
1076 global $wgUser, $wgOut, $wgTitle;
1078 if ( $wgOut->isArticleRelated() ) {
1079 if ( $wgTitle->userIsWatching() ) {
1080 $t = wfMsg( 'unwatchthispage' );
1081 $q = 'action=unwatch';
1083 $t = wfMsg( 'watchthispage' );
1084 $q = 'action=watch';
1086 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1088 $s = wfMsg( 'notanarticle' );
1093 function moveThisPage() {
1096 if ( $wgTitle->userCanMove() ) {
1097 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1098 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1100 // no message if page is protected - would be redundant
1105 function historyLink() {
1108 return $this->makeKnownLinkObj( $wgTitle,
1109 wfMsg( 'history' ), 'action=history' );
1112 function whatLinksHere() {
1115 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1116 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1119 function userContribsLink() {
1122 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1123 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1126 function showEmailUser( $id ) {
1127 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1128 return $wgEnableEmail &&
1129 $wgEnableUserEmail &&
1130 $wgUser->isLoggedIn() && # show only to signed in users
1131 0 != $id; # we can only email to non-anons ..
1132 # '' != $id->getEmail() && # who must have an email address stored ..
1133 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1134 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1137 function emailUserLink() {
1140 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1141 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1144 function watchPageLinksLink() {
1145 global $wgOut, $wgTitle;
1147 if ( ! $wgOut->isArticleRelated() ) {
1148 return '(' . wfMsg( 'notanarticle' ) . ')';
1150 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1151 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1152 'target=' . $wgTitle->getPrefixedURL() );
1156 function trackbackLink() {
1159 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1160 . wfMsg('trackbacklink') . "</a>";
1163 function otherLanguages() {
1164 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1166 if ( $wgHideInterlanguageLinks ) {
1170 $a = $wgOut->getLanguageLinks();
1171 if ( 0 == count( $a ) ) {
1175 $s = wfMsg( 'otherlanguages' ) . ': ';
1177 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1178 foreach( $a as $l ) {
1179 if ( ! $first ) { $s .= ' | '; }
1182 $nt = Title
::newFromText( $l );
1183 $url = $nt->escapeFullURL();
1184 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1186 if ( '' == $text ) { $text = $l; }
1187 $style = $this->getExternalLinkAttributes( $l, $text );
1188 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1190 if($wgContLang->isRTL()) $s .= '</span>';
1194 function bugReportsLink() {
1195 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1196 wfMsg( 'bugreports' ) );
1200 function dateLink() {
1201 global $wgLinkCache;
1202 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1203 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1205 $wgLinkCache->suspend();
1206 $id = $t1->getArticleID();
1207 $wgLinkCache->resume();
1210 $s = $this->makeBrokenLink( $t1->getText() );
1212 $s = $this->makeKnownLink( $t1->getText() );
1216 $wgLinkCache->suspend();
1217 $id = $t2->getArticleID();
1218 $wgLinkCache->resume();
1221 $s .= $this->makeBrokenLink( $t2->getText() );
1223 $s .= $this->makeKnownLink( $t2->getText() );
1228 function talkLink() {
1229 global $wgTitle, $wgLinkCache;
1231 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1232 # No discussion links for special pages
1236 if( $wgTitle->isTalkPage() ) {
1237 $link = $wgTitle->getSubjectPage();
1238 switch( $link->getNamespace() ) {
1240 $text = wfMsg('articlepage');
1243 $text = wfMsg('userpage');
1246 $text = wfMsg('wikipediapage');
1249 $text = wfMsg('imagepage');
1252 $text= wfMsg('articlepage');
1255 $link = $wgTitle->getTalkPage();
1256 $text = wfMsg( 'talkpage' );
1259 $wgLinkCache->suspend();
1260 $s = $this->makeLinkObj( $link, $text );
1261 $wgLinkCache->resume();
1266 function commentLink() {
1267 global $wgContLang, $wgTitle, $wgLinkCache;
1269 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1272 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1273 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1276 /* these are used extensively in SkinPHPTal, but also some other places */
1277 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1278 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1279 return $title->getLocalURL( $urlaction );
1282 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1283 $title = Title
::newFromText( wfMsgForContent($name) );
1284 $this->checkTitle($title, $name);
1285 return $title->getLocalURL( $urlaction );
1288 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1289 $title = Title
::newFromText( $name );
1290 $this->checkTitle($title, $name);
1291 return $title->getLocalURL( $urlaction );
1294 # If url string starts with http, consider as external URL, else
1296 /*static*/ function makeInternalOrExternalUrl( $name ) {
1297 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1300 return $this->makeUrl( $name );
1304 # this can be passed the NS number as defined in Language.php
1305 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1306 $title = Title
::makeTitleSafe( $namespace, $name );
1307 $this->checkTitle($title, $name);
1308 return $title->getLocalURL( $urlaction );
1311 /* these return an array with the 'href' and boolean 'exists' */
1312 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1313 $title = Title
::newFromText( $name );
1314 $this->checkTitle($title, $name);
1316 'href' => $title->getLocalURL( $urlaction ),
1317 'exists' => $title->getArticleID() != 0?
true:false
1322 * Make URL details where the article exists (or at least it's convenient to think so)
1324 function makeKnownUrlDetails( $name, $urlaction='' ) {
1325 $title = Title
::newFromText( $name );
1326 $this->checkTitle($title, $name);
1328 'href' => $title->getLocalURL( $urlaction ),
1333 # make sure we have some title to operate on
1334 /*static*/ function checkTitle ( &$title, &$name ) {
1335 if(!is_object($title)) {
1336 $title = Title
::newFromText( $name );
1337 if(!is_object($title)) {
1338 $title = Title
::newFromText( '--error: link target missing--' );
1344 * Build an array that represents the sidebar(s), the navigation bar among them
1349 function buildSidebar() {
1350 global $wgTitle, $action;
1352 $fname = 'SkinTemplate::buildSidebar';
1353 $pageurl = $wgTitle->getLocalURL();
1354 wfProfileIn( $fname );
1357 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1358 foreach ($lines as $line) {
1359 if (strpos($line, '*') !== 0)
1361 if (strpos($line, '**') !== 0) {
1362 $line = trim($line, '* ');
1365 if (strpos($line, '|') !== false) { // sanity check
1366 $line = explode( '|' , trim($line, '* '), 2 );
1367 $link = wfMsgForContent( $line[0] );
1370 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1372 if (wfEmptyMsg($line[0], $link))
1374 $href = $this->makeInternalOrExternalUrl( $link );
1375 $bar[$heading][] = array(
1378 'id' => 'n-' . strtr($line[1], ' ', '-'),
1379 'active' => $pageurl == $href
1381 } else { continue; }
1385 wfProfileOut( $fname );