3 * @defgroup Skins Skins
6 if ( ! defined( 'MEDIAWIKI' ) )
10 * The main skin class that provide methods and properties for all other skins.
11 * This base class is also the "Standard" skin.
13 * See docs/skin.txt for more information.
17 class Skin
extends Linker
{
21 var $mWatchLinkNum = 0; // Appended to end of watch link id's
22 // How many search boxes have we made? Avoid duplicate id's.
23 protected $searchboxes = '';
25 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
26 protected $skinname = 'standard';
27 // @fixme Should be protected :-\
30 /** Constructor, call parent constructor */
31 function Skin() { parent
::__construct(); }
34 * Fetch the set of available skins.
35 * @return array of strings
38 static function getSkinNames() {
39 global $wgValidSkinNames;
40 static $skinsInitialised = false;
41 if ( !$skinsInitialised ) {
42 # Get a list of available skins
43 # Build using the regular expression '^(.*).php$'
44 # Array keys are all lower case, array value keep the case used by filename
46 wfProfileIn( __METHOD__
. '-init' );
47 global $wgStyleDirectory;
48 $skinDir = dir( $wgStyleDirectory );
50 # while code from www.php.net
51 while( false !== ( $file = $skinDir->read() ) ) {
52 // Skip non-PHP files, hidden files, and '.dep' includes
54 if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
56 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
60 $skinsInitialised = true;
61 wfProfileOut( __METHOD__
. '-init' );
63 return $wgValidSkinNames;
67 * Fetch the list of usable skins in regards to $wgSkipSkins.
68 * Useful for Special:Preferences and other places where you
69 * only want to show skins users _can_ use.
70 * @return array of strings
72 public static function getUsableSkins() {
74 $usableSkins = self
::getSkinNames();
75 foreach ( $wgSkipSkins as $skip ) {
76 unset( $usableSkins[$skip] );
82 * Normalize a skin preference value to a form that can be loaded.
83 * If a skin can't be found, it will fall back to the configured
84 * default (or the old 'Classic' skin if that's broken).
89 static function normalizeKey( $key ) {
90 global $wgDefaultSkin;
91 $skinNames = Skin
::getSkinNames();
94 // Don't return the default immediately;
95 // in a misconfiguration we need to fall back.
96 $key = $wgDefaultSkin;
99 if( isset( $skinNames[$key] ) ) {
103 // Older versions of the software used a numeric setting
104 // in the user preferences.
108 2 => 'cologneblue' );
110 if( isset( $fallback[$key] ) ){
111 $key = $fallback[$key];
114 if( isset( $skinNames[$key] ) ) {
122 * Factory method for loading a skin of a given type
123 * @param string $key 'monobook', 'standard', etc
127 static function &newFromKey( $key ) {
128 global $wgStyleDirectory;
130 $key = Skin
::normalizeKey( $key );
132 $skinNames = Skin
::getSkinNames();
133 $skinName = $skinNames[$key];
134 $className = 'Skin'.ucfirst($key);
136 # Grab the skin class and initialise it.
137 if ( !class_exists( $className ) ) {
138 // Preload base classes to work around APC/PHP5 bug
139 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
140 if( file_exists( $deps ) ) include_once( $deps );
141 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
143 # Check if we got if not failback to default skin
144 if( !class_exists( $className ) ) {
145 # DO NOT die if the class isn't found. This breaks maintenance
146 # scripts and can cause a user account to be unrecoverable
147 # except by SQL manipulation if a previously valid skin name
148 # is no longer valid.
149 wfDebug( "Skin class does not exist: $className\n" );
150 $className = 'SkinMonobook';
151 require_once( "{$wgStyleDirectory}/MonoBook.php" );
154 $skin = new $className;
158 /** @return string path to the skin stylesheet */
159 function getStylesheet() {
160 return 'common/wikistandard.css';
163 /** @return string skin name */
164 public function getSkinName() {
165 return $this->skinname
;
168 function qbSetting() {
169 global $wgOut, $wgUser;
171 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
172 $q = $wgUser->getOption( 'quickbar', 0 );
176 function initPage( OutputPage
$out ) {
177 global $wgFavicon, $wgAppleTouchIcon;
179 wfProfileIn( __METHOD__
);
181 # Generally the order of the favicon and apple-touch-icon links
182 # should not matter, but Konqueror (3.5.9 at least) incorrectly
183 # uses whichever one appears later in the HTML source. Make sure
184 # apple-touch-icon is specified first to avoid this.
185 if( false !== $wgAppleTouchIcon ) {
186 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
189 if( false !== $wgFavicon ) {
190 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
193 # OpenSearch description link
194 $out->addLink( array(
196 'type' => 'application/opensearchdescription+xml',
197 'href' => wfScript( 'opensearch_desc' ),
198 'title' => wfMsgForContent( 'opensearch-desc' ),
201 $this->addMetadataLinks( $out );
203 $this->mRevisionId
= $out->mRevisionId
;
205 $this->preloadExistence();
207 wfProfileOut( __METHOD__
);
211 * Preload the existence of three commonly-requested pages in a single query
213 function preloadExistence() {
217 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
220 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
222 } elseif ( $this->mTitle
->isTalkPage() ) {
223 $titles[] = $this->mTitle
->getSubjectPage();
225 $titles[] = $this->mTitle
->getTalkPage();
228 $lb = new LinkBatch( $titles );
232 function addMetadataLinks( OutputPage
$out ) {
233 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
234 global $wgRightsPage, $wgRightsUrl;
236 if( $out->isArticleRelated() ) {
237 # note: buggy CC software only reads first "meta" link
238 if( $wgEnableCreativeCommonsRdf ) {
239 $out->addMetadataLink( array(
240 'title' => 'Creative Commons',
241 'type' => 'application/rdf+xml',
242 'href' => $this->mTitle
->getLocalURL( 'action=creativecommons' ) )
245 if( $wgEnableDublinCoreRdf ) {
246 $out->addMetadataLink( array(
247 'title' => 'Dublin Core',
248 'type' => 'application/rdf+xml',
249 'href' => $this->mTitle
->getLocalURL( 'action=dublincore' ) )
254 if( $wgRightsPage ) {
255 $copy = Title
::newFromText( $wgRightsPage );
257 $copyright = $copy->getLocalURL();
260 if( !$copyright && $wgRightsUrl ) {
261 $copyright = $wgRightsUrl;
264 $out->addLink( array(
265 'rel' => 'copyright',
266 'href' => $copyright )
272 * Set some local variables
274 protected function setMembers(){
276 $this->mUser
= $wgUser;
277 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
278 $this->usercss
= false;
283 * @param Title $t The title to use
285 public function setTitle( $t ) {
290 public function getTitle() {
291 return $this->mTitle
;
294 function outputPage( OutputPage
$out ) {
295 global $wgDebugComments;
296 wfProfileIn( __METHOD__
);
299 $this->initPage( $out );
301 // See self::afterContentHook() for documentation
302 $afterContent = $this->afterContentHook();
304 $out->out( $out->headElement( $this ) );
306 $out->out( "\n<body" );
307 $ops = $this->getBodyOptions();
308 foreach ( $ops as $name => $val ) {
309 $out->out( " $name='$val'" );
312 if ( $wgDebugComments ) {
313 $out->out( "<!-- Wiki debugging output:\n" .
314 $out->mDebugtext
. "-->\n" );
317 $out->out( $this->beforeContent() );
319 $out->out( $out->mBodytext
. "\n" );
321 $out->out( $this->afterContent() );
323 $out->out( $afterContent );
325 $out->out( $this->bottomScripts() );
327 $out->out( wfReportTime() );
329 $out->out( "\n</body></html>" );
330 wfProfileOut( __METHOD__
);
333 static function makeVariablesScript( $data ) {
336 foreach ( $data as $name => $value ) {
337 $encValue = Xml
::encodeJsVar( $value );
338 $r[] = "$name=$encValue";
340 $js = 'var ' . implode( ",\n", $r ) . ';';
341 return Html
::inlineScript( "\n$js\n" );
348 * Make a <script> tag containing global variables
349 * @param $skinName string Name of the skin
350 * The odd calling convention is for backwards compatibility
351 * @TODO @FIXME Make this not depend on $wgTitle!
353 static function makeGlobalVariablesScript( $skinName ) {
354 if ( is_array( $skinName ) ) {
355 # Weird back-compat stuff.
356 $skinName = $skinName['skinname'];
358 global $wgScript, $wgTitle, $wgStylePath, $wgUser, $wgScriptExtension;
359 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
360 global $wgOut, $wgArticle;
361 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
362 global $wgUseAjax, $wgAjaxWatch;
363 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
364 global $wgRestrictionTypes, $wgLivePreview;
365 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
366 global $wgSitename, $wgEnableIframeApiProxy, $wgEnableJS2system;
368 $ns = $wgTitle->getNamespace();
369 $nsname = MWNamespace
::exists( $ns ) ? MWNamespace
::getCanonicalName( $ns ) : $wgTitle->getNsText();
370 $separatorTransTable = $wgContLang->separatorTransformTable();
371 $separatorTransTable = $separatorTransTable ?
$separatorTransTable : array();
372 $compactSeparatorTransTable = array(
373 implode( "\t", array_keys( $separatorTransTable ) ),
374 implode( "\t", $separatorTransTable ),
376 $digitTransTable = $wgContLang->digitTransformTable();
377 $digitTransTable = $digitTransTable ?
$digitTransTable : array();
378 $compactDigitTransTable = array(
379 implode( "\t", array_keys( $digitTransTable ) ),
380 implode( "\t", $digitTransTable ),
383 $mainPage = Title
::newFromText( wfMsgForContent( 'mainpage' ) );
386 'stylepath' => $wgStylePath,
387 'urlprotocols' => wfUrlProtocols(),
388 'wgArticlePath' => $wgArticlePath,
389 'wgScriptPath' => $wgScriptPath,
390 'wgScriptExtension' => $wgScriptExtension,
391 'wgScript' => $wgScript,
392 'wgVariantArticlePath' => $wgVariantArticlePath,
393 'wgActionPaths' => (object)$wgActionPaths,
394 'wgServer' => $wgServer,
395 'wgCanonicalNamespace' => $nsname,
396 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ?
397 SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115
398 'wgNamespaceNumber' => $wgTitle->getNamespace(),
399 'wgPageName' => $wgTitle->getPrefixedDBKey(),
400 'wgTitle' => $wgTitle->getText(),
401 'wgAction' => $wgRequest->getText( 'action', 'view' ),
402 'wgArticleId' => $wgTitle->getArticleId(),
403 'wgIsArticle' => $wgOut->isArticle(),
404 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
405 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
406 'wgUserLanguage' => $wgLang->getCode(),
407 'wgContentLanguage' => $wgContLang->getCode(),
408 'wgBreakFrames' => $wgBreakFrames,
409 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
410 'wgVersion' => $wgVersion,
411 'wgEnableAPI' => $wgEnableAPI,
412 'wgEnableWriteAPI' => $wgEnableWriteAPI,
413 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
414 'wgDigitTransformTable' => $compactDigitTransTable,
415 'wgMainPageTitle' => $mainPage ?
$mainPage->getPrefixedText() : null,
416 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
417 'wgNamespaceIds' => $wgContLang->getNamespaceIds(),
418 'wgSiteName' => $wgSitename,
420 if ( $wgContLang->hasVariants() ) {
421 $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
424 //if on upload page output the extension list & js_upload
425 if( SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) == "Upload" ) {
426 global $wgFileExtensions, $wgAjaxUploadInterface;
427 $vars['wgFileExtensions'] = $wgFileExtensions;
428 $vars['wgAjaxUploadInterface'] = $wgAjaxUploadInterface;
431 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
432 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
433 $vars['wgDBname'] = $wgDBname;
434 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
435 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
438 foreach( $wgRestrictionTypes as $type )
439 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
441 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
442 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
443 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
444 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
445 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
448 //add api proxy var and script link if on the special proxy page:
449 if( $wgEnableJS2system &&
450 $wgTitle->getNamespace() == NS_MEDIAWIKI
&&
451 $wgTitle->getDBKey() == 'ApiProxy' )
453 $vars['wgEnableIframeApiProxy'] = $wgEnableIframeApiProxy;
454 //also add the apiProxy Page script if we are on that page
455 if( $wgEnableIframeApiProxy )
456 $wgOut->addScriptClass( 'apiProxyPage' );
459 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
460 $msgs = (object)array();
461 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
462 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
464 $vars['wgAjaxWatch'] = $msgs;
467 // Allow extensions to add their custom variables to the global JS variables
468 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
470 return self
::makeVariablesScript( $vars );
474 * To make it harder for someone to slip a user a fake
475 * user-JavaScript or user-CSS preview, a random token
476 * is associated with the login session. If it's not
477 * passed back with the preview request, we won't render
480 * @param string $action
483 public function userCanPreview( $action ) {
484 global $wgRequest, $wgUser;
486 if( $action != 'submit' )
488 if( !$wgRequest->wasPosted() )
490 if( !$this->mTitle
->userCanEditCssSubpage() )
492 if( !$this->mTitle
->userCanEditJsSubpage() )
494 return $wgUser->matchEditToken(
495 $wgRequest->getVal( 'wpEditToken' ) );
499 * generated JavaScript action=raw&gen=js
500 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
501 * nated together. For some bizarre reason, it does *not* return any
502 * custom user JS from subpages. Huh?
504 * There's absolutely no reason to have separate Monobook/Common JSes.
505 * Any JS that cares can just check the skin variable generated at the
506 * top. For now Monobook.js will be maintained, but it should be consi-
509 * @param $force_skin string If set, overrides the skin name
513 public function generateUserJs( $skinName = null ) {
516 wfProfileIn( __METHOD__
);
518 $skinName = $this->getSkinName();
521 $s = "/* generated javascript */\n";
522 $s .= "var skin = '" . Xml
::escapeJsString($skinName ) . "';\n";
523 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
524 $s .= "\n\n/* MediaWiki:Common.js */\n";
525 $commonJs = wfMsgForContent( 'common.js' );
526 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
530 $s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n";
531 // avoid inclusion of non defined user JavaScript (with custom skins only)
532 // by checking for default message content
533 $msgKey = ucfirst( $skinName ) . '.js';
534 $userJS = wfMsgForContent( $msgKey );
535 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
539 wfProfileOut( __METHOD__
);
544 * Generate user stylesheet for action=raw&gen=css
546 public function generateUserStylesheet() {
547 wfProfileIn( __METHOD__
);
548 $s = "/* generated user stylesheet */\n" .
549 $this->reallyGenerateUserStylesheet();
550 wfProfileOut( __METHOD__
);
555 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
557 protected function reallyGenerateUserStylesheet(){
560 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
561 $underline = $undopt ?
'underline' : 'none';
562 $s .= "a { text-decoration: $underline; }\n";
564 if( $wgUser->getOption( 'highlightbroken' ) ) {
565 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
568 a.new, #quickbar a.new,
569 a.stub, #quickbar a.stub {
572 a.new:after, #quickbar a.new:after {
576 a.stub:after, #quickbar a.stub:after {
582 if( $wgUser->getOption( 'justify' ) ) {
583 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
585 if( !$wgUser->getOption( 'showtoc' ) ) {
586 $s .= "#toc { display: none; }\n";
588 if( !$wgUser->getOption( 'editsection' ) ) {
589 $s .= ".editsection { display: none; }\n";
591 $fontstyle = $wgUser->getOption( 'editfont' );
592 if ( $fontstyle !== 'default' ) {
593 $s .= "textarea { font-family: $fontstyle; }\n";
601 function setupUserCss( OutputPage
$out ) {
602 global $wgRequest, $wgContLang, $wgUser;
603 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
605 wfProfileIn( __METHOD__
);
607 $this->setupSkinUserCss( $out );
611 'maxage' => $wgSquidMaxage,
614 // Add any extension CSS
615 foreach ( $out->getExtStyle() as $url ) {
616 $out->addStyle( $url );
619 // If we use the site's dynamic CSS, throw that in, too
620 // Per-site custom styles
621 if( $wgUseSiteCss ) {
622 global $wgHandheldStyle;
623 $query = wfArrayToCGI( array(
624 'usemsgcache' => 'yes',
625 'ctype' => 'text/css',
626 'smaxage' => $wgSquidMaxage
628 # Site settings must override extension css! (bug 15025)
629 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
630 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
631 if( $wgHandheldStyle ) {
632 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
634 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
637 if( $wgUser->isLoggedIn() ) {
638 // Ensure that logged-in users' generated CSS isn't clobbered
639 // by anons' publicly cacheable generated CSS.
640 $siteargs['smaxage'] = '0';
641 $siteargs['ts'] = $wgUser->mTouched
;
643 // Per-user styles based on preferences
644 $siteargs['gen'] = 'css';
645 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
646 $siteargs['useskin'] = $us;
648 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
650 // Per-user custom style pages
651 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
652 $action = $wgRequest->getVal( 'action' );
653 # If we're previewing the CSS page, use it
654 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
655 // @FIXME: properly escape the cdata!
656 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
658 $out->addStyle( self
::makeUrl( $this->userpage
. '/' . $this->getSkinName() .'.css',
659 'action=raw&ctype=text/css' ) );
663 wfProfileOut( __METHOD__
);
667 * Add skin specific stylesheets
668 * @param $out OutputPage
670 function setupSkinUserCss( OutputPage
$out ) {
671 $out->addStyle( 'common/shared.css' );
672 $out->addStyle( 'common/oldshared.css' );
673 $out->addStyle( $this->getStylesheet() );
674 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
677 function getBodyOptions() {
678 global $wgUser, $wgOut, $wgRequest, $wgContLang;
680 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
682 if ( 0 != $this->mTitle
->getNamespace() ) {
683 $a = array( 'bgcolor' => '#ffffec' );
685 else $a = array( 'bgcolor' => '#FFFFFF' );
686 if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
687 $this->mTitle
->quickUserCan( 'edit' ) ) {
688 $s = $this->mTitle
->getFullURL( $this->editUrlOptions() );
689 $s = 'document.location = "' .Xml
::escapeJsString( $s ) .'";';
690 $a +
= array( 'ondblclick' => $s );
692 $a['onload'] = $wgOut->getOnloadHandler();
695 ' '.( $wgContLang->getDir() ).
696 ' '.$this->getPageClasses( $this->mTitle
) .
697 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName() );
701 function getPageClasses( $title ) {
702 $numeric = 'ns-'.$title->getNamespace();
703 if( $title->getNamespace() == NS_SPECIAL
) {
704 $type = 'ns-special';
705 } elseif( $title->isTalkPage() ) {
708 $type = 'ns-subject';
710 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
711 return "$numeric $type $name";
723 * This will be called immediately after the <body> tag. Split into
724 * two functions to make it easier to subclass.
726 function beforeContent() {
727 return $this->doBeforeContent();
730 function doBeforeContent() {
732 wfProfileIn( __METHOD__
);
735 $qb = $this->qbSetting();
737 if( $langlinks = $this->otherLanguages() ) {
743 $borderhack = 'class="top"';
746 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
747 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
749 $shove = ( $qb != 0 );
750 $left = ( $qb == 1 ||
$qb == 3 );
751 if( $wgContLang->isRTL() ) $left = !$left;
754 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
755 $this->logoText() . '</td>';
757 $s .= $this->getQuickbarCompensator( $rows );
759 $l = $wgContLang->alignStart();
760 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
762 $s .= $this->topLinks();
763 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
765 $r = $wgContLang->alignEnd();
766 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
767 $s .= $this->nameAndLogin();
768 $s .= "\n<br />" . $this->searchForm() . "</td>";
771 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
774 if ( $shove && !$left ) { # Right
775 $s .= $this->getQuickbarCompensator( $rows );
777 $s .= "</tr>\n</table>\n</div>\n";
778 $s .= "\n<div id='article'>\n";
780 $notice = wfGetSiteNotice();
782 $s .= "\n<div id='siteNotice'>$notice</div>\n";
784 $s .= $this->pageTitle();
785 $s .= $this->pageSubtitle();
786 $s .= $this->getCategories();
787 wfProfileOut( __METHOD__
);
792 function getCategoryLinks() {
793 global $wgOut, $wgUseCategoryBrowser;
794 global $wgContLang, $wgUser;
796 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
799 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
801 // Use Unicode bidi embedding override characters,
802 // to make sure links don't smash each other up in ugly ways.
803 $dir = $wgContLang->getDir();
804 $embed = "<span dir='$dir'>";
807 $allCats = $wgOut->getCategoryLinks();
809 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
810 if ( !empty( $allCats['normal'] ) ) {
811 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
813 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
814 $s .= '<div id="mw-normal-catlinks">' .
815 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
816 . $colon . $t . '</div>';
820 if ( isset( $allCats['hidden'] ) ) {
821 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
822 $class ='mw-hidden-cats-user-shown';
823 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
824 $class = 'mw-hidden-cats-ns-shown';
826 $class = 'mw-hidden-cats-hidden';
828 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
829 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
830 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
834 # optional 'dmoz-like' category browser. Will be shown under the list
835 # of categories an article belong to
836 if( $wgUseCategoryBrowser ){
837 $s .= '<br /><hr />';
839 # get a big array of the parents tree
840 $parenttree = $this->mTitle
->getParentCategoryTree();
841 # Skin object passed by reference cause it can not be
842 # accessed under the method subfunction drawCategoryBrowser
843 $tempout = explode( "\n", Skin
::drawCategoryBrowser( $parenttree, $this ) );
844 # Clean out bogus first entry and sort them
845 unset( $tempout[0] );
847 # Output one per line
848 $s .= implode( "<br />\n", $tempout );
855 * Render the array as a serie of links.
856 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
857 * @param &skin Object: skin passed by reference
858 * @return String separated by >, terminate with "\n"
860 function drawCategoryBrowser( $tree, &$skin ){
862 foreach( $tree as $element => $parent ) {
863 if( empty( $parent ) ) {
864 # element start a new list
867 # grab the others elements
868 $return .= Skin
::drawCategoryBrowser( $parent, $skin ) . ' > ';
870 # add our current element to the list
871 $eltitle = Title
::newFromText( $element );
872 $return .= $skin->link( $eltitle, $eltitle->getText() );
877 function getCategories() {
878 $catlinks = $this->getCategoryLinks();
880 $classes = 'catlinks';
882 // Check what we're showing
883 global $wgOut, $wgUser;
884 $allCats = $wgOut->getCategoryLinks();
885 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
886 $this->mTitle
->getNamespace() == NS_CATEGORY
;
888 if( empty($allCats['normal']) && !( !empty($allCats['hidden']) && $showHidden ) ) {
889 $classes .= ' catlinks-allhidden';
892 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
895 function getQuickbarCompensator( $rows = 1 ) {
896 return "<td width='152' rowspan='{$rows}'> </td>";
900 * This runs a hook to allow extensions placing their stuff after content
901 * and article metadata (e.g. categories).
902 * Note: This function has nothing to do with afterContent().
904 * This hook is placed here in order to allow using the same hook for all
905 * skins, both the SkinTemplate based ones and the older ones, which directly
906 * use this class to get their data.
908 * The output of this function gets processed in SkinTemplate::outputPage() for
909 * the SkinTemplate based skins, all other skins should directly echo it.
911 * Returns an empty string by default, if not changed by any hook function.
913 protected function afterContentHook() {
916 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
917 // adding just some spaces shouldn't toggle the output
918 // of the whole <div/>, so we use trim() here
919 if( trim( $data ) != '' ){
920 // Doing this here instead of in the skins to
921 // ensure that the div has the same ID in all
923 $data = "<div id='mw-data-after-content'>\n" .
928 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
935 * Generate debug data HTML for displaying at the bottom of the main content
937 * @return String HTML containing debug data, if enabled (otherwise empty).
939 protected function generateDebugHTML() {
940 global $wgShowDebug, $wgOut;
941 if ( $wgShowDebug ) {
942 $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext
);
943 return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
944 $listInternals . "</ul>\n";
949 private function formatDebugHTML( $debugText ) {
950 $lines = explode( "\n", $debugText );
953 foreach( $lines as $line ) {
955 $display = ltrim( $line );
956 $ident = strlen( $line ) - strlen( $display );
957 $diff = $ident - $curIdent;
959 if ( $display == '' )
960 $display = "\xc2\xa0";
962 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
965 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
967 $display = htmlspecialchars( $display );
971 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
972 elseif ( $diff == 0 )
973 $ret .= "</li><li>\n";
975 $ret .= str_repeat( "<ul><li>\n", $diff );
976 $ret .= $display . "\n";
980 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
985 * This gets called shortly before the </body> tag.
986 * @return String HTML to be put before </body>
988 function afterContent() {
989 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
990 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
994 * This gets called shortly before the </body> tag.
995 * @return String HTML-wrapped JS code to be put before </body>
997 function bottomScripts() {
998 $bottomScriptText = "\n" . Html
::inlineScript( 'if (window.runOnloadHook) runOnloadHook();' ) . "\n";
999 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
1000 return $bottomScriptText;
1003 /** @return string Retrievied from HTML text */
1004 function printSource() {
1005 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
1006 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
1009 function printFooter() {
1010 return "<p>" . $this->printSource() .
1011 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
1014 /** overloaded by derived classes */
1015 function doAfterContent() { return '</div></div>'; }
1017 function pageTitleLinks() {
1018 global $wgOut, $wgUser, $wgRequest, $wgLang;
1020 $oldid = $wgRequest->getVal( 'oldid' );
1021 $diff = $wgRequest->getVal( 'diff' );
1022 $action = $wgRequest->getText( 'action' );
1024 $s[] = $this->printableLink();
1025 $disclaimer = $this->disclaimerLink(); # may be empty
1029 $privacy = $this->privacyLink(); # may be empty too
1034 if ( $wgOut->isArticleRelated() ) {
1035 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
1036 $name = $this->mTitle
->getDBkey();
1037 $image = wfFindFile( $this->mTitle
);
1039 $link = htmlspecialchars( $image->getURL() );
1040 $style = $this->getInternalLinkAttributes( $link, $name );
1041 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
1045 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
1046 $s[] .= $this->link(
1048 wfMsg( 'currentrev' ),
1051 array( 'known', 'noclasses' )
1055 if ( $wgUser->getNewtalk() ) {
1056 # do not show "You have new messages" text when we are viewing our
1058 if( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
1060 $wgUser->getTalkPage(),
1061 wfMsgHtml( 'newmessageslink' ),
1063 array( 'redirect' => 'no' ),
1064 array( 'known', 'noclasses' )
1068 $wgUser->getTalkPage(),
1069 wfMsgHtml( 'newmessagesdifflink' ),
1071 array( 'diff' => 'cur' ),
1072 array( 'known', 'noclasses' )
1074 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1076 $wgOut->setSquidMaxage( 0 );
1077 $wgOut->enableClientCache( false );
1081 $undelete = $this->getUndeleteLink();
1082 if( !empty( $undelete ) ) {
1085 return $wgLang->pipeList( $s );
1088 function getUndeleteLink() {
1089 global $wgUser, $wgContLang, $wgLang, $wgRequest;
1091 $action = $wgRequest->getVal( 'action', 'view' );
1093 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1094 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1095 $n = $this->mTitle
->isDeleted();
1097 if ( $wgUser->isAllowed( 'undelete' ) ) {
1098 $msg = 'thisisdeleted';
1100 $msg = 'viewdeleted';
1105 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1106 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1109 array( 'known', 'noclasses' )
1117 function printableLink() {
1118 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1122 if ( !$wgOut->isPrintable() ) {
1123 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1124 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1127 if( $wgOut->isSyndicated() ) {
1128 foreach( $wgFeedClasses as $format => $class ) {
1129 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1130 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1131 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1134 return $wgLang->pipeList( $s );
1137 function pageTitle() {
1139 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1143 function pageSubtitle() {
1146 $sub = $wgOut->getSubtitle();
1148 global $wgExtraSubtitle;
1149 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1151 $subpages = $this->subPageSubtitle();
1152 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1153 $s = "<p class='subtitle'>{$sub}</p>\n";
1157 function subPageSubtitle() {
1159 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
1163 if( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1164 $ptext = $this->mTitle
->getPrefixedText();
1165 if( preg_match( '/\//', $ptext ) ) {
1166 $links = explode( '/', $ptext );
1167 array_pop( $links );
1171 foreach( $links as $link ) {
1172 $growinglink .= $link;
1174 $linkObj = Title
::newFromText( $growinglink );
1175 if( is_object( $linkObj ) && $linkObj->exists() ){
1176 $getlink = $this->link(
1178 htmlspecialchars( $display ),
1181 array( 'known', 'noclasses' )
1185 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1187 $subpages .= '< ';
1189 $subpages .= $getlink;
1194 $growinglink .= '/';
1202 * Returns true if the IP should be shown in the header
1204 function showIPinHeader() {
1205 global $wgShowIPinHeader;
1206 return $wgShowIPinHeader && session_id() != '';
1209 function nameAndLogin() {
1210 global $wgUser, $wgLang, $wgContLang;
1212 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1215 if ( $wgUser->isAnon() ) {
1216 if( $this->showIPinHeader() ) {
1219 $talkLink = $this->link( $wgUser->getTalkPage(),
1220 $wgLang->getNsText( NS_TALK
) );
1222 $ret .= "$name ($talkLink)";
1224 $ret .= wfMsg( 'notloggedin' );
1227 $returnTo = $this->mTitle
->getPrefixedDBkey();
1229 if ( $logoutPage != $returnTo ) {
1230 $query['returnto'] = $returnTo;
1233 $loginlink = $wgUser->isAllowed( 'createaccount' )
1234 ?
'nav-login-createaccount'
1236 $ret .= "\n<br />" . $this->link(
1237 SpecialPage
::getTitleFor( 'Userlogin' ),
1238 wfMsg( $loginlink ), array(), $query
1241 $returnTo = $this->mTitle
->getPrefixedDBkey();
1242 $talkLink = $this->link( $wgUser->getTalkPage(),
1243 $wgLang->getNsText( NS_TALK
) );
1245 $ret .= $this->link( $wgUser->getUserPage(),
1246 htmlspecialchars( $wgUser->getName() ) );
1247 $ret .= " ($talkLink)<br />";
1248 $ret .= $wgLang->pipeList( array(
1250 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1251 array(), array( 'returnto' => $returnTo )
1253 $this->specialLink( 'preferences' ),
1256 $ret = $wgLang->pipeList( array(
1259 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1267 function getSearchLink() {
1268 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1269 return $searchPage->getLocalURL();
1272 function escapeSearchLink() {
1273 return htmlspecialchars( $this->getSearchLink() );
1276 function searchForm() {
1277 global $wgRequest, $wgUseTwoButtonsSearchForm;
1278 $search = $wgRequest->getText( 'search' );
1280 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1281 . $this->escapeSearchLink() . "\">\n"
1282 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1283 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1284 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1286 if( $wgUseTwoButtonsSearchForm )
1287 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1289 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1293 // Ensure unique id's for search boxes made after the first
1294 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1299 function topLinks() {
1303 $this->mainPageLink(),
1304 $this->specialLink( 'recentchanges' )
1307 if ( $wgOut->isArticleRelated() ) {
1308 $s[] = $this->editThisPage();
1309 $s[] = $this->historyLink();
1311 # Many people don't like this dropdown box
1312 #$s[] = $this->specialPagesList();
1314 if( $this->variantLinks() ) {
1315 $s[] = $this->variantLinks();
1318 if( $this->extensionTabLinks() ) {
1319 $s[] = $this->extensionTabLinks();
1322 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1323 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1327 * Compatibility for extensions adding functionality through tabs.
1328 * Eventually these old skins should be replaced with SkinTemplate-based
1332 function extensionTabLinks() {
1336 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1337 foreach( $tabs as $tab ) {
1338 $s[] = Xml
::element( 'a',
1339 array( 'href' => $tab['href'] ),
1346 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1347 $out .= $wgLang->pipeList( $s );
1354 * Language/charset variant links for classic-style skins
1357 function variantLinks() {
1359 /* show links to different language variants */
1360 global $wgDisableLangConversion, $wgLang, $wgContLang;
1361 $variants = $wgContLang->getVariants();
1362 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1363 foreach( $variants as $code ) {
1364 $varname = $wgContLang->getVariantname( $code );
1365 if( $varname == 'disable' )
1367 $s = $wgLang->pipeList( array(
1369 '<a href="' . $this->mTitle
->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1376 function bottomLinks() {
1377 global $wgOut, $wgUser, $wgUseTrackbacks;
1378 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1381 if ( $wgOut->isArticleRelated() ) {
1382 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1383 if ( $wgUser->isLoggedIn() ) {
1384 $element[] = $this->watchThisPage();
1386 $element[] = $this->talkLink();
1387 $element[] = $this->historyLink();
1388 $element[] = $this->whatLinksHere();
1389 $element[] = $this->watchPageLinksLink();
1391 if( $wgUseTrackbacks )
1392 $element[] = $this->trackbackLink();
1394 if ( $this->mTitle
->getNamespace() == NS_USER
1395 ||
$this->mTitle
->getNamespace() == NS_USER_TALK
){
1396 $id = User
::idFromName( $this->mTitle
->getText() );
1397 $ip = User
::isIP( $this->mTitle
->getText() );
1399 if( $id ||
$ip ) { # both anons and non-anons have contri list
1400 $element[] = $this->userContribsLink();
1402 if( $this->showEmailUser( $id ) ) {
1403 $element[] = $this->emailUserLink();
1407 $s = implode( $element, $sep );
1409 if ( $this->mTitle
->getArticleId() ) {
1411 if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1412 if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1413 if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
1415 $s .= "<br />\n" . $this->otherLanguages();
1421 function pageStats() {
1422 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1423 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1425 $oldid = $wgRequest->getVal( 'oldid' );
1426 $diff = $wgRequest->getVal( 'diff' );
1427 if ( ! $wgOut->isArticle() ) { return ''; }
1428 if( !$wgArticle instanceOf Article
) { return ''; }
1429 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1430 if ( 0 == $wgArticle->getID() ) { return ''; }
1433 if ( !$wgDisableCounters ) {
1434 $count = $wgLang->formatNum( $wgArticle->getCount() );
1436 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1440 if( $wgMaxCredits != 0 ){
1441 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1443 $s .= $this->lastModified();
1446 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1447 $dbr = wfGetDB( DB_SLAVE
);
1448 $res = $dbr->select( 'watchlist',
1449 array( 'COUNT(*) AS n' ),
1450 array( 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ), 'wl_namespace' => $this->mTitle
->getNamespace() ),
1453 $x = $dbr->fetchObject( $res );
1455 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1456 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1460 return $s . ' ' . $this->getCopyright();
1463 function getCopyright( $type = 'detect' ) {
1464 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1466 if ( $type == 'detect' ) {
1467 $diff = $wgRequest->getVal( 'diff' );
1468 $isCur = $wgArticle && $wgArticle->isCurrent();
1469 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1476 if ( $type == 'history' ) {
1477 $msg = 'history_copyright';
1483 if( $wgRightsPage ) {
1484 $title = Title
::newFromText( $wgRightsPage );
1485 $link = $this->linkKnown( $title, $wgRightsText );
1486 } elseif( $wgRightsUrl ) {
1487 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1488 } elseif( $wgRightsText ) {
1489 $link = $wgRightsText;
1494 // Allow for site and per-namespace customization of copyright notice.
1495 if( isset($wgArticle) )
1496 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
1498 $out .= wfMsgForContent( $msg, $link );
1502 function getCopyrightIcon() {
1503 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1505 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1506 $out = $wgCopyrightIcon;
1507 } else if ( $wgRightsIcon ) {
1508 $icon = htmlspecialchars( $wgRightsIcon );
1509 if ( $wgRightsUrl ) {
1510 $url = htmlspecialchars( $wgRightsUrl );
1511 $out .= '<a href="'.$url.'">';
1513 $text = htmlspecialchars( $wgRightsText );
1514 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1515 if ( $wgRightsUrl ) {
1522 function getPoweredBy() {
1523 global $wgStylePath;
1524 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1525 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1529 function lastModified() {
1530 global $wgLang, $wgArticle;
1531 if( $this->mRevisionId
&& $this->mRevisionId
!= $wgArticle->getLatest()) {
1532 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1534 $timestamp = $wgArticle->getTimestamp();
1537 $d = $wgLang->date( $timestamp, true );
1538 $t = $wgLang->time( $timestamp, true );
1539 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1543 if ( wfGetLB()->getLaggedSlaveMode() ) {
1544 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1549 function logoText( $align = '' ) {
1550 if ( '' != $align ) {
1551 $a = " align='{$align}'";
1556 $mp = wfMsg( 'mainpage' );
1557 $mptitle = Title
::newMainPage();
1558 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1560 $logourl = $this->getLogo();
1561 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1566 * show a drop-down box of special pages
1568 function specialPagesList() {
1569 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1570 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1571 foreach ( $pages as $name => $page ) {
1572 $pages[$name] = $page->getDescription();
1575 $go = wfMsg( 'go' );
1576 $sp = wfMsg( 'specialpages' );
1577 $spp = $wgContLang->specialPage( 'Specialpages' );
1579 $s = '<form id="specialpages" method="get" ' .
1580 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1581 $s .= "<select name=\"wpDropdown\">\n";
1582 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1585 foreach ( $pages as $name => $desc ) {
1586 $p = $wgContLang->specialPage( $name );
1587 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1589 $s .= "</select>\n";
1590 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1595 function mainPageLink() {
1597 Title
::newMainPage(),
1598 wfMsg( 'mainpage' ),
1601 array( 'known', 'noclasses' )
1606 private function footerLink ( $desc, $page ) {
1607 // if the link description has been set to "-" in the default language,
1608 if ( wfMsgForContent( $desc ) == '-') {
1609 // then it is disabled, for all languages.
1612 // Otherwise, we display the link for the user, described in their
1613 // language (which may or may not be the same as the default language),
1614 // but we make the link target be the one site-wide page.
1615 $title = Title
::newFromText( wfMsgForContent( $page ) );
1616 return $this->linkKnown(
1618 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1623 function privacyLink() {
1624 return $this->footerLink( 'privacy', 'privacypage' );
1627 function aboutLink() {
1628 return $this->footerLink( 'aboutsite', 'aboutpage' );
1631 function disclaimerLink() {
1632 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1635 function editThisPage() {
1638 if ( !$wgOut->isArticleRelated() ) {
1639 $s = wfMsg( 'protectedpage' );
1641 if( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1642 $t = wfMsg( 'editthispage' );
1643 } elseif( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1644 $t = wfMsg( 'create-this-page' );
1646 $t = wfMsg( 'viewsource' );
1653 $this->editUrlOptions(),
1654 array( 'known', 'noclasses' )
1661 * Return URL options for the 'edit page' link.
1662 * This may include an 'oldid' specifier, if the current page view is such.
1667 function editUrlOptions() {
1670 $options = array( 'action' => 'edit' );
1672 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1673 $options['oldid'] = intval( $this->mRevisionId
);
1679 function deleteThisPage() {
1680 global $wgUser, $wgRequest;
1682 $diff = $wgRequest->getVal( 'diff' );
1683 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1684 $t = wfMsg( 'deletethispage' );
1690 array( 'action' => 'delete' ),
1691 array( 'known', 'noclasses' )
1699 function protectThisPage() {
1700 global $wgUser, $wgRequest;
1702 $diff = $wgRequest->getVal( 'diff' );
1703 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1704 if ( $this->mTitle
->isProtected() ) {
1705 $text = wfMsg( 'unprotectthispage' );
1706 $query = array( 'action' => 'unprotect' );
1708 $text = wfMsg( 'protectthispage' );
1709 $query = array( 'action' => 'protect' );
1717 array( 'known', 'noclasses' )
1725 function watchThisPage() {
1727 ++
$this->mWatchLinkNum
;
1729 if ( $wgOut->isArticleRelated() ) {
1730 if ( $this->mTitle
->userIsWatching() ) {
1731 $text = wfMsg( 'unwatchthispage' );
1732 $query = array( 'action' => 'unwatch' );
1733 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1735 $text = wfMsg( 'watchthispage' );
1736 $query = array( 'action' => 'watch' );
1737 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1743 array( 'id' => $id ),
1745 array( 'known', 'noclasses' )
1748 $s = wfMsg( 'notanarticle' );
1753 function moveThisPage() {
1754 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1756 SpecialPage
::getTitleFor( 'Movepage' ),
1757 wfMsg( 'movethispage' ),
1759 array( 'target' => $this->mTitle
->getPrefixedDBkey() ),
1760 array( 'known', 'noclasses' )
1763 // no message if page is protected - would be redundant
1768 function historyLink() {
1771 wfMsgHtml( 'history' ),
1772 array( 'rel' => 'archives' ),
1773 array( 'action' => 'history' )
1777 function whatLinksHere() {
1779 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1780 wfMsgHtml( 'whatlinkshere' ),
1783 array( 'known', 'noclasses' )
1787 function userContribsLink() {
1789 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1790 wfMsgHtml( 'contributions' ),
1793 array( 'known', 'noclasses' )
1797 function showEmailUser( $id ) {
1799 $targetUser = User
::newFromId( $id );
1800 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1801 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1804 function emailUserLink() {
1806 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1807 wfMsg( 'emailuser' ),
1810 array( 'known', 'noclasses' )
1814 function watchPageLinksLink() {
1816 if ( ! $wgOut->isArticleRelated() ) {
1817 return '(' . wfMsg( 'notanarticle' ) . ')';
1820 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1821 wfMsg( 'recentchangeslinked-toolbox' ),
1824 array( 'known', 'noclasses' )
1829 function trackbackLink() {
1830 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1831 . wfMsg( 'trackbacklink' ) . '</a>';
1834 function otherLanguages() {
1835 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1837 if ( $wgHideInterlanguageLinks ) {
1841 $a = $wgOut->getLanguageLinks();
1842 if ( 0 == count( $a ) ) {
1846 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1848 if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
1849 foreach( $a as $l ) {
1851 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1855 $nt = Title
::newFromText( $l );
1856 $url = $nt->escapeFullURL();
1857 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1859 if ( '' == $text ) { $text = $l; }
1860 $style = $this->getExternalLinkAttributes();
1861 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1863 if( $wgContLang->isRTL() ) $s .= '</span>';
1867 function talkLink() {
1868 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1869 # No discussion links for special pages
1873 $linkOptions = array();
1875 if( $this->mTitle
->isTalkPage() ) {
1876 $link = $this->mTitle
->getSubjectPage();
1877 switch( $link->getNamespace() ) {
1879 $text = wfMsg( 'articlepage' );
1882 $text = wfMsg( 'userpage' );
1885 $text = wfMsg( 'projectpage' );
1888 $text = wfMsg( 'imagepage' );
1889 # Make link known if image exists, even if the desc. page doesn't.
1890 if( wfFindFile( $link ) )
1891 $linkOptions[] = 'known';
1894 $text = wfMsg( 'mediawikipage' );
1897 $text = wfMsg( 'templatepage' );
1900 $text = wfMsg( 'viewhelppage' );
1903 $text = wfMsg( 'categorypage' );
1906 $text = wfMsg( 'articlepage' );
1909 $link = $this->mTitle
->getTalkPage();
1910 $text = wfMsg( 'talkpage' );
1913 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1918 function commentLink() {
1921 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1925 # __NEWSECTIONLINK___ changes behaviour here
1926 # If it is present, the link points to this page, otherwise
1927 # it points to the talk page
1928 if( $this->mTitle
->isTalkPage() ) {
1929 $title = $this->mTitle
;
1930 } elseif( $wgOut->showNewSectionLink() ) {
1931 $title = $this->mTitle
;
1933 $title = $this->mTitle
->getTalkPage();
1938 wfMsg( 'postcomment' ),
1944 array( 'known', 'noclasses' )
1948 /* these are used extensively in SkinTemplate, but also some other places */
1949 static function makeMainPageUrl( $urlaction = '' ) {
1950 $title = Title
::newMainPage();
1951 self
::checkTitle( $title, '' );
1952 return $title->getLocalURL( $urlaction );
1955 static function makeSpecialUrl( $name, $urlaction = '' ) {
1956 $title = SpecialPage
::getTitleFor( $name );
1957 return $title->getLocalURL( $urlaction );
1960 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1961 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1962 return $title->getLocalURL( $urlaction );
1965 static function makeI18nUrl( $name, $urlaction = '' ) {
1966 $title = Title
::newFromText( wfMsgForContent( $name ) );
1967 self
::checkTitle( $title, $name );
1968 return $title->getLocalURL( $urlaction );
1971 static function makeUrl( $name, $urlaction = '' ) {
1972 $title = Title
::newFromText( $name );
1973 self
::checkTitle( $title, $name );
1974 return $title->getLocalURL( $urlaction );
1977 # If url string starts with http, consider as external URL, else
1979 static function makeInternalOrExternalUrl( $name ) {
1980 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1983 return self
::makeUrl( $name );
1987 # this can be passed the NS number as defined in Language.php
1988 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1989 $title = Title
::makeTitleSafe( $namespace, $name );
1990 self
::checkTitle( $title, $name );
1991 return $title->getLocalURL( $urlaction );
1994 /* these return an array with the 'href' and boolean 'exists' */
1995 static function makeUrlDetails( $name, $urlaction = '' ) {
1996 $title = Title
::newFromText( $name );
1997 self
::checkTitle( $title, $name );
1999 'href' => $title->getLocalURL( $urlaction ),
2000 'exists' => $title->getArticleID() != 0 ?
true : false
2005 * Make URL details where the article exists (or at least it's convenient to think so)
2007 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
2008 $title = Title
::newFromText( $name );
2009 self
::checkTitle( $title, $name );
2011 'href' => $title->getLocalURL( $urlaction ),
2016 # make sure we have some title to operate on
2017 static function checkTitle( &$title, $name ) {
2018 if( !is_object( $title ) ) {
2019 $title = Title
::newFromText( $name );
2020 if( !is_object( $title ) ) {
2021 $title = Title
::newFromText( '--error: link target missing--' );
2027 * Build an array that represents the sidebar(s), the navigation bar among them
2031 function buildSidebar() {
2032 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2034 wfProfileIn( __METHOD__
);
2036 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2038 if ( $wgEnableSidebarCache ) {
2039 $cachedsidebar = $parserMemc->get( $key );
2040 if ( $cachedsidebar ) {
2041 wfProfileOut( __METHOD__
);
2042 return $cachedsidebar;
2047 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
2049 foreach( $lines as $line ) {
2050 if( strpos( $line, '*' ) !== 0 )
2052 if( strpos( $line, '**') !== 0 ) {
2053 $heading = trim( $line, '* ' );
2054 if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
2056 if( strpos( $line, '|' ) !== false ) { // sanity check
2057 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
2058 $link = wfMsgForContent( $line[0] );
2062 $text = wfMsgExt( $line[1], 'parsemag' );
2063 if( wfEmptyMsg( $line[1], $text ) )
2065 if( wfEmptyMsg( $line[0], $link ) )
2068 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2071 $title = Title
::newFromText( $link );
2073 $title = $title->fixSpecialName();
2074 $href = $title->getLocalURL();
2076 $href = 'INVALID-TITLE';
2080 $bar[$heading][] = array(
2083 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2086 } else { continue; }
2089 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2090 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2091 wfProfileOut( __METHOD__
);
2096 * Should we include common/wikiprintable.css? Skins that have their own
2097 * print stylesheet should override this and return false. (This is an
2098 * ugly hack to get Monobook to play nicely with
2099 * OutputPage::headElement().)
2103 public function commonPrintStylesheet() {