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 ) {
334 global $wgJsMimeType;
336 $doneFirstVar = false;
337 $r = array( "<script type=\"$wgJsMimeType\">/*<![CDATA[*/\n" );
338 foreach ( $data as $name => $value ) {
339 $encValue = Xml
::encodeJsVar( $value );
341 $r[] = ",\n$name=$encValue";
343 $r[] = "var $name=$encValue";
344 $doneFirstVar = true;
347 # No need for ; since the script is terminating
348 $r[] = "\n/*]]>*/</script>\n";
350 return implode( $r );
354 * Make a <script> tag containing global variables
355 * @param $skinName string Name of the skin
356 * The odd calling convention is for backwards compatibility
357 * @TODO @FIXME Make this not depend on $wgTitle!
359 static function makeGlobalVariablesScript( $skinName ) {
360 if ( is_array( $skinName ) ) {
361 # Weird back-compat stuff.
362 $skinName = $skinName['skinname'];
364 global $wgScript, $wgTitle, $wgStylePath, $wgUser;
365 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang, $wgVariant;
366 global $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
367 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
368 global $wgUseAjax, $wgAjaxWatch;
369 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
370 global $wgRestrictionTypes, $wgLivePreview;
371 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
373 $ns = $wgTitle->getNamespace();
374 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
375 $separatorTransTable = $wgContLang->separatorTransformTable();
376 $separatorTransTable = $separatorTransTable ?
$separatorTransTable : array();
377 $compactSeparatorTransTable = array(
378 implode( "\t", array_keys( $separatorTransTable ) ),
379 implode( "\t", $separatorTransTable ),
381 $digitTransTable = $wgContLang->digitTransformTable();
382 $digitTransTable = $digitTransTable ?
$digitTransTable : array();
383 $compactDigitTransTable = array(
384 implode( "\t", array_keys( $digitTransTable ) ),
385 implode( "\t", $digitTransTable ),
390 'stylepath' => $wgStylePath,
391 'wgArticlePath' => $wgArticlePath,
392 'wgScriptPath' => $wgScriptPath,
393 'wgScript' => $wgScript,
394 'wgVariantArticlePath' => $wgVariantArticlePath,
395 'wgActionPaths' => (object)$wgActionPaths,
396 'wgServer' => $wgServer,
397 'wgCanonicalNamespace' => $nsname,
398 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
399 'wgNamespaceNumber' => $wgTitle->getNamespace(),
400 'wgPageName' => $wgTitle->getPrefixedDBKey(),
401 'wgTitle' => $wgTitle->getText(),
402 'wgAction' => $wgRequest->getText( 'action', 'view' ),
403 'wgArticleId' => $wgTitle->getArticleId(),
404 'wgIsArticle' => $wgOut->isArticle(),
405 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
406 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
407 'wgUserVariant' => $wgVariant->getCode(),
408 'wgUserLanguage' => $wgLang->getCode(),
409 'wgContentLanguage' => $wgContLang->getCode(),
410 'wgBreakFrames' => $wgBreakFrames,
411 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
412 'wgVersion' => $wgVersion,
413 'wgEnableAPI' => $wgEnableAPI,
414 'wgEnableWriteAPI' => $wgEnableWriteAPI,
415 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
416 'wgDigitTransformTable' => $compactDigitTransTable,
418 if ( !( $wgContLang->hasVariants() ) ) {
419 unset( $vars['wgUserVariant'] );
422 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
423 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
424 $vars['wgDBname'] = $wgDBname;
425 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
426 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
429 foreach( $wgRestrictionTypes as $type )
430 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
432 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
433 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
434 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
435 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
436 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
439 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
440 $msgs = (object)array();
441 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
442 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
444 $vars['wgAjaxWatch'] = $msgs;
447 // Allow extensions to add their custom variables to the global JS variables
448 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
450 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 * @var $allowUserJs bool Should probably be identical to $wgAllowUserJs,
461 * but is passed as a local variable for some
463 * @var $extraHtml string A bunch of raw HTML to jam into some arbitrary
464 * place where MonoBook has historically wanted it.
465 * Old-style skins formerly put it in a different
466 * place, but if either of those is broken it's
467 * likely to be the old-style skins.
468 * @return string Raw HTML to output in some location in the <head> that's
469 * entirely arbitrary but which will probably break
470 * everything if you put it someplace else.
472 function getHeadScripts( $allowUserJs, $extraHtml = '' ) {
473 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
475 $vars = self
::makeGlobalVariablesScript( $this->getSkinName() );
477 $r = array( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n$extraHtml" );
480 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
481 $r[] = "<script type=\"$wgJsMimeType\" src=\"".
482 htmlspecialchars( self
::makeUrl( '-',
483 "action=raw$jsCache&gen=js&useskin=" .
484 urlencode( $this->getSkinName() ) ) ) .
487 if( $allowUserJs && $wgUser->isLoggedIn() ) {
488 $userpage = $wgUser->getUserPage();
489 $userjs = htmlspecialchars( self
::makeUrl(
490 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
491 'action=raw&ctype='.$wgJsMimeType ) );
492 $r[] = '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>";
494 return $vars . "\t" . implode ( "\n\t", $r );
498 * To make it harder for someone to slip a user a fake
499 * user-JavaScript or user-CSS preview, a random token
500 * is associated with the login session. If it's not
501 * passed back with the preview request, we won't render
504 * @param string $action
508 function userCanPreview( $action ) {
509 global $wgRequest, $wgUser;
511 if( $action != 'submit' )
513 if( !$wgRequest->wasPosted() )
515 if( !$this->mTitle
->userCanEditCssJsSubpage() )
517 return $wgUser->matchEditToken(
518 $wgRequest->getVal( 'wpEditToken' ) );
522 * generated JavaScript action=raw&gen=js
523 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
524 * nated together. For some bizarre reason, it does *not* return any
525 * custom user JS from subpages. Huh?
527 * There's absolutely no reason to have separate Monobook/Common JSes.
528 * Any JS that cares can just check the skin variable generated at the
529 * top. For now Monobook.js will be maintained, but it should be consi-
534 public function generateUserJs() {
537 wfProfileIn( __METHOD__
);
539 $s = "/* generated javascript */\n";
540 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\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( $this->getSkinName() ).".js */\n";
549 // avoid inclusion of non defined user JavaScript (with custom skins only)
550 // by checking for default message content
551 $msgKey = ucfirst( $this->getSkinName() ).'.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";
615 function setupUserCss( OutputPage
$out ) {
616 global $wgRequest, $wgContLang, $wgUser;
617 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
619 wfProfileIn( __METHOD__
);
621 $this->setupSkinUserCss( $out );
625 'maxage' => $wgSquidMaxage,
628 // Add any extension CSS
629 foreach( $out->getExtStyle() as $tag ) {
630 $out->addStyle( $tag['href'] );
633 // If we use the site's dynamic CSS, throw that in, too
634 // Per-site custom styles
635 if( $wgUseSiteCss ) {
636 global $wgHandheldStyle;
637 $query = wfArrayToCGI( array(
638 'usemsgcache' => 'yes',
639 'ctype' => 'text/css',
640 'smaxage' => $wgSquidMaxage
642 # Site settings must override extension css! (bug 15025)
643 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
644 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
645 if( $wgHandheldStyle ) {
646 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
648 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
651 if( $wgUser->isLoggedIn() ) {
652 // Ensure that logged-in users' generated CSS isn't clobbered
653 // by anons' publicly cacheable generated CSS.
654 $siteargs['smaxage'] = '0';
655 $siteargs['ts'] = $wgUser->mTouched
;
657 // Per-user styles based on preferences
658 $siteargs['gen'] = 'css';
659 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
660 $siteargs['useskin'] = $us;
662 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
664 // Per-user custom style pages
665 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
666 $action = $wgRequest->getVal( 'action' );
667 # If we're previewing the CSS page, use it
668 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
669 $previewCss = $wgRequest->getText( 'wpTextbox1' );
670 // @FIXME: properly escape the cdata!
671 $this->usercss
= "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
673 $out->addStyle( self
::makeUrl( $this->userpage
. '/' . $this->getSkinName() .'.css',
674 'action=raw&ctype=text/css' ) );
678 wfProfileOut( __METHOD__
);
682 * Add skin specific stylesheets
683 * @param $out OutputPage
685 function setupSkinUserCss( OutputPage
$out ) {
686 $out->addStyle( 'common/shared.css' );
687 $out->addStyle( 'common/oldshared.css' );
688 $out->addStyle( $this->getStylesheet() );
689 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
692 function getBodyOptions() {
693 global $wgUser, $wgOut, $wgRequest, $wgContLang;
695 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
697 if ( 0 != $this->mTitle
->getNamespace() ) {
698 $a = array( 'bgcolor' => '#ffffec' );
700 else $a = array( 'bgcolor' => '#FFFFFF' );
701 if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
702 $this->mTitle
->quickUserCan( 'edit' ) ) {
703 $s = $this->mTitle
->getFullURL( $this->editUrlOptions() );
704 $s = 'document.location = "' .Xml
::escapeJsString( $s ) .'";';
705 $a +
= array( 'ondblclick' => $s );
707 $a['onload'] = $wgOut->getOnloadHandler();
710 ' '.( $wgContLang->isRTL() ?
'rtl' : 'ltr' ).
711 ' '.$this->getPageClasses( $this->mTitle
) .
712 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName() );
716 function getPageClasses( $title ) {
717 $numeric = 'ns-'.$title->getNamespace();
718 if( $title->getNamespace() == NS_SPECIAL
) {
719 $type = 'ns-special';
720 } elseif( $title->isTalkPage() ) {
723 $type = 'ns-subject';
725 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
726 return "$numeric $type $name";
738 * This will be called immediately after the <body> tag. Split into
739 * two functions to make it easier to subclass.
741 function beforeContent() {
742 return $this->doBeforeContent();
745 function doBeforeContent() {
747 wfProfileIn( __METHOD__
);
750 $qb = $this->qbSetting();
752 if( $langlinks = $this->otherLanguages() ) {
758 $borderhack = 'class="top"';
761 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
762 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
764 $shove = ( $qb != 0 );
765 $left = ( $qb == 1 ||
$qb == 3 );
766 if( $wgContLang->isRTL() ) $left = !$left;
769 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
770 $this->logoText() . '</td>';
772 $s .= $this->getQuickbarCompensator( $rows );
774 $l = $wgContLang->isRTL() ?
'right' : 'left';
775 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
777 $s .= $this->topLinks();
778 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
780 $r = $wgContLang->isRTL() ?
'left' : 'right';
781 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
782 $s .= $this->nameAndLogin();
783 $s .= "\n<br />" . $this->searchForm() . "</td>";
786 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
789 if ( $shove && !$left ) { # Right
790 $s .= $this->getQuickbarCompensator( $rows );
792 $s .= "</tr>\n</table>\n</div>\n";
793 $s .= "\n<div id='article'>\n";
795 $notice = wfGetSiteNotice();
797 $s .= "\n<div id='siteNotice'>$notice</div>\n";
799 $s .= $this->pageTitle();
800 $s .= $this->pageSubtitle();
801 $s .= $this->getCategories();
802 wfProfileOut( __METHOD__
);
807 function getCategoryLinks() {
808 global $wgOut, $wgUseCategoryBrowser;
809 global $wgContLang, $wgUser;
811 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
814 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
816 // Use Unicode bidi embedding override characters,
817 // to make sure links don't smash each other up in ugly ways.
818 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
819 $embed = "<span dir='$dir'>";
822 $allCats = $wgOut->getCategoryLinks();
824 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
825 if ( !empty( $allCats['normal'] ) ) {
826 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
828 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
829 $s .= '<div id="mw-normal-catlinks">' .
830 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
831 . $colon . $t . '</div>';
835 if ( isset( $allCats['hidden'] ) ) {
836 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
837 $class ='mw-hidden-cats-user-shown';
838 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
839 $class = 'mw-hidden-cats-ns-shown';
841 $class = 'mw-hidden-cats-hidden';
843 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
844 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
845 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
849 # optional 'dmoz-like' category browser. Will be shown under the list
850 # of categories an article belong to
851 if( $wgUseCategoryBrowser ){
852 $s .= '<br /><hr />';
854 # get a big array of the parents tree
855 $parenttree = $this->mTitle
->getParentCategoryTree();
856 # Skin object passed by reference cause it can not be
857 # accessed under the method subfunction drawCategoryBrowser
858 $tempout = explode( "\n", Skin
::drawCategoryBrowser( $parenttree, $this ) );
859 # Clean out bogus first entry and sort them
860 unset( $tempout[0] );
862 # Output one per line
863 $s .= implode( "<br />\n", $tempout );
870 * Render the array as a serie of links.
871 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
872 * @param &skin Object: skin passed by reference
873 * @return String separated by >, terminate with "\n"
875 function drawCategoryBrowser( $tree, &$skin ){
877 foreach( $tree as $element => $parent ) {
878 if( empty( $parent ) ) {
879 # element start a new list
882 # grab the others elements
883 $return .= Skin
::drawCategoryBrowser( $parent, $skin ) . ' > ';
885 # add our current element to the list
886 $eltitle = Title
::newFromText( $element );
887 $return .= $skin->link( $eltitle, $eltitle->getText() );
892 function getCategories() {
893 $catlinks=$this->getCategoryLinks();
895 $classes = 'catlinks';
897 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
898 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
899 $classes .= ' catlinks-allhidden';
902 if( !empty( $catlinks ) ){
903 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
907 function getQuickbarCompensator( $rows = 1 ) {
908 return "<td width='152' rowspan='{$rows}'> </td>";
912 * This runs a hook to allow extensions placing their stuff after content
913 * and article metadata (e.g. categories).
914 * Note: This function has nothing to do with afterContent().
916 * This hook is placed here in order to allow using the same hook for all
917 * skins, both the SkinTemplate based ones and the older ones, which directly
918 * use this class to get their data.
920 * The output of this function gets processed in SkinTemplate::outputPage() for
921 * the SkinTemplate based skins, all other skins should directly echo it.
923 * Returns an empty string by default, if not changed by any hook function.
925 protected function afterContentHook() {
928 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
929 // adding just some spaces shouldn't toggle the output
930 // of the whole <div/>, so we use trim() here
931 if( trim( $data ) != '' ){
932 // Doing this here instead of in the skins to
933 // ensure that the div has the same ID in all
935 $data = "<div id='mw-data-after-content'>\n" .
940 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
947 * Generate debug data HTML for displaying at the bottom of the main content
949 * @return String HTML containing debug data, if enabled (otherwise empty).
951 protected function generateDebugHTML() {
952 global $wgShowDebug, $wgOut;
953 if ( $wgShowDebug ) {
954 $listInternals = str_replace( "\n", "</li>\n<li>", htmlspecialchars( $wgOut->mDebugtext
) );
955 return "\n<hr>\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\"><li>" .
956 $listInternals . "</li></ul>\n";
962 * This gets called shortly before the </body> tag.
963 * @return String HTML to be put before </body>
965 function afterContent() {
966 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
967 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
971 * This gets called shortly before the </body> tag.
972 * @return String HTML-wrapped JS code to be put before </body>
974 function bottomScripts() {
975 global $wgJsMimeType;
976 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
977 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
978 return $bottomScriptText;
981 /** @return string Retrievied from HTML text */
982 function printSource() {
983 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
984 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
987 function printFooter() {
988 return "<p>" . $this->printSource() .
989 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
992 /** overloaded by derived classes */
993 function doAfterContent() { return '</div></div>'; }
995 function pageTitleLinks() {
996 global $wgOut, $wgUser, $wgRequest, $wgLang;
998 $oldid = $wgRequest->getVal( 'oldid' );
999 $diff = $wgRequest->getVal( 'diff' );
1000 $action = $wgRequest->getText( 'action' );
1002 $s[] = $this->printableLink();
1003 $disclaimer = $this->disclaimerLink(); # may be empty
1007 $privacy = $this->privacyLink(); # may be empty too
1012 if ( $wgOut->isArticleRelated() ) {
1013 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
1014 $name = $this->mTitle
->getDBkey();
1015 $image = wfFindFile( $this->mTitle
);
1017 $link = htmlspecialchars( $image->getURL() );
1018 $style = $this->getInternalLinkAttributes( $link, $name );
1019 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
1023 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
1024 $s[] .= $this->link(
1026 wfMsg( 'currentrev' ),
1029 array( 'known', 'noclasses' )
1033 if ( $wgUser->getNewtalk() ) {
1034 # do not show "You have new messages" text when we are viewing our
1036 if( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
1038 $wgUser->getTalkPage(),
1039 wfMsgHtml( 'newmessageslink' ),
1041 array( 'redirect' => 'no' ),
1042 array( 'known', 'noclasses' )
1046 $wgUser->getTalkPage(),
1047 wfMsgHtml( 'newmessagesdifflink' ),
1049 array( 'diff' => 'cur' ),
1050 array( 'known', 'noclasses' )
1052 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1054 $wgOut->setSquidMaxage( 0 );
1055 $wgOut->enableClientCache( false );
1059 $undelete = $this->getUndeleteLink();
1060 if( !empty( $undelete ) ) {
1063 return $wgLang->pipeList( $s );
1066 function getUndeleteLink() {
1067 global $wgUser, $wgContLang, $wgLang, $wgRequest;
1069 $action = $wgRequest->getVal( 'action', 'view' );
1071 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1072 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1073 $n = $this->mTitle
->isDeleted();
1075 if ( $wgUser->isAllowed( 'undelete' ) ) {
1076 $msg = 'thisisdeleted';
1078 $msg = 'viewdeleted';
1083 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1084 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1087 array( 'known', 'noclasses' )
1095 function printableLink() {
1096 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1100 if ( !$wgRequest->getBool( 'printable' ) ) {
1101 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1102 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1105 if( $wgOut->isSyndicated() ) {
1106 foreach( $wgFeedClasses as $format => $class ) {
1107 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1108 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1109 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1112 return $wgLang->pipeList( $s );
1115 function pageTitle() {
1117 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1121 function pageSubtitle() {
1124 $sub = $wgOut->getSubtitle();
1126 global $wgExtraSubtitle;
1127 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1129 $subpages = $this->subPageSubtitle();
1130 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1131 $s = "<p class='subtitle'>{$sub}</p>\n";
1135 function subPageSubtitle() {
1137 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
1141 if( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1142 $ptext = $this->mTitle
->getPrefixedText();
1143 if( preg_match( '/\//', $ptext ) ) {
1144 $links = explode( '/', $ptext );
1145 array_pop( $links );
1149 foreach( $links as $link ) {
1150 $growinglink .= $link;
1152 $linkObj = Title
::newFromText( $growinglink );
1153 if( is_object( $linkObj ) && $linkObj->exists() ){
1154 $getlink = $this->link(
1156 htmlspecialchars( $display ),
1159 array( 'known', 'noclasses' )
1163 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1165 $subpages .= '< ';
1167 $subpages .= $getlink;
1172 $growinglink .= '/';
1180 * Returns true if the IP should be shown in the header
1182 function showIPinHeader() {
1183 global $wgShowIPinHeader;
1184 return $wgShowIPinHeader && session_id() != '';
1187 function nameAndLogin() {
1188 global $wgUser, $wgLang, $wgContLang;
1190 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1193 if ( $wgUser->isAnon() ) {
1194 if( $this->showIPinHeader() ) {
1197 $talkLink = $this->link( $wgUser->getTalkPage(),
1198 $wgLang->getNsText( NS_TALK
) );
1200 $ret .= "$name ($talkLink)";
1202 $ret .= wfMsg( 'notloggedin' );
1205 $returnTo = $this->mTitle
->getPrefixedDBkey();
1207 if ( $logoutPage != $returnTo ) {
1208 $query['returnto'] = $returnTo;
1211 $loginlink = $wgUser->isAllowed( 'createaccount' )
1212 ?
'nav-login-createaccount'
1214 $ret .= "\n<br />" . $this->link(
1215 SpecialPage
::getTitleFor( 'Userlogin' ),
1216 wfMsg( $loginlink ), array(), $query
1219 $returnTo = $this->mTitle
->getPrefixedDBkey();
1220 $talkLink = $this->link( $wgUser->getTalkPage(),
1221 $wgLang->getNsText( NS_TALK
) );
1223 $ret .= $this->link( $wgUser->getUserPage(),
1224 htmlspecialchars( $wgUser->getName() ) );
1225 $ret .= " ($talkLink)<br />";
1226 $ret .= $wgLang->pipeList( array(
1228 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1229 array(), array( 'returnto' => $returnTo )
1231 $this->specialLink( 'preferences' ),
1234 $ret = $wgLang->pipeList( array(
1237 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1245 function getSearchLink() {
1246 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1247 return $searchPage->getLocalURL();
1250 function escapeSearchLink() {
1251 return htmlspecialchars( $this->getSearchLink() );
1254 function searchForm() {
1255 global $wgRequest, $wgUseTwoButtonsSearchForm;
1256 $search = $wgRequest->getText( 'search' );
1258 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1259 . $this->escapeSearchLink() . "\">\n"
1260 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1261 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1262 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1264 if( $wgUseTwoButtonsSearchForm )
1265 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1267 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1271 // Ensure unique id's for search boxes made after the first
1272 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1277 function topLinks() {
1281 $this->mainPageLink(),
1282 $this->specialLink( 'recentchanges' )
1285 if ( $wgOut->isArticleRelated() ) {
1286 $s[] = $this->editThisPage();
1287 $s[] = $this->historyLink();
1289 # Many people don't like this dropdown box
1290 #$s[] = $this->specialPagesList();
1292 if( $this->variantLinks() ) {
1293 $s[] = $this->variantLinks();
1296 if( $this->extensionTabLinks() ) {
1297 $s[] = $this->extensionTabLinks();
1300 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1301 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1305 * Compatibility for extensions adding functionality through tabs.
1306 * Eventually these old skins should be replaced with SkinTemplate-based
1310 function extensionTabLinks() {
1314 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1315 foreach( $tabs as $tab ) {
1316 $s[] = Xml
::element( 'a',
1317 array( 'href' => $tab['href'] ),
1324 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1325 $out .= $wgLang->pipeList( $s );
1332 * Language/charset variant links for classic-style skins
1335 function variantLinks() {
1337 /* show links to different language variants */
1338 global $wgDisableLangConversion, $wgLang, $wgContLang;
1339 $variants = $wgContLang->getVariants();
1340 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1341 foreach( $variants as $code ) {
1342 $varname = $wgContLang->getVariantname( $code );
1343 if( $varname == 'disable' )
1345 $s = $wgLang->pipeList( array(
1347 '<a href="' . $this->mTitle
->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1354 function bottomLinks() {
1355 global $wgOut, $wgUser, $wgUseTrackbacks;
1356 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1359 if ( $wgOut->isArticleRelated() ) {
1360 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1361 if ( $wgUser->isLoggedIn() ) {
1362 $element[] = $this->watchThisPage();
1364 $element[] = $this->talkLink();
1365 $element[] = $this->historyLink();
1366 $element[] = $this->whatLinksHere();
1367 $element[] = $this->watchPageLinksLink();
1369 if( $wgUseTrackbacks )
1370 $element[] = $this->trackbackLink();
1372 if ( $this->mTitle
->getNamespace() == NS_USER
1373 ||
$this->mTitle
->getNamespace() == NS_USER_TALK
){
1374 $id = User
::idFromName( $this->mTitle
->getText() );
1375 $ip = User
::isIP( $this->mTitle
->getText() );
1377 if( $id ||
$ip ) { # both anons and non-anons have contri list
1378 $element[] = $this->userContribsLink();
1380 if( $this->showEmailUser( $id ) ) {
1381 $element[] = $this->emailUserLink();
1385 $s = implode( $element, $sep );
1387 if ( $this->mTitle
->getArticleId() ) {
1389 if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1390 if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1391 if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
1393 $s .= "<br />\n" . $this->otherLanguages();
1399 function pageStats() {
1400 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1401 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1403 $oldid = $wgRequest->getVal( 'oldid' );
1404 $diff = $wgRequest->getVal( 'diff' );
1405 if ( ! $wgOut->isArticle() ) { return ''; }
1406 if( !$wgArticle instanceOf Article
) { return ''; }
1407 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1408 if ( 0 == $wgArticle->getID() ) { return ''; }
1411 if ( !$wgDisableCounters ) {
1412 $count = $wgLang->formatNum( $wgArticle->getCount() );
1414 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1418 if( $wgMaxCredits != 0 ){
1419 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1421 $s .= $this->lastModified();
1424 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1425 $dbr = wfGetDB( DB_SLAVE
);
1426 $res = $dbr->select( 'watchlist',
1427 array( 'COUNT(*) AS n' ),
1428 array( 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ), 'wl_namespace' => $this->mTitle
->getNamespace() ),
1431 $x = $dbr->fetchObject( $res );
1433 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1434 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1438 return $s . ' ' . $this->getCopyright();
1441 function getCopyright( $type = 'detect' ) {
1442 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1444 if ( $type == 'detect' ) {
1445 $diff = $wgRequest->getVal( 'diff' );
1446 $isCur = $wgArticle && $wgArticle->isCurrent();
1447 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1454 if ( $type == 'history' ) {
1455 $msg = 'history_copyright';
1461 if( $wgRightsPage ) {
1462 $title = Title
::newFromText( $wgRightsPage );
1463 $link = $this->linkKnown( $title, $wgRightsText );
1464 } elseif( $wgRightsUrl ) {
1465 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1466 } elseif( $wgRightsText ) {
1467 $link = $wgRightsText;
1472 // Allow for site and per-namespace customization of copyright notice.
1473 if( isset($wgArticle) )
1474 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
1476 $out .= wfMsgForContent( $msg, $link );
1480 function getCopyrightIcon() {
1481 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1483 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1484 $out = $wgCopyrightIcon;
1485 } else if ( $wgRightsIcon ) {
1486 $icon = htmlspecialchars( $wgRightsIcon );
1487 if ( $wgRightsUrl ) {
1488 $url = htmlspecialchars( $wgRightsUrl );
1489 $out .= '<a href="'.$url.'">';
1491 $text = htmlspecialchars( $wgRightsText );
1492 $out .= "<img src=\"$icon\" alt='$text' />";
1493 if ( $wgRightsUrl ) {
1500 function getPoweredBy() {
1501 global $wgStylePath;
1502 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1503 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1507 function lastModified() {
1508 global $wgLang, $wgArticle;
1509 if( $this->mRevisionId
) {
1510 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1512 $timestamp = $wgArticle->getTimestamp();
1515 $d = $wgLang->date( $timestamp, true );
1516 $t = $wgLang->time( $timestamp, true );
1517 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1521 if ( wfGetLB()->getLaggedSlaveMode() ) {
1522 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1527 function logoText( $align = '' ) {
1528 if ( '' != $align ) {
1529 $a = " align='{$align}'";
1534 $mp = wfMsg( 'mainpage' );
1535 $mptitle = Title
::newMainPage();
1536 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1538 $logourl = $this->getLogo();
1539 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1544 * show a drop-down box of special pages
1546 function specialPagesList() {
1547 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1548 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1549 foreach ( $pages as $name => $page ) {
1550 $pages[$name] = $page->getDescription();
1553 $go = wfMsg( 'go' );
1554 $sp = wfMsg( 'specialpages' );
1555 $spp = $wgContLang->specialPage( 'Specialpages' );
1557 $s = '<form id="specialpages" method="get" ' .
1558 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1559 $s .= "<select name=\"wpDropdown\">\n";
1560 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1563 foreach ( $pages as $name => $desc ) {
1564 $p = $wgContLang->specialPage( $name );
1565 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1567 $s .= "</select>\n";
1568 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1573 function mainPageLink() {
1575 Title
::newMainPage(),
1576 wfMsg( 'mainpage' ),
1579 array( 'known', 'noclasses' )
1584 function copyrightLink() {
1585 $title = Title
::newFromText( wfMsgForContent( 'copyrightpage' ) );
1586 $s = $this->linkKnown(
1588 wfMsg( 'copyrightpagename' )
1593 private function footerLink ( $desc, $page ) {
1594 // if the link description has been set to "-" in the default language,
1595 if ( wfMsgForContent( $desc ) == '-') {
1596 // then it is disabled, for all languages.
1599 // Otherwise, we display the link for the user, described in their
1600 // language (which may or may not be the same as the default language),
1601 // but we make the link target be the one site-wide page.
1602 $title = Title
::newFromText( wfMsgForContent( $page ) );
1603 return $this->linkKnown(
1605 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1610 function privacyLink() {
1611 return $this->footerLink( 'privacy', 'privacypage' );
1614 function aboutLink() {
1615 return $this->footerLink( 'aboutsite', 'aboutpage' );
1618 function disclaimerLink() {
1619 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1622 function editThisPage() {
1625 if ( !$wgOut->isArticleRelated() ) {
1626 $s = wfMsg( 'protectedpage' );
1628 if( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1629 $t = wfMsg( 'editthispage' );
1630 } elseif( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1631 $t = wfMsg( 'create-this-page' );
1633 $t = wfMsg( 'viewsource' );
1640 $this->editUrlOptions(),
1641 array( 'known', 'noclasses' )
1648 * Return URL options for the 'edit page' link.
1649 * This may include an 'oldid' specifier, if the current page view is such.
1654 function editUrlOptions() {
1657 $options = array( 'action' => 'edit' );
1659 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1660 $options['oldid'] = intval( $this->mRevisionId
);
1666 function deleteThisPage() {
1667 global $wgUser, $wgRequest;
1669 $diff = $wgRequest->getVal( 'diff' );
1670 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1671 $t = wfMsg( 'deletethispage' );
1677 array( 'action' => 'delete' ),
1678 array( 'known', 'noclasses' )
1686 function protectThisPage() {
1687 global $wgUser, $wgRequest;
1689 $diff = $wgRequest->getVal( 'diff' );
1690 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1691 if ( $this->mTitle
->isProtected() ) {
1692 $text = wfMsg( 'unprotectthispage' );
1693 $query = array( 'action' => 'unprotect' );
1695 $text = wfMsg( 'protectthispage' );
1696 $query = array( 'action' => 'protect' );
1704 array( 'known', 'noclasses' )
1712 function watchThisPage() {
1714 ++
$this->mWatchLinkNum
;
1716 if ( $wgOut->isArticleRelated() ) {
1717 if ( $this->mTitle
->userIsWatching() ) {
1718 $text = wfMsg( 'unwatchthispage' );
1719 $query = array( 'action' => 'unwatch' );
1720 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1722 $text = wfMsg( 'watchthispage' );
1723 $query = array( 'action' => 'watch' );
1724 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1730 array( 'id' => $id ),
1732 array( 'known', 'noclasses' )
1735 $s = wfMsg( 'notanarticle' );
1740 function moveThisPage() {
1741 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1743 SpecialPage
::getTitleFor( 'Movepage' ),
1744 wfMsg( 'movethispage' ),
1746 array( 'target' => $this->mTitle
->getPrefixedURL() ),
1747 array( 'known', 'noclasses' )
1750 // no message if page is protected - would be redundant
1755 function historyLink() {
1758 wfMsgHtml( 'history' ),
1759 array( 'rel' => 'archives' ),
1760 array( 'action' => 'history' )
1764 function whatLinksHere() {
1766 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1767 wfMsgHtml( 'whatlinkshere' ),
1770 array( 'known', 'noclasses' )
1774 function userContribsLink() {
1776 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1777 wfMsgHtml( 'contributions' ),
1780 array( 'known', 'noclasses' )
1784 function showEmailUser( $id ) {
1786 $targetUser = User
::newFromId( $id );
1787 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1788 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1791 function emailUserLink() {
1793 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1794 wfMsg( 'emailuser' ),
1797 array( 'known', 'noclasses' )
1801 function watchPageLinksLink() {
1803 if ( ! $wgOut->isArticleRelated() ) {
1804 return '(' . wfMsg( 'notanarticle' ) . ')';
1807 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1808 wfMsg( 'recentchangeslinked-toolbox' ),
1811 array( 'known', 'noclasses' )
1816 function trackbackLink() {
1817 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1818 . wfMsg( 'trackbacklink' ) . '</a>';
1821 function otherLanguages() {
1822 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1824 if ( $wgHideInterlanguageLinks ) {
1828 $a = $wgOut->getLanguageLinks();
1829 if ( 0 == count( $a ) ) {
1833 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1835 if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
1836 foreach( $a as $l ) {
1838 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1842 $nt = Title
::newFromText( $l );
1843 $url = $nt->escapeFullURL();
1844 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1846 if ( '' == $text ) { $text = $l; }
1847 $style = $this->getExternalLinkAttributes();
1848 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1850 if( $wgContLang->isRTL() ) $s .= '</span>';
1854 function talkLink() {
1855 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1856 # No discussion links for special pages
1860 $linkOptions = array();
1862 if( $this->mTitle
->isTalkPage() ) {
1863 $link = $this->mTitle
->getSubjectPage();
1864 switch( $link->getNamespace() ) {
1866 $text = wfMsg( 'articlepage' );
1869 $text = wfMsg( 'userpage' );
1872 $text = wfMsg( 'projectpage' );
1875 $text = wfMsg( 'imagepage' );
1876 # Make link known if image exists, even if the desc. page doesn't.
1877 if( wfFindFile( $link ) )
1878 $linkOptions[] = 'known';
1881 $text = wfMsg( 'mediawikipage' );
1884 $text = wfMsg( 'templatepage' );
1887 $text = wfMsg( 'viewhelppage' );
1890 $text = wfMsg( 'categorypage' );
1893 $text = wfMsg( 'articlepage' );
1896 $link = $this->mTitle
->getTalkPage();
1897 $text = wfMsg( 'talkpage' );
1900 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1905 function commentLink() {
1908 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1912 # __NEWSECTIONLINK___ changes behaviour here
1913 # If it is present, the link points to this page, otherwise
1914 # it points to the talk page
1915 if( $this->mTitle
->isTalkPage() ) {
1916 $title = $this->mTitle
;
1917 } elseif( $wgOut->showNewSectionLink() ) {
1918 $title = $this->mTitle
;
1920 $title = $this->mTitle
->getTalkPage();
1925 wfMsg( 'postcomment' ),
1931 array( 'known', 'noclasses' )
1935 /* these are used extensively in SkinTemplate, but also some other places */
1936 static function makeMainPageUrl( $urlaction = '' ) {
1937 $title = Title
::newMainPage();
1938 self
::checkTitle( $title, '' );
1939 return $title->getLocalURL( $urlaction );
1942 static function makeSpecialUrl( $name, $urlaction = '' ) {
1943 $title = SpecialPage
::getTitleFor( $name );
1944 return $title->getLocalURL( $urlaction );
1947 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1948 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1949 return $title->getLocalURL( $urlaction );
1952 static function makeI18nUrl( $name, $urlaction = '' ) {
1953 $title = Title
::newFromText( wfMsgForContent( $name ) );
1954 self
::checkTitle( $title, $name );
1955 return $title->getLocalURL( $urlaction );
1958 static function makeUrl( $name, $urlaction = '' ) {
1959 $title = Title
::newFromText( $name );
1960 self
::checkTitle( $title, $name );
1961 return $title->getLocalURL( $urlaction );
1964 # If url string starts with http, consider as external URL, else
1966 static function makeInternalOrExternalUrl( $name ) {
1967 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1970 return self
::makeUrl( $name );
1974 # this can be passed the NS number as defined in Language.php
1975 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1976 $title = Title
::makeTitleSafe( $namespace, $name );
1977 self
::checkTitle( $title, $name );
1978 return $title->getLocalURL( $urlaction );
1981 /* these return an array with the 'href' and boolean 'exists' */
1982 static function makeUrlDetails( $name, $urlaction = '' ) {
1983 $title = Title
::newFromText( $name );
1984 self
::checkTitle( $title, $name );
1986 'href' => $title->getLocalURL( $urlaction ),
1987 'exists' => $title->getArticleID() != 0 ?
true : false
1992 * Make URL details where the article exists (or at least it's convenient to think so)
1994 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1995 $title = Title
::newFromText( $name );
1996 self
::checkTitle( $title, $name );
1998 'href' => $title->getLocalURL( $urlaction ),
2003 # make sure we have some title to operate on
2004 static function checkTitle( &$title, $name ) {
2005 if( !is_object( $title ) ) {
2006 $title = Title
::newFromText( $name );
2007 if( !is_object( $title ) ) {
2008 $title = Title
::newFromText( '--error: link target missing--' );
2014 * Build an array that represents the sidebar(s), the navigation bar among them
2018 function buildSidebar() {
2019 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2021 wfProfileIn( __METHOD__
);
2023 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2025 if ( $wgEnableSidebarCache ) {
2026 $cachedsidebar = $parserMemc->get( $key );
2027 if ( $cachedsidebar ) {
2028 wfProfileOut( __METHOD__
);
2029 return $cachedsidebar;
2034 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
2036 foreach( $lines as $line ) {
2037 if( strpos( $line, '*' ) !== 0 )
2039 if( strpos( $line, '**') !== 0 ) {
2040 $heading = trim( $line, '* ' );
2041 if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
2043 if( strpos( $line, '|' ) !== false ) { // sanity check
2044 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
2045 $link = wfMsgForContent( $line[0] );
2049 $text = wfMsgExt( $line[1], 'parsemag' );
2050 if( wfEmptyMsg( $line[1], $text ) )
2052 if( wfEmptyMsg( $line[0], $link ) )
2055 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2058 $title = Title
::newFromText( $link );
2060 $title = $title->fixSpecialName();
2061 $href = $title->getLocalURL();
2063 $href = 'INVALID-TITLE';
2067 $bar[$heading][] = array(
2070 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2073 } else { continue; }
2076 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2077 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2078 wfProfileOut( __METHOD__
);
2083 * Should we include common/wikiprintable.css? Skins that have their own
2084 * print stylesheet should override this and return false. (This is an
2085 * ugly hack to get Monobook to play nicely with
2086 * OutputPage::headElement().)
2090 public function commonPrintStylesheet() {