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;
367 $ns = $wgTitle->getNamespace();
368 $nsname = MWNamespace
::exists( $ns ) ? MWNamespace
::getCanonicalName( $ns ) : $wgTitle->getNsText();
369 $separatorTransTable = $wgContLang->separatorTransformTable();
370 $separatorTransTable = $separatorTransTable ?
$separatorTransTable : array();
371 $compactSeparatorTransTable = array(
372 implode( "\t", array_keys( $separatorTransTable ) ),
373 implode( "\t", $separatorTransTable ),
375 $digitTransTable = $wgContLang->digitTransformTable();
376 $digitTransTable = $digitTransTable ?
$digitTransTable : array();
377 $compactDigitTransTable = array(
378 implode( "\t", array_keys( $digitTransTable ) ),
379 implode( "\t", $digitTransTable ),
382 $mainPage = Title
::newFromText( wfMsgForContent( 'mainpage' ) );
385 'stylepath' => $wgStylePath,
386 'wgArticlePath' => $wgArticlePath,
387 'wgScriptPath' => $wgScriptPath,
388 'wgScriptExtension' => $wgScriptExtension,
389 'wgScript' => $wgScript,
390 'wgVariantArticlePath' => $wgVariantArticlePath,
391 'wgActionPaths' => (object)$wgActionPaths,
392 'wgServer' => $wgServer,
393 'wgCanonicalNamespace' => $nsname,
394 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ?
395 SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115
396 'wgNamespaceNumber' => $wgTitle->getNamespace(),
397 'wgPageName' => $wgTitle->getPrefixedDBKey(),
398 'wgTitle' => $wgTitle->getText(),
399 'wgAction' => $wgRequest->getText( 'action', 'view' ),
400 'wgArticleId' => $wgTitle->getArticleId(),
401 'wgIsArticle' => $wgOut->isArticle(),
402 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
403 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
404 'wgUserLanguage' => $wgLang->getCode(),
405 'wgContentLanguage' => $wgContLang->getCode(),
406 'wgBreakFrames' => $wgBreakFrames,
407 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
408 'wgVersion' => $wgVersion,
409 'wgEnableAPI' => $wgEnableAPI,
410 'wgEnableWriteAPI' => $wgEnableWriteAPI,
411 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
412 'wgDigitTransformTable' => $compactDigitTransTable,
413 'wgMainPageTitle' => $mainPage ?
$mainPage->getPrefixedText() : null,
414 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
415 'wgNamespaceIds' => $wgContLang->getNamespaceIds(),
417 if ( $wgContLang->hasVariants() ) {
418 $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
421 //if on upload page output the extension list & js_upload
422 if( SpecialPage
::resolveAlias( $wgTitle->getDBkey() ) == "Upload" ) {
423 global $wgFileExtensions, $wgAjaxUploadInterface;
424 $vars['wgFileExtensions'] = $wgFileExtensions;
425 $vars['wgAjaxUploadInterface'] = $wgAjaxUploadInterface;
428 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
429 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
430 $vars['wgDBname'] = $wgDBname;
431 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
432 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
435 foreach( $wgRestrictionTypes as $type )
436 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
438 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
439 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
440 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
441 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
442 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
445 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
446 $msgs = (object)array();
447 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
448 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
450 $vars['wgAjaxWatch'] = $msgs;
453 // Allow extensions to add their custom variables to the global JS variables
454 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
456 return self
::makeVariablesScript( $vars );
460 * To make it harder for someone to slip a user a fake
461 * user-JavaScript or user-CSS preview, a random token
462 * is associated with the login session. If it's not
463 * passed back with the preview request, we won't render
466 * @param string $action
469 public function userCanPreview( $action ) {
470 global $wgRequest, $wgUser;
472 if( $action != 'submit' )
474 if( !$wgRequest->wasPosted() )
476 if( !$this->mTitle
->userCanEditCssSubpage() )
478 if( !$this->mTitle
->userCanEditJsSubpage() )
480 return $wgUser->matchEditToken(
481 $wgRequest->getVal( 'wpEditToken' ) );
485 * generated JavaScript action=raw&gen=js
486 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
487 * nated together. For some bizarre reason, it does *not* return any
488 * custom user JS from subpages. Huh?
490 * There's absolutely no reason to have separate Monobook/Common JSes.
491 * Any JS that cares can just check the skin variable generated at the
492 * top. For now Monobook.js will be maintained, but it should be consi-
495 * @param $force_skin string If set, overrides the skin name
499 public function generateUserJs( $skinName = null ) {
502 wfProfileIn( __METHOD__
);
504 $skinName = $this->getSkinName();
507 $s = "/* generated javascript */\n";
508 $s .= "var skin = '" . Xml
::escapeJsString($skinName ) . "';\n";
509 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
510 $s .= "\n\n/* MediaWiki:Common.js */\n";
511 $commonJs = wfMsgForContent( 'common.js' );
512 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
516 $s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n";
517 // avoid inclusion of non defined user JavaScript (with custom skins only)
518 // by checking for default message content
519 $msgKey = ucfirst( $skinName ) . '.js';
520 $userJS = wfMsgForContent( $msgKey );
521 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
525 wfProfileOut( __METHOD__
);
530 * Generate user stylesheet for action=raw&gen=css
532 public function generateUserStylesheet() {
533 wfProfileIn( __METHOD__
);
534 $s = "/* generated user stylesheet */\n" .
535 $this->reallyGenerateUserStylesheet();
536 wfProfileOut( __METHOD__
);
541 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
543 protected function reallyGenerateUserStylesheet(){
546 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
547 $underline = $undopt ?
'underline' : 'none';
548 $s .= "a { text-decoration: $underline; }\n";
550 if( $wgUser->getOption( 'highlightbroken' ) ) {
551 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
554 a.new, #quickbar a.new,
555 a.stub, #quickbar a.stub {
558 a.new:after, #quickbar a.new:after {
562 a.stub:after, #quickbar a.stub:after {
568 if( $wgUser->getOption( 'justify' ) ) {
569 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
571 if( !$wgUser->getOption( 'showtoc' ) ) {
572 $s .= "#toc { display: none; }\n";
574 if( !$wgUser->getOption( 'editsection' ) ) {
575 $s .= ".editsection { display: none; }\n";
577 $fontstyle = $wgUser->getOption( 'editfont' );
578 if ( $fontstyle !== 'default' ) {
579 $s .= "textarea { font-family: $fontstyle; }\n";
587 function setupUserCss( OutputPage
$out ) {
588 global $wgRequest, $wgContLang, $wgUser;
589 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
591 wfProfileIn( __METHOD__
);
593 $this->setupSkinUserCss( $out );
597 'maxage' => $wgSquidMaxage,
600 // Add any extension CSS
601 foreach ( $out->getExtStyle() as $url ) {
602 $out->addStyle( $url );
605 // If we use the site's dynamic CSS, throw that in, too
606 // Per-site custom styles
607 if( $wgUseSiteCss ) {
608 global $wgHandheldStyle;
609 $query = wfArrayToCGI( array(
610 'usemsgcache' => 'yes',
611 'ctype' => 'text/css',
612 'smaxage' => $wgSquidMaxage
614 # Site settings must override extension css! (bug 15025)
615 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
616 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
617 if( $wgHandheldStyle ) {
618 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
620 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
623 if( $wgUser->isLoggedIn() ) {
624 // Ensure that logged-in users' generated CSS isn't clobbered
625 // by anons' publicly cacheable generated CSS.
626 $siteargs['smaxage'] = '0';
627 $siteargs['ts'] = $wgUser->mTouched
;
629 // Per-user styles based on preferences
630 $siteargs['gen'] = 'css';
631 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
632 $siteargs['useskin'] = $us;
634 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
636 // Per-user custom style pages
637 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
638 $action = $wgRequest->getVal( 'action' );
639 # If we're previewing the CSS page, use it
640 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
641 // @FIXME: properly escape the cdata!
642 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
644 $out->addStyle( self
::makeUrl( $this->userpage
. '/' . $this->getSkinName() .'.css',
645 'action=raw&ctype=text/css' ) );
649 wfProfileOut( __METHOD__
);
653 * Add skin specific stylesheets
654 * @param $out OutputPage
656 function setupSkinUserCss( OutputPage
$out ) {
657 $out->addStyle( 'common/shared.css' );
658 $out->addStyle( 'common/oldshared.css' );
659 $out->addStyle( $this->getStylesheet() );
660 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
663 function getBodyOptions() {
664 global $wgUser, $wgOut, $wgRequest, $wgContLang;
666 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
668 if ( 0 != $this->mTitle
->getNamespace() ) {
669 $a = array( 'bgcolor' => '#ffffec' );
671 else $a = array( 'bgcolor' => '#FFFFFF' );
672 if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
673 $this->mTitle
->quickUserCan( 'edit' ) ) {
674 $s = $this->mTitle
->getFullURL( $this->editUrlOptions() );
675 $s = 'document.location = "' .Xml
::escapeJsString( $s ) .'";';
676 $a +
= array( 'ondblclick' => $s );
678 $a['onload'] = $wgOut->getOnloadHandler();
681 ' '.( $wgContLang->getDir() ).
682 ' '.$this->getPageClasses( $this->mTitle
) .
683 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName() );
687 function getPageClasses( $title ) {
688 $numeric = 'ns-'.$title->getNamespace();
689 if( $title->getNamespace() == NS_SPECIAL
) {
690 $type = 'ns-special';
691 } elseif( $title->isTalkPage() ) {
694 $type = 'ns-subject';
696 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
697 return "$numeric $type $name";
709 * This will be called immediately after the <body> tag. Split into
710 * two functions to make it easier to subclass.
712 function beforeContent() {
713 return $this->doBeforeContent();
716 function doBeforeContent() {
718 wfProfileIn( __METHOD__
);
721 $qb = $this->qbSetting();
723 if( $langlinks = $this->otherLanguages() ) {
729 $borderhack = 'class="top"';
732 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
733 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
735 $shove = ( $qb != 0 );
736 $left = ( $qb == 1 ||
$qb == 3 );
737 if( $wgContLang->isRTL() ) $left = !$left;
740 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
741 $this->logoText() . '</td>';
743 $s .= $this->getQuickbarCompensator( $rows );
745 $l = $wgContLang->alignStart();
746 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
748 $s .= $this->topLinks();
749 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
751 $r = $wgContLang->alignEnd();
752 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
753 $s .= $this->nameAndLogin();
754 $s .= "\n<br />" . $this->searchForm() . "</td>";
757 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
760 if ( $shove && !$left ) { # Right
761 $s .= $this->getQuickbarCompensator( $rows );
763 $s .= "</tr>\n</table>\n</div>\n";
764 $s .= "\n<div id='article'>\n";
766 $notice = wfGetSiteNotice();
768 $s .= "\n<div id='siteNotice'>$notice</div>\n";
770 $s .= $this->pageTitle();
771 $s .= $this->pageSubtitle();
772 $s .= $this->getCategories();
773 wfProfileOut( __METHOD__
);
778 function getCategoryLinks() {
779 global $wgOut, $wgUseCategoryBrowser;
780 global $wgContLang, $wgUser;
782 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
785 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
787 // Use Unicode bidi embedding override characters,
788 // to make sure links don't smash each other up in ugly ways.
789 $dir = $wgContLang->getDir();
790 $embed = "<span dir='$dir'>";
793 $allCats = $wgOut->getCategoryLinks();
795 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
796 if ( !empty( $allCats['normal'] ) ) {
797 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
799 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
800 $s .= '<div id="mw-normal-catlinks">' .
801 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
802 . $colon . $t . '</div>';
806 if ( isset( $allCats['hidden'] ) ) {
807 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
808 $class ='mw-hidden-cats-user-shown';
809 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
810 $class = 'mw-hidden-cats-ns-shown';
812 $class = 'mw-hidden-cats-hidden';
814 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
815 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
816 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
820 # optional 'dmoz-like' category browser. Will be shown under the list
821 # of categories an article belong to
822 if( $wgUseCategoryBrowser ){
823 $s .= '<br /><hr />';
825 # get a big array of the parents tree
826 $parenttree = $this->mTitle
->getParentCategoryTree();
827 # Skin object passed by reference cause it can not be
828 # accessed under the method subfunction drawCategoryBrowser
829 $tempout = explode( "\n", Skin
::drawCategoryBrowser( $parenttree, $this ) );
830 # Clean out bogus first entry and sort them
831 unset( $tempout[0] );
833 # Output one per line
834 $s .= implode( "<br />\n", $tempout );
841 * Render the array as a serie of links.
842 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
843 * @param &skin Object: skin passed by reference
844 * @return String separated by >, terminate with "\n"
846 function drawCategoryBrowser( $tree, &$skin ){
848 foreach( $tree as $element => $parent ) {
849 if( empty( $parent ) ) {
850 # element start a new list
853 # grab the others elements
854 $return .= Skin
::drawCategoryBrowser( $parent, $skin ) . ' > ';
856 # add our current element to the list
857 $eltitle = Title
::newFromText( $element );
858 $return .= $skin->link( $eltitle, $eltitle->getText() );
863 function getCategories() {
864 $catlinks = $this->getCategoryLinks();
866 $classes = 'catlinks';
868 // Check what we're showing
869 global $wgOut, $wgUser;
870 $allCats = $wgOut->getCategoryLinks();
871 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
872 $this->mTitle
->getNamespace() == NS_CATEGORY
;
874 if( empty($allCats['normal']) && !( !empty($allCats['hidden']) && $showHidden ) ) {
875 $classes .= ' catlinks-allhidden';
878 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
881 function getQuickbarCompensator( $rows = 1 ) {
882 return "<td width='152' rowspan='{$rows}'> </td>";
886 * This runs a hook to allow extensions placing their stuff after content
887 * and article metadata (e.g. categories).
888 * Note: This function has nothing to do with afterContent().
890 * This hook is placed here in order to allow using the same hook for all
891 * skins, both the SkinTemplate based ones and the older ones, which directly
892 * use this class to get their data.
894 * The output of this function gets processed in SkinTemplate::outputPage() for
895 * the SkinTemplate based skins, all other skins should directly echo it.
897 * Returns an empty string by default, if not changed by any hook function.
899 protected function afterContentHook() {
902 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
903 // adding just some spaces shouldn't toggle the output
904 // of the whole <div/>, so we use trim() here
905 if( trim( $data ) != '' ){
906 // Doing this here instead of in the skins to
907 // ensure that the div has the same ID in all
909 $data = "<div id='mw-data-after-content'>\n" .
914 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
921 * Generate debug data HTML for displaying at the bottom of the main content
923 * @return String HTML containing debug data, if enabled (otherwise empty).
925 protected function generateDebugHTML() {
926 global $wgShowDebug, $wgOut;
927 if ( $wgShowDebug ) {
928 $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext
);
929 return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
930 $listInternals . "</ul>\n";
935 private function formatDebugHTML( $debugText ) {
936 $lines = explode( "\n", $debugText );
939 foreach( $lines as $line ) {
941 $display = ltrim( $line );
942 $ident = strlen( $line ) - strlen( $display );
943 $diff = $ident - $curIdent;
945 if ( $display == '' )
946 $display = "\xc2\xa0";
948 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
951 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
953 $display = htmlspecialchars( $display );
957 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
958 elseif ( $diff == 0 )
959 $ret .= "</li><li>\n";
961 $ret .= str_repeat( "<ul><li>\n", $diff );
962 $ret .= $display . "\n";
966 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
971 * This gets called shortly before the </body> tag.
972 * @return String HTML to be put before </body>
974 function afterContent() {
975 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
976 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
980 * This gets called shortly before the </body> tag.
981 * @return String HTML-wrapped JS code to be put before </body>
983 function bottomScripts() {
984 $bottomScriptText = "\n" . Html
::inlineScript( 'if (window.runOnloadHook) runOnloadHook();' ) . "\n";
985 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
986 return $bottomScriptText;
989 /** @return string Retrievied from HTML text */
990 function printSource() {
991 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
992 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
995 function printFooter() {
996 return "<p>" . $this->printSource() .
997 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
1000 /** overloaded by derived classes */
1001 function doAfterContent() { return '</div></div>'; }
1003 function pageTitleLinks() {
1004 global $wgOut, $wgUser, $wgRequest, $wgLang;
1006 $oldid = $wgRequest->getVal( 'oldid' );
1007 $diff = $wgRequest->getVal( 'diff' );
1008 $action = $wgRequest->getText( 'action' );
1010 $s[] = $this->printableLink();
1011 $disclaimer = $this->disclaimerLink(); # may be empty
1015 $privacy = $this->privacyLink(); # may be empty too
1020 if ( $wgOut->isArticleRelated() ) {
1021 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
1022 $name = $this->mTitle
->getDBkey();
1023 $image = wfFindFile( $this->mTitle
);
1025 $link = htmlspecialchars( $image->getURL() );
1026 $style = $this->getInternalLinkAttributes( $link, $name );
1027 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
1031 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
1032 $s[] .= $this->link(
1034 wfMsg( 'currentrev' ),
1037 array( 'known', 'noclasses' )
1041 if ( $wgUser->getNewtalk() ) {
1042 # do not show "You have new messages" text when we are viewing our
1044 if( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
1046 $wgUser->getTalkPage(),
1047 wfMsgHtml( 'newmessageslink' ),
1049 array( 'redirect' => 'no' ),
1050 array( 'known', 'noclasses' )
1054 $wgUser->getTalkPage(),
1055 wfMsgHtml( 'newmessagesdifflink' ),
1057 array( 'diff' => 'cur' ),
1058 array( 'known', 'noclasses' )
1060 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1062 $wgOut->setSquidMaxage( 0 );
1063 $wgOut->enableClientCache( false );
1067 $undelete = $this->getUndeleteLink();
1068 if( !empty( $undelete ) ) {
1071 return $wgLang->pipeList( $s );
1074 function getUndeleteLink() {
1075 global $wgUser, $wgContLang, $wgLang, $wgRequest;
1077 $action = $wgRequest->getVal( 'action', 'view' );
1079 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1080 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1081 $n = $this->mTitle
->isDeleted();
1083 if ( $wgUser->isAllowed( 'undelete' ) ) {
1084 $msg = 'thisisdeleted';
1086 $msg = 'viewdeleted';
1091 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1092 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1095 array( 'known', 'noclasses' )
1103 function printableLink() {
1104 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1108 if ( !$wgOut->isPrintable() ) {
1109 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1110 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1113 if( $wgOut->isSyndicated() ) {
1114 foreach( $wgFeedClasses as $format => $class ) {
1115 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1116 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1117 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1120 return $wgLang->pipeList( $s );
1123 function pageTitle() {
1125 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1129 function pageSubtitle() {
1132 $sub = $wgOut->getSubtitle();
1134 global $wgExtraSubtitle;
1135 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1137 $subpages = $this->subPageSubtitle();
1138 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1139 $s = "<p class='subtitle'>{$sub}</p>\n";
1143 function subPageSubtitle() {
1145 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
1149 if( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1150 $ptext = $this->mTitle
->getPrefixedText();
1151 if( preg_match( '/\//', $ptext ) ) {
1152 $links = explode( '/', $ptext );
1153 array_pop( $links );
1157 foreach( $links as $link ) {
1158 $growinglink .= $link;
1160 $linkObj = Title
::newFromText( $growinglink );
1161 if( is_object( $linkObj ) && $linkObj->exists() ){
1162 $getlink = $this->link(
1164 htmlspecialchars( $display ),
1167 array( 'known', 'noclasses' )
1171 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1173 $subpages .= '< ';
1175 $subpages .= $getlink;
1180 $growinglink .= '/';
1188 * Returns true if the IP should be shown in the header
1190 function showIPinHeader() {
1191 global $wgShowIPinHeader;
1192 return $wgShowIPinHeader && session_id() != '';
1195 function nameAndLogin() {
1196 global $wgUser, $wgLang, $wgContLang;
1198 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1201 if ( $wgUser->isAnon() ) {
1202 if( $this->showIPinHeader() ) {
1205 $talkLink = $this->link( $wgUser->getTalkPage(),
1206 $wgLang->getNsText( NS_TALK
) );
1208 $ret .= "$name ($talkLink)";
1210 $ret .= wfMsg( 'notloggedin' );
1213 $returnTo = $this->mTitle
->getPrefixedDBkey();
1215 if ( $logoutPage != $returnTo ) {
1216 $query['returnto'] = $returnTo;
1219 $loginlink = $wgUser->isAllowed( 'createaccount' )
1220 ?
'nav-login-createaccount'
1222 $ret .= "\n<br />" . $this->link(
1223 SpecialPage
::getTitleFor( 'Userlogin' ),
1224 wfMsg( $loginlink ), array(), $query
1227 $returnTo = $this->mTitle
->getPrefixedDBkey();
1228 $talkLink = $this->link( $wgUser->getTalkPage(),
1229 $wgLang->getNsText( NS_TALK
) );
1231 $ret .= $this->link( $wgUser->getUserPage(),
1232 htmlspecialchars( $wgUser->getName() ) );
1233 $ret .= " ($talkLink)<br />";
1234 $ret .= $wgLang->pipeList( array(
1236 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1237 array(), array( 'returnto' => $returnTo )
1239 $this->specialLink( 'preferences' ),
1242 $ret = $wgLang->pipeList( array(
1245 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1253 function getSearchLink() {
1254 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1255 return $searchPage->getLocalURL();
1258 function escapeSearchLink() {
1259 return htmlspecialchars( $this->getSearchLink() );
1262 function searchForm() {
1263 global $wgRequest, $wgUseTwoButtonsSearchForm;
1264 $search = $wgRequest->getText( 'search' );
1266 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1267 . $this->escapeSearchLink() . "\">\n"
1268 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1269 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1270 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1272 if( $wgUseTwoButtonsSearchForm )
1273 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1275 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1279 // Ensure unique id's for search boxes made after the first
1280 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1285 function topLinks() {
1289 $this->mainPageLink(),
1290 $this->specialLink( 'recentchanges' )
1293 if ( $wgOut->isArticleRelated() ) {
1294 $s[] = $this->editThisPage();
1295 $s[] = $this->historyLink();
1297 # Many people don't like this dropdown box
1298 #$s[] = $this->specialPagesList();
1300 if( $this->variantLinks() ) {
1301 $s[] = $this->variantLinks();
1304 if( $this->extensionTabLinks() ) {
1305 $s[] = $this->extensionTabLinks();
1308 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1309 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1313 * Compatibility for extensions adding functionality through tabs.
1314 * Eventually these old skins should be replaced with SkinTemplate-based
1318 function extensionTabLinks() {
1322 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1323 foreach( $tabs as $tab ) {
1324 $s[] = Xml
::element( 'a',
1325 array( 'href' => $tab['href'] ),
1332 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1333 $out .= $wgLang->pipeList( $s );
1340 * Language/charset variant links for classic-style skins
1343 function variantLinks() {
1345 /* show links to different language variants */
1346 global $wgDisableLangConversion, $wgLang, $wgContLang;
1347 $variants = $wgContLang->getVariants();
1348 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1349 foreach( $variants as $code ) {
1350 $varname = $wgContLang->getVariantname( $code );
1351 if( $varname == 'disable' )
1353 $s = $wgLang->pipeList( array(
1355 '<a href="' . $this->mTitle
->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1362 function bottomLinks() {
1363 global $wgOut, $wgUser, $wgUseTrackbacks;
1364 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1367 if ( $wgOut->isArticleRelated() ) {
1368 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1369 if ( $wgUser->isLoggedIn() ) {
1370 $element[] = $this->watchThisPage();
1372 $element[] = $this->talkLink();
1373 $element[] = $this->historyLink();
1374 $element[] = $this->whatLinksHere();
1375 $element[] = $this->watchPageLinksLink();
1377 if( $wgUseTrackbacks )
1378 $element[] = $this->trackbackLink();
1380 if ( $this->mTitle
->getNamespace() == NS_USER
1381 ||
$this->mTitle
->getNamespace() == NS_USER_TALK
){
1382 $id = User
::idFromName( $this->mTitle
->getText() );
1383 $ip = User
::isIP( $this->mTitle
->getText() );
1385 if( $id ||
$ip ) { # both anons and non-anons have contri list
1386 $element[] = $this->userContribsLink();
1388 if( $this->showEmailUser( $id ) ) {
1389 $element[] = $this->emailUserLink();
1393 $s = implode( $element, $sep );
1395 if ( $this->mTitle
->getArticleId() ) {
1397 if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1398 if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1399 if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
1401 $s .= "<br />\n" . $this->otherLanguages();
1407 function pageStats() {
1408 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1409 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1411 $oldid = $wgRequest->getVal( 'oldid' );
1412 $diff = $wgRequest->getVal( 'diff' );
1413 if ( ! $wgOut->isArticle() ) { return ''; }
1414 if( !$wgArticle instanceOf Article
) { return ''; }
1415 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1416 if ( 0 == $wgArticle->getID() ) { return ''; }
1419 if ( !$wgDisableCounters ) {
1420 $count = $wgLang->formatNum( $wgArticle->getCount() );
1422 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1426 if( $wgMaxCredits != 0 ){
1427 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1429 $s .= $this->lastModified();
1432 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1433 $dbr = wfGetDB( DB_SLAVE
);
1434 $res = $dbr->select( 'watchlist',
1435 array( 'COUNT(*) AS n' ),
1436 array( 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ), 'wl_namespace' => $this->mTitle
->getNamespace() ),
1439 $x = $dbr->fetchObject( $res );
1441 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1442 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1446 return $s . ' ' . $this->getCopyright();
1449 function getCopyright( $type = 'detect' ) {
1450 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1452 if ( $type == 'detect' ) {
1453 $diff = $wgRequest->getVal( 'diff' );
1454 $isCur = $wgArticle && $wgArticle->isCurrent();
1455 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1462 if ( $type == 'history' ) {
1463 $msg = 'history_copyright';
1469 if( $wgRightsPage ) {
1470 $title = Title
::newFromText( $wgRightsPage );
1471 $link = $this->linkKnown( $title, $wgRightsText );
1472 } elseif( $wgRightsUrl ) {
1473 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1474 } elseif( $wgRightsText ) {
1475 $link = $wgRightsText;
1480 // Allow for site and per-namespace customization of copyright notice.
1481 if( isset($wgArticle) )
1482 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
1484 $out .= wfMsgForContent( $msg, $link );
1488 function getCopyrightIcon() {
1489 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1491 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1492 $out = $wgCopyrightIcon;
1493 } else if ( $wgRightsIcon ) {
1494 $icon = htmlspecialchars( $wgRightsIcon );
1495 if ( $wgRightsUrl ) {
1496 $url = htmlspecialchars( $wgRightsUrl );
1497 $out .= '<a href="'.$url.'">';
1499 $text = htmlspecialchars( $wgRightsText );
1500 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1501 if ( $wgRightsUrl ) {
1508 function getPoweredBy() {
1509 global $wgStylePath;
1510 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1511 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1515 function lastModified() {
1516 global $wgLang, $wgArticle;
1517 if( $this->mRevisionId
&& $this->mRevisionId
!= $wgArticle->getLatest()) {
1518 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1520 $timestamp = $wgArticle->getTimestamp();
1523 $d = $wgLang->date( $timestamp, true );
1524 $t = $wgLang->time( $timestamp, true );
1525 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1529 if ( wfGetLB()->getLaggedSlaveMode() ) {
1530 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1535 function logoText( $align = '' ) {
1536 if ( '' != $align ) {
1537 $a = " align='{$align}'";
1542 $mp = wfMsg( 'mainpage' );
1543 $mptitle = Title
::newMainPage();
1544 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1546 $logourl = $this->getLogo();
1547 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1552 * show a drop-down box of special pages
1554 function specialPagesList() {
1555 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1556 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1557 foreach ( $pages as $name => $page ) {
1558 $pages[$name] = $page->getDescription();
1561 $go = wfMsg( 'go' );
1562 $sp = wfMsg( 'specialpages' );
1563 $spp = $wgContLang->specialPage( 'Specialpages' );
1565 $s = '<form id="specialpages" method="get" ' .
1566 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1567 $s .= "<select name=\"wpDropdown\">\n";
1568 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1571 foreach ( $pages as $name => $desc ) {
1572 $p = $wgContLang->specialPage( $name );
1573 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1575 $s .= "</select>\n";
1576 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1581 function mainPageLink() {
1583 Title
::newMainPage(),
1584 wfMsg( 'mainpage' ),
1587 array( 'known', 'noclasses' )
1592 private function footerLink ( $desc, $page ) {
1593 // if the link description has been set to "-" in the default language,
1594 if ( wfMsgForContent( $desc ) == '-') {
1595 // then it is disabled, for all languages.
1598 // Otherwise, we display the link for the user, described in their
1599 // language (which may or may not be the same as the default language),
1600 // but we make the link target be the one site-wide page.
1601 $title = Title
::newFromText( wfMsgForContent( $page ) );
1602 return $this->linkKnown(
1604 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1609 function privacyLink() {
1610 return $this->footerLink( 'privacy', 'privacypage' );
1613 function aboutLink() {
1614 return $this->footerLink( 'aboutsite', 'aboutpage' );
1617 function disclaimerLink() {
1618 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1621 function editThisPage() {
1624 if ( !$wgOut->isArticleRelated() ) {
1625 $s = wfMsg( 'protectedpage' );
1627 if( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1628 $t = wfMsg( 'editthispage' );
1629 } elseif( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1630 $t = wfMsg( 'create-this-page' );
1632 $t = wfMsg( 'viewsource' );
1639 $this->editUrlOptions(),
1640 array( 'known', 'noclasses' )
1647 * Return URL options for the 'edit page' link.
1648 * This may include an 'oldid' specifier, if the current page view is such.
1653 function editUrlOptions() {
1656 $options = array( 'action' => 'edit' );
1658 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1659 $options['oldid'] = intval( $this->mRevisionId
);
1665 function deleteThisPage() {
1666 global $wgUser, $wgRequest;
1668 $diff = $wgRequest->getVal( 'diff' );
1669 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1670 $t = wfMsg( 'deletethispage' );
1676 array( 'action' => 'delete' ),
1677 array( 'known', 'noclasses' )
1685 function protectThisPage() {
1686 global $wgUser, $wgRequest;
1688 $diff = $wgRequest->getVal( 'diff' );
1689 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1690 if ( $this->mTitle
->isProtected() ) {
1691 $text = wfMsg( 'unprotectthispage' );
1692 $query = array( 'action' => 'unprotect' );
1694 $text = wfMsg( 'protectthispage' );
1695 $query = array( 'action' => 'protect' );
1703 array( 'known', 'noclasses' )
1711 function watchThisPage() {
1713 ++
$this->mWatchLinkNum
;
1715 if ( $wgOut->isArticleRelated() ) {
1716 if ( $this->mTitle
->userIsWatching() ) {
1717 $text = wfMsg( 'unwatchthispage' );
1718 $query = array( 'action' => 'unwatch' );
1719 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1721 $text = wfMsg( 'watchthispage' );
1722 $query = array( 'action' => 'watch' );
1723 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1729 array( 'id' => $id ),
1731 array( 'known', 'noclasses' )
1734 $s = wfMsg( 'notanarticle' );
1739 function moveThisPage() {
1740 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1742 SpecialPage
::getTitleFor( 'Movepage' ),
1743 wfMsg( 'movethispage' ),
1745 array( 'target' => $this->mTitle
->getPrefixedDBkey() ),
1746 array( 'known', 'noclasses' )
1749 // no message if page is protected - would be redundant
1754 function historyLink() {
1757 wfMsgHtml( 'history' ),
1758 array( 'rel' => 'archives' ),
1759 array( 'action' => 'history' )
1763 function whatLinksHere() {
1765 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1766 wfMsgHtml( 'whatlinkshere' ),
1769 array( 'known', 'noclasses' )
1773 function userContribsLink() {
1775 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1776 wfMsgHtml( 'contributions' ),
1779 array( 'known', 'noclasses' )
1783 function showEmailUser( $id ) {
1785 $targetUser = User
::newFromId( $id );
1786 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1787 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1790 function emailUserLink() {
1792 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1793 wfMsg( 'emailuser' ),
1796 array( 'known', 'noclasses' )
1800 function watchPageLinksLink() {
1802 if ( ! $wgOut->isArticleRelated() ) {
1803 return '(' . wfMsg( 'notanarticle' ) . ')';
1806 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1807 wfMsg( 'recentchangeslinked-toolbox' ),
1810 array( 'known', 'noclasses' )
1815 function trackbackLink() {
1816 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1817 . wfMsg( 'trackbacklink' ) . '</a>';
1820 function otherLanguages() {
1821 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1823 if ( $wgHideInterlanguageLinks ) {
1827 $a = $wgOut->getLanguageLinks();
1828 if ( 0 == count( $a ) ) {
1832 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1834 if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
1835 foreach( $a as $l ) {
1837 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1841 $nt = Title
::newFromText( $l );
1842 $url = $nt->escapeFullURL();
1843 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1845 if ( '' == $text ) { $text = $l; }
1846 $style = $this->getExternalLinkAttributes();
1847 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1849 if( $wgContLang->isRTL() ) $s .= '</span>';
1853 function talkLink() {
1854 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1855 # No discussion links for special pages
1859 $linkOptions = array();
1861 if( $this->mTitle
->isTalkPage() ) {
1862 $link = $this->mTitle
->getSubjectPage();
1863 switch( $link->getNamespace() ) {
1865 $text = wfMsg( 'articlepage' );
1868 $text = wfMsg( 'userpage' );
1871 $text = wfMsg( 'projectpage' );
1874 $text = wfMsg( 'imagepage' );
1875 # Make link known if image exists, even if the desc. page doesn't.
1876 if( wfFindFile( $link ) )
1877 $linkOptions[] = 'known';
1880 $text = wfMsg( 'mediawikipage' );
1883 $text = wfMsg( 'templatepage' );
1886 $text = wfMsg( 'viewhelppage' );
1889 $text = wfMsg( 'categorypage' );
1892 $text = wfMsg( 'articlepage' );
1895 $link = $this->mTitle
->getTalkPage();
1896 $text = wfMsg( 'talkpage' );
1899 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1904 function commentLink() {
1907 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1911 # __NEWSECTIONLINK___ changes behaviour here
1912 # If it is present, the link points to this page, otherwise
1913 # it points to the talk page
1914 if( $this->mTitle
->isTalkPage() ) {
1915 $title = $this->mTitle
;
1916 } elseif( $wgOut->showNewSectionLink() ) {
1917 $title = $this->mTitle
;
1919 $title = $this->mTitle
->getTalkPage();
1924 wfMsg( 'postcomment' ),
1930 array( 'known', 'noclasses' )
1934 /* these are used extensively in SkinTemplate, but also some other places */
1935 static function makeMainPageUrl( $urlaction = '' ) {
1936 $title = Title
::newMainPage();
1937 self
::checkTitle( $title, '' );
1938 return $title->getLocalURL( $urlaction );
1941 static function makeSpecialUrl( $name, $urlaction = '' ) {
1942 $title = SpecialPage
::getTitleFor( $name );
1943 return $title->getLocalURL( $urlaction );
1946 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1947 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1948 return $title->getLocalURL( $urlaction );
1951 static function makeI18nUrl( $name, $urlaction = '' ) {
1952 $title = Title
::newFromText( wfMsgForContent( $name ) );
1953 self
::checkTitle( $title, $name );
1954 return $title->getLocalURL( $urlaction );
1957 static function makeUrl( $name, $urlaction = '' ) {
1958 $title = Title
::newFromText( $name );
1959 self
::checkTitle( $title, $name );
1960 return $title->getLocalURL( $urlaction );
1963 # If url string starts with http, consider as external URL, else
1965 static function makeInternalOrExternalUrl( $name ) {
1966 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1969 return self
::makeUrl( $name );
1973 # this can be passed the NS number as defined in Language.php
1974 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1975 $title = Title
::makeTitleSafe( $namespace, $name );
1976 self
::checkTitle( $title, $name );
1977 return $title->getLocalURL( $urlaction );
1980 /* these return an array with the 'href' and boolean 'exists' */
1981 static function makeUrlDetails( $name, $urlaction = '' ) {
1982 $title = Title
::newFromText( $name );
1983 self
::checkTitle( $title, $name );
1985 'href' => $title->getLocalURL( $urlaction ),
1986 'exists' => $title->getArticleID() != 0 ?
true : false
1991 * Make URL details where the article exists (or at least it's convenient to think so)
1993 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1994 $title = Title
::newFromText( $name );
1995 self
::checkTitle( $title, $name );
1997 'href' => $title->getLocalURL( $urlaction ),
2002 # make sure we have some title to operate on
2003 static function checkTitle( &$title, $name ) {
2004 if( !is_object( $title ) ) {
2005 $title = Title
::newFromText( $name );
2006 if( !is_object( $title ) ) {
2007 $title = Title
::newFromText( '--error: link target missing--' );
2013 * Build an array that represents the sidebar(s), the navigation bar among them
2017 function buildSidebar() {
2018 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2020 wfProfileIn( __METHOD__
);
2022 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2024 if ( $wgEnableSidebarCache ) {
2025 $cachedsidebar = $parserMemc->get( $key );
2026 if ( $cachedsidebar ) {
2027 wfProfileOut( __METHOD__
);
2028 return $cachedsidebar;
2033 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
2035 foreach( $lines as $line ) {
2036 if( strpos( $line, '*' ) !== 0 )
2038 if( strpos( $line, '**') !== 0 ) {
2039 $heading = trim( $line, '* ' );
2040 if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
2042 if( strpos( $line, '|' ) !== false ) { // sanity check
2043 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
2044 $link = wfMsgForContent( $line[0] );
2048 $text = wfMsgExt( $line[1], 'parsemag' );
2049 if( wfEmptyMsg( $line[1], $text ) )
2051 if( wfEmptyMsg( $line[0], $link ) )
2054 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2057 $title = Title
::newFromText( $link );
2059 $title = $title->fixSpecialName();
2060 $href = $title->getLocalURL();
2062 $href = 'INVALID-TITLE';
2066 $bar[$heading][] = array(
2069 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2072 } else { continue; }
2075 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2076 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2077 wfProfileOut( __METHOD__
);
2082 * Should we include common/wikiprintable.css? Skins that have their own
2083 * print stylesheet should override this and return false. (This is an
2084 * ugly hack to get Monobook to play nicely with
2085 * OutputPage::headElement().)
2089 public function commonPrintStylesheet() {