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';
28 /** Constructor, call parent constructor */
29 function Skin() { parent
::__construct(); }
32 * Fetch the set of available skins.
33 * @return array of strings
36 static function getSkinNames() {
37 global $wgValidSkinNames;
38 static $skinsInitialised = false;
39 if ( !$skinsInitialised ) {
40 # Get a list of available skins
41 # Build using the regular expression '^(.*).php$'
42 # Array keys are all lower case, array value keep the case used by filename
44 wfProfileIn( __METHOD__
. '-init' );
45 global $wgStyleDirectory;
46 $skinDir = dir( $wgStyleDirectory );
48 # while code from www.php.net
49 while( false !== ( $file = $skinDir->read() ) ) {
50 // Skip non-PHP files, hidden files, and '.dep' includes
52 if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
54 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
58 $skinsInitialised = true;
59 wfProfileOut( __METHOD__
. '-init' );
61 return $wgValidSkinNames;
65 * Fetch the list of usable skins in regards to $wgSkipSkins.
66 * Useful for Special:Preferences and other places where you
67 * only want to show skins users _can_ use.
68 * @return array of strings
70 public static function getUsableSkins() {
72 $usableSkins = self
::getSkinNames();
73 foreach ( $wgSkipSkins as $skip ) {
74 unset( $usableSkins[$skip] );
80 * Normalize a skin preference value to a form that can be loaded.
81 * If a skin can't be found, it will fall back to the configured
82 * default (or the old 'Classic' skin if that's broken).
87 static function normalizeKey( $key ) {
88 global $wgDefaultSkin;
89 $skinNames = Skin
::getSkinNames();
92 // Don't return the default immediately;
93 // in a misconfiguration we need to fall back.
94 $key = $wgDefaultSkin;
97 if( isset( $skinNames[$key] ) ) {
101 // Older versions of the software used a numeric setting
102 // in the user preferences.
106 2 => 'cologneblue' );
108 if( isset( $fallback[$key] ) ){
109 $key = $fallback[$key];
112 if( isset( $skinNames[$key] ) ) {
120 * Factory method for loading a skin of a given type
121 * @param string $key 'monobook', 'standard', etc
125 static function &newFromKey( $key ) {
126 global $wgStyleDirectory;
128 $key = Skin
::normalizeKey( $key );
130 $skinNames = Skin
::getSkinNames();
131 $skinName = $skinNames[$key];
132 $className = 'Skin'.ucfirst($key);
134 # Grab the skin class and initialise it.
135 if ( !class_exists( $className ) ) {
136 // Preload base classes to work around APC/PHP5 bug
137 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
138 if( file_exists( $deps ) ) include_once( $deps );
139 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
141 # Check if we got if not failback to default skin
142 if( !class_exists( $className ) ) {
143 # DO NOT die if the class isn't found. This breaks maintenance
144 # scripts and can cause a user account to be unrecoverable
145 # except by SQL manipulation if a previously valid skin name
146 # is no longer valid.
147 wfDebug( "Skin class does not exist: $className\n" );
148 $className = 'SkinMonobook';
149 require_once( "{$wgStyleDirectory}/MonoBook.php" );
152 $skin = new $className;
156 /** @return string path to the skin stylesheet */
157 function getStylesheet() {
158 return 'common/wikistandard.css';
161 /** @return string skin name */
162 public function getSkinName() {
163 return $this->skinname
;
166 function qbSetting() {
167 global $wgOut, $wgUser;
169 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
170 $q = $wgUser->getOption( 'quickbar', 0 );
174 function initPage( OutputPage
$out ) {
175 global $wgFavicon, $wgAppleTouchIcon;
177 wfProfileIn( __METHOD__
);
179 # Generally the order of the favicon and apple-touch-icon links
180 # should not matter, but Konqueror (3.5.9 at least) incorrectly
181 # uses whichever one appears later in the HTML source. Make sure
182 # apple-touch-icon is specified first to avoid this.
183 if( false !== $wgAppleTouchIcon ) {
184 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
187 if( false !== $wgFavicon ) {
188 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
191 # OpenSearch description link
192 $out->addLink( array(
194 'type' => 'application/opensearchdescription+xml',
195 'href' => wfScript( 'opensearch_desc' ),
196 'title' => wfMsgForContent( 'opensearch-desc' ),
199 $this->addMetadataLinks( $out );
201 $this->mRevisionId
= $out->mRevisionId
;
203 $this->preloadExistence();
205 wfProfileOut( __METHOD__
);
209 * Preload the existence of three commonly-requested pages in a single query
211 function preloadExistence() {
215 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
218 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
220 } elseif ( $this->mTitle
->isTalkPage() ) {
221 $titles[] = $this->mTitle
->getSubjectPage();
223 $titles[] = $this->mTitle
->getTalkPage();
226 $lb = new LinkBatch( $titles );
230 function addMetadataLinks( OutputPage
$out ) {
231 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
232 global $wgRightsPage, $wgRightsUrl;
234 if( $out->isArticleRelated() ) {
235 # note: buggy CC software only reads first "meta" link
236 if( $wgEnableCreativeCommonsRdf ) {
237 $out->addMetadataLink( array(
238 'title' => 'Creative Commons',
239 'type' => 'application/rdf+xml',
240 'href' => $this->mTitle
->getLocalURL( 'action=creativecommons' ) )
243 if( $wgEnableDublinCoreRdf ) {
244 $out->addMetadataLink( array(
245 'title' => 'Dublin Core',
246 'type' => 'application/rdf+xml',
247 'href' => $this->mTitle
->getLocalURL( 'action=dublincore' ) )
252 if( $wgRightsPage ) {
253 $copy = Title
::newFromText( $wgRightsPage );
255 $copyright = $copy->getLocalURL();
258 if( !$copyright && $wgRightsUrl ) {
259 $copyright = $wgRightsUrl;
262 $out->addLink( array(
263 'rel' => 'copyright',
264 'href' => $copyright )
270 * Set some local variables
272 protected function setMembers(){
274 $this->mUser
= $wgUser;
275 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
276 $this->usercss
= false;
281 * @param Title $t The title to use
283 public function setTitle( $t ) {
287 function outputPage( OutputPage
$out ) {
288 global $wgDebugComments;
289 wfProfileIn( __METHOD__
);
292 $this->initPage( $out );
294 // See self::afterContentHook() for documentation
295 $afterContent = $this->afterContentHook();
297 $out->out( $out->headElement( $this ) );
299 $out->out( "\n<body" );
300 $ops = $this->getBodyOptions();
301 foreach ( $ops as $name => $val ) {
302 $out->out( " $name='$val'" );
305 if ( $wgDebugComments ) {
306 $out->out( "<!-- Wiki debugging output:\n" .
307 $out->mDebugtext
. "-->\n" );
310 $out->out( $this->beforeContent() );
312 $out->out( $out->mBodytext
. "\n" );
314 $out->out( $this->afterContent() );
316 $out->out( $afterContent );
318 $out->out( $this->bottomScripts() );
320 $out->out( wfReportTime() );
322 $out->out( "\n</body></html>" );
323 wfProfileOut( __METHOD__
);
326 static function makeVariablesScript( $data ) {
327 global $wgJsMimeType;
329 $r = array( "<script type=\"$wgJsMimeType\">/*<![CDATA[*/" );
330 foreach ( $data as $name => $value ) {
331 $encValue = Xml
::encodeJsVar( $value );
332 $r[] = "var $name = $encValue;";
334 $r[] = "/*]]>*/</script>\n";
336 return implode( "\n\t\t", $r );
340 * Make a <script> tag containing global variables
341 * @param array $data Associative array containing one element:
342 * skinname => the skin name
343 * The odd calling convention is for backwards compatibility
344 * @TODO @FIXME Make this not depend on $wgTitle!
346 static function makeGlobalVariablesScript( $data ) {
347 global $wgScript, $wgTitle, $wgStylePath, $wgUser;
348 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
349 global $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
350 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
351 global $wgUseAjax, $wgAjaxWatch;
352 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
353 global $wgRestrictionTypes, $wgLivePreview;
354 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
356 $ns = $wgTitle->getNamespace();
357 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
358 $separatorTransTable = $wgContLang->separatorTransformTable();
359 $separatorTransTable = $separatorTransTable ?
$separatorTransTable : array();
360 $compactSeparatorTransTable = array(
361 implode( "\t", array_keys( $separatorTransTable ) ),
362 implode( "\t", $separatorTransTable ),
364 $digitTransTable = $wgContLang->digitTransformTable();
365 $digitTransTable = $digitTransTable ?
$digitTransTable : array();
366 $compactDigitTransTable = array(
367 implode( "\t", array_keys( $digitTransTable ) ),
368 implode( "\t", $digitTransTable ),
372 'skin' => $data['skinname'],
373 'stylepath' => $wgStylePath,
374 'wgArticlePath' => $wgArticlePath,
375 'wgScriptPath' => $wgScriptPath,
376 'wgScript' => $wgScript,
377 'wgVariantArticlePath' => $wgVariantArticlePath,
378 'wgActionPaths' => (object)$wgActionPaths,
379 'wgServer' => $wgServer,
380 'wgCanonicalNamespace' => $nsname,
381 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
382 'wgNamespaceNumber' => $wgTitle->getNamespace(),
383 'wgPageName' => $wgTitle->getPrefixedDBKey(),
384 'wgTitle' => $wgTitle->getText(),
385 'wgAction' => $wgRequest->getText( 'action', 'view' ),
386 'wgArticleId' => $wgTitle->getArticleId(),
387 'wgIsArticle' => $wgOut->isArticle(),
388 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
389 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
390 'wgUserLanguage' => $wgLang->getCode(),
391 'wgContentLanguage' => $wgContLang->getCode(),
392 'wgBreakFrames' => $wgBreakFrames,
393 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
394 'wgVersion' => $wgVersion,
395 'wgEnableAPI' => $wgEnableAPI,
396 'wgEnableWriteAPI' => $wgEnableWriteAPI,
397 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
398 'wgDigitTransformTable' => $compactDigitTransTable,
401 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
402 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
403 $vars['wgDBname'] = $wgDBname;
404 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
405 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
408 foreach( $wgRestrictionTypes as $type )
409 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
411 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
412 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
413 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
414 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
415 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
418 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
419 $msgs = (object)array();
420 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
421 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
423 $vars['wgAjaxWatch'] = $msgs;
426 // Allow extensions to add their custom variables to the global JS variables
427 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
429 return self
::makeVariablesScript( $vars );
432 function getHeadScripts( $allowUserJs ) {
433 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
435 $vars = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
437 $r = array( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>" );
440 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
441 $r[] = "<script type=\"$wgJsMimeType\" src=\"".
442 htmlspecialchars( self
::makeUrl( '-',
443 "action=raw$jsCache&gen=js&useskin=" .
444 urlencode( $this->getSkinName() ) ) ) .
445 "\"><!-- site js --></script>";
447 if( $allowUserJs && $wgUser->isLoggedIn() ) {
448 $userpage = $wgUser->getUserPage();
449 $userjs = htmlspecialchars( self
::makeUrl(
450 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
451 'action=raw&ctype='.$wgJsMimeType ) );
452 $r[] = '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>";
454 return $vars . "\t\t" . implode ( "\n\t\t", $r );
458 * To make it harder for someone to slip a user a fake
459 * user-JavaScript or user-CSS preview, a random token
460 * is associated with the login session. If it's not
461 * passed back with the preview request, we won't render
464 * @param string $action
468 function userCanPreview( $action ) {
469 global $wgRequest, $wgUser;
471 if( $action != 'submit' )
473 if( !$wgRequest->wasPosted() )
475 if( !$this->mTitle
->userCanEditCssJsSubpage() )
477 return $wgUser->matchEditToken(
478 $wgRequest->getVal( 'wpEditToken' ) );
482 * generated JavaScript action=raw&gen=js
483 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
484 * nated together. For some bizarre reason, it does *not* return any
485 * custom user JS from subpages. Huh?
487 * There's absolutely no reason to have separate Monobook/Common JSes.
488 * Any JS that cares can just check the skin variable generated at the
489 * top. For now Monobook.js will be maintained, but it should be consi-
494 public function generateUserJs() {
497 wfProfileIn( __METHOD__
);
499 $s = "/* generated javascript */\n";
500 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
501 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
502 $s .= "\n\n/* MediaWiki:Common.js */\n";
503 $commonJs = wfMsgForContent( 'common.js' );
504 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
508 $s .= "\n\n/* MediaWiki:".ucfirst( $this->getSkinName() ).".js */\n";
509 // avoid inclusion of non defined user JavaScript (with custom skins only)
510 // by checking for default message content
511 $msgKey = ucfirst( $this->getSkinName() ).'.js';
512 $userJS = wfMsgForContent( $msgKey );
513 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
517 wfProfileOut( __METHOD__
);
522 * Generate user stylesheet for action=raw&gen=css
524 public function generateUserStylesheet() {
525 wfProfileIn( __METHOD__
);
526 $s = "/* generated user stylesheet */\n" .
527 $this->reallyGenerateUserStylesheet();
528 wfProfileOut( __METHOD__
);
533 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
535 protected function reallyGenerateUserStylesheet(){
538 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
539 $underline = $undopt ?
'underline' : 'none';
540 $s .= "a { text-decoration: $underline; }\n";
542 if( $wgUser->getOption( 'highlightbroken' ) ) {
543 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
546 a.new, #quickbar a.new,
547 a.stub, #quickbar a.stub {
550 a.new:after, #quickbar a.new:after {
554 a.stub:after, #quickbar a.stub:after {
560 if( $wgUser->getOption( 'justify' ) ) {
561 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
563 if( !$wgUser->getOption( 'showtoc' ) ) {
564 $s .= "#toc { display: none; }\n";
566 if( !$wgUser->getOption( 'editsection' ) ) {
567 $s .= ".editsection { display: none; }\n";
575 function setupUserCss( OutputPage
$out ) {
576 global $wgRequest, $wgContLang, $wgUser;
577 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
579 wfProfileIn( __METHOD__
);
581 $this->setupSkinUserCss( $out );
585 'maxage' => $wgSquidMaxage,
588 // Add any extension CSS
589 foreach( $out->getExtStyle() as $tag ) {
590 $out->addStyle( $tag['href'] );
593 // If we use the site's dynamic CSS, throw that in, too
594 // Per-site custom styles
595 if( $wgUseSiteCss ) {
596 global $wgHandheldStyle;
597 $query = wfArrayToCGI( array(
598 'usemsgcache' => 'yes',
599 'ctype' => 'text/css',
600 'smaxage' => $wgSquidMaxage
602 # Site settings must override extension css! (bug 15025)
603 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
604 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
605 if( $wgHandheldStyle ) {
606 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
608 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
611 if( $wgUser->isLoggedIn() ) {
612 // Ensure that logged-in users' generated CSS isn't clobbered
613 // by anons' publicly cacheable generated CSS.
614 $siteargs['smaxage'] = '0';
615 $siteargs['ts'] = $wgUser->mTouched
;
617 // Per-user styles based on preferences
618 $siteargs['gen'] = 'css';
619 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
620 $siteargs['useskin'] = $us;
622 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
624 // Per-user custom style pages
625 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
626 $action = $wgRequest->getVal( 'action' );
627 # If we're previewing the CSS page, use it
628 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
629 $previewCss = $wgRequest->getText( 'wpTextbox1' );
630 // @FIXME: properly escape the cdata!
631 $this->usercss
= "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
633 $out->addStyle( self
::makeUrl( $this->userpage
. '/' . $this->getSkinName() .'.css',
634 'action=raw&ctype=text/css' ) );
638 wfProfileOut( __METHOD__
);
642 * Add skin specific stylesheets
643 * @param $out OutputPage
645 function setupSkinUserCss( OutputPage
$out ) {
646 $out->addStyle( 'common/shared.css' );
647 $out->addStyle( 'common/oldshared.css' );
648 $out->addStyle( $this->getStylesheet() );
649 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
652 function getBodyOptions() {
653 global $wgUser, $wgOut, $wgRequest, $wgContLang;
655 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
657 if ( 0 != $this->mTitle
->getNamespace() ) {
658 $a = array( 'bgcolor' => '#ffffec' );
660 else $a = array( 'bgcolor' => '#FFFFFF' );
661 if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
662 $this->mTitle
->quickUserCan( 'edit' ) ) {
663 $s = $this->mTitle
->getFullURL( $this->editUrlOptions() );
664 $s = 'document.location = "' .Xml
::escapeJsString( $s ) .'";';
665 $a +
= array( 'ondblclick' => $s );
667 $a['onload'] = $wgOut->getOnloadHandler();
670 ' '.( $wgContLang->isRTL() ?
'rtl' : 'ltr' ).
671 ' '.$this->getPageClasses( $this->mTitle
) .
672 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName() );
676 function getPageClasses( $title ) {
677 $numeric = 'ns-'.$title->getNamespace();
678 if( $title->getNamespace() == NS_SPECIAL
) {
679 $type = 'ns-special';
680 } elseif( $title->isTalkPage() ) {
683 $type = 'ns-subject';
685 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
686 return "$numeric $type $name";
698 * This will be called immediately after the <body> tag. Split into
699 * two functions to make it easier to subclass.
701 function beforeContent() {
702 return $this->doBeforeContent();
705 function doBeforeContent() {
707 wfProfileIn( __METHOD__
);
710 $qb = $this->qbSetting();
712 if( $langlinks = $this->otherLanguages() ) {
718 $borderhack = 'class="top"';
721 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
722 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
724 $shove = ( $qb != 0 );
725 $left = ( $qb == 1 ||
$qb == 3 );
726 if( $wgContLang->isRTL() ) $left = !$left;
729 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
730 $this->logoText() . '</td>';
732 $s .= $this->getQuickbarCompensator( $rows );
734 $l = $wgContLang->isRTL() ?
'right' : 'left';
735 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
737 $s .= $this->topLinks();
738 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
740 $r = $wgContLang->isRTL() ?
'left' : 'right';
741 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
742 $s .= $this->nameAndLogin();
743 $s .= "\n<br />" . $this->searchForm() . "</td>";
746 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
749 if ( $shove && !$left ) { # Right
750 $s .= $this->getQuickbarCompensator( $rows );
752 $s .= "</tr>\n</table>\n</div>\n";
753 $s .= "\n<div id='article'>\n";
755 $notice = wfGetSiteNotice();
757 $s .= "\n<div id='siteNotice'>$notice</div>\n";
759 $s .= $this->pageTitle();
760 $s .= $this->pageSubtitle();
761 $s .= $this->getCategories();
762 wfProfileOut( __METHOD__
);
767 function getCategoryLinks() {
768 global $wgOut, $wgUseCategoryBrowser;
769 global $wgContLang, $wgUser;
771 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
774 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
776 // Use Unicode bidi embedding override characters,
777 // to make sure links don't smash each other up in ugly ways.
778 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
779 $embed = "<span dir='$dir'>";
782 $allCats = $wgOut->getCategoryLinks();
784 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
785 if ( !empty( $allCats['normal'] ) ) {
786 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
788 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
789 $s .= '<div id="mw-normal-catlinks">' .
790 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
791 . $colon . $t . '</div>';
795 if ( isset( $allCats['hidden'] ) ) {
796 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
797 $class ='mw-hidden-cats-user-shown';
798 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
799 $class = 'mw-hidden-cats-ns-shown';
801 $class = 'mw-hidden-cats-hidden';
803 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
804 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
805 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
809 # optional 'dmoz-like' category browser. Will be shown under the list
810 # of categories an article belong to
811 if( $wgUseCategoryBrowser ){
812 $s .= '<br /><hr />';
814 # get a big array of the parents tree
815 $parenttree = $this->mTitle
->getParentCategoryTree();
816 # Skin object passed by reference cause it can not be
817 # accessed under the method subfunction drawCategoryBrowser
818 $tempout = explode( "\n", Skin
::drawCategoryBrowser( $parenttree, $this ) );
819 # Clean out bogus first entry and sort them
820 unset( $tempout[0] );
822 # Output one per line
823 $s .= implode( "<br />\n", $tempout );
830 * Render the array as a serie of links.
831 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
832 * @param &skin Object: skin passed by reference
833 * @return String separated by >, terminate with "\n"
835 function drawCategoryBrowser( $tree, &$skin ){
837 foreach( $tree as $element => $parent ) {
838 if( empty( $parent ) ) {
839 # element start a new list
842 # grab the others elements
843 $return .= Skin
::drawCategoryBrowser( $parent, $skin ) . ' > ';
845 # add our current element to the list
846 $eltitle = Title
::newFromText( $element );
847 $return .= $skin->link( $eltitle, $eltitle->getText() );
852 function getCategories() {
853 $catlinks=$this->getCategoryLinks();
855 $classes = 'catlinks';
857 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
858 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
859 $classes .= ' catlinks-allhidden';
862 if( !empty( $catlinks ) ){
863 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
867 function getQuickbarCompensator( $rows = 1 ) {
868 return "<td width='152' rowspan='{$rows}'> </td>";
872 * This runs a hook to allow extensions placing their stuff after content
873 * and article metadata (e.g. categories).
874 * Note: This function has nothing to do with afterContent().
876 * This hook is placed here in order to allow using the same hook for all
877 * skins, both the SkinTemplate based ones and the older ones, which directly
878 * use this class to get their data.
880 * The output of this function gets processed in SkinTemplate::outputPage() for
881 * the SkinTemplate based skins, all other skins should directly echo it.
883 * Returns an empty string by default, if not changed by any hook function.
885 protected function afterContentHook() {
888 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
889 // adding just some spaces shouldn't toggle the output
890 // of the whole <div/>, so we use trim() here
891 if( trim( $data ) != '' ){
892 // Doing this here instead of in the skins to
893 // ensure that the div has the same ID in all
895 $data = "<div id='mw-data-after-content'>\n" .
900 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
907 * Generate debug data HTML for displaying at the bottom of the main content
909 * @return String HTML containing debug data, if enabled (otherwise empty).
911 protected function generateDebugHTML() {
912 global $wgShowDebug, $wgOut;
913 if ( $wgShowDebug ) {
914 $listInternals = str_replace( "\n", "</li>\n<li>", htmlspecialchars( $wgOut->mDebugtext
) );
915 return "\n<hr>\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\"><li>" .
916 $listInternals . "</li></ul>\n";
922 * This gets called shortly before the </body> tag.
923 * @return String HTML to be put before </body>
925 function afterContent() {
926 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
927 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
931 * This gets called shortly before the </body> tag.
932 * @return String HTML-wrapped JS code to be put before </body>
934 function bottomScripts() {
935 global $wgJsMimeType;
936 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
937 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
938 return $bottomScriptText;
941 /** @return string Retrievied from HTML text */
942 function printSource() {
943 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
944 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
947 function printFooter() {
948 return "<p>" . $this->printSource() .
949 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
952 /** overloaded by derived classes */
953 function doAfterContent() { return '</div></div>'; }
955 function pageTitleLinks() {
956 global $wgOut, $wgUser, $wgRequest, $wgLang;
958 $oldid = $wgRequest->getVal( 'oldid' );
959 $diff = $wgRequest->getVal( 'diff' );
960 $action = $wgRequest->getText( 'action' );
962 $s[] = $this->printableLink();
963 $disclaimer = $this->disclaimerLink(); # may be empty
967 $privacy = $this->privacyLink(); # may be empty too
972 if ( $wgOut->isArticleRelated() ) {
973 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
974 $name = $this->mTitle
->getDBkey();
975 $image = wfFindFile( $this->mTitle
);
977 $link = htmlspecialchars( $image->getURL() );
978 $style = $this->getInternalLinkAttributes( $link, $name );
979 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
983 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
984 $s[] .= $this->makeKnownLinkObj( $this->mTitle
,
985 wfMsg( 'currentrev' ) );
988 if ( $wgUser->getNewtalk() ) {
989 # do not show "You have new messages" text when we are viewing our
991 if( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
992 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
993 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
994 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
996 $wgOut->setSquidMaxage( 0 );
997 $wgOut->enableClientCache( false );
1001 $undelete = $this->getUndeleteLink();
1002 if( !empty( $undelete ) ) {
1005 return $wgLang->pipeList( $s );
1008 function getUndeleteLink() {
1009 global $wgUser, $wgContLang, $wgLang, $action;
1010 if( $wgUser->isAllowed( 'deletedhistory' ) &&
1011 ( ( $this->mTitle
->getArticleId() == 0 ) ||
( $action == 'history' ) ) &&
1012 ( $n = $this->mTitle
->isDeleted() ) ){
1013 if ( $wgUser->isAllowed( 'undelete' ) ) {
1014 $msg = 'thisisdeleted';
1016 $msg = 'viewdeleted';
1019 $this->makeKnownLinkObj(
1020 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1021 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
1026 function printableLink() {
1027 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1029 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1031 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1032 if( $wgOut->isSyndicated() ) {
1033 foreach( $wgFeedClasses as $format => $class ) {
1034 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1035 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1036 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1039 return $wgLang->pipeList( $s );
1042 function pageTitle() {
1044 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1048 function pageSubtitle() {
1051 $sub = $wgOut->getSubtitle();
1053 global $wgExtraSubtitle;
1054 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1056 $subpages = $this->subPageSubtitle();
1057 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1058 $s = "<p class='subtitle'>{$sub}</p>\n";
1062 function subPageSubtitle() {
1064 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
1068 if( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1069 $ptext = $this->mTitle
->getPrefixedText();
1070 if( preg_match( '/\//', $ptext ) ) {
1071 $links = explode( '/', $ptext );
1072 array_pop( $links );
1076 foreach( $links as $link ) {
1077 $growinglink .= $link;
1079 $linkObj = Title
::newFromText( $growinglink );
1080 if( is_object( $linkObj ) && $linkObj->exists() ){
1081 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
1084 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1086 $subpages .= '< ';
1088 $subpages .= $getlink;
1093 $growinglink .= '/';
1101 * Returns true if the IP should be shown in the header
1103 function showIPinHeader() {
1104 global $wgShowIPinHeader;
1105 return $wgShowIPinHeader && session_id() != '';
1108 function nameAndLogin() {
1109 global $wgUser, $wgLang, $wgContLang;
1111 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1114 if ( $wgUser->isAnon() ) {
1115 if( $this->showIPinHeader() ) {
1118 $talkLink = $this->link( $wgUser->getTalkPage(),
1119 $wgLang->getNsText( NS_TALK
) );
1121 $ret .= "$name ($talkLink)";
1123 $ret .= wfMsg( 'notloggedin' );
1126 $returnTo = $this->mTitle
->getPrefixedDBkey();
1128 if ( $logoutPage != $returnTo ) {
1129 $query['returnto'] = $returnTo;
1132 $loginlink = $wgUser->isAllowed( 'createaccount' )
1133 ?
'nav-login-createaccount'
1135 $ret .= "\n<br />" . $this->link(
1136 SpecialPage
::getTitleFor( 'Userlogin' ),
1137 wfMsg( $loginlink ), array(), $query
1140 $returnTo = $this->mTitle
->getPrefixedDBkey();
1141 $talkLink = $this->link( $wgUser->getTalkPage(),
1142 $wgLang->getNsText( NS_TALK
) );
1144 $ret .= $this->link( $wgUser->getUserPage(),
1145 htmlspecialchars( $wgUser->getName() ) );
1146 $ret .= " ($talkLink)<br />";
1147 $ret .= $wgLang->pipeList( array(
1149 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1150 array(), array( 'returnto' => $returnTo )
1152 $this->specialLink( 'preferences' ),
1155 $ret = $wgLang->pipeList( array(
1158 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1166 function getSearchLink() {
1167 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1168 return $searchPage->getLocalURL();
1171 function escapeSearchLink() {
1172 return htmlspecialchars( $this->getSearchLink() );
1175 function searchForm() {
1176 global $wgRequest, $wgUseTwoButtonsSearchForm;
1177 $search = $wgRequest->getText( 'search' );
1179 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1180 . $this->escapeSearchLink() . "\">\n"
1181 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1182 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1183 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1185 if( $wgUseTwoButtonsSearchForm )
1186 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1188 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1192 // Ensure unique id's for search boxes made after the first
1193 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1198 function topLinks() {
1202 $this->mainPageLink(),
1203 $this->specialLink( 'recentchanges' )
1206 if ( $wgOut->isArticleRelated() ) {
1207 $s[] = $this->editThisPage();
1208 $s[] = $this->historyLink();
1210 # Many people don't like this dropdown box
1211 #$s[] = $this->specialPagesList();
1213 if( $this->variantLinks() ) {
1214 $s[] = $this->variantLinks();
1217 if( $this->extensionTabLinks() ) {
1218 $s[] = $this->extensionTabLinks();
1221 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1222 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1226 * Compatibility for extensions adding functionality through tabs.
1227 * Eventually these old skins should be replaced with SkinTemplate-based
1231 function extensionTabLinks() {
1235 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1236 foreach( $tabs as $tab ) {
1237 $s[] = Xml
::element( 'a',
1238 array( 'href' => $tab['href'] ),
1245 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1246 $out .= $wgLang->pipeList( $s );
1253 * Language/charset variant links for classic-style skins
1256 function variantLinks() {
1258 /* show links to different language variants */
1259 global $wgDisableLangConversion, $wgLang, $wgContLang;
1260 $variants = $wgContLang->getVariants();
1261 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1262 foreach( $variants as $code ) {
1263 $varname = $wgContLang->getVariantname( $code );
1264 if( $varname == 'disable' )
1266 $s = $wgLang->pipeList( array(
1268 '<a href="' . $this->mTitle
->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1275 function bottomLinks() {
1276 global $wgOut, $wgUser, $wgUseTrackbacks;
1277 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1280 if ( $wgOut->isArticleRelated() ) {
1281 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1282 if ( $wgUser->isLoggedIn() ) {
1283 $element[] = $this->watchThisPage();
1285 $element[] = $this->talkLink();
1286 $element[] = $this->historyLink();
1287 $element[] = $this->whatLinksHere();
1288 $element[] = $this->watchPageLinksLink();
1290 if( $wgUseTrackbacks )
1291 $element[] = $this->trackbackLink();
1293 if ( $this->mTitle
->getNamespace() == NS_USER
1294 ||
$this->mTitle
->getNamespace() == NS_USER_TALK
){
1295 $id = User
::idFromName( $this->mTitle
->getText() );
1296 $ip = User
::isIP( $this->mTitle
->getText() );
1298 if( $id ||
$ip ) { # both anons and non-anons have contri list
1299 $element[] = $this->userContribsLink();
1301 if( $this->showEmailUser( $id ) ) {
1302 $element[] = $this->emailUserLink();
1306 $s = implode( $element, $sep );
1308 if ( $this->mTitle
->getArticleId() ) {
1310 if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1311 if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1312 if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
1314 $s .= "<br />\n" . $this->otherLanguages();
1320 function pageStats() {
1321 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1322 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1324 $oldid = $wgRequest->getVal( 'oldid' );
1325 $diff = $wgRequest->getVal( 'diff' );
1326 if ( ! $wgOut->isArticle() ) { return ''; }
1327 if( !$wgArticle instanceOf Article
) { return ''; }
1328 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1329 if ( 0 == $wgArticle->getID() ) { return ''; }
1332 if ( !$wgDisableCounters ) {
1333 $count = $wgLang->formatNum( $wgArticle->getCount() );
1335 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1339 if( $wgMaxCredits != 0 ){
1340 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1342 $s .= $this->lastModified();
1345 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1346 $dbr = wfGetDB( DB_SLAVE
);
1347 $res = $dbr->select( 'watchlist',
1348 array( 'COUNT(*) AS n' ),
1349 array( 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ), 'wl_namespace' => $this->mTitle
->getNamespace() ),
1352 $x = $dbr->fetchObject( $res );
1354 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1355 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1359 return $s . ' ' . $this->getCopyright();
1362 function getCopyright( $type = 'detect' ) {
1363 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1365 if ( $type == 'detect' ) {
1366 $diff = $wgRequest->getVal( 'diff' );
1367 $isCur = $wgArticle && $wgArticle->isCurrent();
1368 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1375 if ( $type == 'history' ) {
1376 $msg = 'history_copyright';
1382 if( $wgRightsPage ) {
1383 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1384 } elseif( $wgRightsUrl ) {
1385 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1386 } elseif( $wgRightsText ) {
1387 $link = $wgRightsText;
1392 $out .= wfMsgForContent( $msg, $link );
1396 function getCopyrightIcon() {
1397 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1399 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1400 $out = $wgCopyrightIcon;
1401 } else if ( $wgRightsIcon ) {
1402 $icon = htmlspecialchars( $wgRightsIcon );
1403 if ( $wgRightsUrl ) {
1404 $url = htmlspecialchars( $wgRightsUrl );
1405 $out .= '<a href="'.$url.'">';
1407 $text = htmlspecialchars( $wgRightsText );
1408 $out .= "<img src=\"$icon\" alt='$text' />";
1409 if ( $wgRightsUrl ) {
1416 function getPoweredBy() {
1417 global $wgStylePath;
1418 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1419 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1423 function lastModified() {
1424 global $wgLang, $wgArticle;
1425 if( $this->mRevisionId
) {
1426 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1428 $timestamp = $wgArticle->getTimestamp();
1431 $d = $wgLang->date( $timestamp, true );
1432 $t = $wgLang->time( $timestamp, true );
1433 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1437 if ( wfGetLB()->getLaggedSlaveMode() ) {
1438 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1443 function logoText( $align = '' ) {
1444 if ( '' != $align ) {
1445 $a = " align='{$align}'";
1450 $mp = wfMsg( 'mainpage' );
1451 $mptitle = Title
::newMainPage();
1452 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1454 $logourl = $this->getLogo();
1455 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1460 * show a drop-down box of special pages
1462 function specialPagesList() {
1463 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1464 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1465 foreach ( $pages as $name => $page ) {
1466 $pages[$name] = $page->getDescription();
1469 $go = wfMsg( 'go' );
1470 $sp = wfMsg( 'specialpages' );
1471 $spp = $wgContLang->specialPage( 'Specialpages' );
1473 $s = '<form id="specialpages" method="get" ' .
1474 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1475 $s .= "<select name=\"wpDropdown\">\n";
1476 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1479 foreach ( $pages as $name => $desc ) {
1480 $p = $wgContLang->specialPage( $name );
1481 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1483 $s .= "</select>\n";
1484 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1489 function mainPageLink() {
1490 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1494 function copyrightLink() {
1495 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1496 wfMsg( 'copyrightpagename' ) );
1500 private function footerLink ( $desc, $page ) {
1501 // if the link description has been set to "-" in the default language,
1502 if ( wfMsgForContent( $desc ) == '-') {
1503 // then it is disabled, for all languages.
1506 // Otherwise, we display the link for the user, described in their
1507 // language (which may or may not be the same as the default language),
1508 // but we make the link target be the one site-wide page.
1509 return $this->makeKnownLink( wfMsgForContent( $page ),
1510 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1514 function privacyLink() {
1515 return $this->footerLink( 'privacy', 'privacypage' );
1518 function aboutLink() {
1519 return $this->footerLink( 'aboutsite', 'aboutpage' );
1522 function disclaimerLink() {
1523 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1526 function editThisPage() {
1529 if ( !$wgOut->isArticleRelated() ) {
1530 $s = wfMsg( 'protectedpage' );
1532 if( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1533 $t = wfMsg( 'editthispage' );
1534 } elseif( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1535 $t = wfMsg( 'create-this-page' );
1537 $t = wfMsg( 'viewsource' );
1540 $s = $this->makeKnownLinkObj( $this->mTitle
, $t, $this->editUrlOptions() );
1546 * Return URL options for the 'edit page' link.
1547 * This may include an 'oldid' specifier, if the current page view is such.
1552 function editUrlOptions() {
1555 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1556 return 'action=edit&oldid=' . intval( $this->mRevisionId
);
1558 return 'action=edit';
1562 function deleteThisPage() {
1563 global $wgUser, $wgRequest;
1565 $diff = $wgRequest->getVal( 'diff' );
1566 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1567 $t = wfMsg( 'deletethispage' );
1569 $s = $this->makeKnownLinkObj( $this->mTitle
, $t, 'action=delete' );
1576 function protectThisPage() {
1577 global $wgUser, $wgRequest;
1579 $diff = $wgRequest->getVal( 'diff' );
1580 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1581 if ( $this->mTitle
->isProtected() ) {
1582 $t = wfMsg( 'unprotectthispage' );
1583 $q = 'action=unprotect';
1585 $t = wfMsg( 'protectthispage' );
1586 $q = 'action=protect';
1588 $s = $this->makeKnownLinkObj( $this->mTitle
, $t, $q );
1595 function watchThisPage() {
1597 ++
$this->mWatchLinkNum
;
1599 if ( $wgOut->isArticleRelated() ) {
1600 if ( $this->mTitle
->userIsWatching() ) {
1601 $t = wfMsg( 'unwatchthispage' );
1602 $q = 'action=unwatch';
1603 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1605 $t = wfMsg( 'watchthispage' );
1606 $q = 'action=watch';
1607 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1609 $s = $this->makeKnownLinkObj( $this->mTitle
, $t, $q, '', '', " id=\"$id\"" );
1611 $s = wfMsg( 'notanarticle' );
1616 function moveThisPage() {
1617 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1618 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1619 wfMsg( 'movethispage' ), 'target=' . $this->mTitle
->getPrefixedURL() );
1621 // no message if page is protected - would be redundant
1626 function historyLink() {
1627 return $this->link( $this->mTitle
, wfMsg( 'history' ),
1628 array( 'rel' => 'archives' ), array( 'action' => 'history' ) );
1631 function whatLinksHere() {
1632 return $this->makeKnownLinkObj(
1633 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1634 wfMsg( 'whatlinkshere' ) );
1637 function userContribsLink() {
1638 return $this->makeKnownLinkObj(
1639 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1640 wfMsg( 'contributions' ) );
1643 function showEmailUser( $id ) {
1645 $targetUser = User
::newFromId( $id );
1646 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1647 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1650 function emailUserLink() {
1651 return $this->makeKnownLinkObj(
1652 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1653 wfMsg( 'emailuser' ) );
1656 function watchPageLinksLink() {
1658 if ( ! $wgOut->isArticleRelated() ) {
1659 return '(' . wfMsg( 'notanarticle' ) . ')';
1661 return $this->makeKnownLinkObj(
1662 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1663 wfMsg( 'recentchangeslinked' ) );
1667 function trackbackLink() {
1668 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1669 . wfMsg( 'trackbacklink' ) . '</a>';
1672 function otherLanguages() {
1673 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1675 if ( $wgHideInterlanguageLinks ) {
1679 $a = $wgOut->getLanguageLinks();
1680 if ( 0 == count( $a ) ) {
1684 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1686 if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
1687 foreach( $a as $l ) {
1689 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1693 $nt = Title
::newFromText( $l );
1694 $url = $nt->escapeFullURL();
1695 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1697 if ( '' == $text ) { $text = $l; }
1698 $style = $this->getExternalLinkAttributes( $l, $text );
1699 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1701 if( $wgContLang->isRTL() ) $s .= '</span>';
1705 function talkLink() {
1706 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1707 # No discussion links for special pages
1711 $linkOptions = array();
1713 if( $this->mTitle
->isTalkPage() ) {
1714 $link = $this->mTitle
->getSubjectPage();
1715 switch( $link->getNamespace() ) {
1717 $text = wfMsg( 'articlepage' );
1720 $text = wfMsg( 'userpage' );
1723 $text = wfMsg( 'projectpage' );
1726 $text = wfMsg( 'imagepage' );
1727 # Make link known if image exists, even if the desc. page doesn't.
1728 if( wfFindFile( $link ) )
1729 $linkOptions[] = 'known';
1732 $text = wfMsg( 'mediawikipage' );
1735 $text = wfMsg( 'templatepage' );
1738 $text = wfMsg( 'viewhelppage' );
1741 $text = wfMsg( 'categorypage' );
1744 $text = wfMsg( 'articlepage' );
1747 $link = $this->mTitle
->getTalkPage();
1748 $text = wfMsg( 'talkpage' );
1751 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1756 function commentLink() {
1759 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1763 # __NEWSECTIONLINK___ changes behaviour here
1764 # If it's present, the link points to this page, otherwise
1765 # it points to the talk page
1766 if( $this->mTitle
->isTalkPage() ) {
1767 $title = $this->mTitle
;
1768 } elseif( $wgOut->showNewSectionLink() ) {
1769 $title = $this->mTitle
;
1771 $title = $this->mTitle
->getTalkPage();
1774 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1777 /* these are used extensively in SkinTemplate, but also some other places */
1778 static function makeMainPageUrl( $urlaction = '' ) {
1779 $title = Title
::newMainPage();
1780 self
::checkTitle( $title, '' );
1781 return $title->getLocalURL( $urlaction );
1784 static function makeSpecialUrl( $name, $urlaction = '' ) {
1785 $title = SpecialPage
::getTitleFor( $name );
1786 return $title->getLocalURL( $urlaction );
1789 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1790 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1791 return $title->getLocalURL( $urlaction );
1794 static function makeI18nUrl( $name, $urlaction = '' ) {
1795 $title = Title
::newFromText( wfMsgForContent( $name ) );
1796 self
::checkTitle( $title, $name );
1797 return $title->getLocalURL( $urlaction );
1800 static function makeUrl( $name, $urlaction = '' ) {
1801 $title = Title
::newFromText( $name );
1802 self
::checkTitle( $title, $name );
1803 return $title->getLocalURL( $urlaction );
1806 # If url string starts with http, consider as external URL, else
1808 static function makeInternalOrExternalUrl( $name ) {
1809 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1812 return self
::makeUrl( $name );
1816 # this can be passed the NS number as defined in Language.php
1817 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1818 $title = Title
::makeTitleSafe( $namespace, $name );
1819 self
::checkTitle( $title, $name );
1820 return $title->getLocalURL( $urlaction );
1823 /* these return an array with the 'href' and boolean 'exists' */
1824 static function makeUrlDetails( $name, $urlaction = '' ) {
1825 $title = Title
::newFromText( $name );
1826 self
::checkTitle( $title, $name );
1828 'href' => $title->getLocalURL( $urlaction ),
1829 'exists' => $title->getArticleID() != 0 ?
true : false
1834 * Make URL details where the article exists (or at least it's convenient to think so)
1836 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1837 $title = Title
::newFromText( $name );
1838 self
::checkTitle( $title, $name );
1840 'href' => $title->getLocalURL( $urlaction ),
1845 # make sure we have some title to operate on
1846 static function checkTitle( &$title, $name ) {
1847 if( !is_object( $title ) ) {
1848 $title = Title
::newFromText( $name );
1849 if( !is_object( $title ) ) {
1850 $title = Title
::newFromText( '--error: link target missing--' );
1856 * Build an array that represents the sidebar(s), the navigation bar among them
1860 function buildSidebar() {
1861 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1863 wfProfileIn( __METHOD__
);
1865 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
1867 if ( $wgEnableSidebarCache ) {
1868 $cachedsidebar = $parserMemc->get( $key );
1869 if ( $cachedsidebar ) {
1870 wfProfileOut( __METHOD__
);
1871 return $cachedsidebar;
1876 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1878 foreach( $lines as $line ) {
1879 if( strpos( $line, '*' ) !== 0 )
1881 if( strpos( $line, '**') !== 0 ) {
1882 $heading = trim( $line, '* ' );
1883 if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
1885 if( strpos( $line, '|' ) !== false ) { // sanity check
1886 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
1887 $link = wfMsgForContent( $line[0] );
1891 $text = wfMsgExt( $line[1], 'parsemag' );
1892 if( wfEmptyMsg( $line[1], $text ) )
1894 if( wfEmptyMsg( $line[0], $link ) )
1897 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1900 $title = Title
::newFromText( $link );
1902 $title = $title->fixSpecialName();
1903 $href = $title->getLocalURL();
1905 $href = 'INVALID-TITLE';
1909 $bar[$heading][] = array(
1912 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
1915 } else { continue; }
1918 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
1919 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1920 wfProfileOut( __METHOD__
);