3 * @defgroup Skins Skins
6 if ( ! defined( 'MEDIAWIKI' ) )
10 * The main skin class that provide methods and properties for all other skins.
11 * This base class is also the "Standard" skin.
13 * See docs/skin.txt for more information.
17 class Skin
extends Linker
{
21 var $mWatchLinkNum = 0; // Appended to end of watch link id's
22 // How many search boxes have we made? Avoid duplicate id's.
23 protected $searchboxes = '';
25 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
26 protected $skinname = 'standard';
27 // @fixme Should be protected :-\
30 /** Constructor, call parent constructor */
31 function Skin() { parent
::__construct(); }
34 * Fetch the set of available skins.
35 * @return array of strings
38 static function getSkinNames() {
39 global $wgValidSkinNames;
40 static $skinsInitialised = false;
41 if ( !$skinsInitialised ) {
42 # Get a list of available skins
43 # Build using the regular expression '^(.*).php$'
44 # Array keys are all lower case, array value keep the case used by filename
46 wfProfileIn( __METHOD__
. '-init' );
47 global $wgStyleDirectory;
48 $skinDir = dir( $wgStyleDirectory );
50 # while code from www.php.net
51 while( false !== ( $file = $skinDir->read() ) ) {
52 // Skip non-PHP files, hidden files, and '.dep' includes
54 if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
56 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
60 $skinsInitialised = true;
61 wfProfileOut( __METHOD__
. '-init' );
63 return $wgValidSkinNames;
67 * Fetch the list of usable skins in regards to $wgSkipSkins.
68 * Useful for Special:Preferences and other places where you
69 * only want to show skins users _can_ use.
70 * @return array of strings
72 public static function getUsableSkins() {
74 $usableSkins = self
::getSkinNames();
75 foreach ( $wgSkipSkins as $skip ) {
76 unset( $usableSkins[$skip] );
82 * Normalize a skin preference value to a form that can be loaded.
83 * If a skin can't be found, it will fall back to the configured
84 * default (or the old 'Classic' skin if that's broken).
89 static function normalizeKey( $key ) {
90 global $wgDefaultSkin;
91 $skinNames = Skin
::getSkinNames();
94 // Don't return the default immediately;
95 // in a misconfiguration we need to fall back.
96 $key = $wgDefaultSkin;
99 if( isset( $skinNames[$key] ) ) {
103 // Older versions of the software used a numeric setting
104 // in the user preferences.
108 2 => 'cologneblue' );
110 if( isset( $fallback[$key] ) ){
111 $key = $fallback[$key];
114 if( isset( $skinNames[$key] ) ) {
122 * Factory method for loading a skin of a given type
123 * @param string $key 'monobook', 'standard', etc
127 static function &newFromKey( $key ) {
128 global $wgStyleDirectory;
130 $key = Skin
::normalizeKey( $key );
132 $skinNames = Skin
::getSkinNames();
133 $skinName = $skinNames[$key];
134 $className = 'Skin'.ucfirst($key);
136 # Grab the skin class and initialise it.
137 if ( !class_exists( $className ) ) {
138 // Preload base classes to work around APC/PHP5 bug
139 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
140 if( file_exists( $deps ) ) include_once( $deps );
141 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
143 # Check if we got if not failback to default skin
144 if( !class_exists( $className ) ) {
145 # DO NOT die if the class isn't found. This breaks maintenance
146 # scripts and can cause a user account to be unrecoverable
147 # except by SQL manipulation if a previously valid skin name
148 # is no longer valid.
149 wfDebug( "Skin class does not exist: $className\n" );
150 $className = 'SkinMonobook';
151 require_once( "{$wgStyleDirectory}/MonoBook.php" );
154 $skin = new $className;
158 /** @return string path to the skin stylesheet */
159 function getStylesheet() {
160 return 'common/wikistandard.css';
163 /** @return string skin name */
164 public function getSkinName() {
165 return $this->skinname
;
168 function qbSetting() {
169 global $wgOut, $wgUser;
171 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
172 $q = $wgUser->getOption( 'quickbar', 0 );
176 function initPage( OutputPage
$out ) {
177 global $wgFavicon, $wgAppleTouchIcon;
179 wfProfileIn( __METHOD__
);
181 # Generally the order of the favicon and apple-touch-icon links
182 # should not matter, but Konqueror (3.5.9 at least) incorrectly
183 # uses whichever one appears later in the HTML source. Make sure
184 # apple-touch-icon is specified first to avoid this.
185 if( false !== $wgAppleTouchIcon ) {
186 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
189 if( false !== $wgFavicon ) {
190 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
193 # OpenSearch description link
194 $out->addLink( array(
196 'type' => 'application/opensearchdescription+xml',
197 'href' => wfScript( 'opensearch_desc' ),
198 'title' => wfMsgForContent( 'opensearch-desc' ),
201 $this->addMetadataLinks( $out );
203 $this->mRevisionId
= $out->mRevisionId
;
205 $this->preloadExistence();
207 wfProfileOut( __METHOD__
);
211 * Preload the existence of three commonly-requested pages in a single query
213 function preloadExistence() {
217 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
220 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
222 } elseif ( $this->mTitle
->isTalkPage() ) {
223 $titles[] = $this->mTitle
->getSubjectPage();
225 $titles[] = $this->mTitle
->getTalkPage();
228 $lb = new LinkBatch( $titles );
232 function addMetadataLinks( OutputPage
$out ) {
233 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
234 global $wgRightsPage, $wgRightsUrl;
236 if( $out->isArticleRelated() ) {
237 # note: buggy CC software only reads first "meta" link
238 if( $wgEnableCreativeCommonsRdf ) {
239 $out->addMetadataLink( array(
240 'title' => 'Creative Commons',
241 'type' => 'application/rdf+xml',
242 'href' => $this->mTitle
->getLocalURL( 'action=creativecommons' ) )
245 if( $wgEnableDublinCoreRdf ) {
246 $out->addMetadataLink( array(
247 'title' => 'Dublin Core',
248 'type' => 'application/rdf+xml',
249 'href' => $this->mTitle
->getLocalURL( 'action=dublincore' ) )
254 if( $wgRightsPage ) {
255 $copy = Title
::newFromText( $wgRightsPage );
257 $copyright = $copy->getLocalURL();
260 if( !$copyright && $wgRightsUrl ) {
261 $copyright = $wgRightsUrl;
264 $out->addLink( array(
265 'rel' => 'copyright',
266 'href' => $copyright )
272 * Set some local variables
274 protected function setMembers(){
276 $this->mUser
= $wgUser;
277 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
278 $this->usercss
= false;
283 * @param Title $t The title to use
285 public function setTitle( $t ) {
290 public function getTitle() {
291 return $this->mTitle
;
294 function outputPage( OutputPage
$out ) {
295 global $wgDebugComments;
296 wfProfileIn( __METHOD__
);
299 $this->initPage( $out );
301 // See self::afterContentHook() for documentation
302 $afterContent = $this->afterContentHook();
304 $out->out( $out->headElement( $this ) );
306 $out->out( "\n<body" );
307 $ops = $this->getBodyOptions();
308 foreach ( $ops as $name => $val ) {
309 $out->out( " $name='$val'" );
312 if ( $wgDebugComments ) {
313 $out->out( "<!-- Wiki debugging output:\n" .
314 $out->mDebugtext
. "-->\n" );
317 $out->out( $this->beforeContent() );
319 $out->out( $out->mBodytext
. "\n" );
321 $out->out( $this->afterContent() );
323 $out->out( $afterContent );
325 $out->out( $this->bottomScripts() );
327 $out->out( wfReportTime() );
329 $out->out( "\n</body></html>" );
330 wfProfileOut( __METHOD__
);
333 static function makeVariablesScript( $data ) {
334 global $wgJsMimeType;
336 $doneFirstVar = false;
337 $r = array( "<script type=\"$wgJsMimeType\">/*<![CDATA[*/\n" );
338 foreach ( $data as $name => $value ) {
339 $encValue = Xml
::encodeJsVar( $value );
341 $r[] = ",\n$name=$encValue";
343 $r[] = "var $name=$encValue";
344 $doneFirstVar = true;
347 # No need for ; since the script is terminating
348 $r[] = "\n/*]]>*/</script>\n";
350 return implode( $r );
354 * Make a <script> tag containing global variables
355 * @param array $data Associative array containing one element:
356 * skinname => the skin name
357 * The odd calling convention is for backwards compatibility
358 * @TODO @FIXME Make this not depend on $wgTitle!
360 static function makeGlobalVariablesScript( $data ) {
361 global $wgScript, $wgTitle, $wgStylePath, $wgUser;
362 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang, $wgVariant;
363 global $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
364 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
365 global $wgUseAjax, $wgAjaxWatch;
366 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
367 global $wgRestrictionTypes, $wgLivePreview;
368 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
370 $ns = $wgTitle->getNamespace();
371 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
372 $separatorTransTable = $wgContLang->separatorTransformTable();
373 $separatorTransTable = $separatorTransTable ?
$separatorTransTable : array();
374 $compactSeparatorTransTable = array(
375 implode( "\t", array_keys( $separatorTransTable ) ),
376 implode( "\t", $separatorTransTable ),
378 $digitTransTable = $wgContLang->digitTransformTable();
379 $digitTransTable = $digitTransTable ?
$digitTransTable : array();
380 $compactDigitTransTable = array(
381 implode( "\t", array_keys( $digitTransTable ) ),
382 implode( "\t", $digitTransTable ),
386 'skin' => $data['skinname'],
387 'stylepath' => $wgStylePath,
388 'wgArticlePath' => $wgArticlePath,
389 'wgScriptPath' => $wgScriptPath,
390 'wgScript' => $wgScript,
391 'wgVariantArticlePath' => $wgVariantArticlePath,
392 'wgActionPaths' => (object)$wgActionPaths,
393 'wgServer' => $wgServer,
394 'wgCanonicalNamespace' => $nsname,
395 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
396 'wgNamespaceNumber' => $wgTitle->getNamespace(),
397 'wgPageName' => $wgTitle->getPrefixedDBKey(),
398 'wgTitle' => $wgTitle->getText(),
399 'wgAction' => $wgRequest->getText( 'action', 'view' ),
400 'wgArticleId' => $wgTitle->getArticleId(),
401 'wgIsArticle' => $wgOut->isArticle(),
402 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
403 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
404 'wgUserVariant' => $wgVariant->getCode(),
405 'wgUserLanguage' => $wgLang->getCode(),
406 'wgContentLanguage' => $wgContLang->getCode(),
407 'wgBreakFrames' => $wgBreakFrames,
408 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
409 'wgVersion' => $wgVersion,
410 'wgEnableAPI' => $wgEnableAPI,
411 'wgEnableWriteAPI' => $wgEnableWriteAPI,
412 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
413 'wgDigitTransformTable' => $compactDigitTransTable,
415 if ( !( $wgContLang->hasVariants() ) ) {
416 unset( $vars['wgUserVariant'] );
419 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
420 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
421 $vars['wgDBname'] = $wgDBname;
422 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
423 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
426 foreach( $wgRestrictionTypes as $type )
427 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
429 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
430 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
431 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
432 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
433 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
436 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
437 $msgs = (object)array();
438 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
439 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
441 $vars['wgAjaxWatch'] = $msgs;
444 // Allow extensions to add their custom variables to the global JS variables
445 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
447 return self
::makeVariablesScript( $vars );
450 function getHeadScripts( $allowUserJs ) {
451 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
453 $vars = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
455 $r = array( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>" );
458 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
459 $r[] = "<script type=\"$wgJsMimeType\" src=\"".
460 htmlspecialchars( self
::makeUrl( '-',
461 "action=raw$jsCache&gen=js&useskin=" .
462 urlencode( $this->getSkinName() ) ) ) .
463 "\"><!-- site js --></script>";
465 if( $allowUserJs && $wgUser->isLoggedIn() ) {
466 $userpage = $wgUser->getUserPage();
467 $userjs = htmlspecialchars( self
::makeUrl(
468 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
469 'action=raw&ctype='.$wgJsMimeType ) );
470 $r[] = '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>";
472 return $vars . "\t\t" . implode ( "\n\t\t", $r );
476 * To make it harder for someone to slip a user a fake
477 * user-JavaScript or user-CSS preview, a random token
478 * is associated with the login session. If it's not
479 * passed back with the preview request, we won't render
482 * @param string $action
486 function userCanPreview( $action ) {
487 global $wgRequest, $wgUser;
489 if( $action != 'submit' )
491 if( !$wgRequest->wasPosted() )
493 if( !$this->mTitle
->userCanEditCssJsSubpage() )
495 return $wgUser->matchEditToken(
496 $wgRequest->getVal( 'wpEditToken' ) );
500 * generated JavaScript action=raw&gen=js
501 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
502 * nated together. For some bizarre reason, it does *not* return any
503 * custom user JS from subpages. Huh?
505 * There's absolutely no reason to have separate Monobook/Common JSes.
506 * Any JS that cares can just check the skin variable generated at the
507 * top. For now Monobook.js will be maintained, but it should be consi-
512 public function generateUserJs() {
515 wfProfileIn( __METHOD__
);
517 $s = "/* generated javascript */\n";
518 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
519 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
520 $s .= "\n\n/* MediaWiki:Common.js */\n";
521 $commonJs = wfMsgForContent( 'common.js' );
522 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
526 $s .= "\n\n/* MediaWiki:".ucfirst( $this->getSkinName() ).".js */\n";
527 // avoid inclusion of non defined user JavaScript (with custom skins only)
528 // by checking for default message content
529 $msgKey = ucfirst( $this->getSkinName() ).'.js';
530 $userJS = wfMsgForContent( $msgKey );
531 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
535 wfProfileOut( __METHOD__
);
540 * Generate user stylesheet for action=raw&gen=css
542 public function generateUserStylesheet() {
543 wfProfileIn( __METHOD__
);
544 $s = "/* generated user stylesheet */\n" .
545 $this->reallyGenerateUserStylesheet();
546 wfProfileOut( __METHOD__
);
551 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
553 protected function reallyGenerateUserStylesheet(){
556 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
557 $underline = $undopt ?
'underline' : 'none';
558 $s .= "a { text-decoration: $underline; }\n";
560 if( $wgUser->getOption( 'highlightbroken' ) ) {
561 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
564 a.new, #quickbar a.new,
565 a.stub, #quickbar a.stub {
568 a.new:after, #quickbar a.new:after {
572 a.stub:after, #quickbar a.stub:after {
578 if( $wgUser->getOption( 'justify' ) ) {
579 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
581 if( !$wgUser->getOption( 'showtoc' ) ) {
582 $s .= "#toc { display: none; }\n";
584 if( !$wgUser->getOption( 'editsection' ) ) {
585 $s .= ".editsection { display: none; }\n";
593 function setupUserCss( OutputPage
$out ) {
594 global $wgRequest, $wgContLang, $wgUser;
595 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
597 wfProfileIn( __METHOD__
);
599 $this->setupSkinUserCss( $out );
603 'maxage' => $wgSquidMaxage,
606 // Add any extension CSS
607 foreach( $out->getExtStyle() as $tag ) {
608 $out->addStyle( $tag['href'] );
611 // If we use the site's dynamic CSS, throw that in, too
612 // Per-site custom styles
613 if( $wgUseSiteCss ) {
614 global $wgHandheldStyle;
615 $query = wfArrayToCGI( array(
616 'usemsgcache' => 'yes',
617 'ctype' => 'text/css',
618 'smaxage' => $wgSquidMaxage
620 # Site settings must override extension css! (bug 15025)
621 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
622 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
623 if( $wgHandheldStyle ) {
624 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
626 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
629 if( $wgUser->isLoggedIn() ) {
630 // Ensure that logged-in users' generated CSS isn't clobbered
631 // by anons' publicly cacheable generated CSS.
632 $siteargs['smaxage'] = '0';
633 $siteargs['ts'] = $wgUser->mTouched
;
635 // Per-user styles based on preferences
636 $siteargs['gen'] = 'css';
637 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
638 $siteargs['useskin'] = $us;
640 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
642 // Per-user custom style pages
643 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
644 $action = $wgRequest->getVal( 'action' );
645 # If we're previewing the CSS page, use it
646 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
647 $previewCss = $wgRequest->getText( 'wpTextbox1' );
648 // @FIXME: properly escape the cdata!
649 $this->usercss
= "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
651 $out->addStyle( self
::makeUrl( $this->userpage
. '/' . $this->getSkinName() .'.css',
652 'action=raw&ctype=text/css' ) );
656 wfProfileOut( __METHOD__
);
660 * Add skin specific stylesheets
661 * @param $out OutputPage
663 function setupSkinUserCss( OutputPage
$out ) {
664 $out->addStyle( 'common/shared.css' );
665 $out->addStyle( 'common/oldshared.css' );
666 $out->addStyle( $this->getStylesheet() );
667 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
670 function getBodyOptions() {
671 global $wgUser, $wgOut, $wgRequest, $wgContLang;
673 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
675 if ( 0 != $this->mTitle
->getNamespace() ) {
676 $a = array( 'bgcolor' => '#ffffec' );
678 else $a = array( 'bgcolor' => '#FFFFFF' );
679 if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
680 $this->mTitle
->quickUserCan( 'edit' ) ) {
681 $s = $this->mTitle
->getFullURL( $this->editUrlOptions() );
682 $s = 'document.location = "' .Xml
::escapeJsString( $s ) .'";';
683 $a +
= array( 'ondblclick' => $s );
685 $a['onload'] = $wgOut->getOnloadHandler();
688 ' '.( $wgContLang->isRTL() ?
'rtl' : 'ltr' ).
689 ' '.$this->getPageClasses( $this->mTitle
) .
690 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName() );
694 function getPageClasses( $title ) {
695 $numeric = 'ns-'.$title->getNamespace();
696 if( $title->getNamespace() == NS_SPECIAL
) {
697 $type = 'ns-special';
698 } elseif( $title->isTalkPage() ) {
701 $type = 'ns-subject';
703 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
704 return "$numeric $type $name";
716 * This will be called immediately after the <body> tag. Split into
717 * two functions to make it easier to subclass.
719 function beforeContent() {
720 return $this->doBeforeContent();
723 function doBeforeContent() {
725 wfProfileIn( __METHOD__
);
728 $qb = $this->qbSetting();
730 if( $langlinks = $this->otherLanguages() ) {
736 $borderhack = 'class="top"';
739 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
740 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
742 $shove = ( $qb != 0 );
743 $left = ( $qb == 1 ||
$qb == 3 );
744 if( $wgContLang->isRTL() ) $left = !$left;
747 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
748 $this->logoText() . '</td>';
750 $s .= $this->getQuickbarCompensator( $rows );
752 $l = $wgContLang->isRTL() ?
'right' : 'left';
753 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
755 $s .= $this->topLinks();
756 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
758 $r = $wgContLang->isRTL() ?
'left' : 'right';
759 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
760 $s .= $this->nameAndLogin();
761 $s .= "\n<br />" . $this->searchForm() . "</td>";
764 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
767 if ( $shove && !$left ) { # Right
768 $s .= $this->getQuickbarCompensator( $rows );
770 $s .= "</tr>\n</table>\n</div>\n";
771 $s .= "\n<div id='article'>\n";
773 $notice = wfGetSiteNotice();
775 $s .= "\n<div id='siteNotice'>$notice</div>\n";
777 $s .= $this->pageTitle();
778 $s .= $this->pageSubtitle();
779 $s .= $this->getCategories();
780 wfProfileOut( __METHOD__
);
785 function getCategoryLinks() {
786 global $wgOut, $wgUseCategoryBrowser;
787 global $wgContLang, $wgUser;
789 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
792 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
794 // Use Unicode bidi embedding override characters,
795 // to make sure links don't smash each other up in ugly ways.
796 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
797 $embed = "<span dir='$dir'>";
800 $allCats = $wgOut->getCategoryLinks();
802 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
803 if ( !empty( $allCats['normal'] ) ) {
804 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
806 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
807 $s .= '<div id="mw-normal-catlinks">' .
808 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
809 . $colon . $t . '</div>';
813 if ( isset( $allCats['hidden'] ) ) {
814 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
815 $class ='mw-hidden-cats-user-shown';
816 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
817 $class = 'mw-hidden-cats-ns-shown';
819 $class = 'mw-hidden-cats-hidden';
821 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
822 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
823 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
827 # optional 'dmoz-like' category browser. Will be shown under the list
828 # of categories an article belong to
829 if( $wgUseCategoryBrowser ){
830 $s .= '<br /><hr />';
832 # get a big array of the parents tree
833 $parenttree = $this->mTitle
->getParentCategoryTree();
834 # Skin object passed by reference cause it can not be
835 # accessed under the method subfunction drawCategoryBrowser
836 $tempout = explode( "\n", Skin
::drawCategoryBrowser( $parenttree, $this ) );
837 # Clean out bogus first entry and sort them
838 unset( $tempout[0] );
840 # Output one per line
841 $s .= implode( "<br />\n", $tempout );
848 * Render the array as a serie of links.
849 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
850 * @param &skin Object: skin passed by reference
851 * @return String separated by >, terminate with "\n"
853 function drawCategoryBrowser( $tree, &$skin ){
855 foreach( $tree as $element => $parent ) {
856 if( empty( $parent ) ) {
857 # element start a new list
860 # grab the others elements
861 $return .= Skin
::drawCategoryBrowser( $parent, $skin ) . ' > ';
863 # add our current element to the list
864 $eltitle = Title
::newFromText( $element );
865 $return .= $skin->link( $eltitle, $eltitle->getText() );
870 function getCategories() {
871 $catlinks=$this->getCategoryLinks();
873 $classes = 'catlinks';
875 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
876 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
877 $classes .= ' catlinks-allhidden';
880 if( !empty( $catlinks ) ){
881 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
885 function getQuickbarCompensator( $rows = 1 ) {
886 return "<td width='152' rowspan='{$rows}'> </td>";
890 * This runs a hook to allow extensions placing their stuff after content
891 * and article metadata (e.g. categories).
892 * Note: This function has nothing to do with afterContent().
894 * This hook is placed here in order to allow using the same hook for all
895 * skins, both the SkinTemplate based ones and the older ones, which directly
896 * use this class to get their data.
898 * The output of this function gets processed in SkinTemplate::outputPage() for
899 * the SkinTemplate based skins, all other skins should directly echo it.
901 * Returns an empty string by default, if not changed by any hook function.
903 protected function afterContentHook() {
906 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
907 // adding just some spaces shouldn't toggle the output
908 // of the whole <div/>, so we use trim() here
909 if( trim( $data ) != '' ){
910 // Doing this here instead of in the skins to
911 // ensure that the div has the same ID in all
913 $data = "<div id='mw-data-after-content'>\n" .
918 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
925 * Generate debug data HTML for displaying at the bottom of the main content
927 * @return String HTML containing debug data, if enabled (otherwise empty).
929 protected function generateDebugHTML() {
930 global $wgShowDebug, $wgOut;
931 if ( $wgShowDebug ) {
932 $listInternals = str_replace( "\n", "</li>\n<li>", htmlspecialchars( $wgOut->mDebugtext
) );
933 return "\n<hr>\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\"><li>" .
934 $listInternals . "</li></ul>\n";
940 * This gets called shortly before the </body> tag.
941 * @return String HTML to be put before </body>
943 function afterContent() {
944 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
945 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
949 * This gets called shortly before the </body> tag.
950 * @return String HTML-wrapped JS code to be put before </body>
952 function bottomScripts() {
953 global $wgJsMimeType;
954 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
955 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
956 return $bottomScriptText;
959 /** @return string Retrievied from HTML text */
960 function printSource() {
961 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
962 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
965 function printFooter() {
966 return "<p>" . $this->printSource() .
967 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
970 /** overloaded by derived classes */
971 function doAfterContent() { return '</div></div>'; }
973 function pageTitleLinks() {
974 global $wgOut, $wgUser, $wgRequest, $wgLang;
976 $oldid = $wgRequest->getVal( 'oldid' );
977 $diff = $wgRequest->getVal( 'diff' );
978 $action = $wgRequest->getText( 'action' );
980 $s[] = $this->printableLink();
981 $disclaimer = $this->disclaimerLink(); # may be empty
985 $privacy = $this->privacyLink(); # may be empty too
990 if ( $wgOut->isArticleRelated() ) {
991 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
992 $name = $this->mTitle
->getDBkey();
993 $image = wfFindFile( $this->mTitle
);
995 $link = htmlspecialchars( $image->getURL() );
996 $style = $this->getInternalLinkAttributes( $link, $name );
997 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
1001 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
1002 $s[] .= $this->link(
1004 wfMsg( 'currentrev' ),
1007 array( 'known', 'noclasses' )
1011 if ( $wgUser->getNewtalk() ) {
1012 # do not show "You have new messages" text when we are viewing our
1014 if( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
1016 $wgUser->getTalkPage(),
1017 wfMsgHtml( 'newmessageslink' ),
1019 array( 'redirect' => 'no' ),
1020 array( 'known', 'noclasses' )
1024 $wgUser->getTalkPage(),
1025 wfMsgHtml( 'newmessagesdifflink' ),
1027 array( 'diff' => 'cur' ),
1028 array( 'known', 'noclasses' )
1030 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1032 $wgOut->setSquidMaxage( 0 );
1033 $wgOut->enableClientCache( false );
1037 $undelete = $this->getUndeleteLink();
1038 if( !empty( $undelete ) ) {
1041 return $wgLang->pipeList( $s );
1044 function getUndeleteLink() {
1045 global $wgUser, $wgContLang, $wgLang, $wgRequest;
1047 $action = $wgRequest->getVal( 'action', 'view' );
1049 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1050 ( $this->mTitle
->getArticleId() == 0 ||
$action == 'history' ) ) {
1051 $n = $this->mTitle
->isDeleted();
1053 if ( $wgUser->isAllowed( 'undelete' ) ) {
1054 $msg = 'thisisdeleted';
1056 $msg = 'viewdeleted';
1061 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1062 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1065 array( 'known', 'noclasses' )
1073 function printableLink() {
1074 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1076 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1078 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1079 if( $wgOut->isSyndicated() ) {
1080 foreach( $wgFeedClasses as $format => $class ) {
1081 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1082 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1083 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1086 return $wgLang->pipeList( $s );
1089 function pageTitle() {
1091 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1095 function pageSubtitle() {
1098 $sub = $wgOut->getSubtitle();
1100 global $wgExtraSubtitle;
1101 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1103 $subpages = $this->subPageSubtitle();
1104 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1105 $s = "<p class='subtitle'>{$sub}</p>\n";
1109 function subPageSubtitle() {
1111 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
1115 if( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1116 $ptext = $this->mTitle
->getPrefixedText();
1117 if( preg_match( '/\//', $ptext ) ) {
1118 $links = explode( '/', $ptext );
1119 array_pop( $links );
1123 foreach( $links as $link ) {
1124 $growinglink .= $link;
1126 $linkObj = Title
::newFromText( $growinglink );
1127 if( is_object( $linkObj ) && $linkObj->exists() ){
1128 $getlink = $this->link(
1130 htmlspecialchars( $display ),
1133 array( 'known', 'noclasses' )
1137 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1139 $subpages .= '< ';
1141 $subpages .= $getlink;
1146 $growinglink .= '/';
1154 * Returns true if the IP should be shown in the header
1156 function showIPinHeader() {
1157 global $wgShowIPinHeader;
1158 return $wgShowIPinHeader && session_id() != '';
1161 function nameAndLogin() {
1162 global $wgUser, $wgLang, $wgContLang;
1164 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1167 if ( $wgUser->isAnon() ) {
1168 if( $this->showIPinHeader() ) {
1171 $talkLink = $this->link( $wgUser->getTalkPage(),
1172 $wgLang->getNsText( NS_TALK
) );
1174 $ret .= "$name ($talkLink)";
1176 $ret .= wfMsg( 'notloggedin' );
1179 $returnTo = $this->mTitle
->getPrefixedDBkey();
1181 if ( $logoutPage != $returnTo ) {
1182 $query['returnto'] = $returnTo;
1185 $loginlink = $wgUser->isAllowed( 'createaccount' )
1186 ?
'nav-login-createaccount'
1188 $ret .= "\n<br />" . $this->link(
1189 SpecialPage
::getTitleFor( 'Userlogin' ),
1190 wfMsg( $loginlink ), array(), $query
1193 $returnTo = $this->mTitle
->getPrefixedDBkey();
1194 $talkLink = $this->link( $wgUser->getTalkPage(),
1195 $wgLang->getNsText( NS_TALK
) );
1197 $ret .= $this->link( $wgUser->getUserPage(),
1198 htmlspecialchars( $wgUser->getName() ) );
1199 $ret .= " ($talkLink)<br />";
1200 $ret .= $wgLang->pipeList( array(
1202 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1203 array(), array( 'returnto' => $returnTo )
1205 $this->specialLink( 'preferences' ),
1208 $ret = $wgLang->pipeList( array(
1211 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1219 function getSearchLink() {
1220 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1221 return $searchPage->getLocalURL();
1224 function escapeSearchLink() {
1225 return htmlspecialchars( $this->getSearchLink() );
1228 function searchForm() {
1229 global $wgRequest, $wgUseTwoButtonsSearchForm;
1230 $search = $wgRequest->getText( 'search' );
1232 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1233 . $this->escapeSearchLink() . "\">\n"
1234 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1235 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1236 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1238 if( $wgUseTwoButtonsSearchForm )
1239 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1241 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1245 // Ensure unique id's for search boxes made after the first
1246 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1251 function topLinks() {
1255 $this->mainPageLink(),
1256 $this->specialLink( 'recentchanges' )
1259 if ( $wgOut->isArticleRelated() ) {
1260 $s[] = $this->editThisPage();
1261 $s[] = $this->historyLink();
1263 # Many people don't like this dropdown box
1264 #$s[] = $this->specialPagesList();
1266 if( $this->variantLinks() ) {
1267 $s[] = $this->variantLinks();
1270 if( $this->extensionTabLinks() ) {
1271 $s[] = $this->extensionTabLinks();
1274 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1275 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1279 * Compatibility for extensions adding functionality through tabs.
1280 * Eventually these old skins should be replaced with SkinTemplate-based
1284 function extensionTabLinks() {
1288 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1289 foreach( $tabs as $tab ) {
1290 $s[] = Xml
::element( 'a',
1291 array( 'href' => $tab['href'] ),
1298 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1299 $out .= $wgLang->pipeList( $s );
1306 * Language/charset variant links for classic-style skins
1309 function variantLinks() {
1311 /* show links to different language variants */
1312 global $wgDisableLangConversion, $wgLang, $wgContLang;
1313 $variants = $wgContLang->getVariants();
1314 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1315 foreach( $variants as $code ) {
1316 $varname = $wgContLang->getVariantname( $code );
1317 if( $varname == 'disable' )
1319 $s = $wgLang->pipeList( array(
1321 '<a href="' . $this->mTitle
->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1328 function bottomLinks() {
1329 global $wgOut, $wgUser, $wgUseTrackbacks;
1330 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1333 if ( $wgOut->isArticleRelated() ) {
1334 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1335 if ( $wgUser->isLoggedIn() ) {
1336 $element[] = $this->watchThisPage();
1338 $element[] = $this->talkLink();
1339 $element[] = $this->historyLink();
1340 $element[] = $this->whatLinksHere();
1341 $element[] = $this->watchPageLinksLink();
1343 if( $wgUseTrackbacks )
1344 $element[] = $this->trackbackLink();
1346 if ( $this->mTitle
->getNamespace() == NS_USER
1347 ||
$this->mTitle
->getNamespace() == NS_USER_TALK
){
1348 $id = User
::idFromName( $this->mTitle
->getText() );
1349 $ip = User
::isIP( $this->mTitle
->getText() );
1351 if( $id ||
$ip ) { # both anons and non-anons have contri list
1352 $element[] = $this->userContribsLink();
1354 if( $this->showEmailUser( $id ) ) {
1355 $element[] = $this->emailUserLink();
1359 $s = implode( $element, $sep );
1361 if ( $this->mTitle
->getArticleId() ) {
1363 if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1364 if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1365 if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
1367 $s .= "<br />\n" . $this->otherLanguages();
1373 function pageStats() {
1374 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1375 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1377 $oldid = $wgRequest->getVal( 'oldid' );
1378 $diff = $wgRequest->getVal( 'diff' );
1379 if ( ! $wgOut->isArticle() ) { return ''; }
1380 if( !$wgArticle instanceOf Article
) { return ''; }
1381 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1382 if ( 0 == $wgArticle->getID() ) { return ''; }
1385 if ( !$wgDisableCounters ) {
1386 $count = $wgLang->formatNum( $wgArticle->getCount() );
1388 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1392 if( $wgMaxCredits != 0 ){
1393 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1395 $s .= $this->lastModified();
1398 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1399 $dbr = wfGetDB( DB_SLAVE
);
1400 $res = $dbr->select( 'watchlist',
1401 array( 'COUNT(*) AS n' ),
1402 array( 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ), 'wl_namespace' => $this->mTitle
->getNamespace() ),
1405 $x = $dbr->fetchObject( $res );
1407 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1408 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1412 return $s . ' ' . $this->getCopyright();
1415 function getCopyright( $type = 'detect' ) {
1416 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1418 if ( $type == 'detect' ) {
1419 $diff = $wgRequest->getVal( 'diff' );
1420 $isCur = $wgArticle && $wgArticle->isCurrent();
1421 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1428 if ( $type == 'history' ) {
1429 $msg = 'history_copyright';
1435 if( $wgRightsPage ) {
1436 $title = Title
::newFromText( $wgRightsPage );
1437 $link = $this->linkKnown( $title, $wgRightsText );
1438 } elseif( $wgRightsUrl ) {
1439 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1440 } elseif( $wgRightsText ) {
1441 $link = $wgRightsText;
1446 // Allow for site and per-namespace customization of copyright notice.
1447 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
1449 $out .= wfMsgForContent( $msg, $link );
1453 function getCopyrightIcon() {
1454 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1456 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1457 $out = $wgCopyrightIcon;
1458 } else if ( $wgRightsIcon ) {
1459 $icon = htmlspecialchars( $wgRightsIcon );
1460 if ( $wgRightsUrl ) {
1461 $url = htmlspecialchars( $wgRightsUrl );
1462 $out .= '<a href="'.$url.'">';
1464 $text = htmlspecialchars( $wgRightsText );
1465 $out .= "<img src=\"$icon\" alt='$text' />";
1466 if ( $wgRightsUrl ) {
1473 function getPoweredBy() {
1474 global $wgStylePath;
1475 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1476 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1480 function lastModified() {
1481 global $wgLang, $wgArticle;
1482 if( $this->mRevisionId
) {
1483 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1485 $timestamp = $wgArticle->getTimestamp();
1488 $d = $wgLang->date( $timestamp, true );
1489 $t = $wgLang->time( $timestamp, true );
1490 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1494 if ( wfGetLB()->getLaggedSlaveMode() ) {
1495 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1500 function logoText( $align = '' ) {
1501 if ( '' != $align ) {
1502 $a = " align='{$align}'";
1507 $mp = wfMsg( 'mainpage' );
1508 $mptitle = Title
::newMainPage();
1509 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1511 $logourl = $this->getLogo();
1512 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1517 * show a drop-down box of special pages
1519 function specialPagesList() {
1520 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1521 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1522 foreach ( $pages as $name => $page ) {
1523 $pages[$name] = $page->getDescription();
1526 $go = wfMsg( 'go' );
1527 $sp = wfMsg( 'specialpages' );
1528 $spp = $wgContLang->specialPage( 'Specialpages' );
1530 $s = '<form id="specialpages" method="get" ' .
1531 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1532 $s .= "<select name=\"wpDropdown\">\n";
1533 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1536 foreach ( $pages as $name => $desc ) {
1537 $p = $wgContLang->specialPage( $name );
1538 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1540 $s .= "</select>\n";
1541 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1546 function mainPageLink() {
1548 Title
::newMainPage(),
1549 wfMsg( 'mainpage' ),
1552 array( 'known', 'noclasses' )
1557 function copyrightLink() {
1558 $title = Title
::newFromText( wfMsgForContent( 'copyrightpage' ) );
1559 $s = $this->linkKnown(
1561 wfMsg( 'copyrightpagename' )
1566 private function footerLink ( $desc, $page ) {
1567 // if the link description has been set to "-" in the default language,
1568 if ( wfMsgForContent( $desc ) == '-') {
1569 // then it is disabled, for all languages.
1572 // Otherwise, we display the link for the user, described in their
1573 // language (which may or may not be the same as the default language),
1574 // but we make the link target be the one site-wide page.
1575 $title = Title
::newFromText( wfMsgForContent( $page ) );
1576 return $this->linkKnown(
1578 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1583 function privacyLink() {
1584 return $this->footerLink( 'privacy', 'privacypage' );
1587 function aboutLink() {
1588 return $this->footerLink( 'aboutsite', 'aboutpage' );
1591 function disclaimerLink() {
1592 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1595 function editThisPage() {
1598 if ( !$wgOut->isArticleRelated() ) {
1599 $s = wfMsg( 'protectedpage' );
1601 if( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1602 $t = wfMsg( 'editthispage' );
1603 } elseif( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1604 $t = wfMsg( 'create-this-page' );
1606 $t = wfMsg( 'viewsource' );
1613 $this->editUrlOptions(),
1614 array( 'known', 'noclasses' )
1621 * Return URL options for the 'edit page' link.
1622 * This may include an 'oldid' specifier, if the current page view is such.
1627 function editUrlOptions() {
1630 $options = array( 'action' => 'edit' );
1632 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1633 $options['oldid'] = intval( $this->mRevisionId
);
1639 function deleteThisPage() {
1640 global $wgUser, $wgRequest;
1642 $diff = $wgRequest->getVal( 'diff' );
1643 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1644 $t = wfMsg( 'deletethispage' );
1650 array( 'action' => 'delete' ),
1651 array( 'known', 'noclasses' )
1659 function protectThisPage() {
1660 global $wgUser, $wgRequest;
1662 $diff = $wgRequest->getVal( 'diff' );
1663 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1664 if ( $this->mTitle
->isProtected() ) {
1665 $text = wfMsg( 'unprotectthispage' );
1666 $query = array( 'action' => 'unprotect' );
1668 $text = wfMsg( 'protectthispage' );
1669 $query = array( 'action' => 'protect' );
1677 array( 'known', 'noclasses' )
1685 function watchThisPage() {
1687 ++
$this->mWatchLinkNum
;
1689 if ( $wgOut->isArticleRelated() ) {
1690 if ( $this->mTitle
->userIsWatching() ) {
1691 $text = wfMsg( 'unwatchthispage' );
1692 $query = array( 'action' => 'unwatch' );
1693 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1695 $text = wfMsg( 'watchthispage' );
1696 $query = array( 'action' => 'watch' );
1697 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1703 array( 'id' => $id ),
1705 array( 'known', 'noclasses' )
1708 $s = wfMsg( 'notanarticle' );
1713 function moveThisPage() {
1714 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1716 SpecialPage
::getTitleFor( 'Movepage' ),
1717 wfMsg( 'movethispage' ),
1719 array( 'target' => $this->mTitle
->getPrefixedURL() ),
1720 array( 'known', 'noclasses' )
1723 // no message if page is protected - would be redundant
1728 function historyLink() {
1731 wfMsgHtml( 'history' ),
1732 array( 'rel' => 'archives' ),
1733 array( 'action' => 'history' )
1737 function whatLinksHere() {
1739 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1740 wfMsgHtml( 'whatlinkshere' ),
1743 array( 'known', 'noclasses' )
1747 function userContribsLink() {
1749 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1750 wfMsgHtml( 'contributions' ),
1753 array( 'known', 'noclasses' )
1757 function showEmailUser( $id ) {
1759 $targetUser = User
::newFromId( $id );
1760 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1761 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1764 function emailUserLink() {
1766 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1767 wfMsg( 'emailuser' ),
1770 array( 'known', 'noclasses' )
1774 function watchPageLinksLink() {
1776 if ( ! $wgOut->isArticleRelated() ) {
1777 return '(' . wfMsg( 'notanarticle' ) . ')';
1780 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1781 wfMsg( 'recentchangeslinked-toolbox' ),
1784 array( 'known', 'noclasses' )
1789 function trackbackLink() {
1790 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1791 . wfMsg( 'trackbacklink' ) . '</a>';
1794 function otherLanguages() {
1795 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1797 if ( $wgHideInterlanguageLinks ) {
1801 $a = $wgOut->getLanguageLinks();
1802 if ( 0 == count( $a ) ) {
1806 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1808 if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
1809 foreach( $a as $l ) {
1811 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1815 $nt = Title
::newFromText( $l );
1816 $url = $nt->escapeFullURL();
1817 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1819 if ( '' == $text ) { $text = $l; }
1820 $style = $this->getExternalLinkAttributes( $l, $text );
1821 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1823 if( $wgContLang->isRTL() ) $s .= '</span>';
1827 function talkLink() {
1828 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1829 # No discussion links for special pages
1833 $linkOptions = array();
1835 if( $this->mTitle
->isTalkPage() ) {
1836 $link = $this->mTitle
->getSubjectPage();
1837 switch( $link->getNamespace() ) {
1839 $text = wfMsg( 'articlepage' );
1842 $text = wfMsg( 'userpage' );
1845 $text = wfMsg( 'projectpage' );
1848 $text = wfMsg( 'imagepage' );
1849 # Make link known if image exists, even if the desc. page doesn't.
1850 if( wfFindFile( $link ) )
1851 $linkOptions[] = 'known';
1854 $text = wfMsg( 'mediawikipage' );
1857 $text = wfMsg( 'templatepage' );
1860 $text = wfMsg( 'viewhelppage' );
1863 $text = wfMsg( 'categorypage' );
1866 $text = wfMsg( 'articlepage' );
1869 $link = $this->mTitle
->getTalkPage();
1870 $text = wfMsg( 'talkpage' );
1873 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1878 function commentLink() {
1881 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1885 # __NEWSECTIONLINK___ changes behaviour here
1886 # If it is present, the link points to this page, otherwise
1887 # it points to the talk page
1888 if( $this->mTitle
->isTalkPage() ) {
1889 $title = $this->mTitle
;
1890 } elseif( $wgOut->showNewSectionLink() ) {
1891 $title = $this->mTitle
;
1893 $title = $this->mTitle
->getTalkPage();
1898 wfMsg( 'postcomment' ),
1904 array( 'known', 'noclasses' )
1908 /* these are used extensively in SkinTemplate, but also some other places */
1909 static function makeMainPageUrl( $urlaction = '' ) {
1910 $title = Title
::newMainPage();
1911 self
::checkTitle( $title, '' );
1912 return $title->getLocalURL( $urlaction );
1915 static function makeSpecialUrl( $name, $urlaction = '' ) {
1916 $title = SpecialPage
::getTitleFor( $name );
1917 return $title->getLocalURL( $urlaction );
1920 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1921 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1922 return $title->getLocalURL( $urlaction );
1925 static function makeI18nUrl( $name, $urlaction = '' ) {
1926 $title = Title
::newFromText( wfMsgForContent( $name ) );
1927 self
::checkTitle( $title, $name );
1928 return $title->getLocalURL( $urlaction );
1931 static function makeUrl( $name, $urlaction = '' ) {
1932 $title = Title
::newFromText( $name );
1933 self
::checkTitle( $title, $name );
1934 return $title->getLocalURL( $urlaction );
1937 # If url string starts with http, consider as external URL, else
1939 static function makeInternalOrExternalUrl( $name ) {
1940 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1943 return self
::makeUrl( $name );
1947 # this can be passed the NS number as defined in Language.php
1948 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1949 $title = Title
::makeTitleSafe( $namespace, $name );
1950 self
::checkTitle( $title, $name );
1951 return $title->getLocalURL( $urlaction );
1954 /* these return an array with the 'href' and boolean 'exists' */
1955 static function makeUrlDetails( $name, $urlaction = '' ) {
1956 $title = Title
::newFromText( $name );
1957 self
::checkTitle( $title, $name );
1959 'href' => $title->getLocalURL( $urlaction ),
1960 'exists' => $title->getArticleID() != 0 ?
true : false
1965 * Make URL details where the article exists (or at least it's convenient to think so)
1967 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1968 $title = Title
::newFromText( $name );
1969 self
::checkTitle( $title, $name );
1971 'href' => $title->getLocalURL( $urlaction ),
1976 # make sure we have some title to operate on
1977 static function checkTitle( &$title, $name ) {
1978 if( !is_object( $title ) ) {
1979 $title = Title
::newFromText( $name );
1980 if( !is_object( $title ) ) {
1981 $title = Title
::newFromText( '--error: link target missing--' );
1987 * Build an array that represents the sidebar(s), the navigation bar among them
1991 function buildSidebar() {
1992 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1994 wfProfileIn( __METHOD__
);
1996 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
1998 if ( $wgEnableSidebarCache ) {
1999 $cachedsidebar = $parserMemc->get( $key );
2000 if ( $cachedsidebar ) {
2001 wfProfileOut( __METHOD__
);
2002 return $cachedsidebar;
2007 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
2009 foreach( $lines as $line ) {
2010 if( strpos( $line, '*' ) !== 0 )
2012 if( strpos( $line, '**') !== 0 ) {
2013 $heading = trim( $line, '* ' );
2014 if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
2016 if( strpos( $line, '|' ) !== false ) { // sanity check
2017 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
2018 $link = wfMsgForContent( $line[0] );
2022 $text = wfMsgExt( $line[1], 'parsemag' );
2023 if( wfEmptyMsg( $line[1], $text ) )
2025 if( wfEmptyMsg( $line[0], $link ) )
2028 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2031 $title = Title
::newFromText( $link );
2033 $title = $title->fixSpecialName();
2034 $href = $title->getLocalURL();
2036 $href = 'INVALID-TITLE';
2040 $bar[$heading][] = array(
2043 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2046 } else { continue; }
2049 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2050 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2051 wfProfileOut( __METHOD__
);