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 array $data Associative array containing one element:
356 * skinname => the skin name
357 * The odd calling convention is for backwards compatibility
358 * @TODO @FIXME Make this not depend on $wgTitle!
360 static function makeGlobalVariablesScript( $data ) {
361 global $wgScript, $wgTitle, $wgStylePath, $wgUser;
362 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang, $wgVariant;
363 global $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
364 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
365 global $wgUseAjax, $wgAjaxWatch;
366 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
367 global $wgRestrictionTypes, $wgLivePreview;
368 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
370 $ns = $wgTitle->getNamespace();
371 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
372 $separatorTransTable = $wgContLang->separatorTransformTable();
373 $separatorTransTable = $separatorTransTable ?
$separatorTransTable : array();
374 $compactSeparatorTransTable = array(
375 implode( "\t", array_keys( $separatorTransTable ) ),
376 implode( "\t", $separatorTransTable ),
378 $digitTransTable = $wgContLang->digitTransformTable();
379 $digitTransTable = $digitTransTable ?
$digitTransTable : array();
380 $compactDigitTransTable = array(
381 implode( "\t", array_keys( $digitTransTable ) ),
382 implode( "\t", $digitTransTable ),
386 'skin' => $data['skinname'],
387 'stylepath' => $wgStylePath,
388 'wgArticlePath' => $wgArticlePath,
389 'wgScriptPath' => $wgScriptPath,
390 'wgScript' => $wgScript,
391 'wgVariantArticlePath' => $wgVariantArticlePath,
392 'wgActionPaths' => (object)$wgActionPaths,
393 'wgServer' => $wgServer,
394 'wgCanonicalNamespace' => $nsname,
395 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
396 'wgNamespaceNumber' => $wgTitle->getNamespace(),
397 'wgPageName' => $wgTitle->getPrefixedDBKey(),
398 'wgTitle' => $wgTitle->getText(),
399 'wgAction' => $wgRequest->getText( 'action', 'view' ),
400 'wgArticleId' => $wgTitle->getArticleId(),
401 'wgIsArticle' => $wgOut->isArticle(),
402 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
403 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
404 'wgUserVariant' => $wgVariant->getCode(),
405 'wgUserLanguage' => $wgLang->getCode(),
406 'wgContentLanguage' => $wgContLang->getCode(),
407 'wgBreakFrames' => $wgBreakFrames,
408 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
409 'wgVersion' => $wgVersion,
410 'wgEnableAPI' => $wgEnableAPI,
411 'wgEnableWriteAPI' => $wgEnableWriteAPI,
412 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
413 'wgDigitTransformTable' => $compactDigitTransTable,
415 if ( !( $wgContLang->hasVariants() ) ) {
416 unset( $vars['wgUserVariant'] );
419 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
420 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
421 $vars['wgDBname'] = $wgDBname;
422 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
423 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
426 foreach( $wgRestrictionTypes as $type )
427 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
429 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
430 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
431 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
432 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
433 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
436 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
437 $msgs = (object)array();
438 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
439 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
441 $vars['wgAjaxWatch'] = $msgs;
444 // Allow extensions to add their custom variables to the global JS variables
445 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
447 return self
::makeVariablesScript( $vars );
451 * Return a random selection of the scripts we want in the header,
452 * according to no particular rhyme or reason. Various other scripts are
453 * returned from a haphazard assortment of other functions scattered over
454 * various files. This entire hackish system needs to be burned to the
455 * ground and rebuilt.
457 * @var $allowUserJs bool Should probably be identical to $wgAllowUserJs,
458 * but is passed as a local variable for some
460 * @var $extraHtml string A bunch of raw HTML to jam into some arbitrary
461 * place where MonoBook has historically wanted it.
462 * Old-style skins formerly put it in a different
463 * place, but if either of those is broken it's
464 * likely to be the old-style skins.
465 * @return string Raw HTML to output in some location in the <head> that's
466 * entirely arbitrary but which will probably break
467 * everything if you put it someplace else.
469 function getHeadScripts( $allowUserJs, $extraHtml = '' ) {
470 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
472 $vars = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
474 $r = array( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n$extraHtml" );
477 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
478 $r[] = "<script type=\"$wgJsMimeType\" src=\"".
479 htmlspecialchars( self
::makeUrl( '-',
480 "action=raw$jsCache&gen=js&useskin=" .
481 urlencode( $this->getSkinName() ) ) ) .
484 if( $allowUserJs && $wgUser->isLoggedIn() ) {
485 $userpage = $wgUser->getUserPage();
486 $userjs = htmlspecialchars( self
::makeUrl(
487 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
488 'action=raw&ctype='.$wgJsMimeType ) );
489 $r[] = '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>";
491 return $vars . "\t" . implode ( "\n\t", $r );
495 * To make it harder for someone to slip a user a fake
496 * user-JavaScript or user-CSS preview, a random token
497 * is associated with the login session. If it's not
498 * passed back with the preview request, we won't render
501 * @param string $action
505 function userCanPreview( $action ) {
506 global $wgRequest, $wgUser;
508 if( $action != 'submit' )
510 if( !$wgRequest->wasPosted() )
512 if( !$this->mTitle
->userCanEditCssJsSubpage() )
514 return $wgUser->matchEditToken(
515 $wgRequest->getVal( 'wpEditToken' ) );
519 * generated JavaScript action=raw&gen=js
520 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
521 * nated together. For some bizarre reason, it does *not* return any
522 * custom user JS from subpages. Huh?
524 * There's absolutely no reason to have separate Monobook/Common JSes.
525 * Any JS that cares can just check the skin variable generated at the
526 * top. For now Monobook.js will be maintained, but it should be consi-
531 public function generateUserJs() {
534 wfProfileIn( __METHOD__
);
536 $s = "/* generated javascript */\n";
537 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
538 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
539 $s .= "\n\n/* MediaWiki:Common.js */\n";
540 $commonJs = wfMsgForContent( 'common.js' );
541 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
545 $s .= "\n\n/* MediaWiki:".ucfirst( $this->getSkinName() ).".js */\n";
546 // avoid inclusion of non defined user JavaScript (with custom skins only)
547 // by checking for default message content
548 $msgKey = ucfirst( $this->getSkinName() ).'.js';
549 $userJS = wfMsgForContent( $msgKey );
550 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
554 wfProfileOut( __METHOD__
);
559 * Generate user stylesheet for action=raw&gen=css
561 public function generateUserStylesheet() {
562 wfProfileIn( __METHOD__
);
563 $s = "/* generated user stylesheet */\n" .
564 $this->reallyGenerateUserStylesheet();
565 wfProfileOut( __METHOD__
);
570 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
572 protected function reallyGenerateUserStylesheet(){
575 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
576 $underline = $undopt ?
'underline' : 'none';
577 $s .= "a { text-decoration: $underline; }\n";
579 if( $wgUser->getOption( 'highlightbroken' ) ) {
580 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
583 a.new, #quickbar a.new,
584 a.stub, #quickbar a.stub {
587 a.new:after, #quickbar a.new:after {
591 a.stub:after, #quickbar a.stub:after {
597 if( $wgUser->getOption( 'justify' ) ) {
598 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
600 if( !$wgUser->getOption( 'showtoc' ) ) {
601 $s .= "#toc { display: none; }\n";
603 if( !$wgUser->getOption( 'editsection' ) ) {
604 $s .= ".editsection { display: none; }\n";
612 function setupUserCss( OutputPage
$out ) {
613 global $wgRequest, $wgContLang, $wgUser;
614 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
616 wfProfileIn( __METHOD__
);
618 $this->setupSkinUserCss( $out );
622 'maxage' => $wgSquidMaxage,
625 // Add any extension CSS
626 foreach( $out->getExtStyle() as $tag ) {
627 $out->addStyle( $tag['href'] );
630 // If we use the site's dynamic CSS, throw that in, too
631 // Per-site custom styles
632 if( $wgUseSiteCss ) {
633 global $wgHandheldStyle;
634 $query = wfArrayToCGI( array(
635 'usemsgcache' => 'yes',
636 'ctype' => 'text/css',
637 'smaxage' => $wgSquidMaxage
639 # Site settings must override extension css! (bug 15025)
640 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
641 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
642 if( $wgHandheldStyle ) {
643 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
645 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
648 if( $wgUser->isLoggedIn() ) {
649 // Ensure that logged-in users' generated CSS isn't clobbered
650 // by anons' publicly cacheable generated CSS.
651 $siteargs['smaxage'] = '0';
652 $siteargs['ts'] = $wgUser->mTouched
;
654 // Per-user styles based on preferences
655 $siteargs['gen'] = 'css';
656 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
657 $siteargs['useskin'] = $us;
659 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
661 // Per-user custom style pages
662 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
663 $action = $wgRequest->getVal( 'action' );
664 # If we're previewing the CSS page, use it
665 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
666 $previewCss = $wgRequest->getText( 'wpTextbox1' );
667 // @FIXME: properly escape the cdata!
668 $this->usercss
= "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
670 $out->addStyle( self
::makeUrl( $this->userpage
. '/' . $this->getSkinName() .'.css',
671 'action=raw&ctype=text/css' ) );
675 wfProfileOut( __METHOD__
);
679 * Add skin specific stylesheets
680 * @param $out OutputPage
682 function setupSkinUserCss( OutputPage
$out ) {
683 $out->addStyle( 'common/shared.css' );
684 $out->addStyle( 'common/oldshared.css' );
685 $out->addStyle( $this->getStylesheet() );
686 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
689 function getBodyOptions() {
690 global $wgUser, $wgOut, $wgRequest, $wgContLang;
692 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
694 if ( 0 != $this->mTitle
->getNamespace() ) {
695 $a = array( 'bgcolor' => '#ffffec' );
697 else $a = array( 'bgcolor' => '#FFFFFF' );
698 if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
699 $this->mTitle
->quickUserCan( 'edit' ) ) {
700 $s = $this->mTitle
->getFullURL( $this->editUrlOptions() );
701 $s = 'document.location = "' .Xml
::escapeJsString( $s ) .'";';
702 $a +
= array( 'ondblclick' => $s );
704 $a['onload'] = $wgOut->getOnloadHandler();
707 ' '.( $wgContLang->isRTL() ?
'rtl' : 'ltr' ).
708 ' '.$this->getPageClasses( $this->mTitle
) .
709 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName() );
713 function getPageClasses( $title ) {
714 $numeric = 'ns-'.$title->getNamespace();
715 if( $title->getNamespace() == NS_SPECIAL
) {
716 $type = 'ns-special';
717 } elseif( $title->isTalkPage() ) {
720 $type = 'ns-subject';
722 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
723 return "$numeric $type $name";
735 * This will be called immediately after the <body> tag. Split into
736 * two functions to make it easier to subclass.
738 function beforeContent() {
739 return $this->doBeforeContent();
742 function doBeforeContent() {
744 wfProfileIn( __METHOD__
);
747 $qb = $this->qbSetting();
749 if( $langlinks = $this->otherLanguages() ) {
755 $borderhack = 'class="top"';
758 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
759 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
761 $shove = ( $qb != 0 );
762 $left = ( $qb == 1 ||
$qb == 3 );
763 if( $wgContLang->isRTL() ) $left = !$left;
766 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
767 $this->logoText() . '</td>';
769 $s .= $this->getQuickbarCompensator( $rows );
771 $l = $wgContLang->isRTL() ?
'right' : 'left';
772 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
774 $s .= $this->topLinks();
775 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
777 $r = $wgContLang->isRTL() ?
'left' : 'right';
778 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
779 $s .= $this->nameAndLogin();
780 $s .= "\n<br />" . $this->searchForm() . "</td>";
783 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
786 if ( $shove && !$left ) { # Right
787 $s .= $this->getQuickbarCompensator( $rows );
789 $s .= "</tr>\n</table>\n</div>\n";
790 $s .= "\n<div id='article'>\n";
792 $notice = wfGetSiteNotice();
794 $s .= "\n<div id='siteNotice'>$notice</div>\n";
796 $s .= $this->pageTitle();
797 $s .= $this->pageSubtitle();
798 $s .= $this->getCategories();
799 wfProfileOut( __METHOD__
);
804 function getCategoryLinks() {
805 global $wgOut, $wgUseCategoryBrowser;
806 global $wgContLang, $wgUser;
808 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
811 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
813 // Use Unicode bidi embedding override characters,
814 // to make sure links don't smash each other up in ugly ways.
815 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
816 $embed = "<span dir='$dir'>";
819 $allCats = $wgOut->getCategoryLinks();
821 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
822 if ( !empty( $allCats['normal'] ) ) {
823 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
825 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
826 $s .= '<div id="mw-normal-catlinks">' .
827 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
828 . $colon . $t . '</div>';
832 if ( isset( $allCats['hidden'] ) ) {
833 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
834 $class ='mw-hidden-cats-user-shown';
835 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
836 $class = 'mw-hidden-cats-ns-shown';
838 $class = 'mw-hidden-cats-hidden';
840 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
841 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
842 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
846 # optional 'dmoz-like' category browser. Will be shown under the list
847 # of categories an article belong to
848 if( $wgUseCategoryBrowser ){
849 $s .= '<br /><hr />';
851 # get a big array of the parents tree
852 $parenttree = $this->mTitle
->getParentCategoryTree();
853 # Skin object passed by reference cause it can not be
854 # accessed under the method subfunction drawCategoryBrowser
855 $tempout = explode( "\n", Skin
::drawCategoryBrowser( $parenttree, $this ) );
856 # Clean out bogus first entry and sort them
857 unset( $tempout[0] );
859 # Output one per line
860 $s .= implode( "<br />\n", $tempout );
867 * Render the array as a serie of links.
868 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
869 * @param &skin Object: skin passed by reference
870 * @return String separated by >, terminate with "\n"
872 function drawCategoryBrowser( $tree, &$skin ){
874 foreach( $tree as $element => $parent ) {
875 if( empty( $parent ) ) {
876 # element start a new list
879 # grab the others elements
880 $return .= Skin
::drawCategoryBrowser( $parent, $skin ) . ' > ';
882 # add our current element to the list
883 $eltitle = Title
::newFromText( $element );
884 $return .= $skin->link( $eltitle, $eltitle->getText() );
889 function getCategories() {
890 $catlinks=$this->getCategoryLinks();
892 $classes = 'catlinks';
894 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
895 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
896 $classes .= ' catlinks-allhidden';
899 if( !empty( $catlinks ) ){
900 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
904 function getQuickbarCompensator( $rows = 1 ) {
905 return "<td width='152' rowspan='{$rows}'> </td>";
909 * This runs a hook to allow extensions placing their stuff after content
910 * and article metadata (e.g. categories).
911 * Note: This function has nothing to do with afterContent().
913 * This hook is placed here in order to allow using the same hook for all
914 * skins, both the SkinTemplate based ones and the older ones, which directly
915 * use this class to get their data.
917 * The output of this function gets processed in SkinTemplate::outputPage() for
918 * the SkinTemplate based skins, all other skins should directly echo it.
920 * Returns an empty string by default, if not changed by any hook function.
922 protected function afterContentHook() {
925 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
926 // adding just some spaces shouldn't toggle the output
927 // of the whole <div/>, so we use trim() here
928 if( trim( $data ) != '' ){
929 // Doing this here instead of in the skins to
930 // ensure that the div has the same ID in all
932 $data = "<div id='mw-data-after-content'>\n" .
937 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
944 * Generate debug data HTML for displaying at the bottom of the main content
946 * @return String HTML containing debug data, if enabled (otherwise empty).
948 protected function generateDebugHTML() {
949 global $wgShowDebug, $wgOut;
950 if ( $wgShowDebug ) {
951 $listInternals = str_replace( "\n", "</li>\n<li>", htmlspecialchars( $wgOut->mDebugtext
) );
952 return "\n<hr>\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\"><li>" .
953 $listInternals . "</li></ul>\n";
959 * This gets called shortly before the </body> tag.
960 * @return String HTML to be put before </body>
962 function afterContent() {
963 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
964 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
968 * This gets called shortly before the </body> tag.
969 * @return String HTML-wrapped JS code to be put before </body>
971 function bottomScripts() {
972 global $wgJsMimeType;
973 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
974 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
975 return $bottomScriptText;
978 /** @return string Retrievied from HTML text */
979 function printSource() {
980 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
981 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
984 function printFooter() {
985 return "<p>" . $this->printSource() .
986 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
989 /** overloaded by derived classes */
990 function doAfterContent() { return '</div></div>'; }
992 function pageTitleLinks() {
993 global $wgOut, $wgUser, $wgRequest, $wgLang;
995 $oldid = $wgRequest->getVal( 'oldid' );
996 $diff = $wgRequest->getVal( 'diff' );
997 $action = $wgRequest->getText( 'action' );
999 $s[] = $this->printableLink();
1000 $disclaimer = $this->disclaimerLink(); # may be empty
1004 $privacy = $this->privacyLink(); # may be empty too
1009 if ( $wgOut->isArticleRelated() ) {
1010 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
1011 $name = $this->mTitle
->getDBkey();
1012 $image = wfFindFile( $this->mTitle
);
1014 $link = htmlspecialchars( $image->getURL() );
1015 $style = $this->getInternalLinkAttributes( $link, $name );
1016 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
1020 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
1021 $s[] .= $this->link(
1023 wfMsg( 'currentrev' ),
1026 array( 'known', 'noclasses' )
1030 if ( $wgUser->getNewtalk() ) {
1031 # do not show "You have new messages" text when we are viewing our
1033 if( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
1035 $wgUser->getTalkPage(),
1036 wfMsgHtml( 'newmessageslink' ),
1038 array( 'redirect' => 'no' ),
1039 array( 'known', 'noclasses' )
1043 $wgUser->getTalkPage(),
1044 wfMsgHtml( 'newmessagesdifflink' ),
1046 array( 'diff' => 'cur' ),
1047 array( 'known', 'noclasses' )
1049 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1051 $wgOut->setSquidMaxage( 0 );
1052 $wgOut->enableClientCache( false );
1056 $undelete = $this->getUndeleteLink();
1057 if( !empty( $undelete ) ) {
1060 return $wgLang->pipeList( $s );
1063 function getUndeleteLink() {
1064 global $wgUser, $wgContLang, $wgLang, $wgRequest;
1066 $action = $wgRequest->getVal( 'action', 'view' );
1068 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1069 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1070 $n = $this->mTitle
->isDeleted();
1072 if ( $wgUser->isAllowed( 'undelete' ) ) {
1073 $msg = 'thisisdeleted';
1075 $msg = 'viewdeleted';
1080 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1081 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1084 array( 'known', 'noclasses' )
1092 function printableLink() {
1093 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1097 if ( !$wgRequest->getBool( 'printable' ) ) {
1098 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1099 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1102 if( $wgOut->isSyndicated() ) {
1103 foreach( $wgFeedClasses as $format => $class ) {
1104 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1105 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1106 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1109 return $wgLang->pipeList( $s );
1112 function pageTitle() {
1114 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1118 function pageSubtitle() {
1121 $sub = $wgOut->getSubtitle();
1123 global $wgExtraSubtitle;
1124 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1126 $subpages = $this->subPageSubtitle();
1127 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1128 $s = "<p class='subtitle'>{$sub}</p>\n";
1132 function subPageSubtitle() {
1134 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
1138 if( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1139 $ptext = $this->mTitle
->getPrefixedText();
1140 if( preg_match( '/\//', $ptext ) ) {
1141 $links = explode( '/', $ptext );
1142 array_pop( $links );
1146 foreach( $links as $link ) {
1147 $growinglink .= $link;
1149 $linkObj = Title
::newFromText( $growinglink );
1150 if( is_object( $linkObj ) && $linkObj->exists() ){
1151 $getlink = $this->link(
1153 htmlspecialchars( $display ),
1156 array( 'known', 'noclasses' )
1160 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1162 $subpages .= '< ';
1164 $subpages .= $getlink;
1169 $growinglink .= '/';
1177 * Returns true if the IP should be shown in the header
1179 function showIPinHeader() {
1180 global $wgShowIPinHeader;
1181 return $wgShowIPinHeader && session_id() != '';
1184 function nameAndLogin() {
1185 global $wgUser, $wgLang, $wgContLang;
1187 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1190 if ( $wgUser->isAnon() ) {
1191 if( $this->showIPinHeader() ) {
1194 $talkLink = $this->link( $wgUser->getTalkPage(),
1195 $wgLang->getNsText( NS_TALK
) );
1197 $ret .= "$name ($talkLink)";
1199 $ret .= wfMsg( 'notloggedin' );
1202 $returnTo = $this->mTitle
->getPrefixedDBkey();
1204 if ( $logoutPage != $returnTo ) {
1205 $query['returnto'] = $returnTo;
1208 $loginlink = $wgUser->isAllowed( 'createaccount' )
1209 ?
'nav-login-createaccount'
1211 $ret .= "\n<br />" . $this->link(
1212 SpecialPage
::getTitleFor( 'Userlogin' ),
1213 wfMsg( $loginlink ), array(), $query
1216 $returnTo = $this->mTitle
->getPrefixedDBkey();
1217 $talkLink = $this->link( $wgUser->getTalkPage(),
1218 $wgLang->getNsText( NS_TALK
) );
1220 $ret .= $this->link( $wgUser->getUserPage(),
1221 htmlspecialchars( $wgUser->getName() ) );
1222 $ret .= " ($talkLink)<br />";
1223 $ret .= $wgLang->pipeList( array(
1225 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1226 array(), array( 'returnto' => $returnTo )
1228 $this->specialLink( 'preferences' ),
1231 $ret = $wgLang->pipeList( array(
1234 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1242 function getSearchLink() {
1243 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1244 return $searchPage->getLocalURL();
1247 function escapeSearchLink() {
1248 return htmlspecialchars( $this->getSearchLink() );
1251 function searchForm() {
1252 global $wgRequest, $wgUseTwoButtonsSearchForm;
1253 $search = $wgRequest->getText( 'search' );
1255 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1256 . $this->escapeSearchLink() . "\">\n"
1257 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1258 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1259 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1261 if( $wgUseTwoButtonsSearchForm )
1262 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1264 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1268 // Ensure unique id's for search boxes made after the first
1269 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1274 function topLinks() {
1278 $this->mainPageLink(),
1279 $this->specialLink( 'recentchanges' )
1282 if ( $wgOut->isArticleRelated() ) {
1283 $s[] = $this->editThisPage();
1284 $s[] = $this->historyLink();
1286 # Many people don't like this dropdown box
1287 #$s[] = $this->specialPagesList();
1289 if( $this->variantLinks() ) {
1290 $s[] = $this->variantLinks();
1293 if( $this->extensionTabLinks() ) {
1294 $s[] = $this->extensionTabLinks();
1297 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1298 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1302 * Compatibility for extensions adding functionality through tabs.
1303 * Eventually these old skins should be replaced with SkinTemplate-based
1307 function extensionTabLinks() {
1311 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1312 foreach( $tabs as $tab ) {
1313 $s[] = Xml
::element( 'a',
1314 array( 'href' => $tab['href'] ),
1321 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1322 $out .= $wgLang->pipeList( $s );
1329 * Language/charset variant links for classic-style skins
1332 function variantLinks() {
1334 /* show links to different language variants */
1335 global $wgDisableLangConversion, $wgLang, $wgContLang;
1336 $variants = $wgContLang->getVariants();
1337 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1338 foreach( $variants as $code ) {
1339 $varname = $wgContLang->getVariantname( $code );
1340 if( $varname == 'disable' )
1342 $s = $wgLang->pipeList( array(
1344 '<a href="' . $this->mTitle
->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1351 function bottomLinks() {
1352 global $wgOut, $wgUser, $wgUseTrackbacks;
1353 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1356 if ( $wgOut->isArticleRelated() ) {
1357 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1358 if ( $wgUser->isLoggedIn() ) {
1359 $element[] = $this->watchThisPage();
1361 $element[] = $this->talkLink();
1362 $element[] = $this->historyLink();
1363 $element[] = $this->whatLinksHere();
1364 $element[] = $this->watchPageLinksLink();
1366 if( $wgUseTrackbacks )
1367 $element[] = $this->trackbackLink();
1369 if ( $this->mTitle
->getNamespace() == NS_USER
1370 ||
$this->mTitle
->getNamespace() == NS_USER_TALK
){
1371 $id = User
::idFromName( $this->mTitle
->getText() );
1372 $ip = User
::isIP( $this->mTitle
->getText() );
1374 if( $id ||
$ip ) { # both anons and non-anons have contri list
1375 $element[] = $this->userContribsLink();
1377 if( $this->showEmailUser( $id ) ) {
1378 $element[] = $this->emailUserLink();
1382 $s = implode( $element, $sep );
1384 if ( $this->mTitle
->getArticleId() ) {
1386 if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1387 if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1388 if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
1390 $s .= "<br />\n" . $this->otherLanguages();
1396 function pageStats() {
1397 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1398 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1400 $oldid = $wgRequest->getVal( 'oldid' );
1401 $diff = $wgRequest->getVal( 'diff' );
1402 if ( ! $wgOut->isArticle() ) { return ''; }
1403 if( !$wgArticle instanceOf Article
) { return ''; }
1404 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1405 if ( 0 == $wgArticle->getID() ) { return ''; }
1408 if ( !$wgDisableCounters ) {
1409 $count = $wgLang->formatNum( $wgArticle->getCount() );
1411 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1415 if( $wgMaxCredits != 0 ){
1416 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1418 $s .= $this->lastModified();
1421 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1422 $dbr = wfGetDB( DB_SLAVE
);
1423 $res = $dbr->select( 'watchlist',
1424 array( 'COUNT(*) AS n' ),
1425 array( 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ), 'wl_namespace' => $this->mTitle
->getNamespace() ),
1428 $x = $dbr->fetchObject( $res );
1430 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1431 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1435 return $s . ' ' . $this->getCopyright();
1438 function getCopyright( $type = 'detect' ) {
1439 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1441 if ( $type == 'detect' ) {
1442 $diff = $wgRequest->getVal( 'diff' );
1443 $isCur = $wgArticle && $wgArticle->isCurrent();
1444 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1451 if ( $type == 'history' ) {
1452 $msg = 'history_copyright';
1458 if( $wgRightsPage ) {
1459 $title = Title
::newFromText( $wgRightsPage );
1460 $link = $this->linkKnown( $title, $wgRightsText );
1461 } elseif( $wgRightsUrl ) {
1462 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1463 } elseif( $wgRightsText ) {
1464 $link = $wgRightsText;
1469 // Allow for site and per-namespace customization of copyright notice.
1470 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
1472 $out .= wfMsgForContent( $msg, $link );
1476 function getCopyrightIcon() {
1477 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1479 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1480 $out = $wgCopyrightIcon;
1481 } else if ( $wgRightsIcon ) {
1482 $icon = htmlspecialchars( $wgRightsIcon );
1483 if ( $wgRightsUrl ) {
1484 $url = htmlspecialchars( $wgRightsUrl );
1485 $out .= '<a href="'.$url.'">';
1487 $text = htmlspecialchars( $wgRightsText );
1488 $out .= "<img src=\"$icon\" alt='$text' />";
1489 if ( $wgRightsUrl ) {
1496 function getPoweredBy() {
1497 global $wgStylePath;
1498 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1499 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1503 function lastModified() {
1504 global $wgLang, $wgArticle;
1505 if( $this->mRevisionId
) {
1506 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1508 $timestamp = $wgArticle->getTimestamp();
1511 $d = $wgLang->date( $timestamp, true );
1512 $t = $wgLang->time( $timestamp, true );
1513 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1517 if ( wfGetLB()->getLaggedSlaveMode() ) {
1518 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1523 function logoText( $align = '' ) {
1524 if ( '' != $align ) {
1525 $a = " align='{$align}'";
1530 $mp = wfMsg( 'mainpage' );
1531 $mptitle = Title
::newMainPage();
1532 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1534 $logourl = $this->getLogo();
1535 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1540 * show a drop-down box of special pages
1542 function specialPagesList() {
1543 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1544 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1545 foreach ( $pages as $name => $page ) {
1546 $pages[$name] = $page->getDescription();
1549 $go = wfMsg( 'go' );
1550 $sp = wfMsg( 'specialpages' );
1551 $spp = $wgContLang->specialPage( 'Specialpages' );
1553 $s = '<form id="specialpages" method="get" ' .
1554 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1555 $s .= "<select name=\"wpDropdown\">\n";
1556 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1559 foreach ( $pages as $name => $desc ) {
1560 $p = $wgContLang->specialPage( $name );
1561 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1563 $s .= "</select>\n";
1564 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1569 function mainPageLink() {
1571 Title
::newMainPage(),
1572 wfMsg( 'mainpage' ),
1575 array( 'known', 'noclasses' )
1580 function copyrightLink() {
1581 $title = Title
::newFromText( wfMsgForContent( 'copyrightpage' ) );
1582 $s = $this->linkKnown(
1584 wfMsg( 'copyrightpagename' )
1589 private function footerLink ( $desc, $page ) {
1590 // if the link description has been set to "-" in the default language,
1591 if ( wfMsgForContent( $desc ) == '-') {
1592 // then it is disabled, for all languages.
1595 // Otherwise, we display the link for the user, described in their
1596 // language (which may or may not be the same as the default language),
1597 // but we make the link target be the one site-wide page.
1598 $title = Title
::newFromText( wfMsgForContent( $page ) );
1599 return $this->linkKnown(
1601 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1606 function privacyLink() {
1607 return $this->footerLink( 'privacy', 'privacypage' );
1610 function aboutLink() {
1611 return $this->footerLink( 'aboutsite', 'aboutpage' );
1614 function disclaimerLink() {
1615 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1618 function editThisPage() {
1621 if ( !$wgOut->isArticleRelated() ) {
1622 $s = wfMsg( 'protectedpage' );
1624 if( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1625 $t = wfMsg( 'editthispage' );
1626 } elseif( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1627 $t = wfMsg( 'create-this-page' );
1629 $t = wfMsg( 'viewsource' );
1636 $this->editUrlOptions(),
1637 array( 'known', 'noclasses' )
1644 * Return URL options for the 'edit page' link.
1645 * This may include an 'oldid' specifier, if the current page view is such.
1650 function editUrlOptions() {
1653 $options = array( 'action' => 'edit' );
1655 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1656 $options['oldid'] = intval( $this->mRevisionId
);
1662 function deleteThisPage() {
1663 global $wgUser, $wgRequest;
1665 $diff = $wgRequest->getVal( 'diff' );
1666 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1667 $t = wfMsg( 'deletethispage' );
1673 array( 'action' => 'delete' ),
1674 array( 'known', 'noclasses' )
1682 function protectThisPage() {
1683 global $wgUser, $wgRequest;
1685 $diff = $wgRequest->getVal( 'diff' );
1686 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1687 if ( $this->mTitle
->isProtected() ) {
1688 $text = wfMsg( 'unprotectthispage' );
1689 $query = array( 'action' => 'unprotect' );
1691 $text = wfMsg( 'protectthispage' );
1692 $query = array( 'action' => 'protect' );
1700 array( 'known', 'noclasses' )
1708 function watchThisPage() {
1710 ++
$this->mWatchLinkNum
;
1712 if ( $wgOut->isArticleRelated() ) {
1713 if ( $this->mTitle
->userIsWatching() ) {
1714 $text = wfMsg( 'unwatchthispage' );
1715 $query = array( 'action' => 'unwatch' );
1716 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1718 $text = wfMsg( 'watchthispage' );
1719 $query = array( 'action' => 'watch' );
1720 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1726 array( 'id' => $id ),
1728 array( 'known', 'noclasses' )
1731 $s = wfMsg( 'notanarticle' );
1736 function moveThisPage() {
1737 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1739 SpecialPage
::getTitleFor( 'Movepage' ),
1740 wfMsg( 'movethispage' ),
1742 array( 'target' => $this->mTitle
->getPrefixedURL() ),
1743 array( 'known', 'noclasses' )
1746 // no message if page is protected - would be redundant
1751 function historyLink() {
1754 wfMsgHtml( 'history' ),
1755 array( 'rel' => 'archives' ),
1756 array( 'action' => 'history' )
1760 function whatLinksHere() {
1762 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1763 wfMsgHtml( 'whatlinkshere' ),
1766 array( 'known', 'noclasses' )
1770 function userContribsLink() {
1772 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1773 wfMsgHtml( 'contributions' ),
1776 array( 'known', 'noclasses' )
1780 function showEmailUser( $id ) {
1782 $targetUser = User
::newFromId( $id );
1783 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1784 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1787 function emailUserLink() {
1789 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1790 wfMsg( 'emailuser' ),
1793 array( 'known', 'noclasses' )
1797 function watchPageLinksLink() {
1799 if ( ! $wgOut->isArticleRelated() ) {
1800 return '(' . wfMsg( 'notanarticle' ) . ')';
1803 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1804 wfMsg( 'recentchangeslinked-toolbox' ),
1807 array( 'known', 'noclasses' )
1812 function trackbackLink() {
1813 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1814 . wfMsg( 'trackbacklink' ) . '</a>';
1817 function otherLanguages() {
1818 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1820 if ( $wgHideInterlanguageLinks ) {
1824 $a = $wgOut->getLanguageLinks();
1825 if ( 0 == count( $a ) ) {
1829 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1831 if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
1832 foreach( $a as $l ) {
1834 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1838 $nt = Title
::newFromText( $l );
1839 $url = $nt->escapeFullURL();
1840 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1842 if ( '' == $text ) { $text = $l; }
1843 $style = $this->getExternalLinkAttributes( $l, $text );
1844 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1846 if( $wgContLang->isRTL() ) $s .= '</span>';
1850 function talkLink() {
1851 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1852 # No discussion links for special pages
1856 $linkOptions = array();
1858 if( $this->mTitle
->isTalkPage() ) {
1859 $link = $this->mTitle
->getSubjectPage();
1860 switch( $link->getNamespace() ) {
1862 $text = wfMsg( 'articlepage' );
1865 $text = wfMsg( 'userpage' );
1868 $text = wfMsg( 'projectpage' );
1871 $text = wfMsg( 'imagepage' );
1872 # Make link known if image exists, even if the desc. page doesn't.
1873 if( wfFindFile( $link ) )
1874 $linkOptions[] = 'known';
1877 $text = wfMsg( 'mediawikipage' );
1880 $text = wfMsg( 'templatepage' );
1883 $text = wfMsg( 'viewhelppage' );
1886 $text = wfMsg( 'categorypage' );
1889 $text = wfMsg( 'articlepage' );
1892 $link = $this->mTitle
->getTalkPage();
1893 $text = wfMsg( 'talkpage' );
1896 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1901 function commentLink() {
1904 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1908 # __NEWSECTIONLINK___ changes behaviour here
1909 # If it is present, the link points to this page, otherwise
1910 # it points to the talk page
1911 if( $this->mTitle
->isTalkPage() ) {
1912 $title = $this->mTitle
;
1913 } elseif( $wgOut->showNewSectionLink() ) {
1914 $title = $this->mTitle
;
1916 $title = $this->mTitle
->getTalkPage();
1921 wfMsg( 'postcomment' ),
1927 array( 'known', 'noclasses' )
1931 /* these are used extensively in SkinTemplate, but also some other places */
1932 static function makeMainPageUrl( $urlaction = '' ) {
1933 $title = Title
::newMainPage();
1934 self
::checkTitle( $title, '' );
1935 return $title->getLocalURL( $urlaction );
1938 static function makeSpecialUrl( $name, $urlaction = '' ) {
1939 $title = SpecialPage
::getTitleFor( $name );
1940 return $title->getLocalURL( $urlaction );
1943 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1944 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1945 return $title->getLocalURL( $urlaction );
1948 static function makeI18nUrl( $name, $urlaction = '' ) {
1949 $title = Title
::newFromText( wfMsgForContent( $name ) );
1950 self
::checkTitle( $title, $name );
1951 return $title->getLocalURL( $urlaction );
1954 static function makeUrl( $name, $urlaction = '' ) {
1955 $title = Title
::newFromText( $name );
1956 self
::checkTitle( $title, $name );
1957 return $title->getLocalURL( $urlaction );
1960 # If url string starts with http, consider as external URL, else
1962 static function makeInternalOrExternalUrl( $name ) {
1963 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1966 return self
::makeUrl( $name );
1970 # this can be passed the NS number as defined in Language.php
1971 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1972 $title = Title
::makeTitleSafe( $namespace, $name );
1973 self
::checkTitle( $title, $name );
1974 return $title->getLocalURL( $urlaction );
1977 /* these return an array with the 'href' and boolean 'exists' */
1978 static function makeUrlDetails( $name, $urlaction = '' ) {
1979 $title = Title
::newFromText( $name );
1980 self
::checkTitle( $title, $name );
1982 'href' => $title->getLocalURL( $urlaction ),
1983 'exists' => $title->getArticleID() != 0 ?
true : false
1988 * Make URL details where the article exists (or at least it's convenient to think so)
1990 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1991 $title = Title
::newFromText( $name );
1992 self
::checkTitle( $title, $name );
1994 'href' => $title->getLocalURL( $urlaction ),
1999 # make sure we have some title to operate on
2000 static function checkTitle( &$title, $name ) {
2001 if( !is_object( $title ) ) {
2002 $title = Title
::newFromText( $name );
2003 if( !is_object( $title ) ) {
2004 $title = Title
::newFromText( '--error: link target missing--' );
2010 * Build an array that represents the sidebar(s), the navigation bar among them
2014 function buildSidebar() {
2015 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2017 wfProfileIn( __METHOD__
);
2019 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2021 if ( $wgEnableSidebarCache ) {
2022 $cachedsidebar = $parserMemc->get( $key );
2023 if ( $cachedsidebar ) {
2024 wfProfileOut( __METHOD__
);
2025 return $cachedsidebar;
2030 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
2032 foreach( $lines as $line ) {
2033 if( strpos( $line, '*' ) !== 0 )
2035 if( strpos( $line, '**') !== 0 ) {
2036 $heading = trim( $line, '* ' );
2037 if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
2039 if( strpos( $line, '|' ) !== false ) { // sanity check
2040 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
2041 $link = wfMsgForContent( $line[0] );
2045 $text = wfMsgExt( $line[1], 'parsemag' );
2046 if( wfEmptyMsg( $line[1], $text ) )
2048 if( wfEmptyMsg( $line[0], $link ) )
2051 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2054 $title = Title
::newFromText( $link );
2056 $title = $title->fixSpecialName();
2057 $href = $title->getLocalURL();
2059 $href = 'INVALID-TITLE';
2063 $bar[$heading][] = array(
2066 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2069 } else { continue; }
2072 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2073 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2074 wfProfileOut( __METHOD__
);
2079 * Should we include common/wikiprintable.css? Skins that have their own
2080 * print stylesheet should override this and return false. (This is an
2081 * ugly hack to get Monobook to play nicely with
2082 * OutputPage::headElement().)
2086 public function commonPrintStylesheet() {