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 * Normalize a skin preference value to a form that can be loaded.
66 * If a skin can't be found, it will fall back to the configured
67 * default (or the old 'Classic' skin if that's broken).
72 static function normalizeKey( $key ) {
73 global $wgDefaultSkin;
74 $skinNames = Skin
::getSkinNames();
77 // Don't return the default immediately;
78 // in a misconfiguration we need to fall back.
79 $key = $wgDefaultSkin;
82 if( isset( $skinNames[$key] ) ) {
86 // Older versions of the software used a numeric setting
87 // in the user preferences.
93 if( isset( $fallback[$key] ) ){
94 $key = $fallback[$key];
97 if( isset( $skinNames[$key] ) ) {
105 * Factory method for loading a skin of a given type
106 * @param string $key 'monobook', 'standard', etc
110 static function &newFromKey( $key ) {
111 global $wgStyleDirectory;
113 $key = Skin
::normalizeKey( $key );
115 $skinNames = Skin
::getSkinNames();
116 $skinName = $skinNames[$key];
117 $className = 'Skin'.ucfirst($key);
119 # Grab the skin class and initialise it.
120 if ( !class_exists( $className ) ) {
121 // Preload base classes to work around APC/PHP5 bug
122 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
123 if( file_exists( $deps ) ) include_once( $deps );
124 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
126 # Check if we got if not failback to default skin
127 if( !class_exists( $className ) ) {
128 # DO NOT die if the class isn't found. This breaks maintenance
129 # scripts and can cause a user account to be unrecoverable
130 # except by SQL manipulation if a previously valid skin name
131 # is no longer valid.
132 wfDebug( "Skin class does not exist: $className\n" );
133 $className = 'SkinMonobook';
134 require_once( "{$wgStyleDirectory}/MonoBook.php" );
137 $skin = new $className;
141 /** @return string path to the skin stylesheet */
142 function getStylesheet() {
143 return 'common/wikistandard.css';
146 /** @return string skin name */
147 public function getSkinName() {
148 return $this->skinname
;
151 function qbSetting() {
152 global $wgOut, $wgUser;
154 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
155 $q = $wgUser->getOption( 'quickbar', 0 );
159 function initPage( &$out ) {
160 global $wgFavicon, $wgAppleTouchIcon;
162 wfProfileIn( __METHOD__
);
164 if( false !== $wgFavicon ) {
165 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
168 if( false !== $wgAppleTouchIcon ) {
169 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
172 # OpenSearch description link
173 $out->addLink( array(
175 'type' => 'application/opensearchdescription+xml',
176 'href' => wfScript( 'opensearch_desc' ),
177 'title' => wfMsgForContent( 'opensearch-desc' ),
180 $this->addMetadataLinks($out);
182 $this->mRevisionId
= $out->mRevisionId
;
184 $this->preloadExistence();
186 wfProfileOut( __METHOD__
);
190 * Preload the existence of three commonly-requested pages in a single query
192 function preloadExistence() {
193 global $wgUser, $wgTitle;
196 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
199 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
201 } elseif ( $wgTitle->isTalkPage() ) {
202 $titles[] = $wgTitle->getSubjectPage();
204 $titles[] = $wgTitle->getTalkPage();
207 $lb = new LinkBatch( $titles );
211 function addMetadataLinks( &$out ) {
212 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
213 global $wgRightsPage, $wgRightsUrl;
215 if( $out->isArticleRelated() ) {
216 # note: buggy CC software only reads first "meta" link
217 if( $wgEnableCreativeCommonsRdf ) {
218 $out->addMetadataLink( array(
219 'title' => 'Creative Commons',
220 'type' => 'application/rdf+xml',
221 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
223 if( $wgEnableDublinCoreRdf ) {
224 $out->addMetadataLink( array(
225 'title' => 'Dublin Core',
226 'type' => 'application/rdf+xml',
227 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
231 if( $wgRightsPage ) {
232 $copy = Title
::newFromText( $wgRightsPage );
234 $copyright = $copy->getLocalURL();
237 if( !$copyright && $wgRightsUrl ) {
238 $copyright = $wgRightsUrl;
241 $out->addLink( array(
242 'rel' => 'copyright',
243 'href' => $copyright ) );
247 function outputPage( &$out ) {
248 global $wgDebugComments;
250 wfProfileIn( __METHOD__
);
251 $this->initPage( $out );
253 $out->out( $out->headElement() );
255 $out->out( "\n<body" );
256 $ops = $this->getBodyOptions();
257 foreach ( $ops as $name => $val ) {
258 $out->out( " $name='$val'" );
261 if ( $wgDebugComments ) {
262 $out->out( "<!-- Wiki debugging output:\n" .
263 $out->mDebugtext
. "-->\n" );
266 $out->out( $this->beforeContent() );
268 $out->out( $out->mBodytext
. "\n" );
270 $out->out( $this->afterContent() );
272 $out->out( $this->bottomScripts() );
274 $out->out( wfReportTime() );
276 $out->out( "\n</body></html>" );
277 wfProfileOut( __METHOD__
);
280 static function makeVariablesScript( $data ) {
281 global $wgJsMimeType;
283 $r = array( "<script type= \"$wgJsMimeType\">/*<![CDATA[*/" );
284 foreach ( $data as $name => $value ) {
285 $encValue = Xml
::encodeJsVar( $value );
286 $r[] = "var $name = $encValue;";
288 $r[] = "/*]]>*/</script>\n";
290 return implode( "\n\t\t", $r );
294 * Make a <script> tag containing global variables
295 * @param array $data Associative array containing one element:
296 * skinname => the skin name
297 * The odd calling convention is for backwards compatibility
299 static function makeGlobalVariablesScript( $data ) {
300 global $wgScript, $wgStylePath, $wgUser;
301 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
302 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
303 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
304 global $wgUseAjax, $wgAjaxWatch;
305 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
306 global $wgRestrictionTypes, $wgLivePreview;
307 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
309 $ns = $wgTitle->getNamespace();
310 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
313 'skin' => $data['skinname'],
314 'stylepath' => $wgStylePath,
315 'wgArticlePath' => $wgArticlePath,
316 'wgScriptPath' => $wgScriptPath,
317 'wgScript' => $wgScript,
318 'wgVariantArticlePath' => $wgVariantArticlePath,
319 'wgActionPaths' => $wgActionPaths,
320 'wgServer' => $wgServer,
321 'wgCanonicalNamespace' => $nsname,
322 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
323 'wgNamespaceNumber' => $wgTitle->getNamespace(),
324 'wgPageName' => $wgTitle->getPrefixedDBKey(),
325 'wgTitle' => $wgTitle->getText(),
326 'wgAction' => $wgRequest->getText( 'action', 'view' ),
327 'wgArticleId' => $wgTitle->getArticleId(),
328 'wgIsArticle' => $wgOut->isArticle(),
329 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
330 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
331 'wgUserLanguage' => $wgLang->getCode(),
332 'wgContentLanguage' => $wgContLang->getCode(),
333 'wgBreakFrames' => $wgBreakFrames,
334 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
335 'wgVersion' => $wgVersion,
336 'wgEnableAPI' => $wgEnableAPI,
337 'wgEnableWriteAPI' => $wgEnableWriteAPI,
340 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){
341 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
342 $vars['wgDBname'] = $wgDBname;
343 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
344 $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
347 foreach( $wgRestrictionTypes as $type )
348 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
350 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
351 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
352 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
353 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
354 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
357 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
358 $msgs = (object)array();
359 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
360 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
362 $vars['wgAjaxWatch'] = $msgs;
365 wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
367 return self
::makeVariablesScript( $vars );
370 function getHeadScripts( $allowUserJs ) {
371 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
373 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
375 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
378 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
379 $r .= "<script type=\"$wgJsMimeType\" src=\"".
380 htmlspecialchars(self
::makeUrl('-',
381 "action=raw$jsCache&gen=js&useskin=" .
382 urlencode( $this->getSkinName() ) ) ) .
383 "\"><!-- site js --></script>\n";
385 if( $allowUserJs && $wgUser->isLoggedIn() ) {
386 $userpage = $wgUser->getUserPage();
387 $userjs = htmlspecialchars( self
::makeUrl(
388 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
389 'action=raw&ctype='.$wgJsMimeType));
390 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
396 * To make it harder for someone to slip a user a fake
397 * user-JavaScript or user-CSS preview, a random token
398 * is associated with the login session. If it's not
399 * passed back with the preview request, we won't render
402 * @param string $action
406 function userCanPreview( $action ) {
407 global $wgTitle, $wgRequest, $wgUser;
409 if( $action != 'submit' )
411 if( !$wgRequest->wasPosted() )
413 if( !$wgTitle->userCanEditCssJsSubpage() )
415 return $wgUser->matchEditToken(
416 $wgRequest->getVal( 'wpEditToken' ) );
419 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
420 function getUserStylesheet() {
421 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
422 $sheet = $this->getStylesheet();
423 $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n";
424 $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n";
425 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
426 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
428 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
429 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
430 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
432 $s .= $this->doGetUserStyles();
437 * This returns MediaWiki:Common.js, and derived classes may add other JS.
438 * Despite its name, it does *not* return any custom user JS from user
439 * subpages. The returned script is sitewide and publicly cacheable and
440 * therefore must not include anything that varies according to user,
441 * interface language, etc. (although it may vary by skin). See
442 * makeGlobalVariablesScript for things that can vary per page view and are
445 * @return string Raw JavaScript to be returned
447 public function getUserJs() {
448 wfProfileIn( __METHOD__
);
451 $s = "/* generated javascript */\n";
452 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
453 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
454 $s .= "\n\n/* MediaWiki:Common.js */\n";
455 $commonJs = wfMsgForContent('common.js');
456 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
459 wfProfileOut( __METHOD__
);
464 * Return html code that include User stylesheets
466 function getUserStyles() {
467 $s = "<style type='text/css'>\n";
468 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
469 $s .= $this->getUserStylesheet();
470 $s .= "/*]]>*/ /* */\n";
476 * Some styles that are set by user through the user settings interface.
478 function doGetUserStyles() {
479 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
483 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
484 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
485 $s .= $wgRequest->getText('wpTextbox1');
487 $userpage = $wgUser->getUserPage();
488 $s.= '@import "'.self
::makeUrl(
489 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
490 'action=raw&ctype=text/css').'";'."\n";
494 return $s . $this->reallyDoGetUserStyles();
497 function reallyDoGetUserStyles() {
500 if (($undopt = $wgUser->getOption("underline")) < 2) {
501 $underline = $undopt ?
'underline' : 'none';
502 $s .= "a { text-decoration: $underline; }\n";
504 if( $wgUser->getOption( 'highlightbroken' ) ) {
505 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
508 a.new, #quickbar a.new,
509 a.stub, #quickbar a.stub {
512 a.new:after, #quickbar a.new:after {
516 a.stub:after, #quickbar a.stub:after {
522 if( $wgUser->getOption( 'justify' ) ) {
523 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
525 if( !$wgUser->getOption( 'showtoc' ) ) {
526 $s .= "#toc { display: none; }\n";
528 if( !$wgUser->getOption( 'editsection' ) ) {
529 $s .= ".editsection { display: none; }\n";
534 function getBodyOptions() {
535 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
537 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
539 if ( 0 != $wgTitle->getNamespace() ) {
540 $a = array( 'bgcolor' => '#ffffec' );
542 else $a = array( 'bgcolor' => '#FFFFFF' );
543 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
544 $wgTitle->userCan( 'edit' ) ) {
545 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
546 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
547 $a +
= array ('ondblclick' => $s);
550 $a['onload'] = $wgOut->getOnloadHandler();
552 'mediawiki ns-'.$wgTitle->getNamespace().
553 ' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
554 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
567 * This will be called immediately after the <body> tag. Split into
568 * two functions to make it easier to subclass.
570 function beforeContent() {
571 return $this->doBeforeContent();
574 function doBeforeContent() {
576 $fname = 'Skin::doBeforeContent';
577 wfProfileIn( $fname );
580 $qb = $this->qbSetting();
582 if( $langlinks = $this->otherLanguages() ) {
588 $borderhack = 'class="top"';
591 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
592 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
595 $left = ($qb == 1 ||
$qb == 3);
596 if($wgContLang->isRTL()) $left = !$left;
599 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
600 $this->logoText() . '</td>';
602 $s .= $this->getQuickbarCompensator( $rows );
604 $l = $wgContLang->isRTL() ?
'right' : 'left';
605 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
607 $s .= $this->topLinks() ;
608 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
610 $r = $wgContLang->isRTL() ?
"left" : "right";
611 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
612 $s .= $this->nameAndLogin();
613 $s .= "\n<br />" . $this->searchForm() . "</td>";
616 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
619 if ( $shove && !$left ) { # Right
620 $s .= $this->getQuickbarCompensator( $rows );
622 $s .= "</tr>\n</table>\n</div>\n";
623 $s .= "\n<div id='article'>\n";
625 $notice = wfGetSiteNotice();
627 $s .= "\n<div id='siteNotice'>$notice</div>\n";
629 $s .= $this->pageTitle();
630 $s .= $this->pageSubtitle() ;
631 $s .= $this->getCategories();
632 wfProfileOut( $fname );
637 function getCategoryLinks() {
638 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
639 global $wgContLang, $wgUser;
641 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
644 $sep = wfMsgHtml( 'catseparator' );
646 // Use Unicode bidi embedding override characters,
647 // to make sure links don't smash each other up in ugly ways.
648 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
649 $embed = "<span dir='$dir'>";
652 $allCats = $wgOut->getCategoryLinks();
654 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
655 if ( !empty( $allCats['normal'] ) ) {
656 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
658 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
659 $s .= '<div id="mw-normal-catlinks">' .
660 $this->link( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
661 . $colon . $t . '</div>';
665 if ( isset( $allCats['hidden'] ) ) {
666 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
667 $class ='mw-hidden-cats-user-shown';
668 } elseif ( $wgTitle->getNamespace() == NS_CATEGORY
) {
669 $class = 'mw-hidden-cats-ns-shown';
671 $class = 'mw-hidden-cats-hidden';
673 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
674 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
675 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
679 # optional 'dmoz-like' category browser. Will be shown under the list
680 # of categories an article belong to
681 if($wgUseCategoryBrowser) {
682 $s .= '<br /><hr />';
684 # get a big array of the parents tree
685 $parenttree = $wgTitle->getParentCategoryTree();
686 # Skin object passed by reference cause it can not be
687 # accessed under the method subfunction drawCategoryBrowser
688 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
689 # Clean out bogus first entry and sort them
692 # Output one per line
693 $s .= implode("<br />\n", $tempout);
699 /** Render the array as a serie of links.
700 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
701 * @param &skin Object: skin passed by reference
702 * @return String separated by >, terminate with "\n"
704 function drawCategoryBrowser($tree, &$skin) {
706 foreach ($tree as $element => $parent) {
707 if (empty($parent)) {
708 # element start a new list
711 # grab the others elements
712 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
714 # add our current element to the list
715 $eltitle = Title
::newFromText($element);
716 $return .= $skin->link( $eltitle, $eltitle->getText() ) ;
721 function getCategories() {
722 $catlinks=$this->getCategoryLinks();
724 $classes = 'catlinks';
726 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
727 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
728 $classes .= ' catlinks-allhidden';
731 if( !empty( $catlinks ) ){
732 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
736 function getQuickbarCompensator( $rows = 1 ) {
737 return "<td width='152' rowspan='{$rows}'> </td>";
741 * This gets called shortly before the \</body\> tag.
742 * @return String HTML to be put before \</body\>
744 function afterContent() {
745 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
746 return $printfooter . $this->doAfterContent();
750 * This gets called shortly before the \</body\> tag.
751 * @return String HTML-wrapped JS code to be put before \</body\>
753 function bottomScripts() {
754 global $wgJsMimeType;
755 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
756 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
757 return $bottomScriptText;
760 /** @return string Retrievied from HTML text */
761 function printSource() {
763 $url = htmlspecialchars( $wgTitle->getFullURL() );
764 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
767 function printFooter() {
768 return "<p>" . $this->printSource() .
769 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
772 /** overloaded by derived classes */
773 function doAfterContent() { }
775 function pageTitleLinks() {
776 global $wgOut, $wgTitle, $wgUser, $wgRequest;
778 $oldid = $wgRequest->getVal( 'oldid' );
779 $diff = $wgRequest->getVal( 'diff' );
780 $action = $wgRequest->getText( 'action' );
782 $s = $this->printableLink();
783 $disclaimer = $this->disclaimerLink(); # may be empty
785 $s .= ' | ' . $disclaimer;
787 $privacy = $this->privacyLink(); # may be empty too
789 $s .= ' | ' . $privacy;
792 if ( $wgOut->isArticleRelated() ) {
793 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
794 $name = $wgTitle->getDBkey();
795 $image = wfFindFile( $wgTitle );
797 $link = htmlspecialchars( $image->getURL() );
798 $style = $this->getInternalLinkAttributes( $link, $name );
799 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
803 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
804 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
805 wfMsg( 'currentrev' ) );
808 if ( $wgUser->getNewtalk() ) {
809 # do not show "You have new messages" text when we are viewing our
811 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
812 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
813 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
814 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
816 $wgOut->setSquidMaxage(0);
817 $wgOut->enableClientCache(false);
821 $undelete = $this->getUndeleteLink();
822 if( !empty( $undelete ) ) {
823 $s .= ' | '.$undelete;
828 function getUndeleteLink() {
829 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
830 if( $wgUser->isAllowed( 'deletedhistory' ) &&
831 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
832 ($n = $wgTitle->isDeleted() ) )
834 if ( $wgUser->isAllowed( 'undelete' ) ) {
835 $msg = 'thisisdeleted';
837 $msg = 'viewdeleted';
840 $this->makeKnownLinkObj(
841 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
842 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
847 function printableLink() {
848 global $wgOut, $wgFeedClasses, $wgRequest;
850 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
852 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
853 if( $wgOut->isSyndicated() ) {
854 foreach( $wgFeedClasses as $format => $class ) {
855 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
856 $s .= " | <a href=\"$feedurl\">{$format}</a>";
862 function pageTitle() {
864 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
868 function pageSubtitle() {
871 $sub = $wgOut->getSubtitle();
873 global $wgExtraSubtitle;
874 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
876 $subpages = $this->subPageSubtitle();
877 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
878 $s = "<p class='subtitle'>{$sub}</p>\n";
882 function subPageSubtitle() {
884 if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
887 global $wgOut, $wgTitle;
888 if($wgOut->isArticle() && MWNamespace
::hasSubpages( $wgTitle->getNamespace() )) {
889 $ptext=$wgTitle->getPrefixedText();
890 if(preg_match('/\//',$ptext)) {
891 $links = explode('/',$ptext);
896 foreach($links as $link) {
897 $growinglink .= $link;
899 $linkObj = Title
::newFromText( $growinglink );
900 if( is_object( $linkObj ) && $linkObj->exists() ){
901 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
906 $subpages .= '< ';
908 $subpages .= $getlink;
921 * Returns true if the IP should be shown in the header
923 function showIPinHeader() {
924 global $wgShowIPinHeader;
925 return $wgShowIPinHeader && session_id() != '';
928 function nameAndLogin() {
929 global $wgUser, $wgTitle, $wgLang, $wgContLang;
931 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
934 if ( $wgUser->isAnon() ) {
935 if( $this->showIPinHeader() ) {
938 $talkLink = $this->link( $wgUser->getTalkPage(),
939 $wgLang->getNsText( NS_TALK
) );
941 $ret .= "$name ($talkLink)";
943 $ret .= wfMsg( 'notloggedin' );
946 $returnTo = $wgTitle->getPrefixedDBkey();
948 if ( $logoutPage != $returnTo ) {
949 $query['returnto'] = $returnTo;
952 $loginlink = $wgUser->isAllowed( 'createaccount' )
953 ?
'nav-login-createaccount'
955 $ret .= "\n<br />" . $this->link(
956 SpecialPage
::getTitleFor( 'Userlogin' ),
957 wfMsg( $loginlink ), array(), $query
960 $returnTo = $wgTitle->getPrefixedDBkey();
961 $talkLink = $this->link( $wgUser->getTalkPage(),
962 $wgLang->getNsText( NS_TALK
) );
964 $ret .= $this->link( $wgUser->getUserPage(),
965 htmlspecialchars( $wgUser->getName() ) );
966 $ret .= " ($talkLink)<br />";
968 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
969 array(), array( 'returnto' => $returnTo )
971 $ret .= ' | ' . $this->specialLink( 'preferences' );
973 $ret .= ' | ' . $this->link(
974 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
981 function getSearchLink() {
982 $searchPage = SpecialPage
::getTitleFor( 'Search' );
983 return $searchPage->getLocalURL();
986 function escapeSearchLink() {
987 return htmlspecialchars( $this->getSearchLink() );
990 function searchForm() {
992 $search = $wgRequest->getText( 'search' );
994 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
995 . $this->escapeSearchLink() . "\">\n"
996 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
997 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
998 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
999 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
1001 // Ensure unique id's for search boxes made after the first
1002 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1007 function topLinks() {
1011 $s = $this->mainPageLink() . $sep
1012 . $this->specialLink( 'recentchanges' );
1014 if ( $wgOut->isArticleRelated() ) {
1015 $s .= $sep . $this->editThisPage()
1016 . $sep . $this->historyLink();
1018 # Many people don't like this dropdown box
1019 #$s .= $sep . $this->specialPagesList();
1021 $s .= $this->variantLinks();
1023 $s .= $this->extensionTabLinks();
1029 * Compatibility for extensions adding functionality through tabs.
1030 * Eventually these old skins should be replaced with SkinTemplate-based
1034 function extensionTabLinks() {
1037 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1038 foreach( $tabs as $tab ) {
1039 $s .= ' | ' . Xml
::element( 'a',
1040 array( 'href' => $tab['href'] ),
1047 * Language/charset variant links for classic-style skins
1050 function variantLinks() {
1052 /* show links to different language variants */
1053 global $wgDisableLangConversion, $wgContLang, $wgTitle;
1054 $variants = $wgContLang->getVariants();
1055 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1056 foreach( $variants as $code ) {
1057 $varname = $wgContLang->getVariantname( $code );
1058 if( $varname == 'disable' )
1060 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1066 function bottomLinks() {
1067 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1071 if ( $wgOut->isArticleRelated() ) {
1072 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1073 if ( $wgUser->isLoggedIn() ) {
1074 $s .= $sep . $this->watchThisPage();
1076 $s .= $sep . $this->talkLink()
1077 . $sep . $this->historyLink()
1078 . $sep . $this->whatLinksHere()
1079 . $sep . $this->watchPageLinksLink();
1081 if ($wgUseTrackbacks)
1082 $s .= $sep . $this->trackbackLink();
1084 if ( $wgTitle->getNamespace() == NS_USER
1085 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1088 $id=User
::idFromName($wgTitle->getText());
1089 $ip=User
::isIP($wgTitle->getText());
1091 if($id ||
$ip) { # both anons and non-anons have contri list
1092 $s .= $sep . $this->userContribsLink();
1094 if( $this->showEmailUser( $id ) ) {
1095 $s .= $sep . $this->emailUserLink();
1098 if ( $wgTitle->getArticleId() ) {
1100 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1101 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1102 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1104 $s .= "<br />\n" . $this->otherLanguages();
1109 function pageStats() {
1110 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1111 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1113 $oldid = $wgRequest->getVal( 'oldid' );
1114 $diff = $wgRequest->getVal( 'diff' );
1115 if ( ! $wgOut->isArticle() ) { return ''; }
1116 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1117 if ( 0 == $wgArticle->getID() ) { return ''; }
1120 if ( !$wgDisableCounters ) {
1121 $count = $wgLang->formatNum( $wgArticle->getCount() );
1123 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1127 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1128 require_once('Credits.php');
1129 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1131 $s .= $this->lastModified();
1134 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1135 $dbr = wfGetDB( DB_SLAVE
);
1136 $watchlist = $dbr->tableName( 'watchlist' );
1137 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1138 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1139 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1140 $res = $dbr->query( $sql, 'Skin::pageStats');
1141 $x = $dbr->fetchObject( $res );
1143 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1144 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1148 return $s . ' ' . $this->getCopyright();
1151 function getCopyright( $type = 'detect' ) {
1152 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1154 if ( $type == 'detect' ) {
1155 $oldid = $wgRequest->getVal( 'oldid' );
1156 $diff = $wgRequest->getVal( 'diff' );
1158 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1165 if ( $type == 'history' ) {
1166 $msg = 'history_copyright';
1172 if( $wgRightsPage ) {
1173 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1174 } elseif( $wgRightsUrl ) {
1175 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1180 $out .= wfMsgForContent( $msg, $link );
1184 function getCopyrightIcon() {
1185 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1187 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1188 $out = $wgCopyrightIcon;
1189 } else if ( $wgRightsIcon ) {
1190 $icon = htmlspecialchars( $wgRightsIcon );
1191 if ( $wgRightsUrl ) {
1192 $url = htmlspecialchars( $wgRightsUrl );
1193 $out .= '<a href="'.$url.'">';
1195 $text = htmlspecialchars( $wgRightsText );
1196 $out .= "<img src=\"$icon\" alt='$text' />";
1197 if ( $wgRightsUrl ) {
1204 function getPoweredBy() {
1205 global $wgStylePath;
1206 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1207 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1211 function lastModified() {
1212 global $wgLang, $wgArticle;
1213 if( $this->mRevisionId
) {
1214 $timestamp = Revision
::getTimestampFromId( $this->mRevisionId
, $wgArticle->getId() );
1216 $timestamp = $wgArticle->getTimestamp();
1219 $d = $wgLang->date( $timestamp, true );
1220 $t = $wgLang->time( $timestamp, true );
1221 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1225 if ( wfGetLB()->getLaggedSlaveMode() ) {
1226 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1231 function logoText( $align = '' ) {
1232 if ( '' != $align ) { $a = " align='{$align}'"; }
1235 $mp = wfMsg( 'mainpage' );
1236 $mptitle = Title
::newMainPage();
1237 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1239 $logourl = $this->getLogo();
1240 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1245 * show a drop-down box of special pages
1247 function specialPagesList() {
1248 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1249 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1250 foreach ( $pages as $name => $page ) {
1251 $pages[$name] = $page->getDescription();
1254 $go = wfMsg( 'go' );
1255 $sp = wfMsg( 'specialpages' );
1256 $spp = $wgContLang->specialPage( 'Specialpages' );
1258 $s = '<form id="specialpages" method="get" class="inline" ' .
1259 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1260 $s .= "<select name=\"wpDropdown\">\n";
1261 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1264 foreach ( $pages as $name => $desc ) {
1265 $p = $wgContLang->specialPage( $name );
1266 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1268 $s .= "</select>\n";
1269 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1274 function mainPageLink() {
1275 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1279 function copyrightLink() {
1280 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1281 wfMsg( 'copyrightpagename' ) );
1285 private function footerLink ( $desc, $page ) {
1286 // if the link description has been set to "-" in the default language,
1287 if ( wfMsgForContent( $desc ) == '-') {
1288 // then it is disabled, for all languages.
1291 // Otherwise, we display the link for the user, described in their
1292 // language (which may or may not be the same as the default language),
1293 // but we make the link target be the one site-wide page.
1294 return $this->makeKnownLink( wfMsgForContent( $page ),
1295 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1299 function privacyLink() {
1300 return $this->footerLink( 'privacy', 'privacypage' );
1303 function aboutLink() {
1304 return $this->footerLink( 'aboutsite', 'aboutpage' );
1307 function disclaimerLink() {
1308 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1311 function editThisPage() {
1312 global $wgOut, $wgTitle;
1314 if ( !$wgOut->isArticleRelated() ) {
1315 $s = wfMsg( 'protectedpage' );
1317 if( $wgTitle->userCan( 'edit' ) && $wgTitle->exists() ) {
1318 $t = wfMsg( 'editthispage' );
1319 } elseif( $wgTitle->userCan( 'create' ) && !$wgTitle->exists() ) {
1320 $t = wfMsg( 'create-this-page' );
1322 $t = wfMsg( 'viewsource' );
1325 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1331 * Return URL options for the 'edit page' link.
1332 * This may include an 'oldid' specifier, if the current page view is such.
1337 function editUrlOptions() {
1340 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1341 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1343 return "action=edit";
1347 function deleteThisPage() {
1348 global $wgUser, $wgTitle, $wgRequest;
1350 $diff = $wgRequest->getVal( 'diff' );
1351 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1352 $t = wfMsg( 'deletethispage' );
1354 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1361 function protectThisPage() {
1362 global $wgUser, $wgTitle, $wgRequest;
1364 $diff = $wgRequest->getVal( 'diff' );
1365 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1366 if ( $wgTitle->isProtected() ) {
1367 $t = wfMsg( 'unprotectthispage' );
1368 $q = 'action=unprotect';
1370 $t = wfMsg( 'protectthispage' );
1371 $q = 'action=protect';
1373 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1380 function watchThisPage() {
1381 global $wgOut, $wgTitle;
1382 ++
$this->mWatchLinkNum
;
1384 if ( $wgOut->isArticleRelated() ) {
1385 if ( $wgTitle->userIsWatching() ) {
1386 $t = wfMsg( 'unwatchthispage' );
1387 $q = 'action=unwatch';
1388 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1390 $t = wfMsg( 'watchthispage' );
1391 $q = 'action=watch';
1392 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1394 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1396 $s = wfMsg( 'notanarticle' );
1401 function moveThisPage() {
1404 if ( $wgTitle->userCan( 'move' ) ) {
1405 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1406 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1408 // no message if page is protected - would be redundant
1413 function historyLink() {
1416 return $this->makeKnownLinkObj( $wgTitle,
1417 wfMsg( 'history' ), 'action=history' );
1420 function whatLinksHere() {
1423 return $this->makeKnownLinkObj(
1424 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1425 wfMsg( 'whatlinkshere' ) );
1428 function userContribsLink() {
1431 return $this->makeKnownLinkObj(
1432 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1433 wfMsg( 'contributions' ) );
1436 function showEmailUser( $id ) {
1437 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1438 return $wgEnableEmail &&
1439 $wgEnableUserEmail &&
1440 $wgUser->isLoggedIn() && # show only to signed in users
1441 0 != $id; # we can only email to non-anons ..
1442 # '' != $id->getEmail() && # who must have an email address stored ..
1443 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1444 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1447 function emailUserLink() {
1450 return $this->makeKnownLinkObj(
1451 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1452 wfMsg( 'emailuser' ) );
1455 function watchPageLinksLink() {
1456 global $wgOut, $wgTitle;
1458 if ( ! $wgOut->isArticleRelated() ) {
1459 return '(' . wfMsg( 'notanarticle' ) . ')';
1461 return $this->makeKnownLinkObj(
1462 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1463 wfMsg( 'recentchangeslinked' ) );
1467 function trackbackLink() {
1470 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1471 . wfMsg('trackbacklink') . "</a>";
1474 function otherLanguages() {
1475 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1477 if ( $wgHideInterlanguageLinks ) {
1481 $a = $wgOut->getLanguageLinks();
1482 if ( 0 == count( $a ) ) {
1486 $s = wfMsg( 'otherlanguages' ) . ': ';
1488 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1489 foreach( $a as $l ) {
1490 if ( ! $first ) { $s .= ' | '; }
1493 $nt = Title
::newFromText( $l );
1494 $url = $nt->escapeFullURL();
1495 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1497 if ( '' == $text ) { $text = $l; }
1498 $style = $this->getExternalLinkAttributes( $l, $text );
1499 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1501 if($wgContLang->isRTL()) $s .= '</span>';
1505 function bugReportsLink() {
1506 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1507 wfMsg( 'bugreports' ) );
1511 function talkLink() {
1514 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1515 # No discussion links for special pages
1519 if( $wgTitle->isTalkPage() ) {
1520 $link = $wgTitle->getSubjectPage();
1521 switch( $link->getNamespace() ) {
1523 $text = wfMsg( 'articlepage' );
1526 $text = wfMsg( 'userpage' );
1529 $text = wfMsg( 'projectpage' );
1532 $text = wfMsg( 'imagepage' );
1535 $text = wfMsg( 'mediawikipage' );
1538 $text = wfMsg( 'templatepage' );
1541 $text = wfMsg( 'viewhelppage' );
1544 $text = wfMsg( 'categorypage' );
1547 $text = wfMsg( 'articlepage' );
1550 $link = $wgTitle->getTalkPage();
1551 $text = wfMsg( 'talkpage' );
1554 $s = $this->makeLinkObj( $link, $text );
1559 function commentLink() {
1560 global $wgTitle, $wgOut;
1562 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1566 # __NEWSECTIONLINK___ changes behaviour here
1567 # If it's present, the link points to this page, otherwise
1568 # it points to the talk page
1569 if( $wgTitle->isTalkPage() ) {
1571 } elseif( $wgOut->showNewSectionLink() ) {
1574 $title = $wgTitle->getTalkPage();
1577 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1580 /* these are used extensively in SkinTemplate, but also some other places */
1581 static function makeMainPageUrl( $urlaction = '' ) {
1582 $title = Title
::newMainPage();
1583 self
::checkTitle( $title, '' );
1584 return $title->getLocalURL( $urlaction );
1587 static function makeSpecialUrl( $name, $urlaction = '' ) {
1588 $title = SpecialPage
::getTitleFor( $name );
1589 return $title->getLocalURL( $urlaction );
1592 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1593 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1594 return $title->getLocalURL( $urlaction );
1597 static function makeI18nUrl( $name, $urlaction = '' ) {
1598 $title = Title
::newFromText( wfMsgForContent( $name ) );
1599 self
::checkTitle( $title, $name );
1600 return $title->getLocalURL( $urlaction );
1603 static function makeUrl( $name, $urlaction = '' ) {
1604 $title = Title
::newFromText( $name );
1605 self
::checkTitle( $title, $name );
1606 return $title->getLocalURL( $urlaction );
1609 # If url string starts with http, consider as external URL, else
1611 static function makeInternalOrExternalUrl( $name ) {
1612 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1615 return self
::makeUrl( $name );
1619 # this can be passed the NS number as defined in Language.php
1620 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1621 $title = Title
::makeTitleSafe( $namespace, $name );
1622 self
::checkTitle( $title, $name );
1623 return $title->getLocalURL( $urlaction );
1626 /* these return an array with the 'href' and boolean 'exists' */
1627 static function makeUrlDetails( $name, $urlaction = '' ) {
1628 $title = Title
::newFromText( $name );
1629 self
::checkTitle( $title, $name );
1631 'href' => $title->getLocalURL( $urlaction ),
1632 'exists' => $title->getArticleID() != 0 ?
true : false
1637 * Make URL details where the article exists (or at least it's convenient to think so)
1639 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1640 $title = Title
::newFromText( $name );
1641 self
::checkTitle( $title, $name );
1643 'href' => $title->getLocalURL( $urlaction ),
1648 # make sure we have some title to operate on
1649 static function checkTitle( &$title, $name ) {
1650 if( !is_object( $title ) ) {
1651 $title = Title
::newFromText( $name );
1652 if( !is_object( $title ) ) {
1653 $title = Title
::newFromText( '--error: link target missing--' );
1659 * Build an array that represents the sidebar(s), the navigation bar among them
1663 function buildSidebar() {
1664 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1666 wfProfileIn( __METHOD__
);
1668 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
1670 if ( $wgEnableSidebarCache ) {
1671 $cachedsidebar = $parserMemc->get( $key );
1672 if ( $cachedsidebar ) {
1673 wfProfileOut( __METHOD__
);
1674 return $cachedsidebar;
1679 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1681 foreach ($lines as $line) {
1682 if (strpos($line, '*') !== 0)
1684 if (strpos($line, '**') !== 0) {
1685 $line = trim($line, '* ');
1687 if( !array_key_exists($heading, $bar) ) $bar[$heading] = array();
1689 if (strpos($line, '|') !== false) { // sanity check
1690 $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) );
1691 $link = wfMsgForContent( $line[0] );
1694 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1696 if (wfEmptyMsg($line[0], $link))
1699 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1702 $title = Title
::newFromText( $link );
1704 $title = $title->fixSpecialName();
1705 $href = $title->getLocalURL();
1707 $href = 'INVALID-TITLE';
1711 $bar[$heading][] = array(
1714 'id' => 'n-' . strtr($line[1], ' ', '-'),
1717 } else { continue; }
1720 wfRunHooks('SkinBuildSidebar', array($this, &$bar));
1721 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1722 wfProfileOut( __METHOD__
);