abf2bb7e1a661734c43e07a76bc05896008b286a
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( &$out ) {
175 global $wgFavicon, $wgAppleTouchIcon;
177 wfProfileIn( __METHOD__
);
179 if( false !== $wgFavicon ) {
180 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
183 if( false !== $wgAppleTouchIcon ) {
184 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
187 # OpenSearch description link
188 $out->addLink( array(
190 'type' => 'application/opensearchdescription+xml',
191 'href' => wfScript( 'opensearch_desc' ),
192 'title' => wfMsgForContent( 'opensearch-desc' ),
195 $this->addMetadataLinks($out);
197 $this->mRevisionId
= $out->mRevisionId
;
199 $this->preloadExistence();
201 wfProfileOut( __METHOD__
);
205 * Preload the existence of three commonly-requested pages in a single query
207 function preloadExistence() {
208 global $wgUser, $wgTitle;
211 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
214 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
216 } elseif ( $wgTitle->isTalkPage() ) {
217 $titles[] = $wgTitle->getSubjectPage();
219 $titles[] = $wgTitle->getTalkPage();
222 $lb = new LinkBatch( $titles );
226 function addMetadataLinks( &$out ) {
227 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
228 global $wgRightsPage, $wgRightsUrl;
230 if( $out->isArticleRelated() ) {
231 # note: buggy CC software only reads first "meta" link
232 if( $wgEnableCreativeCommonsRdf ) {
233 $out->addMetadataLink( array(
234 'title' => 'Creative Commons',
235 'type' => 'application/rdf+xml',
236 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
238 if( $wgEnableDublinCoreRdf ) {
239 $out->addMetadataLink( array(
240 'title' => 'Dublin Core',
241 'type' => 'application/rdf+xml',
242 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
246 if( $wgRightsPage ) {
247 $copy = Title
::newFromText( $wgRightsPage );
249 $copyright = $copy->getLocalURL();
252 if( !$copyright && $wgRightsUrl ) {
253 $copyright = $wgRightsUrl;
256 $out->addLink( array(
257 'rel' => 'copyright',
258 'href' => $copyright ) );
262 function outputPage( &$out ) {
263 global $wgDebugComments;
265 wfProfileIn( __METHOD__
);
266 $this->initPage( $out );
268 $out->out( $out->headElement() );
270 $out->out( "\n<body" );
271 $ops = $this->getBodyOptions();
272 foreach ( $ops as $name => $val ) {
273 $out->out( " $name='$val'" );
276 if ( $wgDebugComments ) {
277 $out->out( "<!-- Wiki debugging output:\n" .
278 $out->mDebugtext
. "-->\n" );
281 $out->out( $this->beforeContent() );
283 $out->out( $out->mBodytext
. "\n" );
285 // See self::afterContentHook() for documentation
286 $out->out ($this->afterContentHook());
288 $out->out( $this->afterContent() );
290 $out->out( $this->bottomScripts() );
292 $out->out( wfReportTime() );
294 $out->out( "\n</body></html>" );
295 wfProfileOut( __METHOD__
);
298 static function makeVariablesScript( $data ) {
299 global $wgJsMimeType;
301 $r = array( "<script type= \"$wgJsMimeType\">/*<![CDATA[*/" );
302 foreach ( $data as $name => $value ) {
303 $encValue = Xml
::encodeJsVar( $value );
304 $r[] = "var $name = $encValue;";
306 $r[] = "/*]]>*/</script>\n";
308 return implode( "\n\t\t", $r );
312 * Make a <script> tag containing global variables
313 * @param array $data Associative array containing one element:
314 * skinname => the skin name
315 * The odd calling convention is for backwards compatibility
317 static function makeGlobalVariablesScript( $data ) {
318 global $wgScript, $wgStylePath, $wgUser;
319 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
320 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
321 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
322 global $wgUseAjax, $wgAjaxWatch;
323 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
324 global $wgRestrictionTypes, $wgLivePreview;
325 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
327 $ns = $wgTitle->getNamespace();
328 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
331 'skin' => $data['skinname'],
332 'stylepath' => $wgStylePath,
333 'wgArticlePath' => $wgArticlePath,
334 'wgScriptPath' => $wgScriptPath,
335 'wgScript' => $wgScript,
336 'wgVariantArticlePath' => $wgVariantArticlePath,
337 'wgActionPaths' => $wgActionPaths,
338 'wgServer' => $wgServer,
339 'wgCanonicalNamespace' => $nsname,
340 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
341 'wgNamespaceNumber' => $wgTitle->getNamespace(),
342 'wgPageName' => $wgTitle->getPrefixedDBKey(),
343 'wgTitle' => $wgTitle->getText(),
344 'wgAction' => $wgRequest->getText( 'action', 'view' ),
345 'wgArticleId' => $wgTitle->getArticleId(),
346 'wgIsArticle' => $wgOut->isArticle(),
347 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
348 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
349 'wgUserLanguage' => $wgLang->getCode(),
350 'wgContentLanguage' => $wgContLang->getCode(),
351 'wgBreakFrames' => $wgBreakFrames,
352 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
353 'wgVersion' => $wgVersion,
354 'wgEnableAPI' => $wgEnableAPI,
355 'wgEnableWriteAPI' => $wgEnableWriteAPI,
358 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){
359 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
360 $vars['wgDBname'] = $wgDBname;
361 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
362 $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
365 foreach( $wgRestrictionTypes as $type )
366 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
368 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
369 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
370 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
371 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
372 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
375 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
376 $msgs = (object)array();
377 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
378 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
380 $vars['wgAjaxWatch'] = $msgs;
383 wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
385 return self
::makeVariablesScript( $vars );
388 function getHeadScripts( $allowUserJs ) {
389 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
391 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
393 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
396 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
397 $r .= "<script type=\"$wgJsMimeType\" src=\"".
398 htmlspecialchars(self
::makeUrl('-',
399 "action=raw$jsCache&gen=js&useskin=" .
400 urlencode( $this->getSkinName() ) ) ) .
401 "\"><!-- site js --></script>\n";
403 if( $allowUserJs && $wgUser->isLoggedIn() ) {
404 $userpage = $wgUser->getUserPage();
405 $userjs = htmlspecialchars( self
::makeUrl(
406 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
407 'action=raw&ctype='.$wgJsMimeType));
408 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
414 * To make it harder for someone to slip a user a fake
415 * user-JavaScript or user-CSS preview, a random token
416 * is associated with the login session. If it's not
417 * passed back with the preview request, we won't render
420 * @param string $action
424 function userCanPreview( $action ) {
425 global $wgTitle, $wgRequest, $wgUser;
427 if( $action != 'submit' )
429 if( !$wgRequest->wasPosted() )
431 if( !$wgTitle->userCanEditCssJsSubpage() )
433 return $wgUser->matchEditToken(
434 $wgRequest->getVal( 'wpEditToken' ) );
438 * Get the site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
440 function getSiteStylesheet() {
441 global $wgStylePath, $wgContLang, $wgStyleVersion;
442 $sheet = $this->getStylesheet();
443 $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n";
444 $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n";
445 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
446 if( $wgContLang->isRTL() )
447 $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
452 * Get the user-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
454 function getUserStylesheet() {
455 global $wgContLang, $wgSquidMaxage, $wgStyleVersion;
456 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
457 $s = '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n";
458 $s .= '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
459 $s .= $this->doGetUserStyles();
464 * This returns MediaWiki:Common.js, and derived classes may add other JS.
465 * Despite its name, it does *not* return any custom user JS from user
466 * subpages. The returned script is sitewide and publicly cacheable and
467 * therefore must not include anything that varies according to user,
468 * interface language, etc. (although it may vary by skin). See
469 * makeGlobalVariablesScript for things that can vary per page view and are
472 * @return string Raw JavaScript to be returned
474 public function getUserJs() {
475 wfProfileIn( __METHOD__
);
478 $s = "/* generated javascript */\n";
479 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
480 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
481 $s .= "\n\n/* MediaWiki:Common.js */\n";
482 $commonJs = wfMsgForContent('common.js');
483 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
486 wfProfileOut( __METHOD__
);
491 * Return html code that include site stylesheets
493 function getSiteStyles() {
494 $s = "<style type='text/css'>\n";
495 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
496 $s .= $this->getSiteStylesheet();
497 $s .= "/*]]>*/ /* */\n";
503 * Return html code that include User stylesheets
505 function getUserStyles() {
506 $s = "<style type='text/css'>\n";
507 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
508 $s .= $this->getUserStylesheet();
509 $s .= "/*]]>*/ /* */\n";
515 * Some styles that are set by user through the user settings interface.
517 function doGetUserStyles() {
518 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
522 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
523 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
524 $s .= $wgRequest->getText('wpTextbox1');
526 $userpage = $wgUser->getUserPage();
527 $s.= '@import "'.self
::makeUrl(
528 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
529 'action=raw&ctype=text/css').'";'."\n";
533 return $s . $this->reallyDoGetUserStyles();
536 function reallyDoGetUserStyles() {
539 if (($undopt = $wgUser->getOption("underline")) < 2) {
540 $underline = $undopt ?
'underline' : 'none';
541 $s .= "a { text-decoration: $underline; }\n";
543 if( $wgUser->getOption( 'highlightbroken' ) ) {
544 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
547 a.new, #quickbar a.new,
548 a.stub, #quickbar a.stub {
551 a.new:after, #quickbar a.new:after {
555 a.stub:after, #quickbar a.stub:after {
561 if( $wgUser->getOption( 'justify' ) ) {
562 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
564 if( !$wgUser->getOption( 'showtoc' ) ) {
565 $s .= "#toc { display: none; }\n";
567 if( !$wgUser->getOption( 'editsection' ) ) {
568 $s .= ".editsection { display: none; }\n";
573 function getBodyOptions() {
574 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
576 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
578 if ( 0 != $wgTitle->getNamespace() ) {
579 $a = array( 'bgcolor' => '#ffffec' );
581 else $a = array( 'bgcolor' => '#FFFFFF' );
582 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
583 $wgTitle->userCan( 'edit' ) ) {
584 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
585 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
586 $a +
= array ('ondblclick' => $s);
589 $a['onload'] = $wgOut->getOnloadHandler();
592 ' '.$this->getNamespaceClasses( $wgTitle ) .
593 ' '.( $wgContLang->isRTL() ?
"rtl" : "ltr" ).
594 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() ).
595 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName( ) );
599 function getNamespaceClasses( $title ) {
600 $numeric = 'ns-'.$title->getNamespace();
601 if( $title->getNamespace() == NS_SPECIAL
) {
602 $type = "ns-special";
603 } elseif( $title->isTalkPage() ) {
606 $type = "ns-subject";
608 return "$numeric $type";
620 * This will be called immediately after the <body> tag. Split into
621 * two functions to make it easier to subclass.
623 function beforeContent() {
624 return $this->doBeforeContent();
627 function doBeforeContent() {
629 $fname = 'Skin::doBeforeContent';
630 wfProfileIn( $fname );
633 $qb = $this->qbSetting();
635 if( $langlinks = $this->otherLanguages() ) {
641 $borderhack = 'class="top"';
644 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
645 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
648 $left = ($qb == 1 ||
$qb == 3);
649 if($wgContLang->isRTL()) $left = !$left;
652 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
653 $this->logoText() . '</td>';
655 $s .= $this->getQuickbarCompensator( $rows );
657 $l = $wgContLang->isRTL() ?
'right' : 'left';
658 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
660 $s .= $this->topLinks() ;
661 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
663 $r = $wgContLang->isRTL() ?
"left" : "right";
664 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
665 $s .= $this->nameAndLogin();
666 $s .= "\n<br />" . $this->searchForm() . "</td>";
669 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
672 if ( $shove && !$left ) { # Right
673 $s .= $this->getQuickbarCompensator( $rows );
675 $s .= "</tr>\n</table>\n</div>\n";
676 $s .= "\n<div id='article'>\n";
678 $notice = wfGetSiteNotice();
680 $s .= "\n<div id='siteNotice'>$notice</div>\n";
682 $s .= $this->pageTitle();
683 $s .= $this->pageSubtitle() ;
684 $s .= $this->getCategories();
685 wfProfileOut( $fname );
690 function getCategoryLinks() {
691 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
692 global $wgContLang, $wgUser;
694 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
697 $sep = wfMsgHtml( 'catseparator' );
699 // Use Unicode bidi embedding override characters,
700 // to make sure links don't smash each other up in ugly ways.
701 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
702 $embed = "<span dir='$dir'>";
705 $allCats = $wgOut->getCategoryLinks();
707 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
708 if ( !empty( $allCats['normal'] ) ) {
709 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
711 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
712 $s .= '<div id="mw-normal-catlinks">' .
713 $this->link( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
714 . $colon . $t . '</div>';
718 if ( isset( $allCats['hidden'] ) ) {
719 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
720 $class ='mw-hidden-cats-user-shown';
721 } elseif ( $wgTitle->getNamespace() == NS_CATEGORY
) {
722 $class = 'mw-hidden-cats-ns-shown';
724 $class = 'mw-hidden-cats-hidden';
726 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
727 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
728 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
732 # optional 'dmoz-like' category browser. Will be shown under the list
733 # of categories an article belong to
734 if($wgUseCategoryBrowser) {
735 $s .= '<br /><hr />';
737 # get a big array of the parents tree
738 $parenttree = $wgTitle->getParentCategoryTree();
739 # Skin object passed by reference cause it can not be
740 # accessed under the method subfunction drawCategoryBrowser
741 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
742 # Clean out bogus first entry and sort them
745 # Output one per line
746 $s .= implode("<br />\n", $tempout);
752 /** Render the array as a serie of links.
753 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
754 * @param &skin Object: skin passed by reference
755 * @return String separated by >, terminate with "\n"
757 function drawCategoryBrowser($tree, &$skin) {
759 foreach ($tree as $element => $parent) {
760 if (empty($parent)) {
761 # element start a new list
764 # grab the others elements
765 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
767 # add our current element to the list
768 $eltitle = Title
::newFromText($element);
769 $return .= $skin->link( $eltitle, $eltitle->getText() ) ;
774 function getCategories() {
775 $catlinks=$this->getCategoryLinks();
777 $classes = 'catlinks';
779 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
780 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
781 $classes .= ' catlinks-allhidden';
784 if( !empty( $catlinks ) ){
785 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
789 function getQuickbarCompensator( $rows = 1 ) {
790 return "<td width='152' rowspan='{$rows}'> </td>";
794 * This runs a hook to allow extensions placing their stuff after content
795 * and article metadata (e.g. categories).
796 * Note: This function has nothing to do with afterContent().
798 * This hook is placed here in order to allow using the same hook for all
799 * skins, both the SkinTemplate based ones and the older ones, which directly
800 * use this class to get their data.
802 * The output of this function gets processed in SkinTemplate::outputPage() for
803 * the SkinTemplate based skins, all other skins should directly echo it.
805 * Returns an empty string by default, if not changed by any hook function.
807 protected function afterContentHook () {
810 if (wfRunHooks ('SkinAfterContent', array (&$data))) {
811 // adding just some spaces shouldn't toggle the output
812 // of the whole <div/>, so we use trim() here
813 if (trim ($data) != "") {
814 // Doing this here instead of in the skins to
815 // ensure that the div has the same ID in all
817 $data = "<div id='mw-data-after-content'>\n" .
822 wfDebug ('Hook SkinAfterContent changed output processing.');
829 * This gets called shortly before the \</body\> tag.
830 * @return String HTML to be put before \</body\>
832 function afterContent() {
833 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
834 return $printfooter . $this->doAfterContent();
838 * This gets called shortly before the \</body\> tag.
839 * @return String HTML-wrapped JS code to be put before \</body\>
841 function bottomScripts() {
842 global $wgJsMimeType;
843 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
844 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
845 return $bottomScriptText;
848 /** @return string Retrievied from HTML text */
849 function printSource() {
851 $url = htmlspecialchars( $wgTitle->getFullURL() );
852 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
855 function printFooter() {
856 return "<p>" . $this->printSource() .
857 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
860 /** overloaded by derived classes */
861 function doAfterContent() { }
863 function pageTitleLinks() {
864 global $wgOut, $wgTitle, $wgUser, $wgRequest;
866 $oldid = $wgRequest->getVal( 'oldid' );
867 $diff = $wgRequest->getVal( 'diff' );
868 $action = $wgRequest->getText( 'action' );
870 $s = $this->printableLink();
871 $disclaimer = $this->disclaimerLink(); # may be empty
873 $s .= ' | ' . $disclaimer;
875 $privacy = $this->privacyLink(); # may be empty too
877 $s .= ' | ' . $privacy;
880 if ( $wgOut->isArticleRelated() ) {
881 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
882 $name = $wgTitle->getDBkey();
883 $image = wfFindFile( $wgTitle );
885 $link = htmlspecialchars( $image->getURL() );
886 $style = $this->getInternalLinkAttributes( $link, $name );
887 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
891 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
892 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
893 wfMsg( 'currentrev' ) );
896 if ( $wgUser->getNewtalk() ) {
897 # do not show "You have new messages" text when we are viewing our
899 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
900 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
901 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
902 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
904 $wgOut->setSquidMaxage(0);
905 $wgOut->enableClientCache(false);
909 $undelete = $this->getUndeleteLink();
910 if( !empty( $undelete ) ) {
911 $s .= ' | '.$undelete;
916 function getUndeleteLink() {
917 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
918 if( $wgUser->isAllowed( 'deletedhistory' ) &&
919 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
920 ($n = $wgTitle->isDeleted() ) )
922 if ( $wgUser->isAllowed( 'undelete' ) ) {
923 $msg = 'thisisdeleted';
925 $msg = 'viewdeleted';
928 $this->makeKnownLinkObj(
929 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
930 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
935 function printableLink() {
936 global $wgOut, $wgFeedClasses, $wgRequest;
938 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
940 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
941 if( $wgOut->isSyndicated() ) {
942 foreach( $wgFeedClasses as $format => $class ) {
943 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
944 $s .= " | <a href=\"$feedurl\">{$format}</a>";
950 function pageTitle() {
952 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
956 function pageSubtitle() {
959 $sub = $wgOut->getSubtitle();
961 global $wgExtraSubtitle;
962 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
964 $subpages = $this->subPageSubtitle();
965 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
966 $s = "<p class='subtitle'>{$sub}</p>\n";
970 function subPageSubtitle() {
972 if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
975 global $wgOut, $wgTitle;
976 if($wgOut->isArticle() && MWNamespace
::hasSubpages( $wgTitle->getNamespace() )) {
977 $ptext=$wgTitle->getPrefixedText();
978 if(preg_match('/\//',$ptext)) {
979 $links = explode('/',$ptext);
984 foreach($links as $link) {
985 $growinglink .= $link;
987 $linkObj = Title
::newFromText( $growinglink );
988 if( is_object( $linkObj ) && $linkObj->exists() ){
989 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
994 $subpages .= '< ';
996 $subpages .= $getlink;
1001 $growinglink .= '/';
1009 * Returns true if the IP should be shown in the header
1011 function showIPinHeader() {
1012 global $wgShowIPinHeader;
1013 return $wgShowIPinHeader && session_id() != '';
1016 function nameAndLogin() {
1017 global $wgUser, $wgTitle, $wgLang, $wgContLang;
1019 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1022 if ( $wgUser->isAnon() ) {
1023 if( $this->showIPinHeader() ) {
1026 $talkLink = $this->link( $wgUser->getTalkPage(),
1027 $wgLang->getNsText( NS_TALK
) );
1029 $ret .= "$name ($talkLink)";
1031 $ret .= wfMsg( 'notloggedin' );
1034 $returnTo = $wgTitle->getPrefixedDBkey();
1036 if ( $logoutPage != $returnTo ) {
1037 $query['returnto'] = $returnTo;
1040 $loginlink = $wgUser->isAllowed( 'createaccount' )
1041 ?
'nav-login-createaccount'
1043 $ret .= "\n<br />" . $this->link(
1044 SpecialPage
::getTitleFor( 'Userlogin' ),
1045 wfMsg( $loginlink ), array(), $query
1048 $returnTo = $wgTitle->getPrefixedDBkey();
1049 $talkLink = $this->link( $wgUser->getTalkPage(),
1050 $wgLang->getNsText( NS_TALK
) );
1052 $ret .= $this->link( $wgUser->getUserPage(),
1053 htmlspecialchars( $wgUser->getName() ) );
1054 $ret .= " ($talkLink)<br />";
1055 $ret .= $this->link(
1056 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1057 array(), array( 'returnto' => $returnTo )
1059 $ret .= ' | ' . $this->specialLink( 'preferences' );
1061 $ret .= ' | ' . $this->link(
1062 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1069 function getSearchLink() {
1070 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1071 return $searchPage->getLocalURL();
1074 function escapeSearchLink() {
1075 return htmlspecialchars( $this->getSearchLink() );
1078 function searchForm() {
1080 $search = $wgRequest->getText( 'search' );
1082 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1083 . $this->escapeSearchLink() . "\">\n"
1084 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1085 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
1086 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
1087 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
1089 // Ensure unique id's for search boxes made after the first
1090 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1095 function topLinks() {
1099 $s = $this->mainPageLink() . $sep
1100 . $this->specialLink( 'recentchanges' );
1102 if ( $wgOut->isArticleRelated() ) {
1103 $s .= $sep . $this->editThisPage()
1104 . $sep . $this->historyLink();
1106 # Many people don't like this dropdown box
1107 #$s .= $sep . $this->specialPagesList();
1109 $s .= $this->variantLinks();
1111 $s .= $this->extensionTabLinks();
1117 * Compatibility for extensions adding functionality through tabs.
1118 * Eventually these old skins should be replaced with SkinTemplate-based
1122 function extensionTabLinks() {
1125 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1126 foreach( $tabs as $tab ) {
1127 $s .= ' | ' . Xml
::element( 'a',
1128 array( 'href' => $tab['href'] ),
1135 * Language/charset variant links for classic-style skins
1138 function variantLinks() {
1140 /* show links to different language variants */
1141 global $wgDisableLangConversion, $wgContLang, $wgTitle;
1142 $variants = $wgContLang->getVariants();
1143 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1144 foreach( $variants as $code ) {
1145 $varname = $wgContLang->getVariantname( $code );
1146 if( $varname == 'disable' )
1148 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1154 function bottomLinks() {
1155 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1159 if ( $wgOut->isArticleRelated() ) {
1160 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1161 if ( $wgUser->isLoggedIn() ) {
1162 $s .= $sep . $this->watchThisPage();
1164 $s .= $sep . $this->talkLink()
1165 . $sep . $this->historyLink()
1166 . $sep . $this->whatLinksHere()
1167 . $sep . $this->watchPageLinksLink();
1169 if ($wgUseTrackbacks)
1170 $s .= $sep . $this->trackbackLink();
1172 if ( $wgTitle->getNamespace() == NS_USER
1173 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1176 $id=User
::idFromName($wgTitle->getText());
1177 $ip=User
::isIP($wgTitle->getText());
1179 if($id ||
$ip) { # both anons and non-anons have contri list
1180 $s .= $sep . $this->userContribsLink();
1182 if( $this->showEmailUser( $id ) ) {
1183 $s .= $sep . $this->emailUserLink();
1186 if ( $wgTitle->getArticleId() ) {
1188 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1189 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1190 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1192 $s .= "<br />\n" . $this->otherLanguages();
1197 function pageStats() {
1198 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1199 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1201 $oldid = $wgRequest->getVal( 'oldid' );
1202 $diff = $wgRequest->getVal( 'diff' );
1203 if ( ! $wgOut->isArticle() ) { return ''; }
1204 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1205 if ( 0 == $wgArticle->getID() ) { return ''; }
1208 if ( !$wgDisableCounters ) {
1209 $count = $wgLang->formatNum( $wgArticle->getCount() );
1211 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1215 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1216 require_once('Credits.php');
1217 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1219 $s .= $this->lastModified();
1222 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1223 $dbr = wfGetDB( DB_SLAVE
);
1224 $watchlist = $dbr->tableName( 'watchlist' );
1225 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1226 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1227 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1228 $res = $dbr->query( $sql, 'Skin::pageStats');
1229 $x = $dbr->fetchObject( $res );
1231 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1232 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1236 return $s . ' ' . $this->getCopyright();
1239 function getCopyright( $type = 'detect' ) {
1240 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1242 if ( $type == 'detect' ) {
1243 $oldid = $wgRequest->getVal( 'oldid' );
1244 $diff = $wgRequest->getVal( 'diff' );
1246 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1253 if ( $type == 'history' ) {
1254 $msg = 'history_copyright';
1260 if( $wgRightsPage ) {
1261 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1262 } elseif( $wgRightsUrl ) {
1263 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1268 $out .= wfMsgForContent( $msg, $link );
1272 function getCopyrightIcon() {
1273 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1275 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1276 $out = $wgCopyrightIcon;
1277 } else if ( $wgRightsIcon ) {
1278 $icon = htmlspecialchars( $wgRightsIcon );
1279 if ( $wgRightsUrl ) {
1280 $url = htmlspecialchars( $wgRightsUrl );
1281 $out .= '<a href="'.$url.'">';
1283 $text = htmlspecialchars( $wgRightsText );
1284 $out .= "<img src=\"$icon\" alt='$text' />";
1285 if ( $wgRightsUrl ) {
1292 function getPoweredBy() {
1293 global $wgStylePath;
1294 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1295 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1299 function lastModified() {
1300 global $wgLang, $wgArticle;
1301 if( $this->mRevisionId
) {
1302 $timestamp = Revision
::getTimestampFromId( $this->mRevisionId
, $wgArticle->getId() );
1304 $timestamp = $wgArticle->getTimestamp();
1307 $d = $wgLang->date( $timestamp, true );
1308 $t = $wgLang->time( $timestamp, true );
1309 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1313 if ( wfGetLB()->getLaggedSlaveMode() ) {
1314 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1319 function logoText( $align = '' ) {
1320 if ( '' != $align ) { $a = " align='{$align}'"; }
1323 $mp = wfMsg( 'mainpage' );
1324 $mptitle = Title
::newMainPage();
1325 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1327 $logourl = $this->getLogo();
1328 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1333 * show a drop-down box of special pages
1335 function specialPagesList() {
1336 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1337 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1338 foreach ( $pages as $name => $page ) {
1339 $pages[$name] = $page->getDescription();
1342 $go = wfMsg( 'go' );
1343 $sp = wfMsg( 'specialpages' );
1344 $spp = $wgContLang->specialPage( 'Specialpages' );
1346 $s = '<form id="specialpages" method="get" class="inline" ' .
1347 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1348 $s .= "<select name=\"wpDropdown\">\n";
1349 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1352 foreach ( $pages as $name => $desc ) {
1353 $p = $wgContLang->specialPage( $name );
1354 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1356 $s .= "</select>\n";
1357 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1362 function mainPageLink() {
1363 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1367 function copyrightLink() {
1368 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1369 wfMsg( 'copyrightpagename' ) );
1373 private function footerLink ( $desc, $page ) {
1374 // if the link description has been set to "-" in the default language,
1375 if ( wfMsgForContent( $desc ) == '-') {
1376 // then it is disabled, for all languages.
1379 // Otherwise, we display the link for the user, described in their
1380 // language (which may or may not be the same as the default language),
1381 // but we make the link target be the one site-wide page.
1382 return $this->makeKnownLink( wfMsgForContent( $page ),
1383 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1387 function privacyLink() {
1388 return $this->footerLink( 'privacy', 'privacypage' );
1391 function aboutLink() {
1392 return $this->footerLink( 'aboutsite', 'aboutpage' );
1395 function disclaimerLink() {
1396 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1399 function editThisPage() {
1400 global $wgOut, $wgTitle;
1402 if ( !$wgOut->isArticleRelated() ) {
1403 $s = wfMsg( 'protectedpage' );
1405 if( $wgTitle->userCan( 'edit' ) && $wgTitle->exists() ) {
1406 $t = wfMsg( 'editthispage' );
1407 } elseif( $wgTitle->userCan( 'create' ) && !$wgTitle->exists() ) {
1408 $t = wfMsg( 'create-this-page' );
1410 $t = wfMsg( 'viewsource' );
1413 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1419 * Return URL options for the 'edit page' link.
1420 * This may include an 'oldid' specifier, if the current page view is such.
1425 function editUrlOptions() {
1428 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1429 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1431 return "action=edit";
1435 function deleteThisPage() {
1436 global $wgUser, $wgTitle, $wgRequest;
1438 $diff = $wgRequest->getVal( 'diff' );
1439 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1440 $t = wfMsg( 'deletethispage' );
1442 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1449 function protectThisPage() {
1450 global $wgUser, $wgTitle, $wgRequest;
1452 $diff = $wgRequest->getVal( 'diff' );
1453 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1454 if ( $wgTitle->isProtected() ) {
1455 $t = wfMsg( 'unprotectthispage' );
1456 $q = 'action=unprotect';
1458 $t = wfMsg( 'protectthispage' );
1459 $q = 'action=protect';
1461 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1468 function watchThisPage() {
1469 global $wgOut, $wgTitle;
1470 ++
$this->mWatchLinkNum
;
1472 if ( $wgOut->isArticleRelated() ) {
1473 if ( $wgTitle->userIsWatching() ) {
1474 $t = wfMsg( 'unwatchthispage' );
1475 $q = 'action=unwatch';
1476 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1478 $t = wfMsg( 'watchthispage' );
1479 $q = 'action=watch';
1480 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1482 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1484 $s = wfMsg( 'notanarticle' );
1489 function moveThisPage() {
1492 if ( $wgTitle->userCan( 'move' ) ) {
1493 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1494 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1496 // no message if page is protected - would be redundant
1501 function historyLink() {
1504 return $this->makeKnownLinkObj( $wgTitle,
1505 wfMsg( 'history' ), 'action=history' );
1508 function whatLinksHere() {
1511 return $this->makeKnownLinkObj(
1512 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1513 wfMsg( 'whatlinkshere' ) );
1516 function userContribsLink() {
1519 return $this->makeKnownLinkObj(
1520 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1521 wfMsg( 'contributions' ) );
1524 function showEmailUser( $id ) {
1525 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1526 return $wgEnableEmail &&
1527 $wgEnableUserEmail &&
1528 $wgUser->isLoggedIn() && # show only to signed in users
1529 0 != $id; # we can only email to non-anons ..
1530 # '' != $id->getEmail() && # who must have an email address stored ..
1531 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1532 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1535 function emailUserLink() {
1538 return $this->makeKnownLinkObj(
1539 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1540 wfMsg( 'emailuser' ) );
1543 function watchPageLinksLink() {
1544 global $wgOut, $wgTitle;
1546 if ( ! $wgOut->isArticleRelated() ) {
1547 return '(' . wfMsg( 'notanarticle' ) . ')';
1549 return $this->makeKnownLinkObj(
1550 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1551 wfMsg( 'recentchangeslinked' ) );
1555 function trackbackLink() {
1558 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1559 . wfMsg('trackbacklink') . "</a>";
1562 function otherLanguages() {
1563 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1565 if ( $wgHideInterlanguageLinks ) {
1569 $a = $wgOut->getLanguageLinks();
1570 if ( 0 == count( $a ) ) {
1574 $s = wfMsg( 'otherlanguages' ) . ': ';
1576 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1577 foreach( $a as $l ) {
1578 if ( ! $first ) { $s .= ' | '; }
1581 $nt = Title
::newFromText( $l );
1582 $url = $nt->escapeFullURL();
1583 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1585 if ( '' == $text ) { $text = $l; }
1586 $style = $this->getExternalLinkAttributes( $l, $text );
1587 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1589 if($wgContLang->isRTL()) $s .= '</span>';
1593 function bugReportsLink() {
1594 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1595 wfMsg( 'bugreports' ) );
1599 function talkLink() {
1602 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1603 # No discussion links for special pages
1607 if( $wgTitle->isTalkPage() ) {
1608 $link = $wgTitle->getSubjectPage();
1609 switch( $link->getNamespace() ) {
1611 $text = wfMsg( 'articlepage' );
1614 $text = wfMsg( 'userpage' );
1617 $text = wfMsg( 'projectpage' );
1620 $text = wfMsg( 'imagepage' );
1623 $text = wfMsg( 'mediawikipage' );
1626 $text = wfMsg( 'templatepage' );
1629 $text = wfMsg( 'viewhelppage' );
1632 $text = wfMsg( 'categorypage' );
1635 $text = wfMsg( 'articlepage' );
1638 $link = $wgTitle->getTalkPage();
1639 $text = wfMsg( 'talkpage' );
1642 $s = $this->makeLinkObj( $link, $text );
1647 function commentLink() {
1648 global $wgTitle, $wgOut;
1650 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1654 # __NEWSECTIONLINK___ changes behaviour here
1655 # If it's present, the link points to this page, otherwise
1656 # it points to the talk page
1657 if( $wgTitle->isTalkPage() ) {
1659 } elseif( $wgOut->showNewSectionLink() ) {
1662 $title = $wgTitle->getTalkPage();
1665 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1668 /* these are used extensively in SkinTemplate, but also some other places */
1669 static function makeMainPageUrl( $urlaction = '' ) {
1670 $title = Title
::newMainPage();
1671 self
::checkTitle( $title, '' );
1672 return $title->getLocalURL( $urlaction );
1675 static function makeSpecialUrl( $name, $urlaction = '' ) {
1676 $title = SpecialPage
::getTitleFor( $name );
1677 return $title->getLocalURL( $urlaction );
1680 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1681 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1682 return $title->getLocalURL( $urlaction );
1685 static function makeI18nUrl( $name, $urlaction = '' ) {
1686 $title = Title
::newFromText( wfMsgForContent( $name ) );
1687 self
::checkTitle( $title, $name );
1688 return $title->getLocalURL( $urlaction );
1691 static function makeUrl( $name, $urlaction = '' ) {
1692 $title = Title
::newFromText( $name );
1693 self
::checkTitle( $title, $name );
1694 return $title->getLocalURL( $urlaction );
1697 # If url string starts with http, consider as external URL, else
1699 static function makeInternalOrExternalUrl( $name ) {
1700 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1703 return self
::makeUrl( $name );
1707 # this can be passed the NS number as defined in Language.php
1708 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1709 $title = Title
::makeTitleSafe( $namespace, $name );
1710 self
::checkTitle( $title, $name );
1711 return $title->getLocalURL( $urlaction );
1714 /* these return an array with the 'href' and boolean 'exists' */
1715 static function makeUrlDetails( $name, $urlaction = '' ) {
1716 $title = Title
::newFromText( $name );
1717 self
::checkTitle( $title, $name );
1719 'href' => $title->getLocalURL( $urlaction ),
1720 'exists' => $title->getArticleID() != 0 ?
true : false
1725 * Make URL details where the article exists (or at least it's convenient to think so)
1727 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1728 $title = Title
::newFromText( $name );
1729 self
::checkTitle( $title, $name );
1731 'href' => $title->getLocalURL( $urlaction ),
1736 # make sure we have some title to operate on
1737 static function checkTitle( &$title, $name ) {
1738 if( !is_object( $title ) ) {
1739 $title = Title
::newFromText( $name );
1740 if( !is_object( $title ) ) {
1741 $title = Title
::newFromText( '--error: link target missing--' );
1747 * Build an array that represents the sidebar(s), the navigation bar among them
1751 function buildSidebar() {
1752 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1754 wfProfileIn( __METHOD__
);
1756 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
1758 if ( $wgEnableSidebarCache ) {
1759 $cachedsidebar = $parserMemc->get( $key );
1760 if ( $cachedsidebar ) {
1761 wfProfileOut( __METHOD__
);
1762 return $cachedsidebar;
1767 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1769 foreach ($lines as $line) {
1770 if (strpos($line, '*') !== 0)
1772 if (strpos($line, '**') !== 0) {
1773 $line = trim($line, '* ');
1775 if( !array_key_exists($heading, $bar) ) $bar[$heading] = array();
1777 if (strpos($line, '|') !== false) { // sanity check
1778 $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) );
1779 $link = wfMsgForContent( $line[0] );
1782 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1784 if (wfEmptyMsg($line[0], $link))
1787 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1790 $title = Title
::newFromText( $link );
1792 $title = $title->fixSpecialName();
1793 $href = $title->getLocalURL();
1795 $href = 'INVALID-TITLE';
1799 $bar[$heading][] = array(
1802 'id' => 'n-' . strtr($line[1], ' ', '-'),
1805 } else { continue; }
1808 wfRunHooks('SkinBuildSidebar', array($this, &$bar));
1809 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1810 wfProfileOut( __METHOD__
);