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 * Return a random selection of the scripts we want in the header,
453 * according to no particular rhyme or reason. Various other scripts are
454 * returned from a haphazard assortment of other functions scattered over
455 * various files. This entire hackish system needs to be burned to the
456 * ground and rebuilt.
458 * @param $out OutputPage object, should be $wgOut
460 * @return string Raw HTML to output to <head>
462 function getHeadScripts( OutputPage
$out ) {
463 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion, $wgOut;
466 $vars = self
::makeGlobalVariablesScript( $this->getSkinName() );
468 //moved wikibits to be called earlier on
469 //$out->addScriptFile( "{$wgStylePath}/common/wikibits.js" );
471 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
472 $wgOut->addScriptFile( self
::makeUrl( '-',
473 "action=raw$jsCache&gen=js&useskin=" .
474 urlencode( $this->getSkinName() )
478 if( $out->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
479 $userpage = $wgUser->getUserPage();
480 $userjs = self
::makeUrl(
481 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
482 'action=raw&ctype='.$wgJsMimeType );
483 $wgOut->addScriptFile( $userjs );
485 return "\t" . $vars . "\t" . $out->mScripts
;
489 * To make it harder for someone to slip a user a fake
490 * user-JavaScript or user-CSS preview, a random token
491 * is associated with the login session. If it's not
492 * passed back with the preview request, we won't render
495 * @param string $action
499 function userCanPreview( $action ) {
500 global $wgRequest, $wgUser;
502 if( $action != 'submit' )
504 if( !$wgRequest->wasPosted() )
506 if( !$this->mTitle
->userCanEditCssJsSubpage() )
508 return $wgUser->matchEditToken(
509 $wgRequest->getVal( 'wpEditToken' ) );
513 * generated JavaScript action=raw&gen=js
514 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
515 * nated together. For some bizarre reason, it does *not* return any
516 * custom user JS from subpages. Huh?
518 * There's absolutely no reason to have separate Monobook/Common JSes.
519 * Any JS that cares can just check the skin variable generated at the
520 * top. For now Monobook.js will be maintained, but it should be consi-
523 * @param force_skin lets you override the skin name
527 public function generateUserJs( $skinName = null) {
530 wfProfileIn( __METHOD__
);
532 $skinName = $this->getSkinName();
535 $s = "/* generated javascript */\n";
536 $s .= "var skin = '" . Xml
::escapeJsString($skinName ) . "';\n";
537 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
538 $s .= "\n\n/* MediaWiki:Common.js */\n";
539 $commonJs = wfMsgForContent( 'common.js' );
540 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
544 $s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n";
545 // avoid inclusion of non defined user JavaScript (with custom skins only)
546 // by checking for default message content
547 $msgKey = ucfirst( $skinName ).'.js';
548 $userJS = wfMsgForContent( $msgKey );
549 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
553 wfProfileOut( __METHOD__
);
558 * Generate user stylesheet for action=raw&gen=css
560 public function generateUserStylesheet() {
561 wfProfileIn( __METHOD__
);
562 $s = "/* generated user stylesheet */\n" .
563 $this->reallyGenerateUserStylesheet();
564 wfProfileOut( __METHOD__
);
569 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
571 protected function reallyGenerateUserStylesheet(){
574 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
575 $underline = $undopt ?
'underline' : 'none';
576 $s .= "a { text-decoration: $underline; }\n";
578 if( $wgUser->getOption( 'highlightbroken' ) ) {
579 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
582 a.new, #quickbar a.new,
583 a.stub, #quickbar a.stub {
586 a.new:after, #quickbar a.new:after {
590 a.stub:after, #quickbar a.stub:after {
596 if( $wgUser->getOption( 'justify' ) ) {
597 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
599 if( !$wgUser->getOption( 'showtoc' ) ) {
600 $s .= "#toc { display: none; }\n";
602 if( !$wgUser->getOption( 'editsection' ) ) {
603 $s .= ".editsection { display: none; }\n";
611 function setupUserCss( OutputPage
$out ) {
612 global $wgRequest, $wgContLang, $wgUser;
613 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
615 wfProfileIn( __METHOD__
);
617 $this->setupSkinUserCss( $out );
621 'maxage' => $wgSquidMaxage,
624 // Add any extension CSS
625 foreach( $out->getExtStyle() as $tag ) {
626 $out->addStyle( $tag['href'] );
629 // If we use the site's dynamic CSS, throw that in, too
630 // Per-site custom styles
631 if( $wgUseSiteCss ) {
632 global $wgHandheldStyle;
633 $query = wfArrayToCGI( array(
634 'usemsgcache' => 'yes',
635 'ctype' => 'text/css',
636 'smaxage' => $wgSquidMaxage
638 # Site settings must override extension css! (bug 15025)
639 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
640 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
641 if( $wgHandheldStyle ) {
642 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
644 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
647 if( $wgUser->isLoggedIn() ) {
648 // Ensure that logged-in users' generated CSS isn't clobbered
649 // by anons' publicly cacheable generated CSS.
650 $siteargs['smaxage'] = '0';
651 $siteargs['ts'] = $wgUser->mTouched
;
653 // Per-user styles based on preferences
654 $siteargs['gen'] = 'css';
655 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
656 $siteargs['useskin'] = $us;
658 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
660 // Per-user custom style pages
661 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
662 $action = $wgRequest->getVal( 'action' );
663 # If we're previewing the CSS page, use it
664 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
665 $previewCss = $wgRequest->getText( 'wpTextbox1' );
666 // @FIXME: properly escape the cdata!
667 $this->usercss
= "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
669 $out->addStyle( self
::makeUrl( $this->userpage
. '/' . $this->getSkinName() .'.css',
670 'action=raw&ctype=text/css' ) );
674 wfProfileOut( __METHOD__
);
678 * Add skin specific stylesheets
679 * @param $out OutputPage
681 function setupSkinUserCss( OutputPage
$out ) {
682 $out->addStyle( 'common/shared.css' );
683 $out->addStyle( 'common/oldshared.css' );
684 $out->addStyle( $this->getStylesheet() );
685 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
688 function getBodyOptions() {
689 global $wgUser, $wgOut, $wgRequest, $wgContLang;
691 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
693 if ( 0 != $this->mTitle
->getNamespace() ) {
694 $a = array( 'bgcolor' => '#ffffec' );
696 else $a = array( 'bgcolor' => '#FFFFFF' );
697 if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
698 $this->mTitle
->quickUserCan( 'edit' ) ) {
699 $s = $this->mTitle
->getFullURL( $this->editUrlOptions() );
700 $s = 'document.location = "' .Xml
::escapeJsString( $s ) .'";';
701 $a +
= array( 'ondblclick' => $s );
703 $a['onload'] = $wgOut->getOnloadHandler();
706 ' '.( $wgContLang->isRTL() ?
'rtl' : 'ltr' ).
707 ' '.$this->getPageClasses( $this->mTitle
) .
708 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName() );
712 function getPageClasses( $title ) {
713 $numeric = 'ns-'.$title->getNamespace();
714 if( $title->getNamespace() == NS_SPECIAL
) {
715 $type = 'ns-special';
716 } elseif( $title->isTalkPage() ) {
719 $type = 'ns-subject';
721 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
722 return "$numeric $type $name";
734 * This will be called immediately after the <body> tag. Split into
735 * two functions to make it easier to subclass.
737 function beforeContent() {
738 return $this->doBeforeContent();
741 function doBeforeContent() {
743 wfProfileIn( __METHOD__
);
746 $qb = $this->qbSetting();
748 if( $langlinks = $this->otherLanguages() ) {
754 $borderhack = 'class="top"';
757 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
758 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
760 $shove = ( $qb != 0 );
761 $left = ( $qb == 1 ||
$qb == 3 );
762 if( $wgContLang->isRTL() ) $left = !$left;
765 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
766 $this->logoText() . '</td>';
768 $s .= $this->getQuickbarCompensator( $rows );
770 $l = $wgContLang->isRTL() ?
'right' : 'left';
771 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
773 $s .= $this->topLinks();
774 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
776 $r = $wgContLang->isRTL() ?
'left' : 'right';
777 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
778 $s .= $this->nameAndLogin();
779 $s .= "\n<br />" . $this->searchForm() . "</td>";
782 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
785 if ( $shove && !$left ) { # Right
786 $s .= $this->getQuickbarCompensator( $rows );
788 $s .= "</tr>\n</table>\n</div>\n";
789 $s .= "\n<div id='article'>\n";
791 $notice = wfGetSiteNotice();
793 $s .= "\n<div id='siteNotice'>$notice</div>\n";
795 $s .= $this->pageTitle();
796 $s .= $this->pageSubtitle();
797 $s .= $this->getCategories();
798 wfProfileOut( __METHOD__
);
803 function getCategoryLinks() {
804 global $wgOut, $wgUseCategoryBrowser;
805 global $wgContLang, $wgUser;
807 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
810 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
812 // Use Unicode bidi embedding override characters,
813 // to make sure links don't smash each other up in ugly ways.
814 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
815 $embed = "<span dir='$dir'>";
818 $allCats = $wgOut->getCategoryLinks();
820 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
821 if ( !empty( $allCats['normal'] ) ) {
822 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
824 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
825 $s .= '<div id="mw-normal-catlinks">' .
826 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
827 . $colon . $t . '</div>';
831 if ( isset( $allCats['hidden'] ) ) {
832 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
833 $class ='mw-hidden-cats-user-shown';
834 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
835 $class = 'mw-hidden-cats-ns-shown';
837 $class = 'mw-hidden-cats-hidden';
839 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
840 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
841 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
845 # optional 'dmoz-like' category browser. Will be shown under the list
846 # of categories an article belong to
847 if( $wgUseCategoryBrowser ){
848 $s .= '<br /><hr />';
850 # get a big array of the parents tree
851 $parenttree = $this->mTitle
->getParentCategoryTree();
852 # Skin object passed by reference cause it can not be
853 # accessed under the method subfunction drawCategoryBrowser
854 $tempout = explode( "\n", Skin
::drawCategoryBrowser( $parenttree, $this ) );
855 # Clean out bogus first entry and sort them
856 unset( $tempout[0] );
858 # Output one per line
859 $s .= implode( "<br />\n", $tempout );
866 * Render the array as a serie of links.
867 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
868 * @param &skin Object: skin passed by reference
869 * @return String separated by >, terminate with "\n"
871 function drawCategoryBrowser( $tree, &$skin ){
873 foreach( $tree as $element => $parent ) {
874 if( empty( $parent ) ) {
875 # element start a new list
878 # grab the others elements
879 $return .= Skin
::drawCategoryBrowser( $parent, $skin ) . ' > ';
881 # add our current element to the list
882 $eltitle = Title
::newFromText( $element );
883 $return .= $skin->link( $eltitle, $eltitle->getText() );
888 function getCategories() {
889 $catlinks=$this->getCategoryLinks();
891 $classes = 'catlinks';
893 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
894 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
895 $classes .= ' catlinks-allhidden';
898 if( !empty( $catlinks ) ){
899 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
903 function getQuickbarCompensator( $rows = 1 ) {
904 return "<td width='152' rowspan='{$rows}'> </td>";
908 * This runs a hook to allow extensions placing their stuff after content
909 * and article metadata (e.g. categories).
910 * Note: This function has nothing to do with afterContent().
912 * This hook is placed here in order to allow using the same hook for all
913 * skins, both the SkinTemplate based ones and the older ones, which directly
914 * use this class to get their data.
916 * The output of this function gets processed in SkinTemplate::outputPage() for
917 * the SkinTemplate based skins, all other skins should directly echo it.
919 * Returns an empty string by default, if not changed by any hook function.
921 protected function afterContentHook() {
924 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
925 // adding just some spaces shouldn't toggle the output
926 // of the whole <div/>, so we use trim() here
927 if( trim( $data ) != '' ){
928 // Doing this here instead of in the skins to
929 // ensure that the div has the same ID in all
931 $data = "<div id='mw-data-after-content'>\n" .
936 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
943 * Generate debug data HTML for displaying at the bottom of the main content
945 * @return String HTML containing debug data, if enabled (otherwise empty).
947 protected function generateDebugHTML() {
948 global $wgShowDebug, $wgOut;
949 if ( $wgShowDebug ) {
950 $listInternals = str_replace( "\n", "</li>\n<li>", htmlspecialchars( $wgOut->mDebugtext
) );
951 return "\n<hr>\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\"><li>" .
952 $listInternals . "</li></ul>\n";
958 * This gets called shortly before the </body> tag.
959 * @return String HTML to be put before </body>
961 function afterContent() {
962 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
963 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
967 * This gets called shortly before the </body> tag.
968 * @return String HTML-wrapped JS code to be put before </body>
970 function bottomScripts() {
971 global $wgJsMimeType;
972 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
973 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
974 return $bottomScriptText;
977 /** @return string Retrievied from HTML text */
978 function printSource() {
979 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
980 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
983 function printFooter() {
984 return "<p>" . $this->printSource() .
985 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
988 /** overloaded by derived classes */
989 function doAfterContent() { return '</div></div>'; }
991 function pageTitleLinks() {
992 global $wgOut, $wgUser, $wgRequest, $wgLang;
994 $oldid = $wgRequest->getVal( 'oldid' );
995 $diff = $wgRequest->getVal( 'diff' );
996 $action = $wgRequest->getText( 'action' );
998 $s[] = $this->printableLink();
999 $disclaimer = $this->disclaimerLink(); # may be empty
1003 $privacy = $this->privacyLink(); # may be empty too
1008 if ( $wgOut->isArticleRelated() ) {
1009 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
1010 $name = $this->mTitle
->getDBkey();
1011 $image = wfFindFile( $this->mTitle
);
1013 $link = htmlspecialchars( $image->getURL() );
1014 $style = $this->getInternalLinkAttributes( $link, $name );
1015 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
1019 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
1020 $s[] .= $this->link(
1022 wfMsg( 'currentrev' ),
1025 array( 'known', 'noclasses' )
1029 if ( $wgUser->getNewtalk() ) {
1030 # do not show "You have new messages" text when we are viewing our
1032 if( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
1034 $wgUser->getTalkPage(),
1035 wfMsgHtml( 'newmessageslink' ),
1037 array( 'redirect' => 'no' ),
1038 array( 'known', 'noclasses' )
1042 $wgUser->getTalkPage(),
1043 wfMsgHtml( 'newmessagesdifflink' ),
1045 array( 'diff' => 'cur' ),
1046 array( 'known', 'noclasses' )
1048 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1050 $wgOut->setSquidMaxage( 0 );
1051 $wgOut->enableClientCache( false );
1055 $undelete = $this->getUndeleteLink();
1056 if( !empty( $undelete ) ) {
1059 return $wgLang->pipeList( $s );
1062 function getUndeleteLink() {
1063 global $wgUser, $wgContLang, $wgLang, $wgRequest;
1065 $action = $wgRequest->getVal( 'action', 'view' );
1067 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1068 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1069 $n = $this->mTitle
->isDeleted();
1071 if ( $wgUser->isAllowed( 'undelete' ) ) {
1072 $msg = 'thisisdeleted';
1074 $msg = 'viewdeleted';
1079 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1080 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1083 array( 'known', 'noclasses' )
1091 function printableLink() {
1092 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1096 if ( !$wgRequest->getBool( 'printable' ) ) {
1097 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1098 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1101 if( $wgOut->isSyndicated() ) {
1102 foreach( $wgFeedClasses as $format => $class ) {
1103 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1104 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1105 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1108 return $wgLang->pipeList( $s );
1111 function pageTitle() {
1113 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1117 function pageSubtitle() {
1120 $sub = $wgOut->getSubtitle();
1122 global $wgExtraSubtitle;
1123 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1125 $subpages = $this->subPageSubtitle();
1126 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1127 $s = "<p class='subtitle'>{$sub}</p>\n";
1131 function subPageSubtitle() {
1133 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
1137 if( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1138 $ptext = $this->mTitle
->getPrefixedText();
1139 if( preg_match( '/\//', $ptext ) ) {
1140 $links = explode( '/', $ptext );
1141 array_pop( $links );
1145 foreach( $links as $link ) {
1146 $growinglink .= $link;
1148 $linkObj = Title
::newFromText( $growinglink );
1149 if( is_object( $linkObj ) && $linkObj->exists() ){
1150 $getlink = $this->link(
1152 htmlspecialchars( $display ),
1155 array( 'known', 'noclasses' )
1159 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1161 $subpages .= '< ';
1163 $subpages .= $getlink;
1168 $growinglink .= '/';
1176 * Returns true if the IP should be shown in the header
1178 function showIPinHeader() {
1179 global $wgShowIPinHeader;
1180 return $wgShowIPinHeader && session_id() != '';
1183 function nameAndLogin() {
1184 global $wgUser, $wgLang, $wgContLang;
1186 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1189 if ( $wgUser->isAnon() ) {
1190 if( $this->showIPinHeader() ) {
1193 $talkLink = $this->link( $wgUser->getTalkPage(),
1194 $wgLang->getNsText( NS_TALK
) );
1196 $ret .= "$name ($talkLink)";
1198 $ret .= wfMsg( 'notloggedin' );
1201 $returnTo = $this->mTitle
->getPrefixedDBkey();
1203 if ( $logoutPage != $returnTo ) {
1204 $query['returnto'] = $returnTo;
1207 $loginlink = $wgUser->isAllowed( 'createaccount' )
1208 ?
'nav-login-createaccount'
1210 $ret .= "\n<br />" . $this->link(
1211 SpecialPage
::getTitleFor( 'Userlogin' ),
1212 wfMsg( $loginlink ), array(), $query
1215 $returnTo = $this->mTitle
->getPrefixedDBkey();
1216 $talkLink = $this->link( $wgUser->getTalkPage(),
1217 $wgLang->getNsText( NS_TALK
) );
1219 $ret .= $this->link( $wgUser->getUserPage(),
1220 htmlspecialchars( $wgUser->getName() ) );
1221 $ret .= " ($talkLink)<br />";
1222 $ret .= $wgLang->pipeList( array(
1224 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1225 array(), array( 'returnto' => $returnTo )
1227 $this->specialLink( 'preferences' ),
1230 $ret = $wgLang->pipeList( array(
1233 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1241 function getSearchLink() {
1242 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1243 return $searchPage->getLocalURL();
1246 function escapeSearchLink() {
1247 return htmlspecialchars( $this->getSearchLink() );
1250 function searchForm() {
1251 global $wgRequest, $wgUseTwoButtonsSearchForm;
1252 $search = $wgRequest->getText( 'search' );
1254 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1255 . $this->escapeSearchLink() . "\">\n"
1256 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1257 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1258 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1260 if( $wgUseTwoButtonsSearchForm )
1261 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1263 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1267 // Ensure unique id's for search boxes made after the first
1268 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1273 function topLinks() {
1277 $this->mainPageLink(),
1278 $this->specialLink( 'recentchanges' )
1281 if ( $wgOut->isArticleRelated() ) {
1282 $s[] = $this->editThisPage();
1283 $s[] = $this->historyLink();
1285 # Many people don't like this dropdown box
1286 #$s[] = $this->specialPagesList();
1288 if( $this->variantLinks() ) {
1289 $s[] = $this->variantLinks();
1292 if( $this->extensionTabLinks() ) {
1293 $s[] = $this->extensionTabLinks();
1296 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1297 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1301 * Compatibility for extensions adding functionality through tabs.
1302 * Eventually these old skins should be replaced with SkinTemplate-based
1306 function extensionTabLinks() {
1310 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1311 foreach( $tabs as $tab ) {
1312 $s[] = Xml
::element( 'a',
1313 array( 'href' => $tab['href'] ),
1320 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1321 $out .= $wgLang->pipeList( $s );
1328 * Language/charset variant links for classic-style skins
1331 function variantLinks() {
1333 /* show links to different language variants */
1334 global $wgDisableLangConversion, $wgLang, $wgContLang;
1335 $variants = $wgContLang->getVariants();
1336 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1337 foreach( $variants as $code ) {
1338 $varname = $wgContLang->getVariantname( $code );
1339 if( $varname == 'disable' )
1341 $s = $wgLang->pipeList( array(
1343 '<a href="' . $this->mTitle
->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1350 function bottomLinks() {
1351 global $wgOut, $wgUser, $wgUseTrackbacks;
1352 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1355 if ( $wgOut->isArticleRelated() ) {
1356 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1357 if ( $wgUser->isLoggedIn() ) {
1358 $element[] = $this->watchThisPage();
1360 $element[] = $this->talkLink();
1361 $element[] = $this->historyLink();
1362 $element[] = $this->whatLinksHere();
1363 $element[] = $this->watchPageLinksLink();
1365 if( $wgUseTrackbacks )
1366 $element[] = $this->trackbackLink();
1368 if ( $this->mTitle
->getNamespace() == NS_USER
1369 ||
$this->mTitle
->getNamespace() == NS_USER_TALK
){
1370 $id = User
::idFromName( $this->mTitle
->getText() );
1371 $ip = User
::isIP( $this->mTitle
->getText() );
1373 if( $id ||
$ip ) { # both anons and non-anons have contri list
1374 $element[] = $this->userContribsLink();
1376 if( $this->showEmailUser( $id ) ) {
1377 $element[] = $this->emailUserLink();
1381 $s = implode( $element, $sep );
1383 if ( $this->mTitle
->getArticleId() ) {
1385 if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1386 if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1387 if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
1389 $s .= "<br />\n" . $this->otherLanguages();
1395 function pageStats() {
1396 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1397 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1399 $oldid = $wgRequest->getVal( 'oldid' );
1400 $diff = $wgRequest->getVal( 'diff' );
1401 if ( ! $wgOut->isArticle() ) { return ''; }
1402 if( !$wgArticle instanceOf Article
) { return ''; }
1403 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1404 if ( 0 == $wgArticle->getID() ) { return ''; }
1407 if ( !$wgDisableCounters ) {
1408 $count = $wgLang->formatNum( $wgArticle->getCount() );
1410 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1414 if( $wgMaxCredits != 0 ){
1415 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1417 $s .= $this->lastModified();
1420 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1421 $dbr = wfGetDB( DB_SLAVE
);
1422 $res = $dbr->select( 'watchlist',
1423 array( 'COUNT(*) AS n' ),
1424 array( 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ), 'wl_namespace' => $this->mTitle
->getNamespace() ),
1427 $x = $dbr->fetchObject( $res );
1429 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1430 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1434 return $s . ' ' . $this->getCopyright();
1437 function getCopyright( $type = 'detect' ) {
1438 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1440 if ( $type == 'detect' ) {
1441 $diff = $wgRequest->getVal( 'diff' );
1442 $isCur = $wgArticle && $wgArticle->isCurrent();
1443 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1450 if ( $type == 'history' ) {
1451 $msg = 'history_copyright';
1457 if( $wgRightsPage ) {
1458 $title = Title
::newFromText( $wgRightsPage );
1459 $link = $this->linkKnown( $title, $wgRightsText );
1460 } elseif( $wgRightsUrl ) {
1461 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1462 } elseif( $wgRightsText ) {
1463 $link = $wgRightsText;
1468 // Allow for site and per-namespace customization of copyright notice.
1469 if( isset($wgArticle) )
1470 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
1472 $out .= wfMsgForContent( $msg, $link );
1476 function getCopyrightIcon() {
1477 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1479 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1480 $out = $wgCopyrightIcon;
1481 } else if ( $wgRightsIcon ) {
1482 $icon = htmlspecialchars( $wgRightsIcon );
1483 if ( $wgRightsUrl ) {
1484 $url = htmlspecialchars( $wgRightsUrl );
1485 $out .= '<a href="'.$url.'">';
1487 $text = htmlspecialchars( $wgRightsText );
1488 $out .= "<img src=\"$icon\" alt='$text' />";
1489 if ( $wgRightsUrl ) {
1496 function getPoweredBy() {
1497 global $wgStylePath;
1498 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1499 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1503 function lastModified() {
1504 global $wgLang, $wgArticle;
1505 if( $this->mRevisionId
) {
1506 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1508 $timestamp = $wgArticle->getTimestamp();
1511 $d = $wgLang->date( $timestamp, true );
1512 $t = $wgLang->time( $timestamp, true );
1513 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1517 if ( wfGetLB()->getLaggedSlaveMode() ) {
1518 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1523 function logoText( $align = '' ) {
1524 if ( '' != $align ) {
1525 $a = " align='{$align}'";
1530 $mp = wfMsg( 'mainpage' );
1531 $mptitle = Title
::newMainPage();
1532 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1534 $logourl = $this->getLogo();
1535 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1540 * show a drop-down box of special pages
1542 function specialPagesList() {
1543 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1544 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1545 foreach ( $pages as $name => $page ) {
1546 $pages[$name] = $page->getDescription();
1549 $go = wfMsg( 'go' );
1550 $sp = wfMsg( 'specialpages' );
1551 $spp = $wgContLang->specialPage( 'Specialpages' );
1553 $s = '<form id="specialpages" method="get" ' .
1554 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1555 $s .= "<select name=\"wpDropdown\">\n";
1556 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1559 foreach ( $pages as $name => $desc ) {
1560 $p = $wgContLang->specialPage( $name );
1561 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1563 $s .= "</select>\n";
1564 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1569 function mainPageLink() {
1571 Title
::newMainPage(),
1572 wfMsg( 'mainpage' ),
1575 array( 'known', 'noclasses' )
1580 function copyrightLink() {
1581 $title = Title
::newFromText( wfMsgForContent( 'copyrightpage' ) );
1582 $s = $this->linkKnown(
1584 wfMsg( 'copyrightpagename' )
1589 private function footerLink ( $desc, $page ) {
1590 // if the link description has been set to "-" in the default language,
1591 if ( wfMsgForContent( $desc ) == '-') {
1592 // then it is disabled, for all languages.
1595 // Otherwise, we display the link for the user, described in their
1596 // language (which may or may not be the same as the default language),
1597 // but we make the link target be the one site-wide page.
1598 $title = Title
::newFromText( wfMsgForContent( $page ) );
1599 return $this->linkKnown(
1601 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1606 function privacyLink() {
1607 return $this->footerLink( 'privacy', 'privacypage' );
1610 function aboutLink() {
1611 return $this->footerLink( 'aboutsite', 'aboutpage' );
1614 function disclaimerLink() {
1615 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1618 function editThisPage() {
1621 if ( !$wgOut->isArticleRelated() ) {
1622 $s = wfMsg( 'protectedpage' );
1624 if( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1625 $t = wfMsg( 'editthispage' );
1626 } elseif( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1627 $t = wfMsg( 'create-this-page' );
1629 $t = wfMsg( 'viewsource' );
1636 $this->editUrlOptions(),
1637 array( 'known', 'noclasses' )
1644 * Return URL options for the 'edit page' link.
1645 * This may include an 'oldid' specifier, if the current page view is such.
1650 function editUrlOptions() {
1653 $options = array( 'action' => 'edit' );
1655 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1656 $options['oldid'] = intval( $this->mRevisionId
);
1662 function deleteThisPage() {
1663 global $wgUser, $wgRequest;
1665 $diff = $wgRequest->getVal( 'diff' );
1666 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1667 $t = wfMsg( 'deletethispage' );
1673 array( 'action' => 'delete' ),
1674 array( 'known', 'noclasses' )
1682 function protectThisPage() {
1683 global $wgUser, $wgRequest;
1685 $diff = $wgRequest->getVal( 'diff' );
1686 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1687 if ( $this->mTitle
->isProtected() ) {
1688 $text = wfMsg( 'unprotectthispage' );
1689 $query = array( 'action' => 'unprotect' );
1691 $text = wfMsg( 'protectthispage' );
1692 $query = array( 'action' => 'protect' );
1700 array( 'known', 'noclasses' )
1708 function watchThisPage() {
1710 ++
$this->mWatchLinkNum
;
1712 if ( $wgOut->isArticleRelated() ) {
1713 if ( $this->mTitle
->userIsWatching() ) {
1714 $text = wfMsg( 'unwatchthispage' );
1715 $query = array( 'action' => 'unwatch' );
1716 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1718 $text = wfMsg( 'watchthispage' );
1719 $query = array( 'action' => 'watch' );
1720 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1726 array( 'id' => $id ),
1728 array( 'known', 'noclasses' )
1731 $s = wfMsg( 'notanarticle' );
1736 function moveThisPage() {
1737 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1739 SpecialPage
::getTitleFor( 'Movepage' ),
1740 wfMsg( 'movethispage' ),
1742 array( 'target' => $this->mTitle
->getPrefixedDBkey() ),
1743 array( 'known', 'noclasses' )
1746 // no message if page is protected - would be redundant
1751 function historyLink() {
1754 wfMsgHtml( 'history' ),
1755 array( 'rel' => 'archives' ),
1756 array( 'action' => 'history' )
1760 function whatLinksHere() {
1762 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1763 wfMsgHtml( 'whatlinkshere' ),
1766 array( 'known', 'noclasses' )
1770 function userContribsLink() {
1772 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1773 wfMsgHtml( 'contributions' ),
1776 array( 'known', 'noclasses' )
1780 function showEmailUser( $id ) {
1782 $targetUser = User
::newFromId( $id );
1783 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1784 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1787 function emailUserLink() {
1789 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1790 wfMsg( 'emailuser' ),
1793 array( 'known', 'noclasses' )
1797 function watchPageLinksLink() {
1799 if ( ! $wgOut->isArticleRelated() ) {
1800 return '(' . wfMsg( 'notanarticle' ) . ')';
1803 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1804 wfMsg( 'recentchangeslinked-toolbox' ),
1807 array( 'known', 'noclasses' )
1812 function trackbackLink() {
1813 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1814 . wfMsg( 'trackbacklink' ) . '</a>';
1817 function otherLanguages() {
1818 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1820 if ( $wgHideInterlanguageLinks ) {
1824 $a = $wgOut->getLanguageLinks();
1825 if ( 0 == count( $a ) ) {
1829 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1831 if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
1832 foreach( $a as $l ) {
1834 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1838 $nt = Title
::newFromText( $l );
1839 $url = $nt->escapeFullURL();
1840 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1842 if ( '' == $text ) { $text = $l; }
1843 $style = $this->getExternalLinkAttributes();
1844 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1846 if( $wgContLang->isRTL() ) $s .= '</span>';
1850 function talkLink() {
1851 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1852 # No discussion links for special pages
1856 $linkOptions = array();
1858 if( $this->mTitle
->isTalkPage() ) {
1859 $link = $this->mTitle
->getSubjectPage();
1860 switch( $link->getNamespace() ) {
1862 $text = wfMsg( 'articlepage' );
1865 $text = wfMsg( 'userpage' );
1868 $text = wfMsg( 'projectpage' );
1871 $text = wfMsg( 'imagepage' );
1872 # Make link known if image exists, even if the desc. page doesn't.
1873 if( wfFindFile( $link ) )
1874 $linkOptions[] = 'known';
1877 $text = wfMsg( 'mediawikipage' );
1880 $text = wfMsg( 'templatepage' );
1883 $text = wfMsg( 'viewhelppage' );
1886 $text = wfMsg( 'categorypage' );
1889 $text = wfMsg( 'articlepage' );
1892 $link = $this->mTitle
->getTalkPage();
1893 $text = wfMsg( 'talkpage' );
1896 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1901 function commentLink() {
1904 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1908 # __NEWSECTIONLINK___ changes behaviour here
1909 # If it is present, the link points to this page, otherwise
1910 # it points to the talk page
1911 if( $this->mTitle
->isTalkPage() ) {
1912 $title = $this->mTitle
;
1913 } elseif( $wgOut->showNewSectionLink() ) {
1914 $title = $this->mTitle
;
1916 $title = $this->mTitle
->getTalkPage();
1921 wfMsg( 'postcomment' ),
1927 array( 'known', 'noclasses' )
1931 /* these are used extensively in SkinTemplate, but also some other places */
1932 static function makeMainPageUrl( $urlaction = '' ) {
1933 $title = Title
::newMainPage();
1934 self
::checkTitle( $title, '' );
1935 return $title->getLocalURL( $urlaction );
1938 static function makeSpecialUrl( $name, $urlaction = '' ) {
1939 $title = SpecialPage
::getTitleFor( $name );
1940 return $title->getLocalURL( $urlaction );
1943 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1944 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1945 return $title->getLocalURL( $urlaction );
1948 static function makeI18nUrl( $name, $urlaction = '' ) {
1949 $title = Title
::newFromText( wfMsgForContent( $name ) );
1950 self
::checkTitle( $title, $name );
1951 return $title->getLocalURL( $urlaction );
1954 static function makeUrl( $name, $urlaction = '' ) {
1955 $title = Title
::newFromText( $name );
1956 self
::checkTitle( $title, $name );
1957 return $title->getLocalURL( $urlaction );
1960 # If url string starts with http, consider as external URL, else
1962 static function makeInternalOrExternalUrl( $name ) {
1963 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1966 return self
::makeUrl( $name );
1970 # this can be passed the NS number as defined in Language.php
1971 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1972 $title = Title
::makeTitleSafe( $namespace, $name );
1973 self
::checkTitle( $title, $name );
1974 return $title->getLocalURL( $urlaction );
1977 /* these return an array with the 'href' and boolean 'exists' */
1978 static function makeUrlDetails( $name, $urlaction = '' ) {
1979 $title = Title
::newFromText( $name );
1980 self
::checkTitle( $title, $name );
1982 'href' => $title->getLocalURL( $urlaction ),
1983 'exists' => $title->getArticleID() != 0 ?
true : false
1988 * Make URL details where the article exists (or at least it's convenient to think so)
1990 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1991 $title = Title
::newFromText( $name );
1992 self
::checkTitle( $title, $name );
1994 'href' => $title->getLocalURL( $urlaction ),
1999 # make sure we have some title to operate on
2000 static function checkTitle( &$title, $name ) {
2001 if( !is_object( $title ) ) {
2002 $title = Title
::newFromText( $name );
2003 if( !is_object( $title ) ) {
2004 $title = Title
::newFromText( '--error: link target missing--' );
2010 * Build an array that represents the sidebar(s), the navigation bar among them
2014 function buildSidebar() {
2015 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2017 wfProfileIn( __METHOD__
);
2019 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2021 if ( $wgEnableSidebarCache ) {
2022 $cachedsidebar = $parserMemc->get( $key );
2023 if ( $cachedsidebar ) {
2024 wfProfileOut( __METHOD__
);
2025 return $cachedsidebar;
2030 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
2032 foreach( $lines as $line ) {
2033 if( strpos( $line, '*' ) !== 0 )
2035 if( strpos( $line, '**') !== 0 ) {
2036 $heading = trim( $line, '* ' );
2037 if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
2039 if( strpos( $line, '|' ) !== false ) { // sanity check
2040 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
2041 $link = wfMsgForContent( $line[0] );
2045 $text = wfMsgExt( $line[1], 'parsemag' );
2046 if( wfEmptyMsg( $line[1], $text ) )
2048 if( wfEmptyMsg( $line[0], $link ) )
2051 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2054 $title = Title
::newFromText( $link );
2056 $title = $title->fixSpecialName();
2057 $href = $title->getLocalURL();
2059 $href = 'INVALID-TITLE';
2063 $bar[$heading][] = array(
2066 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2069 } else { continue; }
2072 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2073 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2074 wfProfileOut( __METHOD__
);
2079 * Should we include common/wikiprintable.css? Skins that have their own
2080 * print stylesheet should override this and return false. (This is an
2081 * ugly hack to get Monobook to play nicely with
2082 * OutputPage::headElement().)
2086 public function commonPrintStylesheet() {