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 $r = array( "<script type=\"$wgJsMimeType\">/*<![CDATA[*/" );
337 foreach ( $data as $name => $value ) {
338 $encValue = Xml
::encodeJsVar( $value );
339 $r[] = "var $name = $encValue;";
341 $r[] = "/*]]>*/</script>\n";
342 return implode( "\n\t\t", $r );
346 * Make a <script> tag containing global variables
347 * @param $skinName string Name of the skin
348 * The odd calling convention is for backwards compatibility
349 * @TODO @FIXME Make this not depend on $wgTitle!
351 static function makeGlobalVariablesScript( $skinName ) {
352 if ( is_array( $skinName ) ) {
353 # Weird back-compat stuff.
354 $skinName = $skinName['skinname'];
356 global $wgScript, $wgTitle, $wgStylePath, $wgUser;
357 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang, $wgVariant;
358 global $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
359 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
360 global $wgUseAjax, $wgAjaxWatch;
361 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
362 global $wgRestrictionTypes, $wgLivePreview;
363 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
365 $ns = $wgTitle->getNamespace();
366 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
367 $separatorTransTable = $wgContLang->separatorTransformTable();
368 $separatorTransTable = $separatorTransTable ?
$separatorTransTable : array();
369 $compactSeparatorTransTable = array(
370 implode( "\t", array_keys( $separatorTransTable ) ),
371 implode( "\t", $separatorTransTable ),
373 $digitTransTable = $wgContLang->digitTransformTable();
374 $digitTransTable = $digitTransTable ?
$digitTransTable : array();
375 $compactDigitTransTable = array(
376 implode( "\t", array_keys( $digitTransTable ) ),
377 implode( "\t", $digitTransTable ),
382 'stylepath' => $wgStylePath,
383 'wgArticlePath' => $wgArticlePath,
384 'wgScriptPath' => $wgScriptPath,
385 'wgScript' => $wgScript,
386 'wgVariantArticlePath' => $wgVariantArticlePath,
387 'wgActionPaths' => (object)$wgActionPaths,
388 'wgServer' => $wgServer,
389 'wgCanonicalNamespace' => $nsname,
390 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
391 'wgNamespaceNumber' => $wgTitle->getNamespace(),
392 'wgPageName' => $wgTitle->getPrefixedDBKey(),
393 'wgTitle' => $wgTitle->getText(),
394 'wgAction' => $wgRequest->getText( 'action', 'view' ),
395 'wgArticleId' => $wgTitle->getArticleId(),
396 'wgIsArticle' => $wgOut->isArticle(),
397 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
398 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
399 'wgUserVariant' => $wgVariant->getCode(),
400 'wgUserLanguage' => $wgLang->getCode(),
401 'wgContentLanguage' => $wgContLang->getCode(),
402 'wgBreakFrames' => $wgBreakFrames,
403 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
404 'wgVersion' => $wgVersion,
405 'wgEnableAPI' => $wgEnableAPI,
406 'wgEnableWriteAPI' => $wgEnableWriteAPI,
407 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
408 'wgDigitTransformTable' => $compactDigitTransTable,
410 if ( !( $wgContLang->hasVariants() ) ) {
411 unset( $vars['wgUserVariant'] );
414 //if on upload page output the extension list & js_upload
415 if( SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) == "Upload" ){
416 global $wgFileExtensions, $wgAjaxUploadInterface;
417 $vars['wgFileExtensions'] = $wgFileExtensions;
418 $vars['wgAjaxUploadInterface'] = $wgAjaxUploadInterface;
421 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
422 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
423 $vars['wgDBname'] = $wgDBname;
424 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
425 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
428 foreach( $wgRestrictionTypes as $type )
429 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
431 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
432 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
433 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
434 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
435 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
438 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
439 $msgs = (object)array();
440 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
441 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
443 $vars['wgAjaxWatch'] = $msgs;
446 // Allow extensions to add their custom variables to the global JS variables
447 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
449 return self
::makeVariablesScript( $vars );
452 * Returns the Head Scripts (from local skin context)
454 * local $out variable that should be the same as $wgOut
456 * @return string Raw HTML to output to <head>
458 function getHeadScripts( OutputPage
&$out ) {
459 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion, $wgOut;
462 $vars = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
464 //moved wikibits to be called earlier on
465 //$out->addScriptFile( "{$wgStylePath}/common/wikibits.js" );
467 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
468 $wgOut->addScriptFile( self
::makeUrl( '-',
469 "action=raw$jsCache&gen=js&useskin=" .
470 urlencode( $this->getSkinName() )
474 if( $out->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
475 $userpage = $wgUser->getUserPage();
476 $userjs = self
::makeUrl(
477 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
478 'action=raw&ctype='.$wgJsMimeType );
479 $wgOut->addScriptFile( $userjs );
481 return $vars . "\t" . implode ( "\n\t", $r ) . $out->mScripts
;
485 * To make it harder for someone to slip a user a fake
486 * user-JavaScript or user-CSS preview, a random token
487 * is associated with the login session. If it's not
488 * passed back with the preview request, we won't render
491 * @param string $action
495 function userCanPreview( $action ) {
496 global $wgRequest, $wgUser;
498 if( $action != 'submit' )
500 if( !$wgRequest->wasPosted() )
502 if( !$this->mTitle
->userCanEditCssJsSubpage() )
504 return $wgUser->matchEditToken(
505 $wgRequest->getVal( 'wpEditToken' ) );
509 * generated JavaScript action=raw&gen=js
510 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
511 * nated together. For some bizarre reason, it does *not* return any
512 * custom user JS from subpages. Huh?
514 * There's absolutely no reason to have separate Monobook/Common JSes.
515 * Any JS that cares can just check the skin variable generated at the
516 * top. For now Monobook.js will be maintained, but it should be consi-
519 * @param force_skin lets you override the skin name
523 public function generateUserJs( $skinName = null) {
526 wfProfileIn( __METHOD__
);
528 $skinName = $this->getSkinName();
531 $s = "/* generated javascript */\n";
532 $s .= "var skin = '" . Xml
::escapeJsString($skinName ) . "';\n";
533 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
534 $s .= "\n\n/* MediaWiki:Common.js */\n";
535 $commonJs = wfMsgForContent( 'common.js' );
536 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
540 $s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n";
541 // avoid inclusion of non defined user JavaScript (with custom skins only)
542 // by checking for default message content
543 $msgKey = ucfirst( $skinName ).'.js';
544 $userJS = wfMsgForContent( $msgKey );
545 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
549 wfProfileOut( __METHOD__
);
554 * Generate user stylesheet for action=raw&gen=css
556 public function generateUserStylesheet() {
557 wfProfileIn( __METHOD__
);
558 $s = "/* generated user stylesheet */\n" .
559 $this->reallyGenerateUserStylesheet();
560 wfProfileOut( __METHOD__
);
565 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
567 protected function reallyGenerateUserStylesheet(){
570 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
571 $underline = $undopt ?
'underline' : 'none';
572 $s .= "a { text-decoration: $underline; }\n";
574 if( $wgUser->getOption( 'highlightbroken' ) ) {
575 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
578 a.new, #quickbar a.new,
579 a.stub, #quickbar a.stub {
582 a.new:after, #quickbar a.new:after {
586 a.stub:after, #quickbar a.stub:after {
592 if( $wgUser->getOption( 'justify' ) ) {
593 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
595 if( !$wgUser->getOption( 'showtoc' ) ) {
596 $s .= "#toc { display: none; }\n";
598 if( !$wgUser->getOption( 'editsection' ) ) {
599 $s .= ".editsection { display: none; }\n";
607 function setupUserCss( OutputPage
$out ) {
608 global $wgRequest, $wgContLang, $wgUser;
609 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
611 wfProfileIn( __METHOD__
);
613 $this->setupSkinUserCss( $out );
617 'maxage' => $wgSquidMaxage,
620 // Add any extension CSS
621 foreach( $out->getExtStyle() as $tag ) {
622 $out->addStyle( $tag['href'] );
625 // If we use the site's dynamic CSS, throw that in, too
626 // Per-site custom styles
627 if( $wgUseSiteCss ) {
628 global $wgHandheldStyle;
629 $query = wfArrayToCGI( array(
630 'usemsgcache' => 'yes',
631 'ctype' => 'text/css',
632 'smaxage' => $wgSquidMaxage
634 # Site settings must override extension css! (bug 15025)
635 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
636 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
637 if( $wgHandheldStyle ) {
638 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
640 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
643 if( $wgUser->isLoggedIn() ) {
644 // Ensure that logged-in users' generated CSS isn't clobbered
645 // by anons' publicly cacheable generated CSS.
646 $siteargs['smaxage'] = '0';
647 $siteargs['ts'] = $wgUser->mTouched
;
649 // Per-user styles based on preferences
650 $siteargs['gen'] = 'css';
651 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
652 $siteargs['useskin'] = $us;
654 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
656 // Per-user custom style pages
657 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
658 $action = $wgRequest->getVal( 'action' );
659 # If we're previewing the CSS page, use it
660 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
661 $previewCss = $wgRequest->getText( 'wpTextbox1' );
662 // @FIXME: properly escape the cdata!
663 $this->usercss
= "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
665 $out->addStyle( self
::makeUrl( $this->userpage
. '/' . $this->getSkinName() .'.css',
666 'action=raw&ctype=text/css' ) );
670 wfProfileOut( __METHOD__
);
674 * Add skin specific stylesheets
675 * @param $out OutputPage
677 function setupSkinUserCss( OutputPage
$out ) {
678 $out->addStyle( 'common/shared.css' );
679 $out->addStyle( 'common/oldshared.css' );
680 $out->addStyle( $this->getStylesheet() );
681 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
684 function getBodyOptions() {
685 global $wgUser, $wgOut, $wgRequest, $wgContLang;
687 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
689 if ( 0 != $this->mTitle
->getNamespace() ) {
690 $a = array( 'bgcolor' => '#ffffec' );
692 else $a = array( 'bgcolor' => '#FFFFFF' );
693 if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
694 $this->mTitle
->quickUserCan( 'edit' ) ) {
695 $s = $this->mTitle
->getFullURL( $this->editUrlOptions() );
696 $s = 'document.location = "' .Xml
::escapeJsString( $s ) .'";';
697 $a +
= array( 'ondblclick' => $s );
699 $a['onload'] = $wgOut->getOnloadHandler();
702 ' '.( $wgContLang->isRTL() ?
'rtl' : 'ltr' ).
703 ' '.$this->getPageClasses( $this->mTitle
) .
704 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName() );
708 function getPageClasses( $title ) {
709 $numeric = 'ns-'.$title->getNamespace();
710 if( $title->getNamespace() == NS_SPECIAL
) {
711 $type = 'ns-special';
712 } elseif( $title->isTalkPage() ) {
715 $type = 'ns-subject';
717 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
718 return "$numeric $type $name";
730 * This will be called immediately after the <body> tag. Split into
731 * two functions to make it easier to subclass.
733 function beforeContent() {
734 return $this->doBeforeContent();
737 function doBeforeContent() {
739 wfProfileIn( __METHOD__
);
742 $qb = $this->qbSetting();
744 if( $langlinks = $this->otherLanguages() ) {
750 $borderhack = 'class="top"';
753 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
754 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
756 $shove = ( $qb != 0 );
757 $left = ( $qb == 1 ||
$qb == 3 );
758 if( $wgContLang->isRTL() ) $left = !$left;
761 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
762 $this->logoText() . '</td>';
764 $s .= $this->getQuickbarCompensator( $rows );
766 $l = $wgContLang->isRTL() ?
'right' : 'left';
767 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
769 $s .= $this->topLinks();
770 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
772 $r = $wgContLang->isRTL() ?
'left' : 'right';
773 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
774 $s .= $this->nameAndLogin();
775 $s .= "\n<br />" . $this->searchForm() . "</td>";
778 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
781 if ( $shove && !$left ) { # Right
782 $s .= $this->getQuickbarCompensator( $rows );
784 $s .= "</tr>\n</table>\n</div>\n";
785 $s .= "\n<div id='article'>\n";
787 $notice = wfGetSiteNotice();
789 $s .= "\n<div id='siteNotice'>$notice</div>\n";
791 $s .= $this->pageTitle();
792 $s .= $this->pageSubtitle();
793 $s .= $this->getCategories();
794 wfProfileOut( __METHOD__
);
799 function getCategoryLinks() {
800 global $wgOut, $wgUseCategoryBrowser;
801 global $wgContLang, $wgUser;
803 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
806 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
808 // Use Unicode bidi embedding override characters,
809 // to make sure links don't smash each other up in ugly ways.
810 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
811 $embed = "<span dir='$dir'>";
814 $allCats = $wgOut->getCategoryLinks();
816 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
817 if ( !empty( $allCats['normal'] ) ) {
818 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
820 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
821 $s .= '<div id="mw-normal-catlinks">' .
822 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
823 . $colon . $t . '</div>';
827 if ( isset( $allCats['hidden'] ) ) {
828 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
829 $class ='mw-hidden-cats-user-shown';
830 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
831 $class = 'mw-hidden-cats-ns-shown';
833 $class = 'mw-hidden-cats-hidden';
835 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
836 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
837 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
841 # optional 'dmoz-like' category browser. Will be shown under the list
842 # of categories an article belong to
843 if( $wgUseCategoryBrowser ){
844 $s .= '<br /><hr />';
846 # get a big array of the parents tree
847 $parenttree = $this->mTitle
->getParentCategoryTree();
848 # Skin object passed by reference cause it can not be
849 # accessed under the method subfunction drawCategoryBrowser
850 $tempout = explode( "\n", Skin
::drawCategoryBrowser( $parenttree, $this ) );
851 # Clean out bogus first entry and sort them
852 unset( $tempout[0] );
854 # Output one per line
855 $s .= implode( "<br />\n", $tempout );
862 * Render the array as a serie of links.
863 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
864 * @param &skin Object: skin passed by reference
865 * @return String separated by >, terminate with "\n"
867 function drawCategoryBrowser( $tree, &$skin ){
869 foreach( $tree as $element => $parent ) {
870 if( empty( $parent ) ) {
871 # element start a new list
874 # grab the others elements
875 $return .= Skin
::drawCategoryBrowser( $parent, $skin ) . ' > ';
877 # add our current element to the list
878 $eltitle = Title
::newFromText( $element );
879 $return .= $skin->link( $eltitle, $eltitle->getText() );
884 function getCategories() {
885 $catlinks=$this->getCategoryLinks();
887 $classes = 'catlinks';
889 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
890 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
891 $classes .= ' catlinks-allhidden';
894 if( !empty( $catlinks ) ){
895 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
899 function getQuickbarCompensator( $rows = 1 ) {
900 return "<td width='152' rowspan='{$rows}'> </td>";
904 * This runs a hook to allow extensions placing their stuff after content
905 * and article metadata (e.g. categories).
906 * Note: This function has nothing to do with afterContent().
908 * This hook is placed here in order to allow using the same hook for all
909 * skins, both the SkinTemplate based ones and the older ones, which directly
910 * use this class to get their data.
912 * The output of this function gets processed in SkinTemplate::outputPage() for
913 * the SkinTemplate based skins, all other skins should directly echo it.
915 * Returns an empty string by default, if not changed by any hook function.
917 protected function afterContentHook() {
920 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
921 // adding just some spaces shouldn't toggle the output
922 // of the whole <div/>, so we use trim() here
923 if( trim( $data ) != '' ){
924 // Doing this here instead of in the skins to
925 // ensure that the div has the same ID in all
927 $data = "<div id='mw-data-after-content'>\n" .
932 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
939 * Generate debug data HTML for displaying at the bottom of the main content
941 * @return String HTML containing debug data, if enabled (otherwise empty).
943 protected function generateDebugHTML() {
944 global $wgShowDebug, $wgOut;
945 if ( $wgShowDebug ) {
946 $listInternals = str_replace( "\n", "</li>\n<li>", htmlspecialchars( $wgOut->mDebugtext
) );
947 return "\n<hr>\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\"><li>" .
948 $listInternals . "</li></ul>\n";
954 * This gets called shortly before the </body> tag.
955 * @return String HTML to be put before </body>
957 function afterContent() {
958 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
959 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
963 * This gets called shortly before the </body> tag.
964 * @return String HTML-wrapped JS code to be put before </body>
966 function bottomScripts() {
967 global $wgJsMimeType;
968 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
969 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
970 return $bottomScriptText;
973 /** @return string Retrievied from HTML text */
974 function printSource() {
975 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
976 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
979 function printFooter() {
980 return "<p>" . $this->printSource() .
981 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
984 /** overloaded by derived classes */
985 function doAfterContent() { return '</div></div>'; }
987 function pageTitleLinks() {
988 global $wgOut, $wgUser, $wgRequest, $wgLang;
990 $oldid = $wgRequest->getVal( 'oldid' );
991 $diff = $wgRequest->getVal( 'diff' );
992 $action = $wgRequest->getText( 'action' );
994 $s[] = $this->printableLink();
995 $disclaimer = $this->disclaimerLink(); # may be empty
999 $privacy = $this->privacyLink(); # may be empty too
1004 if ( $wgOut->isArticleRelated() ) {
1005 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
1006 $name = $this->mTitle
->getDBkey();
1007 $image = wfFindFile( $this->mTitle
);
1009 $link = htmlspecialchars( $image->getURL() );
1010 $style = $this->getInternalLinkAttributes( $link, $name );
1011 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
1015 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
1016 $s[] .= $this->link(
1018 wfMsg( 'currentrev' ),
1021 array( 'known', 'noclasses' )
1025 if ( $wgUser->getNewtalk() ) {
1026 # do not show "You have new messages" text when we are viewing our
1028 if( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
1030 $wgUser->getTalkPage(),
1031 wfMsgHtml( 'newmessageslink' ),
1033 array( 'redirect' => 'no' ),
1034 array( 'known', 'noclasses' )
1038 $wgUser->getTalkPage(),
1039 wfMsgHtml( 'newmessagesdifflink' ),
1041 array( 'diff' => 'cur' ),
1042 array( 'known', 'noclasses' )
1044 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1046 $wgOut->setSquidMaxage( 0 );
1047 $wgOut->enableClientCache( false );
1051 $undelete = $this->getUndeleteLink();
1052 if( !empty( $undelete ) ) {
1055 return $wgLang->pipeList( $s );
1058 function getUndeleteLink() {
1059 global $wgUser, $wgContLang, $wgLang, $wgRequest;
1061 $action = $wgRequest->getVal( 'action', 'view' );
1063 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1064 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1065 $n = $this->mTitle
->isDeleted();
1067 if ( $wgUser->isAllowed( 'undelete' ) ) {
1068 $msg = 'thisisdeleted';
1070 $msg = 'viewdeleted';
1075 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1076 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1079 array( 'known', 'noclasses' )
1087 function printableLink() {
1088 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1092 if ( !$wgRequest->getBool( 'printable' ) ) {
1093 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1094 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1097 if( $wgOut->isSyndicated() ) {
1098 foreach( $wgFeedClasses as $format => $class ) {
1099 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1100 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1101 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1104 return $wgLang->pipeList( $s );
1107 function pageTitle() {
1109 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1113 function pageSubtitle() {
1116 $sub = $wgOut->getSubtitle();
1118 global $wgExtraSubtitle;
1119 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1121 $subpages = $this->subPageSubtitle();
1122 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1123 $s = "<p class='subtitle'>{$sub}</p>\n";
1127 function subPageSubtitle() {
1129 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
1133 if( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1134 $ptext = $this->mTitle
->getPrefixedText();
1135 if( preg_match( '/\//', $ptext ) ) {
1136 $links = explode( '/', $ptext );
1137 array_pop( $links );
1141 foreach( $links as $link ) {
1142 $growinglink .= $link;
1144 $linkObj = Title
::newFromText( $growinglink );
1145 if( is_object( $linkObj ) && $linkObj->exists() ){
1146 $getlink = $this->link(
1148 htmlspecialchars( $display ),
1151 array( 'known', 'noclasses' )
1155 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1157 $subpages .= '< ';
1159 $subpages .= $getlink;
1164 $growinglink .= '/';
1172 * Returns true if the IP should be shown in the header
1174 function showIPinHeader() {
1175 global $wgShowIPinHeader;
1176 return $wgShowIPinHeader && session_id() != '';
1179 function nameAndLogin() {
1180 global $wgUser, $wgLang, $wgContLang;
1182 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1185 if ( $wgUser->isAnon() ) {
1186 if( $this->showIPinHeader() ) {
1189 $talkLink = $this->link( $wgUser->getTalkPage(),
1190 $wgLang->getNsText( NS_TALK
) );
1192 $ret .= "$name ($talkLink)";
1194 $ret .= wfMsg( 'notloggedin' );
1197 $returnTo = $this->mTitle
->getPrefixedDBkey();
1199 if ( $logoutPage != $returnTo ) {
1200 $query['returnto'] = $returnTo;
1203 $loginlink = $wgUser->isAllowed( 'createaccount' )
1204 ?
'nav-login-createaccount'
1206 $ret .= "\n<br />" . $this->link(
1207 SpecialPage
::getTitleFor( 'Userlogin' ),
1208 wfMsg( $loginlink ), array(), $query
1211 $returnTo = $this->mTitle
->getPrefixedDBkey();
1212 $talkLink = $this->link( $wgUser->getTalkPage(),
1213 $wgLang->getNsText( NS_TALK
) );
1215 $ret .= $this->link( $wgUser->getUserPage(),
1216 htmlspecialchars( $wgUser->getName() ) );
1217 $ret .= " ($talkLink)<br />";
1218 $ret .= $wgLang->pipeList( array(
1220 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1221 array(), array( 'returnto' => $returnTo )
1223 $this->specialLink( 'preferences' ),
1226 $ret = $wgLang->pipeList( array(
1229 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1237 function getSearchLink() {
1238 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1239 return $searchPage->getLocalURL();
1242 function escapeSearchLink() {
1243 return htmlspecialchars( $this->getSearchLink() );
1246 function searchForm() {
1247 global $wgRequest, $wgUseTwoButtonsSearchForm;
1248 $search = $wgRequest->getText( 'search' );
1250 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1251 . $this->escapeSearchLink() . "\">\n"
1252 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1253 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1254 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1256 if( $wgUseTwoButtonsSearchForm )
1257 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1259 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1263 // Ensure unique id's for search boxes made after the first
1264 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1269 function topLinks() {
1273 $this->mainPageLink(),
1274 $this->specialLink( 'recentchanges' )
1277 if ( $wgOut->isArticleRelated() ) {
1278 $s[] = $this->editThisPage();
1279 $s[] = $this->historyLink();
1281 # Many people don't like this dropdown box
1282 #$s[] = $this->specialPagesList();
1284 if( $this->variantLinks() ) {
1285 $s[] = $this->variantLinks();
1288 if( $this->extensionTabLinks() ) {
1289 $s[] = $this->extensionTabLinks();
1292 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1293 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1297 * Compatibility for extensions adding functionality through tabs.
1298 * Eventually these old skins should be replaced with SkinTemplate-based
1302 function extensionTabLinks() {
1306 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1307 foreach( $tabs as $tab ) {
1308 $s[] = Xml
::element( 'a',
1309 array( 'href' => $tab['href'] ),
1316 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1317 $out .= $wgLang->pipeList( $s );
1324 * Language/charset variant links for classic-style skins
1327 function variantLinks() {
1329 /* show links to different language variants */
1330 global $wgDisableLangConversion, $wgLang, $wgContLang;
1331 $variants = $wgContLang->getVariants();
1332 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1333 foreach( $variants as $code ) {
1334 $varname = $wgContLang->getVariantname( $code );
1335 if( $varname == 'disable' )
1337 $s = $wgLang->pipeList( array(
1339 '<a href="' . $this->mTitle
->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1346 function bottomLinks() {
1347 global $wgOut, $wgUser, $wgUseTrackbacks;
1348 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1351 if ( $wgOut->isArticleRelated() ) {
1352 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1353 if ( $wgUser->isLoggedIn() ) {
1354 $element[] = $this->watchThisPage();
1356 $element[] = $this->talkLink();
1357 $element[] = $this->historyLink();
1358 $element[] = $this->whatLinksHere();
1359 $element[] = $this->watchPageLinksLink();
1361 if( $wgUseTrackbacks )
1362 $element[] = $this->trackbackLink();
1364 if ( $this->mTitle
->getNamespace() == NS_USER
1365 ||
$this->mTitle
->getNamespace() == NS_USER_TALK
){
1366 $id = User
::idFromName( $this->mTitle
->getText() );
1367 $ip = User
::isIP( $this->mTitle
->getText() );
1369 if( $id ||
$ip ) { # both anons and non-anons have contri list
1370 $element[] = $this->userContribsLink();
1372 if( $this->showEmailUser( $id ) ) {
1373 $element[] = $this->emailUserLink();
1377 $s = implode( $element, $sep );
1379 if ( $this->mTitle
->getArticleId() ) {
1381 if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1382 if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1383 if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
1385 $s .= "<br />\n" . $this->otherLanguages();
1391 function pageStats() {
1392 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1393 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1395 $oldid = $wgRequest->getVal( 'oldid' );
1396 $diff = $wgRequest->getVal( 'diff' );
1397 if ( ! $wgOut->isArticle() ) { return ''; }
1398 if( !$wgArticle instanceOf Article
) { return ''; }
1399 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1400 if ( 0 == $wgArticle->getID() ) { return ''; }
1403 if ( !$wgDisableCounters ) {
1404 $count = $wgLang->formatNum( $wgArticle->getCount() );
1406 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1410 if( $wgMaxCredits != 0 ){
1411 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1413 $s .= $this->lastModified();
1416 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1417 $dbr = wfGetDB( DB_SLAVE
);
1418 $res = $dbr->select( 'watchlist',
1419 array( 'COUNT(*) AS n' ),
1420 array( 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ), 'wl_namespace' => $this->mTitle
->getNamespace() ),
1423 $x = $dbr->fetchObject( $res );
1425 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1426 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1430 return $s . ' ' . $this->getCopyright();
1433 function getCopyright( $type = 'detect' ) {
1434 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1436 if ( $type == 'detect' ) {
1437 $diff = $wgRequest->getVal( 'diff' );
1438 $isCur = $wgArticle && $wgArticle->isCurrent();
1439 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1446 if ( $type == 'history' ) {
1447 $msg = 'history_copyright';
1453 if( $wgRightsPage ) {
1454 $title = Title
::newFromText( $wgRightsPage );
1455 $link = $this->linkKnown( $title, $wgRightsText );
1456 } elseif( $wgRightsUrl ) {
1457 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1458 } elseif( $wgRightsText ) {
1459 $link = $wgRightsText;
1464 // Allow for site and per-namespace customization of copyright notice.
1465 if( isset($wgArticle) )
1466 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
1468 $out .= wfMsgForContent( $msg, $link );
1472 function getCopyrightIcon() {
1473 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1475 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1476 $out = $wgCopyrightIcon;
1477 } else if ( $wgRightsIcon ) {
1478 $icon = htmlspecialchars( $wgRightsIcon );
1479 if ( $wgRightsUrl ) {
1480 $url = htmlspecialchars( $wgRightsUrl );
1481 $out .= '<a href="'.$url.'">';
1483 $text = htmlspecialchars( $wgRightsText );
1484 $out .= "<img src=\"$icon\" alt='$text' />";
1485 if ( $wgRightsUrl ) {
1492 function getPoweredBy() {
1493 global $wgStylePath;
1494 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1495 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1499 function lastModified() {
1500 global $wgLang, $wgArticle;
1501 if( $this->mRevisionId
) {
1502 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1504 $timestamp = $wgArticle->getTimestamp();
1507 $d = $wgLang->date( $timestamp, true );
1508 $t = $wgLang->time( $timestamp, true );
1509 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1513 if ( wfGetLB()->getLaggedSlaveMode() ) {
1514 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1519 function logoText( $align = '' ) {
1520 if ( '' != $align ) {
1521 $a = " align='{$align}'";
1526 $mp = wfMsg( 'mainpage' );
1527 $mptitle = Title
::newMainPage();
1528 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1530 $logourl = $this->getLogo();
1531 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1536 * show a drop-down box of special pages
1538 function specialPagesList() {
1539 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1540 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1541 foreach ( $pages as $name => $page ) {
1542 $pages[$name] = $page->getDescription();
1545 $go = wfMsg( 'go' );
1546 $sp = wfMsg( 'specialpages' );
1547 $spp = $wgContLang->specialPage( 'Specialpages' );
1549 $s = '<form id="specialpages" method="get" ' .
1550 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1551 $s .= "<select name=\"wpDropdown\">\n";
1552 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1555 foreach ( $pages as $name => $desc ) {
1556 $p = $wgContLang->specialPage( $name );
1557 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1559 $s .= "</select>\n";
1560 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1565 function mainPageLink() {
1567 Title
::newMainPage(),
1568 wfMsg( 'mainpage' ),
1571 array( 'known', 'noclasses' )
1576 function copyrightLink() {
1577 $title = Title
::newFromText( wfMsgForContent( 'copyrightpage' ) );
1578 $s = $this->linkKnown(
1580 wfMsg( 'copyrightpagename' )
1585 private function footerLink ( $desc, $page ) {
1586 // if the link description has been set to "-" in the default language,
1587 if ( wfMsgForContent( $desc ) == '-') {
1588 // then it is disabled, for all languages.
1591 // Otherwise, we display the link for the user, described in their
1592 // language (which may or may not be the same as the default language),
1593 // but we make the link target be the one site-wide page.
1594 $title = Title
::newFromText( wfMsgForContent( $page ) );
1595 return $this->linkKnown(
1597 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1602 function privacyLink() {
1603 return $this->footerLink( 'privacy', 'privacypage' );
1606 function aboutLink() {
1607 return $this->footerLink( 'aboutsite', 'aboutpage' );
1610 function disclaimerLink() {
1611 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1614 function editThisPage() {
1617 if ( !$wgOut->isArticleRelated() ) {
1618 $s = wfMsg( 'protectedpage' );
1620 if( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1621 $t = wfMsg( 'editthispage' );
1622 } elseif( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1623 $t = wfMsg( 'create-this-page' );
1625 $t = wfMsg( 'viewsource' );
1632 $this->editUrlOptions(),
1633 array( 'known', 'noclasses' )
1640 * Return URL options for the 'edit page' link.
1641 * This may include an 'oldid' specifier, if the current page view is such.
1646 function editUrlOptions() {
1649 $options = array( 'action' => 'edit' );
1651 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1652 $options['oldid'] = intval( $this->mRevisionId
);
1658 function deleteThisPage() {
1659 global $wgUser, $wgRequest;
1661 $diff = $wgRequest->getVal( 'diff' );
1662 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1663 $t = wfMsg( 'deletethispage' );
1669 array( 'action' => 'delete' ),
1670 array( 'known', 'noclasses' )
1678 function protectThisPage() {
1679 global $wgUser, $wgRequest;
1681 $diff = $wgRequest->getVal( 'diff' );
1682 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1683 if ( $this->mTitle
->isProtected() ) {
1684 $text = wfMsg( 'unprotectthispage' );
1685 $query = array( 'action' => 'unprotect' );
1687 $text = wfMsg( 'protectthispage' );
1688 $query = array( 'action' => 'protect' );
1696 array( 'known', 'noclasses' )
1704 function watchThisPage() {
1706 ++
$this->mWatchLinkNum
;
1708 if ( $wgOut->isArticleRelated() ) {
1709 if ( $this->mTitle
->userIsWatching() ) {
1710 $text = wfMsg( 'unwatchthispage' );
1711 $query = array( 'action' => 'unwatch' );
1712 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1714 $text = wfMsg( 'watchthispage' );
1715 $query = array( 'action' => 'watch' );
1716 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1722 array( 'id' => $id ),
1724 array( 'known', 'noclasses' )
1727 $s = wfMsg( 'notanarticle' );
1732 function moveThisPage() {
1733 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1735 SpecialPage
::getTitleFor( 'Movepage' ),
1736 wfMsg( 'movethispage' ),
1738 array( 'target' => $this->mTitle
->getPrefixedDBkey() ),
1739 array( 'known', 'noclasses' )
1742 // no message if page is protected - would be redundant
1747 function historyLink() {
1750 wfMsgHtml( 'history' ),
1751 array( 'rel' => 'archives' ),
1752 array( 'action' => 'history' )
1756 function whatLinksHere() {
1758 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1759 wfMsgHtml( 'whatlinkshere' ),
1762 array( 'known', 'noclasses' )
1766 function userContribsLink() {
1768 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1769 wfMsgHtml( 'contributions' ),
1772 array( 'known', 'noclasses' )
1776 function showEmailUser( $id ) {
1778 $targetUser = User
::newFromId( $id );
1779 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1780 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1783 function emailUserLink() {
1785 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1786 wfMsg( 'emailuser' ),
1789 array( 'known', 'noclasses' )
1793 function watchPageLinksLink() {
1795 if ( ! $wgOut->isArticleRelated() ) {
1796 return '(' . wfMsg( 'notanarticle' ) . ')';
1799 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1800 wfMsg( 'recentchangeslinked-toolbox' ),
1803 array( 'known', 'noclasses' )
1808 function trackbackLink() {
1809 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1810 . wfMsg( 'trackbacklink' ) . '</a>';
1813 function otherLanguages() {
1814 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1816 if ( $wgHideInterlanguageLinks ) {
1820 $a = $wgOut->getLanguageLinks();
1821 if ( 0 == count( $a ) ) {
1825 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1827 if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
1828 foreach( $a as $l ) {
1830 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1834 $nt = Title
::newFromText( $l );
1835 $url = $nt->escapeFullURL();
1836 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1838 if ( '' == $text ) { $text = $l; }
1839 $style = $this->getExternalLinkAttributes();
1840 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1842 if( $wgContLang->isRTL() ) $s .= '</span>';
1846 function talkLink() {
1847 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1848 # No discussion links for special pages
1852 $linkOptions = array();
1854 if( $this->mTitle
->isTalkPage() ) {
1855 $link = $this->mTitle
->getSubjectPage();
1856 switch( $link->getNamespace() ) {
1858 $text = wfMsg( 'articlepage' );
1861 $text = wfMsg( 'userpage' );
1864 $text = wfMsg( 'projectpage' );
1867 $text = wfMsg( 'imagepage' );
1868 # Make link known if image exists, even if the desc. page doesn't.
1869 if( wfFindFile( $link ) )
1870 $linkOptions[] = 'known';
1873 $text = wfMsg( 'mediawikipage' );
1876 $text = wfMsg( 'templatepage' );
1879 $text = wfMsg( 'viewhelppage' );
1882 $text = wfMsg( 'categorypage' );
1885 $text = wfMsg( 'articlepage' );
1888 $link = $this->mTitle
->getTalkPage();
1889 $text = wfMsg( 'talkpage' );
1892 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1897 function commentLink() {
1900 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1904 # __NEWSECTIONLINK___ changes behaviour here
1905 # If it is present, the link points to this page, otherwise
1906 # it points to the talk page
1907 if( $this->mTitle
->isTalkPage() ) {
1908 $title = $this->mTitle
;
1909 } elseif( $wgOut->showNewSectionLink() ) {
1910 $title = $this->mTitle
;
1912 $title = $this->mTitle
->getTalkPage();
1917 wfMsg( 'postcomment' ),
1923 array( 'known', 'noclasses' )
1927 /* these are used extensively in SkinTemplate, but also some other places */
1928 static function makeMainPageUrl( $urlaction = '' ) {
1929 $title = Title
::newMainPage();
1930 self
::checkTitle( $title, '' );
1931 return $title->getLocalURL( $urlaction );
1934 static function makeSpecialUrl( $name, $urlaction = '' ) {
1935 $title = SpecialPage
::getTitleFor( $name );
1936 return $title->getLocalURL( $urlaction );
1939 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1940 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1941 return $title->getLocalURL( $urlaction );
1944 static function makeI18nUrl( $name, $urlaction = '' ) {
1945 $title = Title
::newFromText( wfMsgForContent( $name ) );
1946 self
::checkTitle( $title, $name );
1947 return $title->getLocalURL( $urlaction );
1950 static function makeUrl( $name, $urlaction = '' ) {
1951 $title = Title
::newFromText( $name );
1952 self
::checkTitle( $title, $name );
1953 return $title->getLocalURL( $urlaction );
1956 # If url string starts with http, consider as external URL, else
1958 static function makeInternalOrExternalUrl( $name ) {
1959 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1962 return self
::makeUrl( $name );
1966 # this can be passed the NS number as defined in Language.php
1967 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1968 $title = Title
::makeTitleSafe( $namespace, $name );
1969 self
::checkTitle( $title, $name );
1970 return $title->getLocalURL( $urlaction );
1973 /* these return an array with the 'href' and boolean 'exists' */
1974 static function makeUrlDetails( $name, $urlaction = '' ) {
1975 $title = Title
::newFromText( $name );
1976 self
::checkTitle( $title, $name );
1978 'href' => $title->getLocalURL( $urlaction ),
1979 'exists' => $title->getArticleID() != 0 ?
true : false
1984 * Make URL details where the article exists (or at least it's convenient to think so)
1986 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1987 $title = Title
::newFromText( $name );
1988 self
::checkTitle( $title, $name );
1990 'href' => $title->getLocalURL( $urlaction ),
1995 # make sure we have some title to operate on
1996 static function checkTitle( &$title, $name ) {
1997 if( !is_object( $title ) ) {
1998 $title = Title
::newFromText( $name );
1999 if( !is_object( $title ) ) {
2000 $title = Title
::newFromText( '--error: link target missing--' );
2006 * Build an array that represents the sidebar(s), the navigation bar among them
2010 function buildSidebar() {
2011 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2013 wfProfileIn( __METHOD__
);
2015 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2017 if ( $wgEnableSidebarCache ) {
2018 $cachedsidebar = $parserMemc->get( $key );
2019 if ( $cachedsidebar ) {
2020 wfProfileOut( __METHOD__
);
2021 return $cachedsidebar;
2026 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
2028 foreach( $lines as $line ) {
2029 if( strpos( $line, '*' ) !== 0 )
2031 if( strpos( $line, '**') !== 0 ) {
2032 $heading = trim( $line, '* ' );
2033 if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
2035 if( strpos( $line, '|' ) !== false ) { // sanity check
2036 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
2037 $link = wfMsgForContent( $line[0] );
2041 $text = wfMsgExt( $line[1], 'parsemag' );
2042 if( wfEmptyMsg( $line[1], $text ) )
2044 if( wfEmptyMsg( $line[0], $link ) )
2047 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2050 $title = Title
::newFromText( $link );
2052 $title = $title->fixSpecialName();
2053 $href = $title->getLocalURL();
2055 $href = 'INVALID-TITLE';
2059 $bar[$heading][] = array(
2062 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2065 } else { continue; }
2068 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2069 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2070 wfProfileOut( __METHOD__
);
2075 * Should we include common/wikiprintable.css? Skins that have their own
2076 * print stylesheet should override this and return false. (This is an
2077 * ugly hack to get Monobook to play nicely with
2078 * OutputPage::headElement().)
2082 public function commonPrintStylesheet() {