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 protected $mTitle = null;
29 /** Constructor, call parent constructor */
30 function Skin() { parent
::__construct(); }
33 * Fetch the set of available skins.
34 * @return array of strings
37 static function getSkinNames() {
38 global $wgValidSkinNames;
39 static $skinsInitialised = false;
40 if ( !$skinsInitialised ) {
41 # Get a list of available skins
42 # Build using the regular expression '^(.*).php$'
43 # Array keys are all lower case, array value keep the case used by filename
45 wfProfileIn( __METHOD__
. '-init' );
46 global $wgStyleDirectory;
47 $skinDir = dir( $wgStyleDirectory );
49 # while code from www.php.net
50 while( false !== ( $file = $skinDir->read() ) ) {
51 // Skip non-PHP files, hidden files, and '.dep' includes
53 if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
55 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
59 $skinsInitialised = true;
60 wfProfileOut( __METHOD__
. '-init' );
62 return $wgValidSkinNames;
66 * Fetch the list of usable skins in regards to $wgSkipSkins.
67 * Useful for Special:Preferences and other places where you
68 * only want to show skins users _can_ use.
69 * @return array of strings
71 public static function getUsableSkins() {
73 $usableSkins = self
::getSkinNames();
74 foreach ( $wgSkipSkins as $skip ) {
75 unset( $usableSkins[$skip] );
81 * Normalize a skin preference value to a form that can be loaded.
82 * If a skin can't be found, it will fall back to the configured
83 * default (or the old 'Classic' skin if that's broken).
88 static function normalizeKey( $key ) {
89 global $wgDefaultSkin;
90 $skinNames = Skin
::getSkinNames();
93 // Don't return the default immediately;
94 // in a misconfiguration we need to fall back.
95 $key = $wgDefaultSkin;
98 if( isset( $skinNames[$key] ) ) {
102 // Older versions of the software used a numeric setting
103 // in the user preferences.
107 2 => 'cologneblue' );
109 if( isset( $fallback[$key] ) ){
110 $key = $fallback[$key];
113 if( isset( $skinNames[$key] ) ) {
121 * Factory method for loading a skin of a given type
122 * @param string $key 'monobook', 'standard', etc
126 static function &newFromKey( $key ) {
127 global $wgStyleDirectory;
129 $key = Skin
::normalizeKey( $key );
131 $skinNames = Skin
::getSkinNames();
132 $skinName = $skinNames[$key];
133 $className = 'Skin'.ucfirst($key);
135 # Grab the skin class and initialise it.
136 if ( !class_exists( $className ) ) {
137 // Preload base classes to work around APC/PHP5 bug
138 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
139 if( file_exists( $deps ) ) include_once( $deps );
140 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
142 # Check if we got if not failback to default skin
143 if( !class_exists( $className ) ) {
144 # DO NOT die if the class isn't found. This breaks maintenance
145 # scripts and can cause a user account to be unrecoverable
146 # except by SQL manipulation if a previously valid skin name
147 # is no longer valid.
148 wfDebug( "Skin class does not exist: $className\n" );
149 $className = 'SkinMonobook';
150 require_once( "{$wgStyleDirectory}/MonoBook.php" );
153 $skin = new $className;
157 /** @return string path to the skin stylesheet */
158 function getStylesheet() {
159 return 'common/wikistandard.css';
162 /** @return string skin name */
163 public function getSkinName() {
164 return $this->skinname
;
167 function qbSetting() {
168 global $wgOut, $wgUser;
170 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
171 $q = $wgUser->getOption( 'quickbar', 0 );
175 function initPage( OutputPage
$out ) {
176 global $wgFavicon, $wgAppleTouchIcon;
178 wfProfileIn( __METHOD__
);
180 # Generally the order of the favicon and apple-touch-icon links
181 # should not matter, but Konqueror (3.5.9 at least) incorrectly
182 # uses whichever one appears later in the HTML source. Make sure
183 # apple-touch-icon is specified first to avoid this.
184 if( false !== $wgAppleTouchIcon ) {
185 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
188 if( false !== $wgFavicon ) {
189 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
192 # OpenSearch description link
193 $out->addLink( array(
195 'type' => 'application/opensearchdescription+xml',
196 'href' => wfScript( 'opensearch_desc' ),
197 'title' => wfMsgForContent( 'opensearch-desc' ),
200 $this->addMetadataLinks( $out );
202 $this->mRevisionId
= $out->mRevisionId
;
204 $this->preloadExistence();
206 wfProfileOut( __METHOD__
);
210 * Preload the existence of three commonly-requested pages in a single query
212 function preloadExistence() {
216 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
219 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
221 } elseif ( $this->mTitle
->isTalkPage() ) {
222 $titles[] = $this->mTitle
->getSubjectPage();
224 $titles[] = $this->mTitle
->getTalkPage();
227 $lb = new LinkBatch( $titles );
231 function addMetadataLinks( OutputPage
$out ) {
232 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
233 global $wgRightsPage, $wgRightsUrl;
235 if( $out->isArticleRelated() ) {
236 # note: buggy CC software only reads first "meta" link
237 if( $wgEnableCreativeCommonsRdf ) {
238 $out->addMetadataLink( array(
239 'title' => 'Creative Commons',
240 'type' => 'application/rdf+xml',
241 'href' => $this->mTitle
->getLocalURL( 'action=creativecommons' ) )
244 if( $wgEnableDublinCoreRdf ) {
245 $out->addMetadataLink( array(
246 'title' => 'Dublin Core',
247 'type' => 'application/rdf+xml',
248 'href' => $this->mTitle
->getLocalURL( 'action=dublincore' ) )
253 if( $wgRightsPage ) {
254 $copy = Title
::newFromText( $wgRightsPage );
256 $copyright = $copy->getLocalURL();
259 if( !$copyright && $wgRightsUrl ) {
260 $copyright = $wgRightsUrl;
263 $out->addLink( array(
264 'rel' => 'copyright',
265 'href' => $copyright )
271 * Set some local variables
273 protected function setMembers(){
275 $this->mUser
= $wgUser;
276 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
277 $this->usercss
= false;
282 * @param Title $t The title to use
284 public function setTitle( $t ) {
289 public function getTitle() {
290 return $this->mTitle
;
293 function outputPage( OutputPage
$out ) {
294 global $wgDebugComments;
295 wfProfileIn( __METHOD__
);
298 $this->initPage( $out );
300 // See self::afterContentHook() for documentation
301 $afterContent = $this->afterContentHook();
303 $out->out( $out->headElement( $this ) );
305 $out->out( "\n<body" );
306 $ops = $this->getBodyOptions();
307 foreach ( $ops as $name => $val ) {
308 $out->out( " $name='$val'" );
311 if ( $wgDebugComments ) {
312 $out->out( "<!-- Wiki debugging output:\n" .
313 $out->mDebugtext
. "-->\n" );
316 $out->out( $this->beforeContent() );
318 $out->out( $out->mBodytext
. "\n" );
320 $out->out( $this->afterContent() );
322 $out->out( $afterContent );
324 $out->out( $this->bottomScripts() );
326 $out->out( wfReportTime() );
328 $out->out( "\n</body></html>" );
329 wfProfileOut( __METHOD__
);
332 static function makeVariablesScript( $data ) {
333 global $wgJsMimeType;
335 $r = array( "<script type=\"$wgJsMimeType\">/*<![CDATA[*/" );
336 foreach ( $data as $name => $value ) {
337 $encValue = Xml
::encodeJsVar( $value );
338 $r[] = "var $name = $encValue;";
340 $r[] = "/*]]>*/</script>\n";
342 return implode( "\n\t\t", $r );
346 * Make a <script> tag containing global variables
347 * @param array $data Associative array containing one element:
348 * skinname => the skin name
349 * The odd calling convention is for backwards compatibility
350 * @TODO @FIXME Make this not depend on $wgTitle!
352 static function makeGlobalVariablesScript( $data ) {
353 global $wgScript, $wgTitle, $wgStylePath, $wgUser;
354 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
355 global $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
356 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
357 global $wgUseAjax, $wgAjaxWatch;
358 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
359 global $wgRestrictionTypes, $wgLivePreview;
360 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
362 $ns = $wgTitle->getNamespace();
363 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
364 $separatorTransTable = $wgContLang->separatorTransformTable();
365 $separatorTransTable = $separatorTransTable ?
$separatorTransTable : array();
366 $compactSeparatorTransTable = array(
367 implode( "\t", array_keys( $separatorTransTable ) ),
368 implode( "\t", $separatorTransTable ),
370 $digitTransTable = $wgContLang->digitTransformTable();
371 $digitTransTable = $digitTransTable ?
$digitTransTable : array();
372 $compactDigitTransTable = array(
373 implode( "\t", array_keys( $digitTransTable ) ),
374 implode( "\t", $digitTransTable ),
378 'skin' => $data['skinname'],
379 'stylepath' => $wgStylePath,
380 'wgArticlePath' => $wgArticlePath,
381 'wgScriptPath' => $wgScriptPath,
382 'wgScript' => $wgScript,
383 'wgVariantArticlePath' => $wgVariantArticlePath,
384 'wgActionPaths' => (object)$wgActionPaths,
385 'wgServer' => $wgServer,
386 'wgCanonicalNamespace' => $nsname,
387 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
388 'wgNamespaceNumber' => $wgTitle->getNamespace(),
389 'wgPageName' => $wgTitle->getPrefixedDBKey(),
390 'wgTitle' => $wgTitle->getText(),
391 'wgAction' => $wgRequest->getText( 'action', 'view' ),
392 'wgArticleId' => $wgTitle->getArticleId(),
393 'wgIsArticle' => $wgOut->isArticle(),
394 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
395 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
396 'wgUserLanguage' => $wgLang->getCode(),
397 'wgContentLanguage' => $wgContLang->getCode(),
398 'wgBreakFrames' => $wgBreakFrames,
399 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
400 'wgVersion' => $wgVersion,
401 'wgEnableAPI' => $wgEnableAPI,
402 'wgEnableWriteAPI' => $wgEnableWriteAPI,
403 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
404 'wgDigitTransformTable' => $compactDigitTransTable,
407 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
408 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
409 $vars['wgDBname'] = $wgDBname;
410 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
411 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
414 foreach( $wgRestrictionTypes as $type )
415 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
417 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
418 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
419 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
420 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
421 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
424 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
425 $msgs = (object)array();
426 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
427 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
429 $vars['wgAjaxWatch'] = $msgs;
432 // Allow extensions to add their custom variables to the global JS variables
433 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
435 return self
::makeVariablesScript( $vars );
438 function getHeadScripts( $allowUserJs ) {
439 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
441 $vars = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
443 $r = array( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>" );
446 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
447 $r[] = "<script type=\"$wgJsMimeType\" src=\"".
448 htmlspecialchars( self
::makeUrl( '-',
449 "action=raw$jsCache&gen=js&useskin=" .
450 urlencode( $this->getSkinName() ) ) ) .
451 "\"><!-- site js --></script>";
453 if( $allowUserJs && $wgUser->isLoggedIn() ) {
454 $userpage = $wgUser->getUserPage();
455 $userjs = htmlspecialchars( self
::makeUrl(
456 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
457 'action=raw&ctype='.$wgJsMimeType ) );
458 $r[] = '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>";
460 return $vars . "\t\t" . implode ( "\n\t\t", $r );
464 * To make it harder for someone to slip a user a fake
465 * user-JavaScript or user-CSS preview, a random token
466 * is associated with the login session. If it's not
467 * passed back with the preview request, we won't render
470 * @param string $action
474 function userCanPreview( $action ) {
475 global $wgRequest, $wgUser;
477 if( $action != 'submit' )
479 if( !$wgRequest->wasPosted() )
481 if( !$this->mTitle
->userCanEditCssJsSubpage() )
483 return $wgUser->matchEditToken(
484 $wgRequest->getVal( 'wpEditToken' ) );
488 * generated JavaScript action=raw&gen=js
489 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
490 * nated together. For some bizarre reason, it does *not* return any
491 * custom user JS from subpages. Huh?
493 * There's absolutely no reason to have separate Monobook/Common JSes.
494 * Any JS that cares can just check the skin variable generated at the
495 * top. For now Monobook.js will be maintained, but it should be consi-
500 public function generateUserJs() {
503 wfProfileIn( __METHOD__
);
505 $s = "/* generated javascript */\n";
506 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
507 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
508 $s .= "\n\n/* MediaWiki:Common.js */\n";
509 $commonJs = wfMsgForContent( 'common.js' );
510 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
514 $s .= "\n\n/* MediaWiki:".ucfirst( $this->getSkinName() ).".js */\n";
515 // avoid inclusion of non defined user JavaScript (with custom skins only)
516 // by checking for default message content
517 $msgKey = ucfirst( $this->getSkinName() ).'.js';
518 $userJS = wfMsgForContent( $msgKey );
519 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
523 wfProfileOut( __METHOD__
);
528 * Generate user stylesheet for action=raw&gen=css
530 public function generateUserStylesheet() {
531 wfProfileIn( __METHOD__
);
532 $s = "/* generated user stylesheet */\n" .
533 $this->reallyGenerateUserStylesheet();
534 wfProfileOut( __METHOD__
);
539 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
541 protected function reallyGenerateUserStylesheet(){
544 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
545 $underline = $undopt ?
'underline' : 'none';
546 $s .= "a { text-decoration: $underline; }\n";
548 if( $wgUser->getOption( 'highlightbroken' ) ) {
549 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
552 a.new, #quickbar a.new,
553 a.stub, #quickbar a.stub {
556 a.new:after, #quickbar a.new:after {
560 a.stub:after, #quickbar a.stub:after {
566 if( $wgUser->getOption( 'justify' ) ) {
567 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
569 if( !$wgUser->getOption( 'showtoc' ) ) {
570 $s .= "#toc { display: none; }\n";
572 if( !$wgUser->getOption( 'editsection' ) ) {
573 $s .= ".editsection { display: none; }\n";
581 function setupUserCss( OutputPage
$out ) {
582 global $wgRequest, $wgContLang, $wgUser;
583 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
585 wfProfileIn( __METHOD__
);
587 $this->setupSkinUserCss( $out );
591 'maxage' => $wgSquidMaxage,
594 // Add any extension CSS
595 foreach( $out->getExtStyle() as $tag ) {
596 $out->addStyle( $tag['href'] );
599 // If we use the site's dynamic CSS, throw that in, too
600 // Per-site custom styles
601 if( $wgUseSiteCss ) {
602 global $wgHandheldStyle;
603 $query = wfArrayToCGI( array(
604 'usemsgcache' => 'yes',
605 'ctype' => 'text/css',
606 'smaxage' => $wgSquidMaxage
608 # Site settings must override extension css! (bug 15025)
609 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
610 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
611 if( $wgHandheldStyle ) {
612 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
614 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
617 if( $wgUser->isLoggedIn() ) {
618 // Ensure that logged-in users' generated CSS isn't clobbered
619 // by anons' publicly cacheable generated CSS.
620 $siteargs['smaxage'] = '0';
621 $siteargs['ts'] = $wgUser->mTouched
;
623 // Per-user styles based on preferences
624 $siteargs['gen'] = 'css';
625 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
626 $siteargs['useskin'] = $us;
628 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
630 // Per-user custom style pages
631 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
632 $action = $wgRequest->getVal( 'action' );
633 # If we're previewing the CSS page, use it
634 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
635 $previewCss = $wgRequest->getText( 'wpTextbox1' );
636 // @FIXME: properly escape the cdata!
637 $this->usercss
= "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
639 $out->addStyle( self
::makeUrl( $this->userpage
. '/' . $this->getSkinName() .'.css',
640 'action=raw&ctype=text/css' ) );
644 wfProfileOut( __METHOD__
);
648 * Add skin specific stylesheets
649 * @param $out OutputPage
651 function setupSkinUserCss( OutputPage
$out ) {
652 $out->addStyle( 'common/shared.css' );
653 $out->addStyle( 'common/oldshared.css' );
654 $out->addStyle( $this->getStylesheet() );
655 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
658 function getBodyOptions() {
659 global $wgUser, $wgOut, $wgRequest, $wgContLang;
661 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
663 if ( 0 != $this->mTitle
->getNamespace() ) {
664 $a = array( 'bgcolor' => '#ffffec' );
666 else $a = array( 'bgcolor' => '#FFFFFF' );
667 if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
668 $this->mTitle
->quickUserCan( 'edit' ) ) {
669 $s = $this->mTitle
->getFullURL( $this->editUrlOptions() );
670 $s = 'document.location = "' .Xml
::escapeJsString( $s ) .'";';
671 $a +
= array( 'ondblclick' => $s );
673 $a['onload'] = $wgOut->getOnloadHandler();
676 ' '.( $wgContLang->isRTL() ?
'rtl' : 'ltr' ).
677 ' '.$this->getPageClasses( $this->mTitle
) .
678 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName() );
682 function getPageClasses( $title ) {
683 $numeric = 'ns-'.$title->getNamespace();
684 if( $title->getNamespace() == NS_SPECIAL
) {
685 $type = 'ns-special';
686 } elseif( $title->isTalkPage() ) {
689 $type = 'ns-subject';
691 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
692 return "$numeric $type $name";
704 * This will be called immediately after the <body> tag. Split into
705 * two functions to make it easier to subclass.
707 function beforeContent() {
708 return $this->doBeforeContent();
711 function doBeforeContent() {
713 wfProfileIn( __METHOD__
);
716 $qb = $this->qbSetting();
718 if( $langlinks = $this->otherLanguages() ) {
724 $borderhack = 'class="top"';
727 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
728 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
730 $shove = ( $qb != 0 );
731 $left = ( $qb == 1 ||
$qb == 3 );
732 if( $wgContLang->isRTL() ) $left = !$left;
735 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
736 $this->logoText() . '</td>';
738 $s .= $this->getQuickbarCompensator( $rows );
740 $l = $wgContLang->isRTL() ?
'right' : 'left';
741 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
743 $s .= $this->topLinks();
744 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
746 $r = $wgContLang->isRTL() ?
'left' : 'right';
747 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
748 $s .= $this->nameAndLogin();
749 $s .= "\n<br />" . $this->searchForm() . "</td>";
752 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
755 if ( $shove && !$left ) { # Right
756 $s .= $this->getQuickbarCompensator( $rows );
758 $s .= "</tr>\n</table>\n</div>\n";
759 $s .= "\n<div id='article'>\n";
761 $notice = wfGetSiteNotice();
763 $s .= "\n<div id='siteNotice'>$notice</div>\n";
765 $s .= $this->pageTitle();
766 $s .= $this->pageSubtitle();
767 $s .= $this->getCategories();
768 wfProfileOut( __METHOD__
);
773 function getCategoryLinks() {
774 global $wgOut, $wgUseCategoryBrowser;
775 global $wgContLang, $wgUser;
777 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
780 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
782 // Use Unicode bidi embedding override characters,
783 // to make sure links don't smash each other up in ugly ways.
784 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
785 $embed = "<span dir='$dir'>";
788 $allCats = $wgOut->getCategoryLinks();
790 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
791 if ( !empty( $allCats['normal'] ) ) {
792 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
794 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
795 $s .= '<div id="mw-normal-catlinks">' .
796 $this->link( Title
::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
797 . $colon . $t . '</div>';
801 if ( isset( $allCats['hidden'] ) ) {
802 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
803 $class ='mw-hidden-cats-user-shown';
804 } elseif ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
805 $class = 'mw-hidden-cats-ns-shown';
807 $class = 'mw-hidden-cats-hidden';
809 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
810 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
811 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
815 # optional 'dmoz-like' category browser. Will be shown under the list
816 # of categories an article belong to
817 if( $wgUseCategoryBrowser ){
818 $s .= '<br /><hr />';
820 # get a big array of the parents tree
821 $parenttree = $this->mTitle
->getParentCategoryTree();
822 # Skin object passed by reference cause it can not be
823 # accessed under the method subfunction drawCategoryBrowser
824 $tempout = explode( "\n", Skin
::drawCategoryBrowser( $parenttree, $this ) );
825 # Clean out bogus first entry and sort them
826 unset( $tempout[0] );
828 # Output one per line
829 $s .= implode( "<br />\n", $tempout );
836 * Render the array as a serie of links.
837 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
838 * @param &skin Object: skin passed by reference
839 * @return String separated by >, terminate with "\n"
841 function drawCategoryBrowser( $tree, &$skin ){
843 foreach( $tree as $element => $parent ) {
844 if( empty( $parent ) ) {
845 # element start a new list
848 # grab the others elements
849 $return .= Skin
::drawCategoryBrowser( $parent, $skin ) . ' > ';
851 # add our current element to the list
852 $eltitle = Title
::newFromText( $element );
853 $return .= $skin->link( $eltitle, $eltitle->getText() );
858 function getCategories() {
859 $catlinks=$this->getCategoryLinks();
861 $classes = 'catlinks';
863 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
864 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
865 $classes .= ' catlinks-allhidden';
868 if( !empty( $catlinks ) ){
869 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
873 function getQuickbarCompensator( $rows = 1 ) {
874 return "<td width='152' rowspan='{$rows}'> </td>";
878 * This runs a hook to allow extensions placing their stuff after content
879 * and article metadata (e.g. categories).
880 * Note: This function has nothing to do with afterContent().
882 * This hook is placed here in order to allow using the same hook for all
883 * skins, both the SkinTemplate based ones and the older ones, which directly
884 * use this class to get their data.
886 * The output of this function gets processed in SkinTemplate::outputPage() for
887 * the SkinTemplate based skins, all other skins should directly echo it.
889 * Returns an empty string by default, if not changed by any hook function.
891 protected function afterContentHook() {
894 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
895 // adding just some spaces shouldn't toggle the output
896 // of the whole <div/>, so we use trim() here
897 if( trim( $data ) != '' ){
898 // Doing this here instead of in the skins to
899 // ensure that the div has the same ID in all
901 $data = "<div id='mw-data-after-content'>\n" .
906 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
913 * Generate debug data HTML for displaying at the bottom of the main content
915 * @return String HTML containing debug data, if enabled (otherwise empty).
917 protected function generateDebugHTML() {
918 global $wgShowDebug, $wgOut;
919 if ( $wgShowDebug ) {
920 $listInternals = str_replace( "\n", "</li>\n<li>", htmlspecialchars( $wgOut->mDebugtext
) );
921 return "\n<hr>\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\"><li>" .
922 $listInternals . "</li></ul>\n";
928 * This gets called shortly before the </body> tag.
929 * @return String HTML to be put before </body>
931 function afterContent() {
932 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
933 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
937 * This gets called shortly before the </body> tag.
938 * @return String HTML-wrapped JS code to be put before </body>
940 function bottomScripts() {
941 global $wgJsMimeType;
942 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
943 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
944 return $bottomScriptText;
947 /** @return string Retrievied from HTML text */
948 function printSource() {
949 $url = htmlspecialchars( $this->mTitle
->getFullURL() );
950 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
953 function printFooter() {
954 return "<p>" . $this->printSource() .
955 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
958 /** overloaded by derived classes */
959 function doAfterContent() { return '</div></div>'; }
961 function pageTitleLinks() {
962 global $wgOut, $wgUser, $wgRequest, $wgLang;
964 $oldid = $wgRequest->getVal( 'oldid' );
965 $diff = $wgRequest->getVal( 'diff' );
966 $action = $wgRequest->getText( 'action' );
968 $s[] = $this->printableLink();
969 $disclaimer = $this->disclaimerLink(); # may be empty
973 $privacy = $this->privacyLink(); # may be empty too
978 if ( $wgOut->isArticleRelated() ) {
979 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
980 $name = $this->mTitle
->getDBkey();
981 $image = wfFindFile( $this->mTitle
);
983 $link = htmlspecialchars( $image->getURL() );
984 $style = $this->getInternalLinkAttributes( $link, $name );
985 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
989 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
990 $s[] .= $this->makeKnownLinkObj( $this->mTitle
,
991 wfMsg( 'currentrev' ) );
994 if ( $wgUser->getNewtalk() ) {
995 # do not show "You have new messages" text when we are viewing our
997 if( !$this->mTitle
->equals( $wgUser->getTalkPage() ) ) {
998 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
999 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
1000 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1002 $wgOut->setSquidMaxage( 0 );
1003 $wgOut->enableClientCache( false );
1007 $undelete = $this->getUndeleteLink();
1008 if( !empty( $undelete ) ) {
1011 return $wgLang->pipeList( $s );
1014 function getUndeleteLink() {
1015 global $wgUser, $wgContLang, $wgLang, $action;
1016 if( $wgUser->isAllowed( 'deletedhistory' ) &&
1017 ( ( $this->mTitle
->getArticleId() == 0 ) ||
( $action == 'history' ) ) &&
1018 ( $n = $this->mTitle
->isDeleted() ) ){
1019 if ( $wgUser->isAllowed( 'undelete' ) ) {
1020 $msg = 'thisisdeleted';
1022 $msg = 'viewdeleted';
1025 $this->makeKnownLinkObj(
1026 SpecialPage
::getTitleFor( 'Undelete', $this->mTitle
->getPrefixedDBkey() ),
1027 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
1032 function printableLink() {
1033 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1035 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1037 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1038 if( $wgOut->isSyndicated() ) {
1039 foreach( $wgFeedClasses as $format => $class ) {
1040 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1041 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1042 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1045 return $wgLang->pipeList( $s );
1048 function pageTitle() {
1050 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1054 function pageSubtitle() {
1057 $sub = $wgOut->getSubtitle();
1059 global $wgExtraSubtitle;
1060 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1062 $subpages = $this->subPageSubtitle();
1063 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
1064 $s = "<p class='subtitle'>{$sub}</p>\n";
1068 function subPageSubtitle() {
1070 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
1074 if( $wgOut->isArticle() && MWNamespace
::hasSubpages( $this->mTitle
->getNamespace() ) ) {
1075 $ptext = $this->mTitle
->getPrefixedText();
1076 if( preg_match( '/\//', $ptext ) ) {
1077 $links = explode( '/', $ptext );
1078 array_pop( $links );
1082 foreach( $links as $link ) {
1083 $growinglink .= $link;
1085 $linkObj = Title
::newFromText( $growinglink );
1086 if( is_object( $linkObj ) && $linkObj->exists() ){
1087 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
1090 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1092 $subpages .= '< ';
1094 $subpages .= $getlink;
1099 $growinglink .= '/';
1107 * Returns true if the IP should be shown in the header
1109 function showIPinHeader() {
1110 global $wgShowIPinHeader;
1111 return $wgShowIPinHeader && session_id() != '';
1114 function nameAndLogin() {
1115 global $wgUser, $wgLang, $wgContLang;
1117 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1120 if ( $wgUser->isAnon() ) {
1121 if( $this->showIPinHeader() ) {
1124 $talkLink = $this->link( $wgUser->getTalkPage(),
1125 $wgLang->getNsText( NS_TALK
) );
1127 $ret .= "$name ($talkLink)";
1129 $ret .= wfMsg( 'notloggedin' );
1132 $returnTo = $this->mTitle
->getPrefixedDBkey();
1134 if ( $logoutPage != $returnTo ) {
1135 $query['returnto'] = $returnTo;
1138 $loginlink = $wgUser->isAllowed( 'createaccount' )
1139 ?
'nav-login-createaccount'
1141 $ret .= "\n<br />" . $this->link(
1142 SpecialPage
::getTitleFor( 'Userlogin' ),
1143 wfMsg( $loginlink ), array(), $query
1146 $returnTo = $this->mTitle
->getPrefixedDBkey();
1147 $talkLink = $this->link( $wgUser->getTalkPage(),
1148 $wgLang->getNsText( NS_TALK
) );
1150 $ret .= $this->link( $wgUser->getUserPage(),
1151 htmlspecialchars( $wgUser->getName() ) );
1152 $ret .= " ($talkLink)<br />";
1153 $ret .= $wgLang->pipeList( array(
1155 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1156 array(), array( 'returnto' => $returnTo )
1158 $this->specialLink( 'preferences' ),
1161 $ret = $wgLang->pipeList( array(
1164 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1172 function getSearchLink() {
1173 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1174 return $searchPage->getLocalURL();
1177 function escapeSearchLink() {
1178 return htmlspecialchars( $this->getSearchLink() );
1181 function searchForm() {
1182 global $wgRequest, $wgUseTwoButtonsSearchForm;
1183 $search = $wgRequest->getText( 'search' );
1185 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1186 . $this->escapeSearchLink() . "\">\n"
1187 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1188 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1189 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1191 if( $wgUseTwoButtonsSearchForm )
1192 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1194 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1198 // Ensure unique id's for search boxes made after the first
1199 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1204 function topLinks() {
1208 $this->mainPageLink(),
1209 $this->specialLink( 'recentchanges' )
1212 if ( $wgOut->isArticleRelated() ) {
1213 $s[] = $this->editThisPage();
1214 $s[] = $this->historyLink();
1216 # Many people don't like this dropdown box
1217 #$s[] = $this->specialPagesList();
1219 if( $this->variantLinks() ) {
1220 $s[] = $this->variantLinks();
1223 if( $this->extensionTabLinks() ) {
1224 $s[] = $this->extensionTabLinks();
1227 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1228 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1232 * Compatibility for extensions adding functionality through tabs.
1233 * Eventually these old skins should be replaced with SkinTemplate-based
1237 function extensionTabLinks() {
1241 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1242 foreach( $tabs as $tab ) {
1243 $s[] = Xml
::element( 'a',
1244 array( 'href' => $tab['href'] ),
1251 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1252 $out .= $wgLang->pipeList( $s );
1259 * Language/charset variant links for classic-style skins
1262 function variantLinks() {
1264 /* show links to different language variants */
1265 global $wgDisableLangConversion, $wgLang, $wgContLang;
1266 $variants = $wgContLang->getVariants();
1267 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1268 foreach( $variants as $code ) {
1269 $varname = $wgContLang->getVariantname( $code );
1270 if( $varname == 'disable' )
1272 $s = $wgLang->pipeList( array(
1274 '<a href="' . $this->mTitle
->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1281 function bottomLinks() {
1282 global $wgOut, $wgUser, $wgUseTrackbacks;
1283 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1286 if ( $wgOut->isArticleRelated() ) {
1287 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1288 if ( $wgUser->isLoggedIn() ) {
1289 $element[] = $this->watchThisPage();
1291 $element[] = $this->talkLink();
1292 $element[] = $this->historyLink();
1293 $element[] = $this->whatLinksHere();
1294 $element[] = $this->watchPageLinksLink();
1296 if( $wgUseTrackbacks )
1297 $element[] = $this->trackbackLink();
1299 if ( $this->mTitle
->getNamespace() == NS_USER
1300 ||
$this->mTitle
->getNamespace() == NS_USER_TALK
){
1301 $id = User
::idFromName( $this->mTitle
->getText() );
1302 $ip = User
::isIP( $this->mTitle
->getText() );
1304 if( $id ||
$ip ) { # both anons and non-anons have contri list
1305 $element[] = $this->userContribsLink();
1307 if( $this->showEmailUser( $id ) ) {
1308 $element[] = $this->emailUserLink();
1312 $s = implode( $element, $sep );
1314 if ( $this->mTitle
->getArticleId() ) {
1316 if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1317 if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1318 if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
1320 $s .= "<br />\n" . $this->otherLanguages();
1326 function pageStats() {
1327 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1328 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1330 $oldid = $wgRequest->getVal( 'oldid' );
1331 $diff = $wgRequest->getVal( 'diff' );
1332 if ( ! $wgOut->isArticle() ) { return ''; }
1333 if( !$wgArticle instanceOf Article
) { return ''; }
1334 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1335 if ( 0 == $wgArticle->getID() ) { return ''; }
1338 if ( !$wgDisableCounters ) {
1339 $count = $wgLang->formatNum( $wgArticle->getCount() );
1341 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1345 if( $wgMaxCredits != 0 ){
1346 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1348 $s .= $this->lastModified();
1351 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1352 $dbr = wfGetDB( DB_SLAVE
);
1353 $res = $dbr->select( 'watchlist',
1354 array( 'COUNT(*) AS n' ),
1355 array( 'wl_title' => $dbr->strencode( $this->mTitle
->getDBkey() ), 'wl_namespace' => $this->mTitle
->getNamespace() ),
1358 $x = $dbr->fetchObject( $res );
1360 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1361 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
1365 return $s . ' ' . $this->getCopyright();
1368 function getCopyright( $type = 'detect' ) {
1369 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1371 if ( $type == 'detect' ) {
1372 $diff = $wgRequest->getVal( 'diff' );
1373 $isCur = $wgArticle && $wgArticle->isCurrent();
1374 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1381 if ( $type == 'history' ) {
1382 $msg = 'history_copyright';
1388 if( $wgRightsPage ) {
1389 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1390 } elseif( $wgRightsUrl ) {
1391 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1392 } elseif( $wgRightsText ) {
1393 $link = $wgRightsText;
1398 $out .= wfMsgForContent( $msg, $link );
1402 function getCopyrightIcon() {
1403 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1405 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1406 $out = $wgCopyrightIcon;
1407 } else if ( $wgRightsIcon ) {
1408 $icon = htmlspecialchars( $wgRightsIcon );
1409 if ( $wgRightsUrl ) {
1410 $url = htmlspecialchars( $wgRightsUrl );
1411 $out .= '<a href="'.$url.'">';
1413 $text = htmlspecialchars( $wgRightsText );
1414 $out .= "<img src=\"$icon\" alt='$text' />";
1415 if ( $wgRightsUrl ) {
1422 function getPoweredBy() {
1423 global $wgStylePath;
1424 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1425 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1429 function lastModified() {
1430 global $wgLang, $wgArticle;
1431 if( $this->mRevisionId
) {
1432 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1434 $timestamp = $wgArticle->getTimestamp();
1437 $d = $wgLang->date( $timestamp, true );
1438 $t = $wgLang->time( $timestamp, true );
1439 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1443 if ( wfGetLB()->getLaggedSlaveMode() ) {
1444 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1449 function logoText( $align = '' ) {
1450 if ( '' != $align ) {
1451 $a = " align='{$align}'";
1456 $mp = wfMsg( 'mainpage' );
1457 $mptitle = Title
::newMainPage();
1458 $url = ( is_object( $mptitle ) ?
$mptitle->escapeLocalURL() : '' );
1460 $logourl = $this->getLogo();
1461 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1466 * show a drop-down box of special pages
1468 function specialPagesList() {
1469 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1470 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1471 foreach ( $pages as $name => $page ) {
1472 $pages[$name] = $page->getDescription();
1475 $go = wfMsg( 'go' );
1476 $sp = wfMsg( 'specialpages' );
1477 $spp = $wgContLang->specialPage( 'Specialpages' );
1479 $s = '<form id="specialpages" method="get" ' .
1480 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1481 $s .= "<select name=\"wpDropdown\">\n";
1482 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1485 foreach ( $pages as $name => $desc ) {
1486 $p = $wgContLang->specialPage( $name );
1487 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1489 $s .= "</select>\n";
1490 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1495 function mainPageLink() {
1496 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1500 function copyrightLink() {
1501 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1502 wfMsg( 'copyrightpagename' ) );
1506 private function footerLink ( $desc, $page ) {
1507 // if the link description has been set to "-" in the default language,
1508 if ( wfMsgForContent( $desc ) == '-') {
1509 // then it is disabled, for all languages.
1512 // Otherwise, we display the link for the user, described in their
1513 // language (which may or may not be the same as the default language),
1514 // but we make the link target be the one site-wide page.
1515 return $this->makeKnownLink( wfMsgForContent( $page ),
1516 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1520 function privacyLink() {
1521 return $this->footerLink( 'privacy', 'privacypage' );
1524 function aboutLink() {
1525 return $this->footerLink( 'aboutsite', 'aboutpage' );
1528 function disclaimerLink() {
1529 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1532 function editThisPage() {
1535 if ( !$wgOut->isArticleRelated() ) {
1536 $s = wfMsg( 'protectedpage' );
1538 if( $this->mTitle
->quickUserCan( 'edit' ) && $this->mTitle
->exists() ) {
1539 $t = wfMsg( 'editthispage' );
1540 } elseif( $this->mTitle
->quickUserCan( 'create' ) && !$this->mTitle
->exists() ) {
1541 $t = wfMsg( 'create-this-page' );
1543 $t = wfMsg( 'viewsource' );
1546 $s = $this->makeKnownLinkObj( $this->mTitle
, $t, $this->editUrlOptions() );
1552 * Return URL options for the 'edit page' link.
1553 * This may include an 'oldid' specifier, if the current page view is such.
1558 function editUrlOptions() {
1561 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1562 return 'action=edit&oldid=' . intval( $this->mRevisionId
);
1564 return 'action=edit';
1568 function deleteThisPage() {
1569 global $wgUser, $wgRequest;
1571 $diff = $wgRequest->getVal( 'diff' );
1572 if ( $this->mTitle
->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1573 $t = wfMsg( 'deletethispage' );
1575 $s = $this->makeKnownLinkObj( $this->mTitle
, $t, 'action=delete' );
1582 function protectThisPage() {
1583 global $wgUser, $wgRequest;
1585 $diff = $wgRequest->getVal( 'diff' );
1586 if ( $this->mTitle
->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1587 if ( $this->mTitle
->isProtected() ) {
1588 $t = wfMsg( 'unprotectthispage' );
1589 $q = 'action=unprotect';
1591 $t = wfMsg( 'protectthispage' );
1592 $q = 'action=protect';
1594 $s = $this->makeKnownLinkObj( $this->mTitle
, $t, $q );
1601 function watchThisPage() {
1603 ++
$this->mWatchLinkNum
;
1605 if ( $wgOut->isArticleRelated() ) {
1606 if ( $this->mTitle
->userIsWatching() ) {
1607 $t = wfMsg( 'unwatchthispage' );
1608 $q = 'action=unwatch';
1609 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
1611 $t = wfMsg( 'watchthispage' );
1612 $q = 'action=watch';
1613 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
1615 $s = $this->makeKnownLinkObj( $this->mTitle
, $t, $q, '', '', " id=\"$id\"" );
1617 $s = wfMsg( 'notanarticle' );
1622 function moveThisPage() {
1623 if ( $this->mTitle
->quickUserCan( 'move' ) ) {
1624 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1625 wfMsg( 'movethispage' ), 'target=' . $this->mTitle
->getPrefixedURL() );
1627 // no message if page is protected - would be redundant
1632 function historyLink() {
1633 return $this->link( $this->mTitle
, wfMsg( 'history' ),
1634 array( 'rel' => 'archives' ), array( 'action' => 'history' ) );
1637 function whatLinksHere() {
1638 return $this->makeKnownLinkObj(
1639 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->mTitle
->getPrefixedDBkey() ),
1640 wfMsg( 'whatlinkshere' ) );
1643 function userContribsLink() {
1644 return $this->makeKnownLinkObj(
1645 SpecialPage
::getTitleFor( 'Contributions', $this->mTitle
->getDBkey() ),
1646 wfMsg( 'contributions' ) );
1649 function showEmailUser( $id ) {
1651 $targetUser = User
::newFromId( $id );
1652 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1653 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1656 function emailUserLink() {
1657 return $this->makeKnownLinkObj(
1658 SpecialPage
::getTitleFor( 'Emailuser', $this->mTitle
->getDBkey() ),
1659 wfMsg( 'emailuser' ) );
1662 function watchPageLinksLink() {
1664 if ( ! $wgOut->isArticleRelated() ) {
1665 return '(' . wfMsg( 'notanarticle' ) . ')';
1667 return $this->makeKnownLinkObj(
1668 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->mTitle
->getPrefixedDBkey() ),
1669 wfMsg( 'recentchangeslinked' ) );
1673 function trackbackLink() {
1674 return '<a href="' . $this->mTitle
->trackbackURL() . '">'
1675 . wfMsg( 'trackbacklink' ) . '</a>';
1678 function otherLanguages() {
1679 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1681 if ( $wgHideInterlanguageLinks ) {
1685 $a = $wgOut->getLanguageLinks();
1686 if ( 0 == count( $a ) ) {
1690 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1692 if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
1693 foreach( $a as $l ) {
1695 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1699 $nt = Title
::newFromText( $l );
1700 $url = $nt->escapeFullURL();
1701 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1703 if ( '' == $text ) { $text = $l; }
1704 $style = $this->getExternalLinkAttributes( $l, $text );
1705 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1707 if( $wgContLang->isRTL() ) $s .= '</span>';
1711 function talkLink() {
1712 if ( NS_SPECIAL
== $this->mTitle
->getNamespace() ) {
1713 # No discussion links for special pages
1717 $linkOptions = array();
1719 if( $this->mTitle
->isTalkPage() ) {
1720 $link = $this->mTitle
->getSubjectPage();
1721 switch( $link->getNamespace() ) {
1723 $text = wfMsg( 'articlepage' );
1726 $text = wfMsg( 'userpage' );
1729 $text = wfMsg( 'projectpage' );
1732 $text = wfMsg( 'imagepage' );
1733 # Make link known if image exists, even if the desc. page doesn't.
1734 if( wfFindFile( $link ) )
1735 $linkOptions[] = 'known';
1738 $text = wfMsg( 'mediawikipage' );
1741 $text = wfMsg( 'templatepage' );
1744 $text = wfMsg( 'viewhelppage' );
1747 $text = wfMsg( 'categorypage' );
1750 $text = wfMsg( 'articlepage' );
1753 $link = $this->mTitle
->getTalkPage();
1754 $text = wfMsg( 'talkpage' );
1757 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1762 function commentLink() {
1765 if ( $this->mTitle
->getNamespace() == NS_SPECIAL
) {
1769 # __NEWSECTIONLINK___ changes behaviour here
1770 # If it's present, the link points to this page, otherwise
1771 # it points to the talk page
1772 if( $this->mTitle
->isTalkPage() ) {
1773 $title = $this->mTitle
;
1774 } elseif( $wgOut->showNewSectionLink() ) {
1775 $title = $this->mTitle
;
1777 $title = $this->mTitle
->getTalkPage();
1780 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1783 /* these are used extensively in SkinTemplate, but also some other places */
1784 static function makeMainPageUrl( $urlaction = '' ) {
1785 $title = Title
::newMainPage();
1786 self
::checkTitle( $title, '' );
1787 return $title->getLocalURL( $urlaction );
1790 static function makeSpecialUrl( $name, $urlaction = '' ) {
1791 $title = SpecialPage
::getTitleFor( $name );
1792 return $title->getLocalURL( $urlaction );
1795 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1796 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1797 return $title->getLocalURL( $urlaction );
1800 static function makeI18nUrl( $name, $urlaction = '' ) {
1801 $title = Title
::newFromText( wfMsgForContent( $name ) );
1802 self
::checkTitle( $title, $name );
1803 return $title->getLocalURL( $urlaction );
1806 static function makeUrl( $name, $urlaction = '' ) {
1807 $title = Title
::newFromText( $name );
1808 self
::checkTitle( $title, $name );
1809 return $title->getLocalURL( $urlaction );
1812 # If url string starts with http, consider as external URL, else
1814 static function makeInternalOrExternalUrl( $name ) {
1815 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1818 return self
::makeUrl( $name );
1822 # this can be passed the NS number as defined in Language.php
1823 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1824 $title = Title
::makeTitleSafe( $namespace, $name );
1825 self
::checkTitle( $title, $name );
1826 return $title->getLocalURL( $urlaction );
1829 /* these return an array with the 'href' and boolean 'exists' */
1830 static function makeUrlDetails( $name, $urlaction = '' ) {
1831 $title = Title
::newFromText( $name );
1832 self
::checkTitle( $title, $name );
1834 'href' => $title->getLocalURL( $urlaction ),
1835 'exists' => $title->getArticleID() != 0 ?
true : false
1840 * Make URL details where the article exists (or at least it's convenient to think so)
1842 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1843 $title = Title
::newFromText( $name );
1844 self
::checkTitle( $title, $name );
1846 'href' => $title->getLocalURL( $urlaction ),
1851 # make sure we have some title to operate on
1852 static function checkTitle( &$title, $name ) {
1853 if( !is_object( $title ) ) {
1854 $title = Title
::newFromText( $name );
1855 if( !is_object( $title ) ) {
1856 $title = Title
::newFromText( '--error: link target missing--' );
1862 * Build an array that represents the sidebar(s), the navigation bar among them
1866 function buildSidebar() {
1867 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1869 wfProfileIn( __METHOD__
);
1871 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
1873 if ( $wgEnableSidebarCache ) {
1874 $cachedsidebar = $parserMemc->get( $key );
1875 if ( $cachedsidebar ) {
1876 wfProfileOut( __METHOD__
);
1877 return $cachedsidebar;
1882 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1884 foreach( $lines as $line ) {
1885 if( strpos( $line, '*' ) !== 0 )
1887 if( strpos( $line, '**') !== 0 ) {
1888 $heading = trim( $line, '* ' );
1889 if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
1891 if( strpos( $line, '|' ) !== false ) { // sanity check
1892 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
1893 $link = wfMsgForContent( $line[0] );
1897 $text = wfMsgExt( $line[1], 'parsemag' );
1898 if( wfEmptyMsg( $line[1], $text ) )
1900 if( wfEmptyMsg( $line[0], $link ) )
1903 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1906 $title = Title
::newFromText( $link );
1908 $title = $title->fixSpecialName();
1909 $href = $title->getLocalURL();
1911 $href = 'INVALID-TITLE';
1915 $bar[$heading][] = array(
1918 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
1921 } else { continue; }
1924 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
1925 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1926 wfProfileOut( __METHOD__
);