3 * @defgroup Skins Skins
6 if ( ! defined( 'MEDIAWIKI' ) )
10 * The main skin class that provide methods and properties for all other skins.
11 * This base class is also the "Standard" skin.
13 * See docs/skin.txt for more information.
17 class Skin
extends Linker
{
21 var $mWatchLinkNum = 0; // Appended to end of watch link id's
22 // How many search boxes have we made? Avoid duplicate id's.
23 protected $searchboxes = '';
25 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
26 protected $skinname = 'standard';
27 // @fixme Should be protected :-\
30 /** Constructor, call parent constructor */
31 function Skin() { parent
::__construct(); }
34 * Fetch the set of available skins.
35 * @return array of strings
38 static function getSkinNames() {
39 global $wgValidSkinNames;
40 static $skinsInitialised = false;
41 if ( !$skinsInitialised ) {
42 # Get a list of available skins
43 # Build using the regular expression '^(.*).php$'
44 # Array keys are all lower case, array value keep the case used by filename
46 wfProfileIn( __METHOD__
. '-init' );
47 global $wgStyleDirectory;
48 $skinDir = dir( $wgStyleDirectory );
50 # while code from www.php.net
51 while( false !== ( $file = $skinDir->read() ) ) {
52 // Skip non-PHP files, hidden files, and '.dep' includes
54 if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
56 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
60 $skinsInitialised = true;
61 wfProfileOut( __METHOD__
. '-init' );
63 return $wgValidSkinNames;
67 * Fetch the list of usable skins in regards to $wgSkipSkins.
68 * Useful for Special:Preferences and other places where you
69 * only want to show skins users _can_ use.
70 * @return array of strings
72 public static function getUsableSkins() {
74 $usableSkins = self
::getSkinNames();
75 foreach ( $wgSkipSkins as $skip ) {
76 unset( $usableSkins[$skip] );
82 * Normalize a skin preference value to a form that can be loaded.
83 * If a skin can't be found, it will fall back to the configured
84 * default (or the old 'Classic' skin if that's broken).
89 static function normalizeKey( $key ) {
90 global $wgDefaultSkin;
91 $skinNames = Skin
::getSkinNames();
94 // Don't return the default immediately;
95 // in a misconfiguration we need to fall back.
96 $key = $wgDefaultSkin;
99 if( isset( $skinNames[$key] ) ) {
103 // Older versions of the software used a numeric setting
104 // in the user preferences.
108 2 => 'cologneblue' );
110 if( isset( $fallback[$key] ) ){
111 $key = $fallback[$key];
114 if( isset( $skinNames[$key] ) ) {
122 * Factory method for loading a skin of a given type
123 * @param string $key 'monobook', 'standard', etc
127 static function &newFromKey( $key ) {
128 global $wgStyleDirectory;
130 $key = Skin
::normalizeKey( $key );
132 $skinNames = Skin
::getSkinNames();
133 $skinName = $skinNames[$key];
134 $className = 'Skin'.ucfirst($key);
136 # Grab the skin class and initialise it.
137 if ( !class_exists( $className ) ) {
138 // Preload base classes to work around APC/PHP5 bug
139 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
140 if( file_exists( $deps ) ) include_once( $deps );
141 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
143 # Check if we got if not failback to default skin
144 if( !class_exists( $className ) ) {
145 # DO NOT die if the class isn't found. This breaks maintenance
146 # scripts and can cause a user account to be unrecoverable
147 # except by SQL manipulation if a previously valid skin name
148 # is no longer valid.
149 wfDebug( "Skin class does not exist: $className\n" );
150 $className = 'SkinMonobook';
151 require_once( "{$wgStyleDirectory}/MonoBook.php" );
154 $skin = new $className;
158 /** @return string path to the skin stylesheet */
159 function getStylesheet() {
160 return 'common/wikistandard.css';
163 /** @return string skin name */
164 public function getSkinName() {
165 return $this->skinname
;
168 function qbSetting() {
169 global $wgOut, $wgUser;
171 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
172 $q = $wgUser->getOption( 'quickbar', 0 );
176 function initPage( OutputPage
$out ) {
177 global $wgFavicon, $wgAppleTouchIcon;
179 wfProfileIn( __METHOD__
);
181 # Generally the order of the favicon and apple-touch-icon links
182 # should not matter, but Konqueror (3.5.9 at least) incorrectly
183 # uses whichever one appears later in the HTML source. Make sure
184 # apple-touch-icon is specified first to avoid this.
185 if( false !== $wgAppleTouchIcon ) {
186 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
189 if( false !== $wgFavicon ) {
190 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
193 # OpenSearch description link
194 $out->addLink( array(
196 'type' => 'application/opensearchdescription+xml',
197 'href' => wfScript( 'opensearch_desc' ),
198 'title' => wfMsgForContent( 'opensearch-desc' ),
201 $this->addMetadataLinks( $out );
203 $this->mRevisionId
= $out->mRevisionId
;
205 $this->preloadExistence();
207 wfProfileOut( __METHOD__
);
211 * Preload the existence of three commonly-requested pages in a single query
213 function preloadExistence() {
217 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
220 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
222 } elseif ( $this->mTitle
->isTalkPage() ) {
223 $titles[] = $this->mTitle
->getSubjectPage();
225 $titles[] = $this->mTitle
->getTalkPage();
228 $lb = new LinkBatch( $titles );
232 function addMetadataLinks( OutputPage
$out ) {
233 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
234 global $wgRightsPage, $wgRightsUrl;
236 if( $out->isArticleRelated() ) {
237 # note: buggy CC software only reads first "meta" link
238 if( $wgEnableCreativeCommonsRdf ) {
239 $out->addMetadataLink( array(
240 'title' => 'Creative Commons',
241 'type' => 'application/rdf+xml',
242 'href' => $this->mTitle
->getLocalURL( 'action=creativecommons' ) )
245 if( $wgEnableDublinCoreRdf ) {
246 $out->addMetadataLink( array(
247 'title' => 'Dublin Core',
248 'type' => 'application/rdf+xml',
249 'href' => $this->mTitle
->getLocalURL( 'action=dublincore' ) )
254 if( $wgRightsPage ) {
255 $copy = Title
::newFromText( $wgRightsPage );
257 $copyright = $copy->getLocalURL();
260 if( !$copyright && $wgRightsUrl ) {
261 $copyright = $wgRightsUrl;
264 $out->addLink( array(
265 'rel' => 'copyright',
266 'href' => $copyright )
272 * Set some local variables
274 protected function setMembers(){
276 $this->mUser
= $wgUser;
277 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
278 $this->usercss
= false;
283 * @param Title $t The title to use
285 public function setTitle( $t ) {
290 public function getTitle() {
291 return $this->mTitle
;
294 function outputPage( OutputPage
$out ) {
295 global $wgDebugComments;
296 wfProfileIn( __METHOD__
);
299 $this->initPage( $out );
301 // See self::afterContentHook() for documentation
302 $afterContent = $this->afterContentHook();
304 $out->out( $out->headElement( $this ) );
306 $out->out( "\n<body" );
307 $ops = $this->getBodyOptions();
308 foreach ( $ops as $name => $val ) {
309 $out->out( " $name='$val'" );
312 if ( $wgDebugComments ) {
313 $out->out( "<!-- Wiki debugging output:\n" .
314 $out->mDebugtext
. "-->\n" );
317 $out->out( $this->beforeContent() );
319 $out->out( $out->mBodytext
. "\n" );
321 $out->out( $this->afterContent() );
323 $out->out( $afterContent );
325 $out->out( $this->bottomScripts() );
327 $out->out( wfReportTime() );
329 $out->out( "\n</body></html>" );
330 wfProfileOut( __METHOD__
);
333 static function makeVariablesScript( $data ) {
336 foreach ( $data as $name => $value ) {
337 $encValue = Xml
::encodeJsVar( $value );
338 $r[] = "$name=$encValue";
340 $js = 'var ' . implode( ",\n", $r ) . ';';
341 return Html
::inlineScript( "\n$js\n" );
348 * Make a <script> tag containing global variables
349 * @param $skinName string Name of the skin
350 * The odd calling convention is for backwards compatibility
351 * @TODO @FIXME Make this not depend on $wgTitle!
353 static function makeGlobalVariablesScript( $skinName ) {
354 if ( is_array( $skinName ) ) {
355 # Weird back-compat stuff.
356 $skinName = $skinName['skinname'];
358 global $wgScript, $wgTitle, $wgStylePath, $wgUser;
359 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang, $wgVariant;
360 global $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
361 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
362 global $wgUseAjax, $wgAjaxWatch;
363 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
364 global $wgRestrictionTypes, $wgLivePreview;
365 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
367 $ns = $wgTitle->getNamespace();
368 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
369 $separatorTransTable = $wgContLang->separatorTransformTable();
370 $separatorTransTable = $separatorTransTable ?
$separatorTransTable : array();
371 $compactSeparatorTransTable = array(
372 implode( "\t", array_keys( $separatorTransTable ) ),
373 implode( "\t", $separatorTransTable ),
375 $digitTransTable = $wgContLang->digitTransformTable();
376 $digitTransTable = $digitTransTable ?
$digitTransTable : array();
377 $compactDigitTransTable = array(
378 implode( "\t", array_keys( $digitTransTable ) ),
379 implode( "\t", $digitTransTable ),
382 $mainPage = Title
::newFromText( wfMsgForContent( 'mainpage' ) );
385 'stylepath' => $wgStylePath,
386 'wgArticlePath' => $wgArticlePath,
387 'wgScriptPath' => $wgScriptPath,
388 'wgScript' => $wgScript,
389 'wgVariantArticlePath' => $wgVariantArticlePath,
390 'wgActionPaths' => (object)$wgActionPaths,
391 'wgServer' => $wgServer,
392 'wgCanonicalNamespace' => $nsname,
393 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
394 'wgNamespaceNumber' => $wgTitle->getNamespace(),
395 'wgPageName' => $wgTitle->getPrefixedDBKey(),
396 'wgTitle' => $wgTitle->getText(),
397 'wgAction' => $wgRequest->getText( 'action', 'view' ),
398 'wgArticleId' => $wgTitle->getArticleId(),
399 'wgIsArticle' => $wgOut->isArticle(),
400 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
401 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
402 'wgUserVariant' => $wgVariant->getCode(),
403 'wgUserLanguage' => $wgLang->getCode(),
404 'wgContentLanguage' => $wgContLang->getCode(),
405 'wgBreakFrames' => $wgBreakFrames,
406 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
407 'wgVersion' => $wgVersion,
408 'wgEnableAPI' => $wgEnableAPI,
409 'wgEnableWriteAPI' => $wgEnableWriteAPI,
410 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
411 'wgDigitTransformTable' => $compactDigitTransTable,
412 'wgMainPageTitle' => $mainPage ?
$mainPage->getPrefixedText() : null,
414 if ( !( $wgContLang->hasVariants() ) ) {
415 unset( $vars['wgUserVariant'] );
418 //if on upload page output the extension list & js_upload
419 if( SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) == "Upload" ){
420 global $wgFileExtensions, $wgAjaxUploadInterface;
421 $vars['wgFileExtensions'] = $wgFileExtensions;
422 $vars['wgAjaxUploadInterface'] = $wgAjaxUploadInterface;
425 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
426 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
427 $vars['wgDBname'] = $wgDBname;
428 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
429 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
432 foreach( $wgRestrictionTypes as $type )
433 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
435 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
436 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
437 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
438 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
439 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
442 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
443 $msgs = (object)array();
444 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
445 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
447 $vars['wgAjaxWatch'] = $msgs;
450 // Allow extensions to add their custom variables to the global JS variables
451 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
453 return self
::makeVariablesScript( $vars );
456 * Return a random selection of the scripts we want in the header,
457 * according to no particular rhyme or reason. Various other scripts are
458 * returned from a haphazard assortment of other functions scattered over
459 * various files. This entire hackish system needs to be burned to the
460 * ground and rebuilt.
462 * @param $out OutputPage object, should be $wgOut
464 * @return string Raw HTML to output to <head>
466 function getHeadScripts( OutputPage
$out ) {
467 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion, $wgOut;
470 $vars = self
::makeGlobalVariablesScript( $this->getSkinName() );
472 //moved wikibits to be called earlier on
473 //$out->addScriptFile( "{$wgStylePath}/common/wikibits.js" );
475 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
476 $wgOut->addScriptFile( self
::makeUrl( '-',
477 "action=raw$jsCache&gen=js&useskin=" .
478 urlencode( $this->getSkinName() )
482 if( $out->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
483 $userpage = $wgUser->getUserPage();
484 $userjs = self
::makeUrl(
485 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
486 'action=raw&ctype='.$wgJsMimeType );
487 $wgOut->addScriptFile( $userjs );
489 return $vars . "\n" . $out->mScripts
;
493 * To make it harder for someone to slip a user a fake
494 * user-JavaScript or user-CSS preview, a random token
495 * is associated with the login session. If it's not
496 * passed back with the preview request, we won't render
499 * @param string $action
503 function userCanPreview( $action ) {
504 global $wgRequest, $wgUser;
506 if( $action != 'submit' )
508 if( !$wgRequest->wasPosted() )
510 if( !$this->mTitle
->userCanEditCssSubpage() )
512 if( !$this->mTitle
->userCanEditJsSubpage() )
514 return $wgUser->matchEditToken(
515 $wgRequest->getVal( 'wpEditToken' ) );
519 * generated JavaScript action=raw&gen=js
520 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
521 * nated together. For some bizarre reason, it does *not* return any
522 * custom user JS from subpages. Huh?
524 * There's absolutely no reason to have separate Monobook/Common JSes.
525 * Any JS that cares can just check the skin variable generated at the
526 * top. For now Monobook.js will be maintained, but it should be consi-
529 * @param force_skin lets you override the skin name
533 public function generateUserJs( $skinName = null) {
536 wfProfileIn( __METHOD__
);
538 $skinName = $this->getSkinName();
541 $s = "/* generated javascript */\n";
542 $s .= "var skin = '" . Xml
::escapeJsString($skinName ) . "';\n";
543 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
544 $s .= "\n\n/* MediaWiki:Common.js */\n";
545 $commonJs = wfMsgForContent( 'common.js' );
546 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
550 $s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n";
551 // avoid inclusion of non defined user JavaScript (with custom skins only)
552 // by checking for default message content
553 $msgKey = ucfirst( $skinName ).'.js';
554 $userJS = wfMsgForContent( $msgKey );
555 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
559 wfProfileOut( __METHOD__
);
564 * Generate user stylesheet for action=raw&gen=css
566 public function generateUserStylesheet() {
567 wfProfileIn( __METHOD__
);
568 $s = "/* generated user stylesheet */\n" .
569 $this->reallyGenerateUserStylesheet();
570 wfProfileOut( __METHOD__
);
575 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
577 protected function reallyGenerateUserStylesheet(){
580 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
581 $underline = $undopt ?
'underline' : 'none';
582 $s .= "a { text-decoration: $underline; }\n";
584 if( $wgUser->getOption( 'highlightbroken' ) ) {
585 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
588 a.new, #quickbar a.new,
589 a.stub, #quickbar a.stub {
592 a.new:after, #quickbar a.new:after {
596 a.stub:after, #quickbar a.stub:after {
602 if( $wgUser->getOption( 'justify' ) ) {
603 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
605 if( !$wgUser->getOption( 'showtoc' ) ) {
606 $s .= "#toc { display: none; }\n";
608 if( !$wgUser->getOption( 'editsection' ) ) {
609 $s .= ".editsection { display: none; }\n";
611 $fontstyle = $wgUser->getOption( 'editfont' );
612 if ( $fontstyle !== 'default' ) {
613 $s .= "textarea { font-family: $fontstyle; }\n";
621 function setupUserCss( OutputPage
$out ) {
622 global $wgRequest, $wgContLang, $wgUser;
623 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
625 wfProfileIn( __METHOD__
);
627 $this->setupSkinUserCss( $out );
631 'maxage' => $wgSquidMaxage,
634 // Add any extension CSS
635 foreach ( $out->getExtStyle() as $url ) {
636 $out->addStyle( $url );
639 // If we use the site's dynamic CSS, throw that in, too
640 // Per-site custom styles
641 if( $wgUseSiteCss ) {
642 global $wgHandheldStyle;
643 $query = wfArrayToCGI( array(
644 'usemsgcache' => 'yes',
645 'ctype' => 'text/css',
646 'smaxage' => $wgSquidMaxage
648 # Site settings must override extension css! (bug 15025)
649 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
650 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
651 if( $wgHandheldStyle ) {
652 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
654 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
657 if( $wgUser->isLoggedIn() ) {
658 // Ensure that logged-in users' generated CSS isn't clobbered
659 // by anons' publicly cacheable generated CSS.
660 $siteargs['smaxage'] = '0';
661 $siteargs['ts'] = $wgUser->mTouched
;
663 // Per-user styles based on preferences
664 $siteargs['gen'] = 'css';
665 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
666 $siteargs['useskin'] = $us;
668 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
670 // Per-user custom style pages
671 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
672 $action = $wgRequest->getVal( 'action' );
673 # If we're previewing the CSS page, use it
674 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
675 $previewCss = $wgRequest->getText( 'wpTextbox1' );
676 // @FIXME: properly escape the cdata!
677 $this->usercss
= "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
679 $out->addStyle( self
::makeUrl( $this->userpage
. '/' . $this->getSkinName() .'.css',
680 'action=raw&ctype=text/css' ) );
684 wfProfileOut( __METHOD__
);
688 * Add skin specific stylesheets
689 * @param $out OutputPage
691 function setupSkinUserCss( OutputPage
$out ) {
692 $out->addStyle( 'common/shared.css' );
693 $out->addStyle( 'common/oldshared.css' );
694 $out->addStyle( $this->getStylesheet() );
695 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
698 function getBodyOptions() {
699 global $wgUser, $wgOut, $wgRequest, $wgContLang;
701 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
703 if ( 0 != $this->mTitle
->getNamespace() ) {
704 $a = array( 'bgcolor' => '#ffffec' );
706 else $a = array( 'bgcolor' => '#FFFFFF' );
707 if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
708 $this->mTitle
->quickUserCan( 'edit' ) ) {
709 $s = $this->mTitle
->getFullURL( $this->editUrlOptions() );
710 $s = 'document.location = "' .Xml
::escapeJsString( $s ) .'";';
711 $a +
= array( 'ondblclick' => $s );
713 $a['onload'] = $wgOut->getOnloadHandler();
716 ' '.( $wgContLang->getDir() ).
717 ' '.$this->getPageClasses( $this->mTitle
) .
718 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName() );
722 function getPageClasses( $title ) {
723 $numeric = 'ns-'.$title->getNamespace();
724 if( $title->getNamespace() == NS_SPECIAL
) {
725 $type = 'ns-special';
726 } elseif( $title->isTalkPage() ) {
729 $type = 'ns-subject';
731 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
732 return "$numeric $type $name";
744 * This will be called immediately after the <body> tag. Split into
745 * two functions to make it easier to subclass.
747 function beforeContent() {
748 return $this->doBeforeContent();
751 function doBeforeContent() {
753 wfProfileIn( __METHOD__
);
756 $qb = $this->qbSetting();
758 if( $langlinks = $this->otherLanguages() ) {
764 $borderhack = 'class="top"';
767 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
768 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
770 $shove = ( $qb != 0 );
771 $left = ( $qb == 1 ||
$qb == 3 );
772 if( $wgContLang->isRTL() ) $left = !$left;
775 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
776 $this->logoText() . '</td>';
778 $s .= $this->getQuickbarCompensator( $rows );
780 $l = $wgContLang->alignStart();
781 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
783 $s .= $this->topLinks();
784 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
786 $r = $wgContLang->alignEnd();
787 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
788 $s .= $this->nameAndLogin();
789 $s .= "\n<br />" . $this->searchForm() . "</td>";
792 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
795 if ( $shove && !$left ) { # Right
796 $s .= $this->getQuickbarCompensator( $rows );
798 $s .= "</tr>\n</table>\n</div>\n";
799 $s .= "\n<div id='article'>\n";
801 $notice = wfGetSiteNotice();
803 $s .= "\n<div id='siteNotice'>$notice</div>\n";
805 $s .= $this->pageTitle();
806 $s .= $this->pageSubtitle();
807 $s .= $this->getCategories();
808 wfProfileOut( __METHOD__
);
813 function getCategoryLinks() {
814 global $wgOut, $wgUseCategoryBrowser;
815 global $wgContLang, $wgUser;
817 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
820 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
822 // Use Unicode bidi embedding override characters,
823 // to make sure links don't smash each other up in ugly ways.
824 $dir = $wgContLang->getDir();
825 $embed = "<span dir='$dir'>";
828 $allCats = $wgOut->getCategoryLinks();
830 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
831 if ( !empty( $allCats['normal'] ) ) {
832 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
834 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
835 $s .= '<div id="mw-normal-catlinks">' .
836 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
837 . $colon . $t . '</div>';
841 if ( isset( $allCats['hidden'] ) ) {
842 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
843 $class ='mw-hidden-cats-user-shown';
844 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
845 $class = 'mw-hidden-cats-ns-shown';
847 $class = 'mw-hidden-cats-hidden';
849 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
850 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
851 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
855 # optional 'dmoz-like' category browser. Will be shown under the list
856 # of categories an article belong to
857 if( $wgUseCategoryBrowser ){
858 $s .= '<br /><hr />';
860 # get a big array of the parents tree
861 $parenttree = $this->mTitle
->getParentCategoryTree();
862 # Skin object passed by reference cause it can not be
863 # accessed under the method subfunction drawCategoryBrowser
864 $tempout = explode( "\n", Skin
::drawCategoryBrowser( $parenttree, $this ) );
865 # Clean out bogus first entry and sort them
866 unset( $tempout[0] );
868 # Output one per line
869 $s .= implode( "<br />\n", $tempout );
876 * Render the array as a serie of links.
877 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
878 * @param &skin Object: skin passed by reference
879 * @return String separated by >, terminate with "\n"
881 function drawCategoryBrowser( $tree, &$skin ){
883 foreach( $tree as $element => $parent ) {
884 if( empty( $parent ) ) {
885 # element start a new list
888 # grab the others elements
889 $return .= Skin
::drawCategoryBrowser( $parent, $skin ) . ' > ';
891 # add our current element to the list
892 $eltitle = Title
::newFromText( $element );
893 $return .= $skin->link( $eltitle, $eltitle->getText() );
898 function getCategories() {
899 $catlinks=$this->getCategoryLinks();
901 $classes = 'catlinks';
903 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false ) {
904 $classes .= ' catlinks-allhidden';
907 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
910 function getQuickbarCompensator( $rows = 1 ) {
911 return "<td width='152' rowspan='{$rows}'> </td>";
915 * This runs a hook to allow extensions placing their stuff after content
916 * and article metadata (e.g. categories).
917 * Note: This function has nothing to do with afterContent().
919 * This hook is placed here in order to allow using the same hook for all
920 * skins, both the SkinTemplate based ones and the older ones, which directly
921 * use this class to get their data.
923 * The output of this function gets processed in SkinTemplate::outputPage() for
924 * the SkinTemplate based skins, all other skins should directly echo it.
926 * Returns an empty string by default, if not changed by any hook function.
928 protected function afterContentHook() {
931 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
932 // adding just some spaces shouldn't toggle the output
933 // of the whole <div/>, so we use trim() here
934 if( trim( $data ) != '' ){
935 // Doing this here instead of in the skins to
936 // ensure that the div has the same ID in all
938 $data = "<div id='mw-data-after-content'>\n" .
943 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
950 * Generate debug data HTML for displaying at the bottom of the main content
952 * @return String HTML containing debug data, if enabled (otherwise empty).
954 protected function generateDebugHTML() {
955 global $wgShowDebug, $wgOut;
956 if ( $wgShowDebug ) {
957 $listInternals = str_replace( "\n", "</li>\n<li>", htmlspecialchars( $wgOut->mDebugtext
) );
958 return "\n<hr>\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\"><li>" .
959 $listInternals . "</li></ul>\n";
965 * This gets called shortly before the </body> tag.
966 * @return String HTML to be put before </body>
968 function afterContent() {
969 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
970 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
974 * This gets called shortly before the </body> tag.
975 * @return String HTML-wrapped JS code to be put before </body>
977 function bottomScripts() {
978 $bottomScriptText = "\n" . Html
::inlineScript( 'if (window.runOnloadHook) runOnloadHook();' ) . "\n";
979 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
980 return $bottomScriptText;
983 /** @return string Retrievied from HTML text */
984 function printSource() {
985 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
986 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
989 function printFooter() {
990 return "<p>" . $this->printSource() .
991 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
994 /** overloaded by derived classes */
995 function doAfterContent() { return '</div></div>'; }
997 function pageTitleLinks() {
998 global $wgOut, $wgUser, $wgRequest, $wgLang;
1000 $oldid = $wgRequest->getVal( 'oldid' );
1001 $diff = $wgRequest->getVal( 'diff' );
1002 $action = $wgRequest->getText( 'action' );
1004 $s[] = $this->printableLink();
1005 $disclaimer = $this->disclaimerLink(); # may be empty
1009 $privacy = $this->privacyLink(); # may be empty too
1014 if ( $wgOut->isArticleRelated() ) {
1015 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
1016 $name = $this->mTitle
->getDBkey();
1017 $image = wfFindFile( $this->mTitle
);
1019 $link = htmlspecialchars( $image->getURL() );
1020 $style = $this->getInternalLinkAttributes( $link, $name );
1021 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
1025 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
1026 $s[] .= $this->link(
1028 wfMsg( 'currentrev' ),
1031 array( 'known', 'noclasses' )
1035 if ( $wgUser->getNewtalk() ) {
1036 # do not show "You have new messages" text when we are viewing our
1038 if( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
1040 $wgUser->getTalkPage(),
1041 wfMsgHtml( 'newmessageslink' ),
1043 array( 'redirect' => 'no' ),
1044 array( 'known', 'noclasses' )
1048 $wgUser->getTalkPage(),
1049 wfMsgHtml( 'newmessagesdifflink' ),
1051 array( 'diff' => 'cur' ),
1052 array( 'known', 'noclasses' )
1054 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1056 $wgOut->setSquidMaxage( 0 );
1057 $wgOut->enableClientCache( false );
1061 $undelete = $this->getUndeleteLink();
1062 if( !empty( $undelete ) ) {
1065 return $wgLang->pipeList( $s );
1068 function getUndeleteLink() {
1069 global $wgUser, $wgContLang, $wgLang, $wgRequest;
1071 $action = $wgRequest->getVal( 'action', 'view' );
1073 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1074 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1075 $n = $this->mTitle
->isDeleted();
1077 if ( $wgUser->isAllowed( 'undelete' ) ) {
1078 $msg = 'thisisdeleted';
1080 $msg = 'viewdeleted';
1085 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1086 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1089 array( 'known', 'noclasses' )
1097 function printableLink() {
1098 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1102 if ( !$wgOut->isPrintable() ) {
1103 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1104 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1107 if( $wgOut->isSyndicated() ) {
1108 foreach( $wgFeedClasses as $format => $class ) {
1109 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1110 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1111 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1114 return $wgLang->pipeList( $s );
1117 function pageTitle() {
1119 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1123 function pageSubtitle() {
1126 $sub = $wgOut->getSubtitle();
1128 global $wgExtraSubtitle;
1129 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1131 $subpages = $this->subPageSubtitle();
1132 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1133 $s = "<p class='subtitle'>{$sub}</p>\n";
1137 function subPageSubtitle() {
1139 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
1143 if( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1144 $ptext = $this->mTitle
->getPrefixedText();
1145 if( preg_match( '/\//', $ptext ) ) {
1146 $links = explode( '/', $ptext );
1147 array_pop( $links );
1151 foreach( $links as $link ) {
1152 $growinglink .= $link;
1154 $linkObj = Title
::newFromText( $growinglink );
1155 if( is_object( $linkObj ) && $linkObj->exists() ){
1156 $getlink = $this->link(
1158 htmlspecialchars( $display ),
1161 array( 'known', 'noclasses' )
1165 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1167 $subpages .= '< ';
1169 $subpages .= $getlink;
1174 $growinglink .= '/';
1182 * Returns true if the IP should be shown in the header
1184 function showIPinHeader() {
1185 global $wgShowIPinHeader;
1186 return $wgShowIPinHeader && session_id() != '';
1189 function nameAndLogin() {
1190 global $wgUser, $wgLang, $wgContLang;
1192 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1195 if ( $wgUser->isAnon() ) {
1196 if( $this->showIPinHeader() ) {
1199 $talkLink = $this->link( $wgUser->getTalkPage(),
1200 $wgLang->getNsText( NS_TALK
) );
1202 $ret .= "$name ($talkLink)";
1204 $ret .= wfMsg( 'notloggedin' );
1207 $returnTo = $this->mTitle
->getPrefixedDBkey();
1209 if ( $logoutPage != $returnTo ) {
1210 $query['returnto'] = $returnTo;
1213 $loginlink = $wgUser->isAllowed( 'createaccount' )
1214 ?
'nav-login-createaccount'
1216 $ret .= "\n<br />" . $this->link(
1217 SpecialPage
::getTitleFor( 'Userlogin' ),
1218 wfMsg( $loginlink ), array(), $query
1221 $returnTo = $this->mTitle
->getPrefixedDBkey();
1222 $talkLink = $this->link( $wgUser->getTalkPage(),
1223 $wgLang->getNsText( NS_TALK
) );
1225 $ret .= $this->link( $wgUser->getUserPage(),
1226 htmlspecialchars( $wgUser->getName() ) );
1227 $ret .= " ($talkLink)<br />";
1228 $ret .= $wgLang->pipeList( array(
1230 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1231 array(), array( 'returnto' => $returnTo )
1233 $this->specialLink( 'preferences' ),
1236 $ret = $wgLang->pipeList( array(
1239 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1247 function getSearchLink() {
1248 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1249 return $searchPage->getLocalURL();
1252 function escapeSearchLink() {
1253 return htmlspecialchars( $this->getSearchLink() );
1256 function searchForm() {
1257 global $wgRequest, $wgUseTwoButtonsSearchForm;
1258 $search = $wgRequest->getText( 'search' );
1260 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1261 . $this->escapeSearchLink() . "\">\n"
1262 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1263 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1264 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1266 if( $wgUseTwoButtonsSearchForm )
1267 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1269 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1273 // Ensure unique id's for search boxes made after the first
1274 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1279 function topLinks() {
1283 $this->mainPageLink(),
1284 $this->specialLink( 'recentchanges' )
1287 if ( $wgOut->isArticleRelated() ) {
1288 $s[] = $this->editThisPage();
1289 $s[] = $this->historyLink();
1291 # Many people don't like this dropdown box
1292 #$s[] = $this->specialPagesList();
1294 if( $this->variantLinks() ) {
1295 $s[] = $this->variantLinks();
1298 if( $this->extensionTabLinks() ) {
1299 $s[] = $this->extensionTabLinks();
1302 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1303 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1307 * Compatibility for extensions adding functionality through tabs.
1308 * Eventually these old skins should be replaced with SkinTemplate-based
1312 function extensionTabLinks() {
1316 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1317 foreach( $tabs as $tab ) {
1318 $s[] = Xml
::element( 'a',
1319 array( 'href' => $tab['href'] ),
1326 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1327 $out .= $wgLang->pipeList( $s );
1334 * Language/charset variant links for classic-style skins
1337 function variantLinks() {
1339 /* show links to different language variants */
1340 global $wgDisableLangConversion, $wgLang, $wgContLang;
1341 $variants = $wgContLang->getVariants();
1342 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1343 foreach( $variants as $code ) {
1344 $varname = $wgContLang->getVariantname( $code );
1345 if( $varname == 'disable' )
1347 $s = $wgLang->pipeList( array(
1349 '<a href="' . $this->mTitle
->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1356 function bottomLinks() {
1357 global $wgOut, $wgUser, $wgUseTrackbacks;
1358 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1361 if ( $wgOut->isArticleRelated() ) {
1362 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1363 if ( $wgUser->isLoggedIn() ) {
1364 $element[] = $this->watchThisPage();
1366 $element[] = $this->talkLink();
1367 $element[] = $this->historyLink();
1368 $element[] = $this->whatLinksHere();
1369 $element[] = $this->watchPageLinksLink();
1371 if( $wgUseTrackbacks )
1372 $element[] = $this->trackbackLink();
1374 if ( $this->mTitle
->getNamespace() == NS_USER
1375 ||
$this->mTitle
->getNamespace() == NS_USER_TALK
){
1376 $id = User
::idFromName( $this->mTitle
->getText() );
1377 $ip = User
::isIP( $this->mTitle
->getText() );
1379 if( $id ||
$ip ) { # both anons and non-anons have contri list
1380 $element[] = $this->userContribsLink();
1382 if( $this->showEmailUser( $id ) ) {
1383 $element[] = $this->emailUserLink();
1387 $s = implode( $element, $sep );
1389 if ( $this->mTitle
->getArticleId() ) {
1391 if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1392 if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1393 if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
1395 $s .= "<br />\n" . $this->otherLanguages();
1401 function pageStats() {
1402 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1403 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1405 $oldid = $wgRequest->getVal( 'oldid' );
1406 $diff = $wgRequest->getVal( 'diff' );
1407 if ( ! $wgOut->isArticle() ) { return ''; }
1408 if( !$wgArticle instanceOf Article
) { return ''; }
1409 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1410 if ( 0 == $wgArticle->getID() ) { return ''; }
1413 if ( !$wgDisableCounters ) {
1414 $count = $wgLang->formatNum( $wgArticle->getCount() );
1416 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1420 if( $wgMaxCredits != 0 ){
1421 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1423 $s .= $this->lastModified();
1426 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1427 $dbr = wfGetDB( DB_SLAVE
);
1428 $res = $dbr->select( 'watchlist',
1429 array( 'COUNT(*) AS n' ),
1430 array( 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ), 'wl_namespace' => $this->mTitle
->getNamespace() ),
1433 $x = $dbr->fetchObject( $res );
1435 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1436 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1440 return $s . ' ' . $this->getCopyright();
1443 function getCopyright( $type = 'detect' ) {
1444 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1446 if ( $type == 'detect' ) {
1447 $diff = $wgRequest->getVal( 'diff' );
1448 $isCur = $wgArticle && $wgArticle->isCurrent();
1449 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1456 if ( $type == 'history' ) {
1457 $msg = 'history_copyright';
1463 if( $wgRightsPage ) {
1464 $title = Title
::newFromText( $wgRightsPage );
1465 $link = $this->linkKnown( $title, $wgRightsText );
1466 } elseif( $wgRightsUrl ) {
1467 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1468 } elseif( $wgRightsText ) {
1469 $link = $wgRightsText;
1474 // Allow for site and per-namespace customization of copyright notice.
1475 if( isset($wgArticle) )
1476 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
1478 $out .= wfMsgForContent( $msg, $link );
1482 function getCopyrightIcon() {
1483 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1485 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1486 $out = $wgCopyrightIcon;
1487 } else if ( $wgRightsIcon ) {
1488 $icon = htmlspecialchars( $wgRightsIcon );
1489 if ( $wgRightsUrl ) {
1490 $url = htmlspecialchars( $wgRightsUrl );
1491 $out .= '<a href="'.$url.'">';
1493 $text = htmlspecialchars( $wgRightsText );
1494 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1495 if ( $wgRightsUrl ) {
1502 function getPoweredBy() {
1503 global $wgStylePath;
1504 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1505 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1509 function lastModified() {
1510 global $wgLang, $wgArticle;
1511 if( $this->mRevisionId
) {
1512 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1514 $timestamp = $wgArticle->getTimestamp();
1517 $d = $wgLang->date( $timestamp, true );
1518 $t = $wgLang->time( $timestamp, true );
1519 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1523 if ( wfGetLB()->getLaggedSlaveMode() ) {
1524 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1529 function logoText( $align = '' ) {
1530 if ( '' != $align ) {
1531 $a = " align='{$align}'";
1536 $mp = wfMsg( 'mainpage' );
1537 $mptitle = Title
::newMainPage();
1538 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1540 $logourl = $this->getLogo();
1541 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1546 * show a drop-down box of special pages
1548 function specialPagesList() {
1549 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1550 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1551 foreach ( $pages as $name => $page ) {
1552 $pages[$name] = $page->getDescription();
1555 $go = wfMsg( 'go' );
1556 $sp = wfMsg( 'specialpages' );
1557 $spp = $wgContLang->specialPage( 'Specialpages' );
1559 $s = '<form id="specialpages" method="get" ' .
1560 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1561 $s .= "<select name=\"wpDropdown\">\n";
1562 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1565 foreach ( $pages as $name => $desc ) {
1566 $p = $wgContLang->specialPage( $name );
1567 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1569 $s .= "</select>\n";
1570 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1575 function mainPageLink() {
1577 Title
::newMainPage(),
1578 wfMsg( 'mainpage' ),
1581 array( 'known', 'noclasses' )
1586 private function footerLink ( $desc, $page ) {
1587 // if the link description has been set to "-" in the default language,
1588 if ( wfMsgForContent( $desc ) == '-') {
1589 // then it is disabled, for all languages.
1592 // Otherwise, we display the link for the user, described in their
1593 // language (which may or may not be the same as the default language),
1594 // but we make the link target be the one site-wide page.
1595 $title = Title
::newFromText( wfMsgForContent( $page ) );
1596 return $this->linkKnown(
1598 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1603 function privacyLink() {
1604 return $this->footerLink( 'privacy', 'privacypage' );
1607 function aboutLink() {
1608 return $this->footerLink( 'aboutsite', 'aboutpage' );
1611 function disclaimerLink() {
1612 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1615 function editThisPage() {
1618 if ( !$wgOut->isArticleRelated() ) {
1619 $s = wfMsg( 'protectedpage' );
1621 if( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1622 $t = wfMsg( 'editthispage' );
1623 } elseif( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1624 $t = wfMsg( 'create-this-page' );
1626 $t = wfMsg( 'viewsource' );
1633 $this->editUrlOptions(),
1634 array( 'known', 'noclasses' )
1641 * Return URL options for the 'edit page' link.
1642 * This may include an 'oldid' specifier, if the current page view is such.
1647 function editUrlOptions() {
1650 $options = array( 'action' => 'edit' );
1652 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1653 $options['oldid'] = intval( $this->mRevisionId
);
1659 function deleteThisPage() {
1660 global $wgUser, $wgRequest;
1662 $diff = $wgRequest->getVal( 'diff' );
1663 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1664 $t = wfMsg( 'deletethispage' );
1670 array( 'action' => 'delete' ),
1671 array( 'known', 'noclasses' )
1679 function protectThisPage() {
1680 global $wgUser, $wgRequest;
1682 $diff = $wgRequest->getVal( 'diff' );
1683 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1684 if ( $this->mTitle
->isProtected() ) {
1685 $text = wfMsg( 'unprotectthispage' );
1686 $query = array( 'action' => 'unprotect' );
1688 $text = wfMsg( 'protectthispage' );
1689 $query = array( 'action' => 'protect' );
1697 array( 'known', 'noclasses' )
1705 function watchThisPage() {
1707 ++
$this->mWatchLinkNum
;
1709 if ( $wgOut->isArticleRelated() ) {
1710 if ( $this->mTitle
->userIsWatching() ) {
1711 $text = wfMsg( 'unwatchthispage' );
1712 $query = array( 'action' => 'unwatch' );
1713 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1715 $text = wfMsg( 'watchthispage' );
1716 $query = array( 'action' => 'watch' );
1717 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1723 array( 'id' => $id ),
1725 array( 'known', 'noclasses' )
1728 $s = wfMsg( 'notanarticle' );
1733 function moveThisPage() {
1734 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1736 SpecialPage
::getTitleFor( 'Movepage' ),
1737 wfMsg( 'movethispage' ),
1739 array( 'target' => $this->mTitle
->getPrefixedDBkey() ),
1740 array( 'known', 'noclasses' )
1743 // no message if page is protected - would be redundant
1748 function historyLink() {
1751 wfMsgHtml( 'history' ),
1752 array( 'rel' => 'archives' ),
1753 array( 'action' => 'history' )
1757 function whatLinksHere() {
1759 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1760 wfMsgHtml( 'whatlinkshere' ),
1763 array( 'known', 'noclasses' )
1767 function userContribsLink() {
1769 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1770 wfMsgHtml( 'contributions' ),
1773 array( 'known', 'noclasses' )
1777 function showEmailUser( $id ) {
1779 $targetUser = User
::newFromId( $id );
1780 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1781 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1784 function emailUserLink() {
1786 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1787 wfMsg( 'emailuser' ),
1790 array( 'known', 'noclasses' )
1794 function watchPageLinksLink() {
1796 if ( ! $wgOut->isArticleRelated() ) {
1797 return '(' . wfMsg( 'notanarticle' ) . ')';
1800 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1801 wfMsg( 'recentchangeslinked-toolbox' ),
1804 array( 'known', 'noclasses' )
1809 function trackbackLink() {
1810 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1811 . wfMsg( 'trackbacklink' ) . '</a>';
1814 function otherLanguages() {
1815 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1817 if ( $wgHideInterlanguageLinks ) {
1821 $a = $wgOut->getLanguageLinks();
1822 if ( 0 == count( $a ) ) {
1826 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1828 if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
1829 foreach( $a as $l ) {
1831 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1835 $nt = Title
::newFromText( $l );
1836 $url = $nt->escapeFullURL();
1837 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1839 if ( '' == $text ) { $text = $l; }
1840 $style = $this->getExternalLinkAttributes();
1841 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1843 if( $wgContLang->isRTL() ) $s .= '</span>';
1847 function talkLink() {
1848 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1849 # No discussion links for special pages
1853 $linkOptions = array();
1855 if( $this->mTitle
->isTalkPage() ) {
1856 $link = $this->mTitle
->getSubjectPage();
1857 switch( $link->getNamespace() ) {
1859 $text = wfMsg( 'articlepage' );
1862 $text = wfMsg( 'userpage' );
1865 $text = wfMsg( 'projectpage' );
1868 $text = wfMsg( 'imagepage' );
1869 # Make link known if image exists, even if the desc. page doesn't.
1870 if( wfFindFile( $link ) )
1871 $linkOptions[] = 'known';
1874 $text = wfMsg( 'mediawikipage' );
1877 $text = wfMsg( 'templatepage' );
1880 $text = wfMsg( 'viewhelppage' );
1883 $text = wfMsg( 'categorypage' );
1886 $text = wfMsg( 'articlepage' );
1889 $link = $this->mTitle
->getTalkPage();
1890 $text = wfMsg( 'talkpage' );
1893 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1898 function commentLink() {
1901 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1905 # __NEWSECTIONLINK___ changes behaviour here
1906 # If it is present, the link points to this page, otherwise
1907 # it points to the talk page
1908 if( $this->mTitle
->isTalkPage() ) {
1909 $title = $this->mTitle
;
1910 } elseif( $wgOut->showNewSectionLink() ) {
1911 $title = $this->mTitle
;
1913 $title = $this->mTitle
->getTalkPage();
1918 wfMsg( 'postcomment' ),
1924 array( 'known', 'noclasses' )
1928 /* these are used extensively in SkinTemplate, but also some other places */
1929 static function makeMainPageUrl( $urlaction = '' ) {
1930 $title = Title
::newMainPage();
1931 self
::checkTitle( $title, '' );
1932 return $title->getLocalURL( $urlaction );
1935 static function makeSpecialUrl( $name, $urlaction = '' ) {
1936 $title = SpecialPage
::getTitleFor( $name );
1937 return $title->getLocalURL( $urlaction );
1940 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1941 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1942 return $title->getLocalURL( $urlaction );
1945 static function makeI18nUrl( $name, $urlaction = '' ) {
1946 $title = Title
::newFromText( wfMsgForContent( $name ) );
1947 self
::checkTitle( $title, $name );
1948 return $title->getLocalURL( $urlaction );
1951 static function makeUrl( $name, $urlaction = '' ) {
1952 $title = Title
::newFromText( $name );
1953 self
::checkTitle( $title, $name );
1954 return $title->getLocalURL( $urlaction );
1957 # If url string starts with http, consider as external URL, else
1959 static function makeInternalOrExternalUrl( $name ) {
1960 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1963 return self
::makeUrl( $name );
1967 # this can be passed the NS number as defined in Language.php
1968 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1969 $title = Title
::makeTitleSafe( $namespace, $name );
1970 self
::checkTitle( $title, $name );
1971 return $title->getLocalURL( $urlaction );
1974 /* these return an array with the 'href' and boolean 'exists' */
1975 static function makeUrlDetails( $name, $urlaction = '' ) {
1976 $title = Title
::newFromText( $name );
1977 self
::checkTitle( $title, $name );
1979 'href' => $title->getLocalURL( $urlaction ),
1980 'exists' => $title->getArticleID() != 0 ?
true : false
1985 * Make URL details where the article exists (or at least it's convenient to think so)
1987 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1988 $title = Title
::newFromText( $name );
1989 self
::checkTitle( $title, $name );
1991 'href' => $title->getLocalURL( $urlaction ),
1996 # make sure we have some title to operate on
1997 static function checkTitle( &$title, $name ) {
1998 if( !is_object( $title ) ) {
1999 $title = Title
::newFromText( $name );
2000 if( !is_object( $title ) ) {
2001 $title = Title
::newFromText( '--error: link target missing--' );
2007 * Build an array that represents the sidebar(s), the navigation bar among them
2011 function buildSidebar() {
2012 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2014 wfProfileIn( __METHOD__
);
2016 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2018 if ( $wgEnableSidebarCache ) {
2019 $cachedsidebar = $parserMemc->get( $key );
2020 if ( $cachedsidebar ) {
2021 wfProfileOut( __METHOD__
);
2022 return $cachedsidebar;
2027 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
2029 foreach( $lines as $line ) {
2030 if( strpos( $line, '*' ) !== 0 )
2032 if( strpos( $line, '**') !== 0 ) {
2033 $heading = trim( $line, '* ' );
2034 if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
2036 if( strpos( $line, '|' ) !== false ) { // sanity check
2037 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
2038 $link = wfMsgForContent( $line[0] );
2042 $text = wfMsgExt( $line[1], 'parsemag' );
2043 if( wfEmptyMsg( $line[1], $text ) )
2045 if( wfEmptyMsg( $line[0], $link ) )
2048 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2051 $title = Title
::newFromText( $link );
2053 $title = $title->fixSpecialName();
2054 $href = $title->getLocalURL();
2056 $href = 'INVALID-TITLE';
2060 $bar[$heading][] = array(
2063 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2066 } else { continue; }
2069 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2070 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2071 wfProfileOut( __METHOD__
);
2076 * Should we include common/wikiprintable.css? Skins that have their own
2077 * print stylesheet should override this and return false. (This is an
2078 * ugly hack to get Monobook to play nicely with
2079 * OutputPage::headElement().)
2083 public function commonPrintStylesheet() {