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() {
212 global $wgUser, $wgTitle;
215 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
218 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
220 } elseif ( $wgTitle->isTalkPage() ) {
221 $titles[] = $wgTitle->getSubjectPage();
223 $titles[] = $wgTitle->getTalkPage();
226 $lb = new LinkBatch( $titles );
230 function addMetadataLinks( OutputPage
$out ) {
231 global $wgTitle, $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' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
242 if( $wgEnableDublinCoreRdf ) {
243 $out->addMetadataLink( array(
244 'title' => 'Dublin Core',
245 'type' => 'application/rdf+xml',
246 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
250 if( $wgRightsPage ) {
251 $copy = Title
::newFromText( $wgRightsPage );
253 $copyright = $copy->getLocalURL();
256 if( !$copyright && $wgRightsUrl ) {
257 $copyright = $wgRightsUrl;
260 $out->addLink( array(
261 'rel' => 'copyright',
262 'href' => $copyright ) );
266 function setMembers(){
267 global $wgTitle, $wgUser;
268 $this->mTitle
= $wgTitle;
269 $this->mUser
= $wgUser;
270 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
271 $this->usercss
= false;
274 function outputPage( OutputPage
$out ) {
275 global $wgDebugComments;
276 wfProfileIn( __METHOD__
);
279 $this->initPage( $out );
281 // See self::afterContentHook() for documentation
282 $afterContent = $this->afterContentHook();
284 $out->out( $out->headElement( $this ) );
286 $out->out( "\n<body" );
287 $ops = $this->getBodyOptions();
288 foreach ( $ops as $name => $val ) {
289 $out->out( " $name='$val'" );
292 if ( $wgDebugComments ) {
293 $out->out( "<!-- Wiki debugging output:\n" .
294 $out->mDebugtext
. "-->\n" );
297 $out->out( $this->beforeContent() );
299 $out->out( $out->mBodytext
. "\n" );
301 $out->out( $this->afterContent() );
303 $out->out( $afterContent );
305 $out->out( $this->bottomScripts() );
307 $out->out( wfReportTime() );
309 $out->out( "\n</body></html>" );
310 wfProfileOut( __METHOD__
);
313 static function makeVariablesScript( $data ) {
314 global $wgJsMimeType;
316 $r = array( "<script type= \"$wgJsMimeType\">/*<![CDATA[*/" );
317 foreach ( $data as $name => $value ) {
318 $encValue = Xml
::encodeJsVar( $value );
319 $r[] = "var $name = $encValue;";
321 $r[] = "/*]]>*/</script>\n";
323 return implode( "\n\t\t", $r );
327 * Make a <script> tag containing global variables
328 * @param array $data Associative array containing one element:
329 * skinname => the skin name
330 * The odd calling convention is for backwards compatibility
332 static function makeGlobalVariablesScript( $data ) {
333 global $wgScript, $wgStylePath, $wgUser;
334 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
335 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
336 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
337 global $wgUseAjax, $wgAjaxWatch;
338 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
339 global $wgRestrictionTypes, $wgLivePreview;
340 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
342 $ns = $wgTitle->getNamespace();
343 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
344 $separatorTransTable = $wgContLang->separatorTransformTable();
345 $separatorTransTable = $separatorTransTable ?
$separatorTransTable : array();
346 $compactSeparatorTransTable = array(
347 implode( "\t", array_keys( $separatorTransTable ) ),
348 implode( "\t", $separatorTransTable ),
350 $digitTransTable = $wgContLang->digitTransformTable();
351 $digitTransTable = $digitTransTable ?
$digitTransTable : array();
352 $compactDigitTransTable = array(
353 implode( "\t", array_keys( $digitTransTable ) ),
354 implode( "\t", $digitTransTable ),
358 'skin' => $data['skinname'],
359 'stylepath' => $wgStylePath,
360 'wgArticlePath' => $wgArticlePath,
361 'wgScriptPath' => $wgScriptPath,
362 'wgScript' => $wgScript,
363 'wgVariantArticlePath' => $wgVariantArticlePath,
364 'wgActionPaths' => (object)$wgActionPaths,
365 'wgServer' => $wgServer,
366 'wgCanonicalNamespace' => $nsname,
367 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
368 'wgNamespaceNumber' => $wgTitle->getNamespace(),
369 'wgPageName' => $wgTitle->getPrefixedDBKey(),
370 'wgTitle' => $wgTitle->getText(),
371 'wgAction' => $wgRequest->getText( 'action', 'view' ),
372 'wgArticleId' => $wgTitle->getArticleId(),
373 'wgIsArticle' => $wgOut->isArticle(),
374 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
375 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
376 'wgUserLanguage' => $wgLang->getCode(),
377 'wgContentLanguage' => $wgContLang->getCode(),
378 'wgBreakFrames' => $wgBreakFrames,
379 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
380 'wgVersion' => $wgVersion,
381 'wgEnableAPI' => $wgEnableAPI,
382 'wgEnableWriteAPI' => $wgEnableWriteAPI,
383 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
384 'wgDigitTransformTable' => $compactDigitTransTable,
387 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){
388 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
389 $vars['wgDBname'] = $wgDBname;
390 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
391 $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
394 foreach( $wgRestrictionTypes as $type )
395 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
397 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
398 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
399 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
400 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
401 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
404 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
405 $msgs = (object)array();
406 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
407 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
409 $vars['wgAjaxWatch'] = $msgs;
412 wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
414 return self
::makeVariablesScript( $vars );
417 function getHeadScripts( $allowUserJs ) {
418 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
420 $vars = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
422 $r = array( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>" );
425 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
426 $r[] = "<script type=\"$wgJsMimeType\" src=\"".
427 htmlspecialchars(self
::makeUrl('-',
428 "action=raw$jsCache&gen=js&useskin=" .
429 urlencode( $this->getSkinName() ) ) ) .
430 "\"><!-- site js --></script>";
432 if( $allowUserJs && $wgUser->isLoggedIn() ) {
433 $userpage = $wgUser->getUserPage();
434 $userjs = htmlspecialchars( self
::makeUrl(
435 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
436 'action=raw&ctype='.$wgJsMimeType));
437 $r[] = '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>";
439 return $vars . "\t\t" . implode ( "\n\t\t", $r );
443 * To make it harder for someone to slip a user a fake
444 * user-JavaScript or user-CSS preview, a random token
445 * is associated with the login session. If it's not
446 * passed back with the preview request, we won't render
449 * @param string $action
453 function userCanPreview( $action ) {
454 global $wgTitle, $wgRequest, $wgUser;
456 if( $action != 'submit' )
458 if( !$wgRequest->wasPosted() )
460 if( !$wgTitle->userCanEditCssJsSubpage() )
462 return $wgUser->matchEditToken(
463 $wgRequest->getVal( 'wpEditToken' ) );
467 * generated JavaScript action=raw&gen=js
468 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
469 * nated together. For some bizarre reason, it does *not* return any
470 * custom user JS from subpages. Huh?
472 * There's absolutely no reason to have separate Monobook/Common JSes.
473 * Any JS that cares can just check the skin variable generated at the
474 * top. For now Monobook.js will be maintained, but it should be consi-
479 public function generateUserJs() {
482 wfProfileIn( __METHOD__
);
484 $s = "/* generated javascript */\n";
485 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
486 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
487 $s .= "\n\n/* MediaWiki:Common.js */\n";
488 $commonJs = wfMsgForContent('common.js');
489 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
493 $s .= "\n\n/* MediaWiki:".ucfirst( $this->getSkinName() ).".js */\n";
494 // avoid inclusion of non defined user JavaScript (with custom skins only)
495 // by checking for default message content
496 $msgKey = ucfirst( $this->getSkinName() ).'.js';
497 $userJS = wfMsgForContent($msgKey);
498 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
502 wfProfileOut( __METHOD__
);
507 * generate user stylesheet for action=raw&gen=css
509 public function generateUserStylesheet() {
510 wfProfileIn( __METHOD__
);
511 $s = "/* generated user stylesheet */\n" .
512 $this->reallyGenerateUserStylesheet();
513 wfProfileOut( __METHOD__
);
518 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
520 protected function reallyGenerateUserStylesheet(){
523 if (($undopt = $wgUser->getOption("underline")) < 2) {
524 $underline = $undopt ?
'underline' : 'none';
525 $s .= "a { text-decoration: $underline; }\n";
527 if( $wgUser->getOption( 'highlightbroken' ) ) {
528 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
531 a.new, #quickbar a.new,
532 a.stub, #quickbar a.stub {
535 a.new:after, #quickbar a.new:after {
539 a.stub:after, #quickbar a.stub:after {
545 if( $wgUser->getOption( 'justify' ) ) {
546 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
548 if( !$wgUser->getOption( 'showtoc' ) ) {
549 $s .= "#toc { display: none; }\n";
551 if( !$wgUser->getOption( 'editsection' ) ) {
552 $s .= ".editsection { display: none; }\n";
560 function setupUserCss( OutputPage
$out ) {
561 global $wgRequest, $wgContLang, $wgUser;
562 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
564 wfProfileIn( __METHOD__
);
566 $this->setupSkinUserCss( $out );
570 'maxage' => $wgSquidMaxage,
573 // Add any extension CSS
574 foreach( $out->getExtStyle() as $tag ) {
575 $out->addStyle( $tag['href'] );
578 // If we use the site's dynamic CSS, throw that in, too
579 // Per-site custom styles
580 if( $wgUseSiteCss ) {
581 global $wgHandheldStyle;
582 $query = wfArrayToCGI( array(
583 'usemsgcache' => 'yes',
584 'ctype' => 'text/css',
585 'smaxage' => $wgSquidMaxage
587 # Site settings must override extension css! (bug 15025)
588 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
589 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
590 if( $wgHandheldStyle ) {
591 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
593 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
596 if( $wgUser->isLoggedIn() ) {
597 // Ensure that logged-in users' generated CSS isn't clobbered
598 // by anons' publicly cacheable generated CSS.
599 $siteargs['smaxage'] = '0';
600 $siteargs['ts'] = $wgUser->mTouched
;
602 // Per-user styles based on preferences
603 $siteargs['gen'] = 'css';
604 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
605 $siteargs['useskin'] = $us;
607 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
609 // Per-user custom style pages
610 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
611 $action = $wgRequest->getVal('action');
612 # If we're previewing the CSS page, use it
613 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
614 $previewCss = $wgRequest->getText('wpTextbox1');
615 // @FIXME: properly escape the cdata!
616 $this->usercss
= "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
618 $out->addStyle( self
::makeUrl($this->userpage
. '/' . $this->getSkinName() .'.css',
619 'action=raw&ctype=text/css' ) );
623 wfProfileOut( __METHOD__
);
627 * Add skin specific stylesheets
628 * @param $out OutputPage
630 function setupSkinUserCss( OutputPage
$out ) {
631 $out->addStyle( 'common/shared.css' );
632 $out->addStyle( 'common/oldshared.css' );
633 $out->addStyle( $this->getStylesheet() );
634 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
637 function getBodyOptions() {
638 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
640 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
642 if ( 0 != $wgTitle->getNamespace() ) {
643 $a = array( 'bgcolor' => '#ffffec' );
645 else $a = array( 'bgcolor' => '#FFFFFF' );
646 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
647 $wgTitle->quickUserCan( 'edit' ) ) {
648 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
649 $s = 'document.location = "' .Xml
::escapeJsString( $s ) .'";';
650 $a +
= array ('ondblclick' => $s);
653 $a['onload'] = $wgOut->getOnloadHandler();
656 ' '.( $wgContLang->isRTL() ?
"rtl" : "ltr" ).
657 ' '.$this->getPageClasses( $wgTitle ) .
658 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName( ) );
662 function getPageClasses( $title ) {
663 $numeric = 'ns-'.$title->getNamespace();
664 if( $title->getNamespace() == NS_SPECIAL
) {
665 $type = "ns-special";
666 } elseif( $title->isTalkPage() ) {
669 $type = "ns-subject";
671 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
672 return "$numeric $type $name";
684 * This will be called immediately after the <body> tag. Split into
685 * two functions to make it easier to subclass.
687 function beforeContent() {
688 return $this->doBeforeContent();
691 function doBeforeContent() {
693 $fname = 'Skin::doBeforeContent';
694 wfProfileIn( $fname );
697 $qb = $this->qbSetting();
699 if( $langlinks = $this->otherLanguages() ) {
705 $borderhack = 'class="top"';
708 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
709 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
711 $shove = ( $qb != 0 );
712 $left = ( $qb == 1 ||
$qb == 3 );
713 if( $wgContLang->isRTL() ) $left = !$left;
716 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
717 $this->logoText() . '</td>';
719 $s .= $this->getQuickbarCompensator( $rows );
721 $l = $wgContLang->isRTL() ?
'right' : 'left';
722 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
724 $s .= $this->topLinks() ;
725 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
727 $r = $wgContLang->isRTL() ?
"left" : "right";
728 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
729 $s .= $this->nameAndLogin();
730 $s .= "\n<br />" . $this->searchForm() . "</td>";
733 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
736 if ( $shove && !$left ) { # Right
737 $s .= $this->getQuickbarCompensator( $rows );
739 $s .= "</tr>\n</table>\n</div>\n";
740 $s .= "\n<div id='article'>\n";
742 $notice = wfGetSiteNotice();
744 $s .= "\n<div id='siteNotice'>$notice</div>\n";
746 $s .= $this->pageTitle();
747 $s .= $this->pageSubtitle() ;
748 $s .= $this->getCategories();
749 wfProfileOut( $fname );
754 function getCategoryLinks() {
755 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
756 global $wgContLang, $wgUser;
758 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
761 $sep = wfMsgHtml( 'catseparator' );
763 // Use Unicode bidi embedding override characters,
764 // to make sure links don't smash each other up in ugly ways.
765 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
766 $embed = "<span dir='$dir'>";
769 $allCats = $wgOut->getCategoryLinks();
771 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
772 if ( !empty( $allCats['normal'] ) ) {
773 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
775 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
776 $s .= '<div id="mw-normal-catlinks">' .
777 $this->link( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
778 . $colon . $t . '</div>';
782 if ( isset( $allCats['hidden'] ) ) {
783 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
784 $class ='mw-hidden-cats-user-shown';
785 } elseif ( $wgTitle->getNamespace() == NS_CATEGORY
) {
786 $class = 'mw-hidden-cats-ns-shown';
788 $class = 'mw-hidden-cats-hidden';
790 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
791 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
792 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
796 # optional 'dmoz-like' category browser. Will be shown under the list
797 # of categories an article belong to
798 if( $wgUseCategoryBrowser ){
799 $s .= '<br /><hr />';
801 # get a big array of the parents tree
802 $parenttree = $wgTitle->getParentCategoryTree();
803 # Skin object passed by reference cause it can not be
804 # accessed under the method subfunction drawCategoryBrowser
805 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
806 # Clean out bogus first entry and sort them
809 # Output one per line
810 $s .= implode("<br />\n", $tempout);
816 /** Render the array as a serie of links.
817 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
818 * @param &skin Object: skin passed by reference
819 * @return String separated by >, terminate with "\n"
821 function drawCategoryBrowser( $tree, &$skin ){
823 foreach ($tree as $element => $parent) {
824 if (empty($parent)) {
825 # element start a new list
828 # grab the others elements
829 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
831 # add our current element to the list
832 $eltitle = Title
::newFromText($element);
833 $return .= $skin->link( $eltitle, $eltitle->getText() ) ;
838 function getCategories() {
839 $catlinks=$this->getCategoryLinks();
841 $classes = 'catlinks';
843 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
844 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
845 $classes .= ' catlinks-allhidden';
848 if( !empty( $catlinks ) ){
849 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
853 function getQuickbarCompensator( $rows = 1 ) {
854 return "<td width='152' rowspan='{$rows}'> </td>";
858 * This runs a hook to allow extensions placing their stuff after content
859 * and article metadata (e.g. categories).
860 * Note: This function has nothing to do with afterContent().
862 * This hook is placed here in order to allow using the same hook for all
863 * skins, both the SkinTemplate based ones and the older ones, which directly
864 * use this class to get their data.
866 * The output of this function gets processed in SkinTemplate::outputPage() for
867 * the SkinTemplate based skins, all other skins should directly echo it.
869 * Returns an empty string by default, if not changed by any hook function.
871 protected function afterContentHook() {
874 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
875 // adding just some spaces shouldn't toggle the output
876 // of the whole <div/>, so we use trim() here
877 if( trim( $data ) != '' ){
878 // Doing this here instead of in the skins to
879 // ensure that the div has the same ID in all
881 $data = "<div id='mw-data-after-content'>\n" .
886 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
893 * This gets called shortly before the </body> tag.
894 * @return String HTML to be put before </body>
896 function afterContent() {
897 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
898 return $printfooter . $this->doAfterContent();
902 * This gets called shortly before the </body> tag.
903 * @return String HTML-wrapped JS code to be put before </body>
905 function bottomScripts() {
906 global $wgJsMimeType;
907 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
908 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
909 return $bottomScriptText;
912 /** @return string Retrievied from HTML text */
913 function printSource() {
915 $url = htmlspecialchars( $wgTitle->getFullURL() );
916 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
919 function printFooter() {
920 return "<p>" . $this->printSource() .
921 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
924 /** overloaded by derived classes */
925 function doAfterContent() { return "</div></div>"; }
927 function pageTitleLinks() {
928 global $wgOut, $wgTitle, $wgUser, $wgRequest;
930 $oldid = $wgRequest->getVal( 'oldid' );
931 $diff = $wgRequest->getVal( 'diff' );
932 $action = $wgRequest->getText( 'action' );
934 $s = $this->printableLink();
935 $disclaimer = $this->disclaimerLink(); # may be empty
937 $s .= ' | ' . $disclaimer;
939 $privacy = $this->privacyLink(); # may be empty too
941 $s .= ' | ' . $privacy;
944 if ( $wgOut->isArticleRelated() ) {
945 if ( $wgTitle->getNamespace() == NS_FILE
) {
946 $name = $wgTitle->getDBkey();
947 $image = wfFindFile( $wgTitle );
949 $link = htmlspecialchars( $image->getURL() );
950 $style = $this->getInternalLinkAttributes( $link, $name );
951 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
955 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
956 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
957 wfMsg( 'currentrev' ) );
960 if ( $wgUser->getNewtalk() ) {
961 # do not show "You have new messages" text when we are viewing our
963 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
964 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
965 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
966 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
968 $wgOut->setSquidMaxage(0);
969 $wgOut->enableClientCache(false);
973 $undelete = $this->getUndeleteLink();
974 if( !empty( $undelete ) ) {
975 $s .= ' | '.$undelete;
980 function getUndeleteLink() {
981 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
982 if( $wgUser->isAllowed( 'deletedhistory' ) &&
983 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
984 ($n = $wgTitle->isDeleted() ) )
986 if ( $wgUser->isAllowed( 'undelete' ) ) {
987 $msg = 'thisisdeleted';
989 $msg = 'viewdeleted';
992 $this->makeKnownLinkObj(
993 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
994 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
999 function printableLink() {
1000 global $wgOut, $wgFeedClasses, $wgRequest;
1002 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1004 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
1005 if( $wgOut->isSyndicated() ) {
1006 foreach( $wgFeedClasses as $format => $class ) {
1007 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1008 $s .= " | <a href=\"$feedurl\">{$format}</a>";
1014 function pageTitle() {
1016 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
1020 function pageSubtitle() {
1023 $sub = $wgOut->getSubtitle();
1025 global $wgExtraSubtitle;
1026 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
1028 $subpages = $this->subPageSubtitle();
1029 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
1030 $s = "<p class='subtitle'>{$sub}</p>\n";
1034 function subPageSubtitle() {
1036 if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
1039 global $wgOut, $wgTitle;
1040 if($wgOut->isArticle() && MWNamespace
::hasSubpages( $wgTitle->getNamespace() )) {
1041 $ptext=$wgTitle->getPrefixedText();
1042 if(preg_match('/\//',$ptext)) {
1043 $links = explode('/',$ptext);
1044 array_pop( $links );
1048 foreach($links as $link) {
1049 $growinglink .= $link;
1051 $linkObj = Title
::newFromText( $growinglink );
1052 if( is_object( $linkObj ) && $linkObj->exists() ){
1053 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
1058 $subpages .= '< ';
1060 $subpages .= $getlink;
1065 $growinglink .= '/';
1073 * Returns true if the IP should be shown in the header
1075 function showIPinHeader() {
1076 global $wgShowIPinHeader;
1077 return $wgShowIPinHeader && session_id() != '';
1080 function nameAndLogin() {
1081 global $wgUser, $wgTitle, $wgLang, $wgContLang;
1083 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1086 if ( $wgUser->isAnon() ) {
1087 if( $this->showIPinHeader() ) {
1090 $talkLink = $this->link( $wgUser->getTalkPage(),
1091 $wgLang->getNsText( NS_TALK
) );
1093 $ret .= "$name ($talkLink)";
1095 $ret .= wfMsg( 'notloggedin' );
1098 $returnTo = $wgTitle->getPrefixedDBkey();
1100 if ( $logoutPage != $returnTo ) {
1101 $query['returnto'] = $returnTo;
1104 $loginlink = $wgUser->isAllowed( 'createaccount' )
1105 ?
'nav-login-createaccount'
1107 $ret .= "\n<br />" . $this->link(
1108 SpecialPage
::getTitleFor( 'Userlogin' ),
1109 wfMsg( $loginlink ), array(), $query
1112 $returnTo = $wgTitle->getPrefixedDBkey();
1113 $talkLink = $this->link( $wgUser->getTalkPage(),
1114 $wgLang->getNsText( NS_TALK
) );
1116 $ret .= $this->link( $wgUser->getUserPage(),
1117 htmlspecialchars( $wgUser->getName() ) );
1118 $ret .= " ($talkLink)<br />";
1119 $ret .= $this->link(
1120 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1121 array(), array( 'returnto' => $returnTo )
1123 $ret .= ' | ' . $this->specialLink( 'preferences' );
1125 $ret .= ' | ' . $this->link(
1126 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1133 function getSearchLink() {
1134 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1135 return $searchPage->getLocalURL();
1138 function escapeSearchLink() {
1139 return htmlspecialchars( $this->getSearchLink() );
1142 function searchForm() {
1144 $search = $wgRequest->getText( 'search' );
1146 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1147 . $this->escapeSearchLink() . "\">\n"
1148 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1149 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
1150 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
1151 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
1153 // Ensure unique id's for search boxes made after the first
1154 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1159 function topLinks() {
1163 $s = $this->mainPageLink() . $sep
1164 . $this->specialLink( 'recentchanges' );
1166 if ( $wgOut->isArticleRelated() ) {
1167 $s .= $sep . $this->editThisPage()
1168 . $sep . $this->historyLink();
1170 # Many people don't like this dropdown box
1171 #$s .= $sep . $this->specialPagesList();
1173 $s .= $this->variantLinks();
1175 $s .= $this->extensionTabLinks();
1181 * Compatibility for extensions adding functionality through tabs.
1182 * Eventually these old skins should be replaced with SkinTemplate-based
1186 function extensionTabLinks() {
1189 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1190 foreach( $tabs as $tab ) {
1191 $s .= ' | ' . Xml
::element( 'a',
1192 array( 'href' => $tab['href'] ),
1199 * Language/charset variant links for classic-style skins
1202 function variantLinks() {
1204 /* show links to different language variants */
1205 global $wgDisableLangConversion, $wgContLang, $wgTitle;
1206 $variants = $wgContLang->getVariants();
1207 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1208 foreach( $variants as $code ) {
1209 $varname = $wgContLang->getVariantname( $code );
1210 if( $varname == 'disable' )
1212 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1218 function bottomLinks() {
1219 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1223 if ( $wgOut->isArticleRelated() ) {
1224 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1225 if ( $wgUser->isLoggedIn() ) {
1226 $s .= $sep . $this->watchThisPage();
1228 $s .= $sep . $this->talkLink()
1229 . $sep . $this->historyLink()
1230 . $sep . $this->whatLinksHere()
1231 . $sep . $this->watchPageLinksLink();
1233 if ($wgUseTrackbacks)
1234 $s .= $sep . $this->trackbackLink();
1236 if ( $wgTitle->getNamespace() == NS_USER
1237 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1240 $id=User
::idFromName($wgTitle->getText());
1241 $ip=User
::isIP($wgTitle->getText());
1243 if($id ||
$ip) { # both anons and non-anons have contri list
1244 $s .= $sep . $this->userContribsLink();
1246 if( $this->showEmailUser( $id ) ) {
1247 $s .= $sep . $this->emailUserLink();
1250 if ( $wgTitle->getArticleId() ) {
1252 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1253 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1254 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1256 $s .= "<br />\n" . $this->otherLanguages();
1261 function pageStats() {
1262 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1263 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1265 $oldid = $wgRequest->getVal( 'oldid' );
1266 $diff = $wgRequest->getVal( 'diff' );
1267 if ( ! $wgOut->isArticle() ) { return ''; }
1268 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1269 if ( 0 == $wgArticle->getID() ) { return ''; }
1272 if ( !$wgDisableCounters ) {
1273 $count = $wgLang->formatNum( $wgArticle->getCount() );
1275 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1279 if( $wgMaxCredits != 0 ){
1280 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1282 $s .= $this->lastModified();
1285 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1286 $dbr = wfGetDB( DB_SLAVE
);
1287 $watchlist = $dbr->tableName( 'watchlist' );
1288 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1289 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1290 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1291 $res = $dbr->query( $sql, 'Skin::pageStats');
1292 $x = $dbr->fetchObject( $res );
1294 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1295 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1299 return $s . ' ' . $this->getCopyright();
1302 function getCopyright( $type = 'detect' ) {
1303 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1305 if ( $type == 'detect' ) {
1306 $diff = $wgRequest->getVal( 'diff' );
1307 $isCur = $wgArticle && $wgArticle->isCurrent();
1308 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1315 if ( $type == 'history' ) {
1316 $msg = 'history_copyright';
1322 if( $wgRightsPage ) {
1323 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1324 } elseif( $wgRightsUrl ) {
1325 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1326 } elseif( $wgRightsText ) {
1327 $link = $wgRightsText;
1332 $out .= wfMsgForContent( $msg, $link );
1336 function getCopyrightIcon() {
1337 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1339 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1340 $out = $wgCopyrightIcon;
1341 } else if ( $wgRightsIcon ) {
1342 $icon = htmlspecialchars( $wgRightsIcon );
1343 if ( $wgRightsUrl ) {
1344 $url = htmlspecialchars( $wgRightsUrl );
1345 $out .= '<a href="'.$url.'">';
1347 $text = htmlspecialchars( $wgRightsText );
1348 $out .= "<img src=\"$icon\" alt='$text' />";
1349 if ( $wgRightsUrl ) {
1356 function getPoweredBy() {
1357 global $wgStylePath;
1358 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1359 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1363 function lastModified() {
1364 global $wgLang, $wgArticle;
1365 if( $this->mRevisionId
) {
1366 $timestamp = Revision
::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId
);
1368 $timestamp = $wgArticle->getTimestamp();
1371 $d = $wgLang->date( $timestamp, true );
1372 $t = $wgLang->time( $timestamp, true );
1373 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1377 if ( wfGetLB()->getLaggedSlaveMode() ) {
1378 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1383 function logoText( $align = '' ) {
1384 if ( '' != $align ) { $a = " align='{$align}'"; }
1387 $mp = wfMsg( 'mainpage' );
1388 $mptitle = Title
::newMainPage();
1389 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1391 $logourl = $this->getLogo();
1392 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1397 * show a drop-down box of special pages
1399 function specialPagesList() {
1400 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1401 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1402 foreach ( $pages as $name => $page ) {
1403 $pages[$name] = $page->getDescription();
1406 $go = wfMsg( 'go' );
1407 $sp = wfMsg( 'specialpages' );
1408 $spp = $wgContLang->specialPage( 'Specialpages' );
1410 $s = '<form id="specialpages" method="get" ' .
1411 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1412 $s .= "<select name=\"wpDropdown\">\n";
1413 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1416 foreach ( $pages as $name => $desc ) {
1417 $p = $wgContLang->specialPage( $name );
1418 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1420 $s .= "</select>\n";
1421 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1426 function mainPageLink() {
1427 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1431 function copyrightLink() {
1432 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1433 wfMsg( 'copyrightpagename' ) );
1437 private function footerLink ( $desc, $page ) {
1438 // if the link description has been set to "-" in the default language,
1439 if ( wfMsgForContent( $desc ) == '-') {
1440 // then it is disabled, for all languages.
1443 // Otherwise, we display the link for the user, described in their
1444 // language (which may or may not be the same as the default language),
1445 // but we make the link target be the one site-wide page.
1446 return $this->makeKnownLink( wfMsgForContent( $page ),
1447 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1451 function privacyLink() {
1452 return $this->footerLink( 'privacy', 'privacypage' );
1455 function aboutLink() {
1456 return $this->footerLink( 'aboutsite', 'aboutpage' );
1459 function disclaimerLink() {
1460 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1463 function editThisPage() {
1464 global $wgOut, $wgTitle;
1466 if ( !$wgOut->isArticleRelated() ) {
1467 $s = wfMsg( 'protectedpage' );
1469 if( $wgTitle->quickUserCan( 'edit' ) && $wgTitle->exists() ) {
1470 $t = wfMsg( 'editthispage' );
1471 } elseif( $wgTitle->quickUserCan( 'create' ) && !$wgTitle->exists() ) {
1472 $t = wfMsg( 'create-this-page' );
1474 $t = wfMsg( 'viewsource' );
1477 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1483 * Return URL options for the 'edit page' link.
1484 * This may include an 'oldid' specifier, if the current page view is such.
1489 function editUrlOptions() {
1492 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1493 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1495 return "action=edit";
1499 function deleteThisPage() {
1500 global $wgUser, $wgTitle, $wgRequest;
1502 $diff = $wgRequest->getVal( 'diff' );
1503 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1504 $t = wfMsg( 'deletethispage' );
1506 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1513 function protectThisPage() {
1514 global $wgUser, $wgTitle, $wgRequest;
1516 $diff = $wgRequest->getVal( 'diff' );
1517 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1518 if ( $wgTitle->isProtected() ) {
1519 $t = wfMsg( 'unprotectthispage' );
1520 $q = 'action=unprotect';
1522 $t = wfMsg( 'protectthispage' );
1523 $q = 'action=protect';
1525 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1532 function watchThisPage() {
1533 global $wgOut, $wgTitle;
1534 ++
$this->mWatchLinkNum
;
1536 if ( $wgOut->isArticleRelated() ) {
1537 if ( $wgTitle->userIsWatching() ) {
1538 $t = wfMsg( 'unwatchthispage' );
1539 $q = 'action=unwatch';
1540 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1542 $t = wfMsg( 'watchthispage' );
1543 $q = 'action=watch';
1544 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1546 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1548 $s = wfMsg( 'notanarticle' );
1553 function moveThisPage() {
1556 if ( $wgTitle->quickUserCan( 'move' ) ) {
1557 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1558 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1560 // no message if page is protected - would be redundant
1565 function historyLink() {
1568 return $this->makeKnownLinkObj( $wgTitle,
1569 wfMsg( 'history' ), 'action=history' );
1572 function whatLinksHere() {
1575 return $this->makeKnownLinkObj(
1576 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1577 wfMsg( 'whatlinkshere' ) );
1580 function userContribsLink() {
1583 return $this->makeKnownLinkObj(
1584 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1585 wfMsg( 'contributions' ) );
1588 function showEmailUser( $id ) {
1590 $targetUser = User
::newFromId( $id );
1591 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1592 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1595 function emailUserLink() {
1598 return $this->makeKnownLinkObj(
1599 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1600 wfMsg( 'emailuser' ) );
1603 function watchPageLinksLink() {
1604 global $wgOut, $wgTitle;
1606 if ( ! $wgOut->isArticleRelated() ) {
1607 return '(' . wfMsg( 'notanarticle' ) . ')';
1609 return $this->makeKnownLinkObj(
1610 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1611 wfMsg( 'recentchangeslinked' ) );
1615 function trackbackLink() {
1618 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1619 . wfMsg('trackbacklink') . "</a>";
1622 function otherLanguages() {
1623 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1625 if ( $wgHideInterlanguageLinks ) {
1629 $a = $wgOut->getLanguageLinks();
1630 if ( 0 == count( $a ) ) {
1634 $s = wfMsg( 'otherlanguages' ) . ': ';
1636 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1637 foreach( $a as $l ) {
1638 if ( ! $first ) { $s .= ' | '; }
1641 $nt = Title
::newFromText( $l );
1642 $url = $nt->escapeFullURL();
1643 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1645 if ( '' == $text ) { $text = $l; }
1646 $style = $this->getExternalLinkAttributes( $l, $text );
1647 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1649 if($wgContLang->isRTL()) $s .= '</span>';
1653 function bugReportsLink() {
1654 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1655 wfMsg( 'bugreports' ) );
1659 function talkLink() {
1662 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1663 # No discussion links for special pages
1667 $linkOptions = array();
1669 if( $wgTitle->isTalkPage() ) {
1670 $link = $wgTitle->getSubjectPage();
1671 switch( $link->getNamespace() ) {
1673 $text = wfMsg( 'articlepage' );
1676 $text = wfMsg( 'userpage' );
1679 $text = wfMsg( 'projectpage' );
1682 $text = wfMsg( 'imagepage' );
1683 # Make link known if image exists, even if the desc. page doesn't.
1684 if( wfFindFile( $link ) )
1685 $linkOptions[] = 'known';
1688 $text = wfMsg( 'mediawikipage' );
1691 $text = wfMsg( 'templatepage' );
1694 $text = wfMsg( 'viewhelppage' );
1697 $text = wfMsg( 'categorypage' );
1700 $text = wfMsg( 'articlepage' );
1703 $link = $wgTitle->getTalkPage();
1704 $text = wfMsg( 'talkpage' );
1707 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1712 function commentLink() {
1713 global $wgTitle, $wgOut;
1715 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1719 # __NEWSECTIONLINK___ changes behaviour here
1720 # If it's present, the link points to this page, otherwise
1721 # it points to the talk page
1722 if( $wgTitle->isTalkPage() ) {
1724 } elseif( $wgOut->showNewSectionLink() ) {
1727 $title = $wgTitle->getTalkPage();
1730 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1733 /* these are used extensively in SkinTemplate, but also some other places */
1734 static function makeMainPageUrl( $urlaction = '' ) {
1735 $title = Title
::newMainPage();
1736 self
::checkTitle( $title, '' );
1737 return $title->getLocalURL( $urlaction );
1740 static function makeSpecialUrl( $name, $urlaction = '' ) {
1741 $title = SpecialPage
::getTitleFor( $name );
1742 return $title->getLocalURL( $urlaction );
1745 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1746 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1747 return $title->getLocalURL( $urlaction );
1750 static function makeI18nUrl( $name, $urlaction = '' ) {
1751 $title = Title
::newFromText( wfMsgForContent( $name ) );
1752 self
::checkTitle( $title, $name );
1753 return $title->getLocalURL( $urlaction );
1756 static function makeUrl( $name, $urlaction = '' ) {
1757 $title = Title
::newFromText( $name );
1758 self
::checkTitle( $title, $name );
1759 return $title->getLocalURL( $urlaction );
1762 # If url string starts with http, consider as external URL, else
1764 static function makeInternalOrExternalUrl( $name ) {
1765 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1768 return self
::makeUrl( $name );
1772 # this can be passed the NS number as defined in Language.php
1773 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1774 $title = Title
::makeTitleSafe( $namespace, $name );
1775 self
::checkTitle( $title, $name );
1776 return $title->getLocalURL( $urlaction );
1779 /* these return an array with the 'href' and boolean 'exists' */
1780 static function makeUrlDetails( $name, $urlaction = '' ) {
1781 $title = Title
::newFromText( $name );
1782 self
::checkTitle( $title, $name );
1784 'href' => $title->getLocalURL( $urlaction ),
1785 'exists' => $title->getArticleID() != 0 ?
true : false
1790 * Make URL details where the article exists (or at least it's convenient to think so)
1792 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1793 $title = Title
::newFromText( $name );
1794 self
::checkTitle( $title, $name );
1796 'href' => $title->getLocalURL( $urlaction ),
1801 # make sure we have some title to operate on
1802 static function checkTitle( &$title, $name ) {
1803 if( !is_object( $title ) ) {
1804 $title = Title
::newFromText( $name );
1805 if( !is_object( $title ) ) {
1806 $title = Title
::newFromText( '--error: link target missing--' );
1812 * Build an array that represents the sidebar(s), the navigation bar among them
1816 function buildSidebar() {
1817 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1819 wfProfileIn( __METHOD__
);
1821 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
1823 if ( $wgEnableSidebarCache ) {
1824 $cachedsidebar = $parserMemc->get( $key );
1825 if ( $cachedsidebar ) {
1826 wfProfileOut( __METHOD__
);
1827 return $cachedsidebar;
1832 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1834 foreach ($lines as $line) {
1835 if (strpos($line, '*') !== 0)
1837 if (strpos($line, '**') !== 0) {
1838 $line = trim($line, '* ');
1840 if( !array_key_exists($heading, $bar) ) $bar[$heading] = array();
1842 if (strpos($line, '|') !== false) { // sanity check
1843 $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) );
1844 $link = wfMsgForContent( $line[0] );
1847 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1849 if (wfEmptyMsg($line[0], $link))
1852 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1855 $title = Title
::newFromText( $link );
1857 $title = $title->fixSpecialName();
1858 $href = $title->getLocalURL();
1860 $href = 'INVALID-TITLE';
1864 $bar[$heading][] = array(
1867 'id' => 'n-' . strtr($line[1], ' ', '-'),
1870 } else { continue; }
1873 wfRunHooks('SkinBuildSidebar', array($this, &$bar));
1874 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1875 wfProfileOut( __METHOD__
);