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 # Add favicons and Apple touch icons, if they're not the defaults
183 # Generally the order of the favicon and apple-touch-icon links
184 # should not matter, but Konqueror (3.5.9 at least) incorrectly
185 # uses whichever one appears later in the HTML source. Make sure
186 # apple-touch-icon is specified first to avoid this.
187 if( false !== $wgAppleTouchIcon && wfExpandUrl('/apple-touch-icon.png') != wfExpandUrl($wgAppleTouchIcon) ) {
188 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
191 if( false !== $wgFavicon && wfExpandUrl('/favicon.ico') != wfExpandUrl($wgFavicon) ) {
192 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
195 # OpenSearch description link
196 $out->addLink( array(
198 'type' => 'application/opensearchdescription+xml',
199 'href' => wfScript( 'opensearch_desc' ),
200 'title' => wfMsgForContent( 'opensearch-desc' ),
203 $this->addMetadataLinks( $out );
205 $this->mRevisionId
= $out->mRevisionId
;
207 $this->preloadExistence();
209 wfProfileOut( __METHOD__
);
213 * Preload the existence of three commonly-requested pages in a single query
215 function preloadExistence() {
219 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
222 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
224 } elseif ( $this->mTitle
->isTalkPage() ) {
225 $titles[] = $this->mTitle
->getSubjectPage();
227 $titles[] = $this->mTitle
->getTalkPage();
230 $lb = new LinkBatch( $titles );
234 function addMetadataLinks( OutputPage
$out ) {
235 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
236 global $wgRightsPage, $wgRightsUrl;
238 if( $out->isArticleRelated() ) {
239 # note: buggy CC software only reads first "meta" link
240 if( $wgEnableCreativeCommonsRdf ) {
241 $out->addMetadataLink( array(
242 'title' => 'Creative Commons',
243 'type' => 'application/rdf+xml',
244 'href' => $this->mTitle
->getLocalURL( 'action=creativecommons' ) )
247 if( $wgEnableDublinCoreRdf ) {
248 $out->addMetadataLink( array(
249 'title' => 'Dublin Core',
250 'type' => 'application/rdf+xml',
251 'href' => $this->mTitle
->getLocalURL( 'action=dublincore' ) )
256 if( $wgRightsPage ) {
257 $copy = Title
::newFromText( $wgRightsPage );
259 $copyright = $copy->getLocalURL();
262 if( !$copyright && $wgRightsUrl ) {
263 $copyright = $wgRightsUrl;
266 $out->addLink( array(
267 'rel' => 'copyright',
268 'href' => $copyright )
274 * Set some local variables
276 protected function setMembers(){
278 $this->mUser
= $wgUser;
279 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
280 $this->usercss
= false;
285 * @param Title $t The title to use
287 public function setTitle( $t ) {
292 public function getTitle() {
293 return $this->mTitle
;
296 function outputPage( OutputPage
$out ) {
297 global $wgDebugComments;
298 wfProfileIn( __METHOD__
);
301 $this->initPage( $out );
303 // See self::afterContentHook() for documentation
304 $afterContent = $this->afterContentHook();
306 $out->out( $out->headElement( $this ) );
308 $out->out( "\n<body" );
309 $ops = $this->getBodyOptions();
310 foreach ( $ops as $name => $val ) {
311 $out->out( " $name='$val'" );
314 if ( $wgDebugComments ) {
315 $out->out( "<!-- Wiki debugging output:\n" .
316 $out->mDebugtext
. "-->\n" );
319 $out->out( $this->beforeContent() );
321 $out->out( $out->mBodytext
. "\n" );
323 $out->out( $this->afterContent() );
325 $out->out( $afterContent );
327 $out->out( $this->bottomScripts() );
329 $out->out( wfReportTime() );
331 $out->out( "\n</body></html>" );
332 wfProfileOut( __METHOD__
);
335 static function makeVariablesScript( $data ) {
337 foreach ( $data as $name => $value ) {
338 $encValue = Xml
::encodeJsVar( $value );
339 $r[] = "var $name = $encValue;";
341 return Html
::inlineScript( "\n\t\t" . implode( "\n\t\t", $r ) .
346 * Make a <script> tag containing global variables
347 * @param $skinName string Name of the skin
348 * The odd calling convention is for backwards compatibility
349 * @TODO @FIXME Make this not depend on $wgTitle!
351 static function makeGlobalVariablesScript( $skinName ) {
352 if ( is_array( $skinName ) ) {
353 # Weird back-compat stuff.
354 $skinName = $skinName['skinname'];
356 global $wgScript, $wgTitle, $wgStylePath, $wgUser;
357 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang, $wgVariant;
358 global $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
359 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
360 global $wgUseAjax, $wgAjaxWatch;
361 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
362 global $wgRestrictionTypes, $wgLivePreview;
363 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
365 $ns = $wgTitle->getNamespace();
366 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
367 $separatorTransTable = $wgContLang->separatorTransformTable();
368 $separatorTransTable = $separatorTransTable ?
$separatorTransTable : array();
369 $compactSeparatorTransTable = array(
370 implode( "\t", array_keys( $separatorTransTable ) ),
371 implode( "\t", $separatorTransTable ),
373 $digitTransTable = $wgContLang->digitTransformTable();
374 $digitTransTable = $digitTransTable ?
$digitTransTable : array();
375 $compactDigitTransTable = array(
376 implode( "\t", array_keys( $digitTransTable ) ),
377 implode( "\t", $digitTransTable ),
380 $mainPage = Title
::newFromText( wfMsgForContent( 'mainpage' ) );
383 'stylepath' => $wgStylePath,
384 'wgArticlePath' => $wgArticlePath,
385 'wgScriptPath' => $wgScriptPath,
386 'wgScript' => $wgScript,
387 'wgVariantArticlePath' => $wgVariantArticlePath,
388 'wgActionPaths' => (object)$wgActionPaths,
389 'wgServer' => $wgServer,
390 'wgCanonicalNamespace' => $nsname,
391 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
392 'wgNamespaceNumber' => $wgTitle->getNamespace(),
393 'wgPageName' => $wgTitle->getPrefixedDBKey(),
394 'wgTitle' => $wgTitle->getText(),
395 'wgAction' => $wgRequest->getText( 'action', 'view' ),
396 'wgArticleId' => $wgTitle->getArticleId(),
397 'wgIsArticle' => $wgOut->isArticle(),
398 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
399 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
400 'wgUserVariant' => $wgVariant->getCode(),
401 'wgUserLanguage' => $wgLang->getCode(),
402 'wgContentLanguage' => $wgContLang->getCode(),
403 'wgBreakFrames' => $wgBreakFrames,
404 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
405 'wgVersion' => $wgVersion,
406 'wgEnableAPI' => $wgEnableAPI,
407 'wgEnableWriteAPI' => $wgEnableWriteAPI,
408 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
409 'wgDigitTransformTable' => $compactDigitTransTable,
410 'wgMainPageTitle' => $mainPage ?
$mainPage->getPrefixedText() : null,
412 if ( !( $wgContLang->hasVariants() ) ) {
413 unset( $vars['wgUserVariant'] );
416 //if on upload page output the extension list & js_upload
417 if( SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) == "Upload" ){
418 global $wgFileExtensions, $wgAjaxUploadInterface;
419 $vars['wgFileExtensions'] = $wgFileExtensions;
420 $vars['wgAjaxUploadInterface'] = $wgAjaxUploadInterface;
423 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
424 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
425 $vars['wgDBname'] = $wgDBname;
426 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
427 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
430 foreach( $wgRestrictionTypes as $type )
431 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
433 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
434 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
435 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
436 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
437 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
440 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
441 $msgs = (object)array();
442 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
443 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
445 $vars['wgAjaxWatch'] = $msgs;
448 // Allow extensions to add their custom variables to the global JS variables
449 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
451 return self
::makeVariablesScript( $vars );
454 * Return a random selection of the scripts we want in the header,
455 * according to no particular rhyme or reason. Various other scripts are
456 * returned from a haphazard assortment of other functions scattered over
457 * various files. This entire hackish system needs to be burned to the
458 * ground and rebuilt.
460 * @param $out OutputPage object, should be $wgOut
462 * @return string Raw HTML to output to <head>
464 function getHeadScripts( OutputPage
$out ) {
465 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion, $wgOut;
468 $vars = self
::makeGlobalVariablesScript( $this->getSkinName() );
470 //moved wikibits to be called earlier on
471 //$out->addScriptFile( "{$wgStylePath}/common/wikibits.js" );
473 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
474 $wgOut->addScriptFile( self
::makeUrl( '-',
475 "action=raw$jsCache&gen=js&useskin=" .
476 urlencode( $this->getSkinName() )
480 if( $out->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
481 $userpage = $wgUser->getUserPage();
482 $userjs = self
::makeUrl(
483 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
484 'action=raw&ctype='.$wgJsMimeType );
485 $wgOut->addScriptFile( $userjs );
487 return "\t" . $vars . "\t" . $out->mScripts
;
491 * To make it harder for someone to slip a user a fake
492 * user-JavaScript or user-CSS preview, a random token
493 * is associated with the login session. If it's not
494 * passed back with the preview request, we won't render
497 * @param string $action
501 function userCanPreview( $action ) {
502 global $wgRequest, $wgUser;
504 if( $action != 'submit' )
506 if( !$wgRequest->wasPosted() )
508 if( !$this->mTitle
->userCanEditCssSubpage() )
510 if( !$this->mTitle
->userCanEditJsSubpage() )
512 return $wgUser->matchEditToken(
513 $wgRequest->getVal( 'wpEditToken' ) );
517 * generated JavaScript action=raw&gen=js
518 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
519 * nated together. For some bizarre reason, it does *not* return any
520 * custom user JS from subpages. Huh?
522 * There's absolutely no reason to have separate Monobook/Common JSes.
523 * Any JS that cares can just check the skin variable generated at the
524 * top. For now Monobook.js will be maintained, but it should be consi-
527 * @param force_skin lets you override the skin name
531 public function generateUserJs( $skinName = null) {
534 wfProfileIn( __METHOD__
);
536 $skinName = $this->getSkinName();
539 $s = "/* generated javascript */\n";
540 $s .= "var skin = '" . Xml
::escapeJsString($skinName ) . "';\n";
541 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
542 $s .= "\n\n/* MediaWiki:Common.js */\n";
543 $commonJs = wfMsgForContent( 'common.js' );
544 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
548 $s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n";
549 // avoid inclusion of non defined user JavaScript (with custom skins only)
550 // by checking for default message content
551 $msgKey = ucfirst( $skinName ).'.js';
552 $userJS = wfMsgForContent( $msgKey );
553 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
557 wfProfileOut( __METHOD__
);
562 * Generate user stylesheet for action=raw&gen=css
564 public function generateUserStylesheet() {
565 wfProfileIn( __METHOD__
);
566 $s = "/* generated user stylesheet */\n" .
567 $this->reallyGenerateUserStylesheet();
568 wfProfileOut( __METHOD__
);
573 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
575 protected function reallyGenerateUserStylesheet(){
578 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
579 $underline = $undopt ?
'underline' : 'none';
580 $s .= "a { text-decoration: $underline; }\n";
582 if( $wgUser->getOption( 'highlightbroken' ) ) {
583 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
586 a.new, #quickbar a.new,
587 a.stub, #quickbar a.stub {
590 a.new:after, #quickbar a.new:after {
594 a.stub:after, #quickbar a.stub:after {
600 if( $wgUser->getOption( 'justify' ) ) {
601 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
603 if( !$wgUser->getOption( 'showtoc' ) ) {
604 $s .= "#toc { display: none; }\n";
606 if( !$wgUser->getOption( 'editsection' ) ) {
607 $s .= ".editsection { display: none; }\n";
609 $fontstyle = $wgUser->getOption( 'editfont' );
610 if ( $fontstyle !== 'default' ) {
611 $s .= "textarea { font-family: $fontstyle; }\n";
619 function setupUserCss( OutputPage
$out ) {
620 global $wgRequest, $wgContLang, $wgUser;
621 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
623 wfProfileIn( __METHOD__
);
625 $this->setupSkinUserCss( $out );
629 'maxage' => $wgSquidMaxage,
632 // Add any extension CSS
633 foreach ( $out->getExtStyle() as $url ) {
634 $out->addStyle( $url );
637 // If we use the site's dynamic CSS, throw that in, too
638 // Per-site custom styles
639 if( $wgUseSiteCss ) {
640 global $wgHandheldStyle;
641 $query = wfArrayToCGI( array(
642 'usemsgcache' => 'yes',
643 'ctype' => 'text/css',
644 'smaxage' => $wgSquidMaxage
646 # Site settings must override extension css! (bug 15025)
647 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
648 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
649 if( $wgHandheldStyle ) {
650 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
652 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
655 if( $wgUser->isLoggedIn() ) {
656 // Ensure that logged-in users' generated CSS isn't clobbered
657 // by anons' publicly cacheable generated CSS.
658 $siteargs['smaxage'] = '0';
659 $siteargs['ts'] = $wgUser->mTouched
;
661 // Per-user styles based on preferences
662 $siteargs['gen'] = 'css';
663 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
664 $siteargs['useskin'] = $us;
666 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
668 // Per-user custom style pages
669 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
670 $action = $wgRequest->getVal( 'action' );
671 # If we're previewing the CSS page, use it
672 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
673 $previewCss = $wgRequest->getText( 'wpTextbox1' );
674 // @FIXME: properly escape the cdata!
675 $this->usercss
= "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
677 $out->addStyle( self
::makeUrl( $this->userpage
. '/' . $this->getSkinName() .'.css',
678 'action=raw&ctype=text/css' ) );
682 wfProfileOut( __METHOD__
);
686 * Add skin specific stylesheets
687 * @param $out OutputPage
689 function setupSkinUserCss( OutputPage
$out ) {
690 $out->addStyle( 'common/shared.css' );
691 $out->addStyle( 'common/oldshared.css' );
692 $out->addStyle( $this->getStylesheet() );
693 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
696 function getBodyOptions() {
697 global $wgUser, $wgOut, $wgRequest, $wgContLang;
699 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
701 if ( 0 != $this->mTitle
->getNamespace() ) {
702 $a = array( 'bgcolor' => '#ffffec' );
704 else $a = array( 'bgcolor' => '#FFFFFF' );
705 if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
706 $this->mTitle
->quickUserCan( 'edit' ) ) {
707 $s = $this->mTitle
->getFullURL( $this->editUrlOptions() );
708 $s = 'document.location = "' .Xml
::escapeJsString( $s ) .'";';
709 $a +
= array( 'ondblclick' => $s );
711 $a['onload'] = $wgOut->getOnloadHandler();
714 ' '.( $wgContLang->getDir() ).
715 ' '.$this->getPageClasses( $this->mTitle
) .
716 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName() );
720 function getPageClasses( $title ) {
721 $numeric = 'ns-'.$title->getNamespace();
722 if( $title->getNamespace() == NS_SPECIAL
) {
723 $type = 'ns-special';
724 } elseif( $title->isTalkPage() ) {
727 $type = 'ns-subject';
729 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
730 return "$numeric $type $name";
742 * This will be called immediately after the <body> tag. Split into
743 * two functions to make it easier to subclass.
745 function beforeContent() {
746 return $this->doBeforeContent();
749 function doBeforeContent() {
751 wfProfileIn( __METHOD__
);
754 $qb = $this->qbSetting();
756 if( $langlinks = $this->otherLanguages() ) {
762 $borderhack = 'class="top"';
765 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
766 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
768 $shove = ( $qb != 0 );
769 $left = ( $qb == 1 ||
$qb == 3 );
770 if( $wgContLang->isRTL() ) $left = !$left;
773 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
774 $this->logoText() . '</td>';
776 $s .= $this->getQuickbarCompensator( $rows );
778 $l = $wgContLang->alignStart();
779 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
781 $s .= $this->topLinks();
782 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
784 $r = $wgContLang->alignEnd();
785 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
786 $s .= $this->nameAndLogin();
787 $s .= "\n<br />" . $this->searchForm() . "</td>";
790 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
793 if ( $shove && !$left ) { # Right
794 $s .= $this->getQuickbarCompensator( $rows );
796 $s .= "</tr>\n</table>\n</div>\n";
797 $s .= "\n<div id='article'>\n";
799 $notice = wfGetSiteNotice();
801 $s .= "\n<div id='siteNotice'>$notice</div>\n";
803 $s .= $this->pageTitle();
804 $s .= $this->pageSubtitle();
805 $s .= $this->getCategories();
806 wfProfileOut( __METHOD__
);
811 function getCategoryLinks() {
812 global $wgOut, $wgUseCategoryBrowser;
813 global $wgContLang, $wgUser;
815 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
818 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
820 // Use Unicode bidi embedding override characters,
821 // to make sure links don't smash each other up in ugly ways.
822 $dir = $wgContLang->getDir();
823 $embed = "<span dir='$dir'>";
826 $allCats = $wgOut->getCategoryLinks();
828 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
829 if ( !empty( $allCats['normal'] ) ) {
830 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
832 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
833 $s .= '<div id="mw-normal-catlinks">' .
834 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
835 . $colon . $t . '</div>';
839 if ( isset( $allCats['hidden'] ) ) {
840 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
841 $class ='mw-hidden-cats-user-shown';
842 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
843 $class = 'mw-hidden-cats-ns-shown';
845 $class = 'mw-hidden-cats-hidden';
847 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
848 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
849 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
853 # optional 'dmoz-like' category browser. Will be shown under the list
854 # of categories an article belong to
855 if( $wgUseCategoryBrowser ){
856 $s .= '<br /><hr />';
858 # get a big array of the parents tree
859 $parenttree = $this->mTitle
->getParentCategoryTree();
860 # Skin object passed by reference cause it can not be
861 # accessed under the method subfunction drawCategoryBrowser
862 $tempout = explode( "\n", Skin
::drawCategoryBrowser( $parenttree, $this ) );
863 # Clean out bogus first entry and sort them
864 unset( $tempout[0] );
866 # Output one per line
867 $s .= implode( "<br />\n", $tempout );
874 * Render the array as a serie of links.
875 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
876 * @param &skin Object: skin passed by reference
877 * @return String separated by >, terminate with "\n"
879 function drawCategoryBrowser( $tree, &$skin ){
881 foreach( $tree as $element => $parent ) {
882 if( empty( $parent ) ) {
883 # element start a new list
886 # grab the others elements
887 $return .= Skin
::drawCategoryBrowser( $parent, $skin ) . ' > ';
889 # add our current element to the list
890 $eltitle = Title
::newFromText( $element );
891 $return .= $skin->link( $eltitle, $eltitle->getText() );
896 function getCategories() {
897 $catlinks=$this->getCategoryLinks();
899 $classes = 'catlinks';
901 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
902 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
903 $classes .= ' catlinks-allhidden';
906 if( !empty( $catlinks ) ){
907 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
911 function getQuickbarCompensator( $rows = 1 ) {
912 return "<td width='152' rowspan='{$rows}'> </td>";
916 * This runs a hook to allow extensions placing their stuff after content
917 * and article metadata (e.g. categories).
918 * Note: This function has nothing to do with afterContent().
920 * This hook is placed here in order to allow using the same hook for all
921 * skins, both the SkinTemplate based ones and the older ones, which directly
922 * use this class to get their data.
924 * The output of this function gets processed in SkinTemplate::outputPage() for
925 * the SkinTemplate based skins, all other skins should directly echo it.
927 * Returns an empty string by default, if not changed by any hook function.
929 protected function afterContentHook() {
932 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
933 // adding just some spaces shouldn't toggle the output
934 // of the whole <div/>, so we use trim() here
935 if( trim( $data ) != '' ){
936 // Doing this here instead of in the skins to
937 // ensure that the div has the same ID in all
939 $data = "<div id='mw-data-after-content'>\n" .
944 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
951 * Generate debug data HTML for displaying at the bottom of the main content
953 * @return String HTML containing debug data, if enabled (otherwise empty).
955 protected function generateDebugHTML() {
956 global $wgShowDebug, $wgOut;
957 if ( $wgShowDebug ) {
958 $listInternals = str_replace( "\n", "</li>\n<li>", htmlspecialchars( $wgOut->mDebugtext
) );
959 return "\n<hr>\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\"><li>" .
960 $listInternals . "</li></ul>\n";
966 * This gets called shortly before the </body> tag.
967 * @return String HTML to be put before </body>
969 function afterContent() {
970 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
971 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
975 * This gets called shortly before the </body> tag.
976 * @return String HTML-wrapped JS code to be put before </body>
978 function bottomScripts() {
979 $bottomScriptText = "\n\t\t" . Html
::inlineScript( 'if (window.runOnloadHook) runOnloadHook();' ) . "\n";
980 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
981 return $bottomScriptText;
984 /** @return string Retrievied from HTML text */
985 function printSource() {
986 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
987 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
990 function printFooter() {
991 return "<p>" . $this->printSource() .
992 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
995 /** overloaded by derived classes */
996 function doAfterContent() { return '</div></div>'; }
998 function pageTitleLinks() {
999 global $wgOut, $wgUser, $wgRequest, $wgLang;
1001 $oldid = $wgRequest->getVal( 'oldid' );
1002 $diff = $wgRequest->getVal( 'diff' );
1003 $action = $wgRequest->getText( 'action' );
1005 $s[] = $this->printableLink();
1006 $disclaimer = $this->disclaimerLink(); # may be empty
1010 $privacy = $this->privacyLink(); # may be empty too
1015 if ( $wgOut->isArticleRelated() ) {
1016 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
1017 $name = $this->mTitle
->getDBkey();
1018 $image = wfFindFile( $this->mTitle
);
1020 $link = htmlspecialchars( $image->getURL() );
1021 $style = $this->getInternalLinkAttributes( $link, $name );
1022 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
1026 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
1027 $s[] .= $this->link(
1029 wfMsg( 'currentrev' ),
1032 array( 'known', 'noclasses' )
1036 if ( $wgUser->getNewtalk() ) {
1037 # do not show "You have new messages" text when we are viewing our
1039 if( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
1041 $wgUser->getTalkPage(),
1042 wfMsgHtml( 'newmessageslink' ),
1044 array( 'redirect' => 'no' ),
1045 array( 'known', 'noclasses' )
1049 $wgUser->getTalkPage(),
1050 wfMsgHtml( 'newmessagesdifflink' ),
1052 array( 'diff' => 'cur' ),
1053 array( 'known', 'noclasses' )
1055 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1057 $wgOut->setSquidMaxage( 0 );
1058 $wgOut->enableClientCache( false );
1062 $undelete = $this->getUndeleteLink();
1063 if( !empty( $undelete ) ) {
1066 return $wgLang->pipeList( $s );
1069 function getUndeleteLink() {
1070 global $wgUser, $wgContLang, $wgLang, $wgRequest;
1072 $action = $wgRequest->getVal( 'action', 'view' );
1074 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1075 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1076 $n = $this->mTitle
->isDeleted();
1078 if ( $wgUser->isAllowed( 'undelete' ) ) {
1079 $msg = 'thisisdeleted';
1081 $msg = 'viewdeleted';
1086 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1087 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1090 array( 'known', 'noclasses' )
1098 function printableLink() {
1099 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1103 if ( !$wgRequest->getBool( 'printable' ) ) {
1104 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1105 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1108 if( $wgOut->isSyndicated() ) {
1109 foreach( $wgFeedClasses as $format => $class ) {
1110 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1111 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1112 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1115 return $wgLang->pipeList( $s );
1118 function pageTitle() {
1120 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1124 function pageSubtitle() {
1127 $sub = $wgOut->getSubtitle();
1129 global $wgExtraSubtitle;
1130 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1132 $subpages = $this->subPageSubtitle();
1133 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1134 $s = "<p class='subtitle'>{$sub}</p>\n";
1138 function subPageSubtitle() {
1140 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
1144 if( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1145 $ptext = $this->mTitle
->getPrefixedText();
1146 if( preg_match( '/\//', $ptext ) ) {
1147 $links = explode( '/', $ptext );
1148 array_pop( $links );
1152 foreach( $links as $link ) {
1153 $growinglink .= $link;
1155 $linkObj = Title
::newFromText( $growinglink );
1156 if( is_object( $linkObj ) && $linkObj->exists() ){
1157 $getlink = $this->link(
1159 htmlspecialchars( $display ),
1162 array( 'known', 'noclasses' )
1166 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1168 $subpages .= '< ';
1170 $subpages .= $getlink;
1175 $growinglink .= '/';
1183 * Returns true if the IP should be shown in the header
1185 function showIPinHeader() {
1186 global $wgShowIPinHeader;
1187 return $wgShowIPinHeader && session_id() != '';
1190 function nameAndLogin() {
1191 global $wgUser, $wgLang, $wgContLang;
1193 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1196 if ( $wgUser->isAnon() ) {
1197 if( $this->showIPinHeader() ) {
1200 $talkLink = $this->link( $wgUser->getTalkPage(),
1201 $wgLang->getNsText( NS_TALK
) );
1203 $ret .= "$name ($talkLink)";
1205 $ret .= wfMsg( 'notloggedin' );
1208 $returnTo = $this->mTitle
->getPrefixedDBkey();
1210 if ( $logoutPage != $returnTo ) {
1211 $query['returnto'] = $returnTo;
1214 $loginlink = $wgUser->isAllowed( 'createaccount' )
1215 ?
'nav-login-createaccount'
1217 $ret .= "\n<br />" . $this->link(
1218 SpecialPage
::getTitleFor( 'Userlogin' ),
1219 wfMsg( $loginlink ), array(), $query
1222 $returnTo = $this->mTitle
->getPrefixedDBkey();
1223 $talkLink = $this->link( $wgUser->getTalkPage(),
1224 $wgLang->getNsText( NS_TALK
) );
1226 $ret .= $this->link( $wgUser->getUserPage(),
1227 htmlspecialchars( $wgUser->getName() ) );
1228 $ret .= " ($talkLink)<br />";
1229 $ret .= $wgLang->pipeList( array(
1231 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1232 array(), array( 'returnto' => $returnTo )
1234 $this->specialLink( 'preferences' ),
1237 $ret = $wgLang->pipeList( array(
1240 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1248 function getSearchLink() {
1249 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1250 return $searchPage->getLocalURL();
1253 function escapeSearchLink() {
1254 return htmlspecialchars( $this->getSearchLink() );
1257 function searchForm() {
1258 global $wgRequest, $wgUseTwoButtonsSearchForm;
1259 $search = $wgRequest->getText( 'search' );
1261 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1262 . $this->escapeSearchLink() . "\">\n"
1263 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1264 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1265 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1267 if( $wgUseTwoButtonsSearchForm )
1268 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1270 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1274 // Ensure unique id's for search boxes made after the first
1275 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1280 function topLinks() {
1284 $this->mainPageLink(),
1285 $this->specialLink( 'recentchanges' )
1288 if ( $wgOut->isArticleRelated() ) {
1289 $s[] = $this->editThisPage();
1290 $s[] = $this->historyLink();
1292 # Many people don't like this dropdown box
1293 #$s[] = $this->specialPagesList();
1295 if( $this->variantLinks() ) {
1296 $s[] = $this->variantLinks();
1299 if( $this->extensionTabLinks() ) {
1300 $s[] = $this->extensionTabLinks();
1303 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1304 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1308 * Compatibility for extensions adding functionality through tabs.
1309 * Eventually these old skins should be replaced with SkinTemplate-based
1313 function extensionTabLinks() {
1317 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1318 foreach( $tabs as $tab ) {
1319 $s[] = Xml
::element( 'a',
1320 array( 'href' => $tab['href'] ),
1327 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1328 $out .= $wgLang->pipeList( $s );
1335 * Language/charset variant links for classic-style skins
1338 function variantLinks() {
1340 /* show links to different language variants */
1341 global $wgDisableLangConversion, $wgLang, $wgContLang;
1342 $variants = $wgContLang->getVariants();
1343 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1344 foreach( $variants as $code ) {
1345 $varname = $wgContLang->getVariantname( $code );
1346 if( $varname == 'disable' )
1348 $s = $wgLang->pipeList( array(
1350 '<a href="' . $this->mTitle
->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1357 function bottomLinks() {
1358 global $wgOut, $wgUser, $wgUseTrackbacks;
1359 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1362 if ( $wgOut->isArticleRelated() ) {
1363 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1364 if ( $wgUser->isLoggedIn() ) {
1365 $element[] = $this->watchThisPage();
1367 $element[] = $this->talkLink();
1368 $element[] = $this->historyLink();
1369 $element[] = $this->whatLinksHere();
1370 $element[] = $this->watchPageLinksLink();
1372 if( $wgUseTrackbacks )
1373 $element[] = $this->trackbackLink();
1375 if ( $this->mTitle
->getNamespace() == NS_USER
1376 ||
$this->mTitle
->getNamespace() == NS_USER_TALK
){
1377 $id = User
::idFromName( $this->mTitle
->getText() );
1378 $ip = User
::isIP( $this->mTitle
->getText() );
1380 if( $id ||
$ip ) { # both anons and non-anons have contri list
1381 $element[] = $this->userContribsLink();
1383 if( $this->showEmailUser( $id ) ) {
1384 $element[] = $this->emailUserLink();
1388 $s = implode( $element, $sep );
1390 if ( $this->mTitle
->getArticleId() ) {
1392 if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1393 if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1394 if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
1396 $s .= "<br />\n" . $this->otherLanguages();
1402 function pageStats() {
1403 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1404 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1406 $oldid = $wgRequest->getVal( 'oldid' );
1407 $diff = $wgRequest->getVal( 'diff' );
1408 if ( ! $wgOut->isArticle() ) { return ''; }
1409 if( !$wgArticle instanceOf Article
) { return ''; }
1410 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1411 if ( 0 == $wgArticle->getID() ) { return ''; }
1414 if ( !$wgDisableCounters ) {
1415 $count = $wgLang->formatNum( $wgArticle->getCount() );
1417 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1421 if( $wgMaxCredits != 0 ){
1422 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1424 $s .= $this->lastModified();
1427 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1428 $dbr = wfGetDB( DB_SLAVE
);
1429 $res = $dbr->select( 'watchlist',
1430 array( 'COUNT(*) AS n' ),
1431 array( 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ), 'wl_namespace' => $this->mTitle
->getNamespace() ),
1434 $x = $dbr->fetchObject( $res );
1436 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1437 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1441 return $s . ' ' . $this->getCopyright();
1444 function getCopyright( $type = 'detect' ) {
1445 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1447 if ( $type == 'detect' ) {
1448 $diff = $wgRequest->getVal( 'diff' );
1449 $isCur = $wgArticle && $wgArticle->isCurrent();
1450 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1457 if ( $type == 'history' ) {
1458 $msg = 'history_copyright';
1464 if( $wgRightsPage ) {
1465 $title = Title
::newFromText( $wgRightsPage );
1466 $link = $this->linkKnown( $title, $wgRightsText );
1467 } elseif( $wgRightsUrl ) {
1468 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1469 } elseif( $wgRightsText ) {
1470 $link = $wgRightsText;
1475 // Allow for site and per-namespace customization of copyright notice.
1476 if( isset($wgArticle) )
1477 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
1479 $out .= wfMsgForContent( $msg, $link );
1483 function getCopyrightIcon() {
1484 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1486 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1487 $out = $wgCopyrightIcon;
1488 } else if ( $wgRightsIcon ) {
1489 $icon = htmlspecialchars( $wgRightsIcon );
1490 if ( $wgRightsUrl ) {
1491 $url = htmlspecialchars( $wgRightsUrl );
1492 $out .= '<a href="'.$url.'">';
1494 $text = htmlspecialchars( $wgRightsText );
1495 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1496 if ( $wgRightsUrl ) {
1503 function getPoweredBy() {
1504 global $wgStylePath;
1505 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1506 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1510 function lastModified() {
1511 global $wgLang, $wgArticle;
1512 if( $this->mRevisionId
) {
1513 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1515 $timestamp = $wgArticle->getTimestamp();
1518 $d = $wgLang->date( $timestamp, true );
1519 $t = $wgLang->time( $timestamp, true );
1520 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1524 if ( wfGetLB()->getLaggedSlaveMode() ) {
1525 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1530 function logoText( $align = '' ) {
1531 if ( '' != $align ) {
1532 $a = " align='{$align}'";
1537 $mp = wfMsg( 'mainpage' );
1538 $mptitle = Title
::newMainPage();
1539 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1541 $logourl = $this->getLogo();
1542 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1547 * show a drop-down box of special pages
1549 function specialPagesList() {
1550 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1551 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1552 foreach ( $pages as $name => $page ) {
1553 $pages[$name] = $page->getDescription();
1556 $go = wfMsg( 'go' );
1557 $sp = wfMsg( 'specialpages' );
1558 $spp = $wgContLang->specialPage( 'Specialpages' );
1560 $s = '<form id="specialpages" method="get" ' .
1561 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1562 $s .= "<select name=\"wpDropdown\">\n";
1563 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1566 foreach ( $pages as $name => $desc ) {
1567 $p = $wgContLang->specialPage( $name );
1568 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1570 $s .= "</select>\n";
1571 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1576 function mainPageLink() {
1578 Title
::newMainPage(),
1579 wfMsg( 'mainpage' ),
1582 array( 'known', 'noclasses' )
1587 private function footerLink ( $desc, $page ) {
1588 // if the link description has been set to "-" in the default language,
1589 if ( wfMsgForContent( $desc ) == '-') {
1590 // then it is disabled, for all languages.
1593 // Otherwise, we display the link for the user, described in their
1594 // language (which may or may not be the same as the default language),
1595 // but we make the link target be the one site-wide page.
1596 $title = Title
::newFromText( wfMsgForContent( $page ) );
1597 return $this->linkKnown(
1599 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1604 function privacyLink() {
1605 return $this->footerLink( 'privacy', 'privacypage' );
1608 function aboutLink() {
1609 return $this->footerLink( 'aboutsite', 'aboutpage' );
1612 function disclaimerLink() {
1613 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1616 function editThisPage() {
1619 if ( !$wgOut->isArticleRelated() ) {
1620 $s = wfMsg( 'protectedpage' );
1622 if( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1623 $t = wfMsg( 'editthispage' );
1624 } elseif( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1625 $t = wfMsg( 'create-this-page' );
1627 $t = wfMsg( 'viewsource' );
1634 $this->editUrlOptions(),
1635 array( 'known', 'noclasses' )
1642 * Return URL options for the 'edit page' link.
1643 * This may include an 'oldid' specifier, if the current page view is such.
1648 function editUrlOptions() {
1651 $options = array( 'action' => 'edit' );
1653 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1654 $options['oldid'] = intval( $this->mRevisionId
);
1660 function deleteThisPage() {
1661 global $wgUser, $wgRequest;
1663 $diff = $wgRequest->getVal( 'diff' );
1664 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1665 $t = wfMsg( 'deletethispage' );
1671 array( 'action' => 'delete' ),
1672 array( 'known', 'noclasses' )
1680 function protectThisPage() {
1681 global $wgUser, $wgRequest;
1683 $diff = $wgRequest->getVal( 'diff' );
1684 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1685 if ( $this->mTitle
->isProtected() ) {
1686 $text = wfMsg( 'unprotectthispage' );
1687 $query = array( 'action' => 'unprotect' );
1689 $text = wfMsg( 'protectthispage' );
1690 $query = array( 'action' => 'protect' );
1698 array( 'known', 'noclasses' )
1706 function watchThisPage() {
1708 ++
$this->mWatchLinkNum
;
1710 if ( $wgOut->isArticleRelated() ) {
1711 if ( $this->mTitle
->userIsWatching() ) {
1712 $text = wfMsg( 'unwatchthispage' );
1713 $query = array( 'action' => 'unwatch' );
1714 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1716 $text = wfMsg( 'watchthispage' );
1717 $query = array( 'action' => 'watch' );
1718 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1724 array( 'id' => $id ),
1726 array( 'known', 'noclasses' )
1729 $s = wfMsg( 'notanarticle' );
1734 function moveThisPage() {
1735 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1737 SpecialPage
::getTitleFor( 'Movepage' ),
1738 wfMsg( 'movethispage' ),
1740 array( 'target' => $this->mTitle
->getPrefixedDBkey() ),
1741 array( 'known', 'noclasses' )
1744 // no message if page is protected - would be redundant
1749 function historyLink() {
1752 wfMsgHtml( 'history' ),
1753 array( 'rel' => 'archives' ),
1754 array( 'action' => 'history' )
1758 function whatLinksHere() {
1760 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1761 wfMsgHtml( 'whatlinkshere' ),
1764 array( 'known', 'noclasses' )
1768 function userContribsLink() {
1770 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1771 wfMsgHtml( 'contributions' ),
1774 array( 'known', 'noclasses' )
1778 function showEmailUser( $id ) {
1780 $targetUser = User
::newFromId( $id );
1781 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1782 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1785 function emailUserLink() {
1787 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1788 wfMsg( 'emailuser' ),
1791 array( 'known', 'noclasses' )
1795 function watchPageLinksLink() {
1797 if ( ! $wgOut->isArticleRelated() ) {
1798 return '(' . wfMsg( 'notanarticle' ) . ')';
1801 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1802 wfMsg( 'recentchangeslinked-toolbox' ),
1805 array( 'known', 'noclasses' )
1810 function trackbackLink() {
1811 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1812 . wfMsg( 'trackbacklink' ) . '</a>';
1815 function otherLanguages() {
1816 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1818 if ( $wgHideInterlanguageLinks ) {
1822 $a = $wgOut->getLanguageLinks();
1823 if ( 0 == count( $a ) ) {
1827 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1829 if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
1830 foreach( $a as $l ) {
1832 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1836 $nt = Title
::newFromText( $l );
1837 $url = $nt->escapeFullURL();
1838 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1840 if ( '' == $text ) { $text = $l; }
1841 $style = $this->getExternalLinkAttributes();
1842 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1844 if( $wgContLang->isRTL() ) $s .= '</span>';
1848 function talkLink() {
1849 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1850 # No discussion links for special pages
1854 $linkOptions = array();
1856 if( $this->mTitle
->isTalkPage() ) {
1857 $link = $this->mTitle
->getSubjectPage();
1858 switch( $link->getNamespace() ) {
1860 $text = wfMsg( 'articlepage' );
1863 $text = wfMsg( 'userpage' );
1866 $text = wfMsg( 'projectpage' );
1869 $text = wfMsg( 'imagepage' );
1870 # Make link known if image exists, even if the desc. page doesn't.
1871 if( wfFindFile( $link ) )
1872 $linkOptions[] = 'known';
1875 $text = wfMsg( 'mediawikipage' );
1878 $text = wfMsg( 'templatepage' );
1881 $text = wfMsg( 'viewhelppage' );
1884 $text = wfMsg( 'categorypage' );
1887 $text = wfMsg( 'articlepage' );
1890 $link = $this->mTitle
->getTalkPage();
1891 $text = wfMsg( 'talkpage' );
1894 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1899 function commentLink() {
1902 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1906 # __NEWSECTIONLINK___ changes behaviour here
1907 # If it is present, the link points to this page, otherwise
1908 # it points to the talk page
1909 if( $this->mTitle
->isTalkPage() ) {
1910 $title = $this->mTitle
;
1911 } elseif( $wgOut->showNewSectionLink() ) {
1912 $title = $this->mTitle
;
1914 $title = $this->mTitle
->getTalkPage();
1919 wfMsg( 'postcomment' ),
1925 array( 'known', 'noclasses' )
1929 /* these are used extensively in SkinTemplate, but also some other places */
1930 static function makeMainPageUrl( $urlaction = '' ) {
1931 $title = Title
::newMainPage();
1932 self
::checkTitle( $title, '' );
1933 return $title->getLocalURL( $urlaction );
1936 static function makeSpecialUrl( $name, $urlaction = '' ) {
1937 $title = SpecialPage
::getTitleFor( $name );
1938 return $title->getLocalURL( $urlaction );
1941 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1942 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1943 return $title->getLocalURL( $urlaction );
1946 static function makeI18nUrl( $name, $urlaction = '' ) {
1947 $title = Title
::newFromText( wfMsgForContent( $name ) );
1948 self
::checkTitle( $title, $name );
1949 return $title->getLocalURL( $urlaction );
1952 static function makeUrl( $name, $urlaction = '' ) {
1953 $title = Title
::newFromText( $name );
1954 self
::checkTitle( $title, $name );
1955 return $title->getLocalURL( $urlaction );
1958 # If url string starts with http, consider as external URL, else
1960 static function makeInternalOrExternalUrl( $name ) {
1961 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1964 return self
::makeUrl( $name );
1968 # this can be passed the NS number as defined in Language.php
1969 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1970 $title = Title
::makeTitleSafe( $namespace, $name );
1971 self
::checkTitle( $title, $name );
1972 return $title->getLocalURL( $urlaction );
1975 /* these return an array with the 'href' and boolean 'exists' */
1976 static function makeUrlDetails( $name, $urlaction = '' ) {
1977 $title = Title
::newFromText( $name );
1978 self
::checkTitle( $title, $name );
1980 'href' => $title->getLocalURL( $urlaction ),
1981 'exists' => $title->getArticleID() != 0 ?
true : false
1986 * Make URL details where the article exists (or at least it's convenient to think so)
1988 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1989 $title = Title
::newFromText( $name );
1990 self
::checkTitle( $title, $name );
1992 'href' => $title->getLocalURL( $urlaction ),
1997 # make sure we have some title to operate on
1998 static function checkTitle( &$title, $name ) {
1999 if( !is_object( $title ) ) {
2000 $title = Title
::newFromText( $name );
2001 if( !is_object( $title ) ) {
2002 $title = Title
::newFromText( '--error: link target missing--' );
2008 * Build an array that represents the sidebar(s), the navigation bar among them
2012 function buildSidebar() {
2013 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2015 wfProfileIn( __METHOD__
);
2017 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2019 if ( $wgEnableSidebarCache ) {
2020 $cachedsidebar = $parserMemc->get( $key );
2021 if ( $cachedsidebar ) {
2022 wfProfileOut( __METHOD__
);
2023 return $cachedsidebar;
2028 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
2030 foreach( $lines as $line ) {
2031 if( strpos( $line, '*' ) !== 0 )
2033 if( strpos( $line, '**') !== 0 ) {
2034 $heading = trim( $line, '* ' );
2035 if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
2037 if( strpos( $line, '|' ) !== false ) { // sanity check
2038 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
2039 $link = wfMsgForContent( $line[0] );
2043 $text = wfMsgExt( $line[1], 'parsemag' );
2044 if( wfEmptyMsg( $line[1], $text ) )
2046 if( wfEmptyMsg( $line[0], $link ) )
2049 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2052 $title = Title
::newFromText( $link );
2054 $title = $title->fixSpecialName();
2055 $href = $title->getLocalURL();
2057 $href = 'INVALID-TITLE';
2061 $bar[$heading][] = array(
2064 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2067 } else { continue; }
2070 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2071 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2072 wfProfileOut( __METHOD__
);
2077 * Should we include common/wikiprintable.css? Skins that have their own
2078 * print stylesheet should override this and return false. (This is an
2079 * ugly hack to get Monobook to play nicely with
2080 * OutputPage::headElement().)
2084 public function commonPrintStylesheet() {