2 if ( ! defined( 'MEDIAWIKI' ) )
8 * The main skin class that provide methods and properties for all other skins.
9 * This base class is also the "Standard" skin.
11 * See docs/skin.txt for more information.
15 class Skin
extends Linker
{
19 var $mWatchLinkNum = 0; // Appended to end of watch link id's
21 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
22 protected $skinname = 'standard' ;
24 /** Constructor, call parent constructor */
25 function Skin() { parent
::__construct(); }
28 * Fetch the set of available skins.
29 * @return array of strings
32 static function getSkinNames() {
33 global $wgValidSkinNames;
34 static $skinsInitialised = false;
35 if ( !$skinsInitialised ) {
36 # Get a list of available skins
37 # Build using the regular expression '^(.*).php$'
38 # Array keys are all lower case, array value keep the case used by filename
40 wfProfileIn( __METHOD__
. '-init' );
41 global $wgStyleDirectory;
42 $skinDir = dir( $wgStyleDirectory );
44 # while code from www.php.net
45 while (false !== ($file = $skinDir->read())) {
46 // Skip non-PHP files, hidden files, and '.dep' includes
48 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
50 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
54 $skinsInitialised = true;
55 wfProfileOut( __METHOD__
. '-init' );
57 return $wgValidSkinNames;
61 * Normalize a skin preference value to a form that can be loaded.
62 * If a skin can't be found, it will fall back to the configured
63 * default (or the old 'Classic' skin if that's broken).
68 static function normalizeKey( $key ) {
69 global $wgDefaultSkin;
70 $skinNames = Skin
::getSkinNames();
73 // Don't return the default immediately;
74 // in a misconfiguration we need to fall back.
75 $key = $wgDefaultSkin;
78 if( isset( $skinNames[$key] ) ) {
82 // Older versions of the software used a numeric setting
83 // in the user preferences.
89 if( isset( $fallback[$key] ) ){
90 $key = $fallback[$key];
93 if( isset( $skinNames[$key] ) ) {
101 * Factory method for loading a skin of a given type
102 * @param string $key 'monobook', 'standard', etc
106 static function &newFromKey( $key ) {
107 global $wgStyleDirectory;
109 $key = Skin
::normalizeKey( $key );
111 $skinNames = Skin
::getSkinNames();
112 $skinName = $skinNames[$key];
113 $className = 'Skin'.ucfirst($key);
115 # Grab the skin class and initialise it.
116 if ( !class_exists( $className ) ) {
117 // Preload base classes to work around APC/PHP5 bug
118 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
119 if( file_exists( $deps ) ) include_once( $deps );
120 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
122 # Check if we got if not failback to default skin
123 if( !class_exists( $className ) ) {
124 # DO NOT die if the class isn't found. This breaks maintenance
125 # scripts and can cause a user account to be unrecoverable
126 # except by SQL manipulation if a previously valid skin name
127 # is no longer valid.
128 wfDebug( "Skin class does not exist: $className\n" );
129 $className = 'SkinMonobook';
130 require_once( "{$wgStyleDirectory}/MonoBook.php" );
133 $skin = new $className;
137 /** @return string path to the skin stylesheet */
138 function getStylesheet() {
139 return 'common/wikistandard.css';
142 /** @return string skin name */
143 public function getSkinName() {
144 return $this->skinname
;
147 function qbSetting() {
148 global $wgOut, $wgUser;
150 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
151 $q = $wgUser->getOption( 'quickbar', 0 );
155 function initPage( &$out ) {
156 global $wgFavicon, $wgAppleTouchIcon, $wgScriptPath, $wgScriptExtension;
158 wfProfileIn( __METHOD__
);
160 if( false !== $wgFavicon ) {
161 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
164 if( false !== $wgAppleTouchIcon ) {
165 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
168 # OpenSearch description link
169 $out->addLink( array(
171 'type' => 'application/opensearchdescription+xml',
172 'href' => "$wgScriptPath/opensearch_desc{$wgScriptExtension}",
173 'title' => wfMsgForContent( 'opensearch-desc' ),
176 $this->addMetadataLinks($out);
178 $this->mRevisionId
= $out->mRevisionId
;
180 $this->preloadExistence();
182 wfProfileOut( __METHOD__
);
186 * Preload the existence of three commonly-requested pages in a single query
188 function preloadExistence() {
189 global $wgUser, $wgTitle;
192 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
195 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
197 } elseif ( $wgTitle->isTalkPage() ) {
198 $titles[] = $wgTitle->getSubjectPage();
200 $titles[] = $wgTitle->getTalkPage();
203 $lb = new LinkBatch( $titles );
207 function addMetadataLinks( &$out ) {
208 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
209 global $wgRightsPage, $wgRightsUrl;
211 if( $out->isArticleRelated() ) {
212 # note: buggy CC software only reads first "meta" link
213 if( $wgEnableCreativeCommonsRdf ) {
214 $out->addMetadataLink( array(
215 'title' => 'Creative Commons',
216 'type' => 'application/rdf+xml',
217 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
219 if( $wgEnableDublinCoreRdf ) {
220 $out->addMetadataLink( array(
221 'title' => 'Dublin Core',
222 'type' => 'application/rdf+xml',
223 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
227 if( $wgRightsPage ) {
228 $copy = Title
::newFromText( $wgRightsPage );
230 $copyright = $copy->getLocalURL();
233 if( !$copyright && $wgRightsUrl ) {
234 $copyright = $wgRightsUrl;
237 $out->addLink( array(
238 'rel' => 'copyright',
239 'href' => $copyright ) );
243 function outputPage( &$out ) {
244 global $wgDebugComments;
246 wfProfileIn( __METHOD__
);
247 $this->initPage( $out );
249 $out->out( $out->headElement() );
251 $out->out( "\n<body" );
252 $ops = $this->getBodyOptions();
253 foreach ( $ops as $name => $val ) {
254 $out->out( " $name='$val'" );
257 if ( $wgDebugComments ) {
258 $out->out( "<!-- Wiki debugging output:\n" .
259 $out->mDebugtext
. "-->\n" );
262 $out->out( $this->beforeContent() );
264 $out->out( $out->mBodytext
. "\n" );
266 $out->out( $this->afterContent() );
268 $out->out( $this->bottomScripts() );
270 $out->out( $out->reportTime() );
272 $out->out( "\n</body></html>" );
273 wfProfileOut( __METHOD__
);
276 static function makeVariablesScript( $data ) {
277 global $wgJsMimeType;
279 $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n";
280 foreach ( $data as $name => $value ) {
281 $encValue = Xml
::encodeJsVar( $value );
282 $r .= "var $name = $encValue;\n";
284 $r .= "/*]]>*/</script>\n";
290 * Make a <script> tag containing global variables
291 * @param array $data Associative array containing one element:
292 * skinname => the skin name
293 * The odd calling convention is for backwards compatibility
295 static function makeGlobalVariablesScript( $data ) {
296 global $wgScript, $wgStylePath, $wgUser;
297 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
298 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
299 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
300 global $wgUseAjax, $wgAjaxWatch;
301 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
302 global $wgRestrictionTypes, $wgLivePreview;
304 $ns = $wgTitle->getNamespace();
305 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
308 'skin' => $data['skinname'],
309 'stylepath' => $wgStylePath,
310 'wgArticlePath' => $wgArticlePath,
311 'wgScriptPath' => $wgScriptPath,
312 'wgScript' => $wgScript,
313 'wgVariantArticlePath' => $wgVariantArticlePath,
314 'wgActionPaths' => $wgActionPaths,
315 'wgServer' => $wgServer,
316 'wgCanonicalNamespace' => $nsname,
317 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
318 'wgNamespaceNumber' => $wgTitle->getNamespace(),
319 'wgPageName' => $wgTitle->getPrefixedDBKey(),
320 'wgTitle' => $wgTitle->getText(),
321 'wgAction' => $wgRequest->getText( 'action', 'view' ),
322 'wgArticleId' => $wgTitle->getArticleId(),
323 'wgIsArticle' => $wgOut->isArticle(),
324 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
325 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
326 'wgUserLanguage' => $wgLang->getCode(),
327 'wgContentLanguage' => $wgContLang->getCode(),
328 'wgBreakFrames' => $wgBreakFrames,
329 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
330 'wgVersion' => $wgVersion,
331 'wgEnableAPI' => $wgEnableAPI,
332 'wgEnableWriteAPI' => $wgEnableWriteAPI,
335 foreach( $wgRestrictionTypes as $type )
336 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
338 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
339 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
340 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
341 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
342 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
345 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
346 $msgs = (object)array();
347 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
348 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
350 $vars['wgAjaxWatch'] = $msgs;
353 return self
::makeVariablesScript( $vars );
356 function getHeadScripts( $allowUserJs ) {
357 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
359 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
361 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
364 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
365 $r .= "<script type=\"$wgJsMimeType\" src=\"".
366 htmlspecialchars(self
::makeUrl('-',
367 "action=raw$jsCache&gen=js&useskin=" .
368 urlencode( $this->getSkinName() ) ) ) .
369 "\"><!-- site js --></script>\n";
371 if( $allowUserJs && $wgUser->isLoggedIn() ) {
372 $userpage = $wgUser->getUserPage();
373 $userjs = htmlspecialchars( self
::makeUrl(
374 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
375 'action=raw&ctype='.$wgJsMimeType));
376 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
382 * To make it harder for someone to slip a user a fake
383 * user-JavaScript or user-CSS preview, a random token
384 * is associated with the login session. If it's not
385 * passed back with the preview request, we won't render
388 * @param string $action
392 function userCanPreview( $action ) {
393 global $wgTitle, $wgRequest, $wgUser;
395 if( $action != 'submit' )
397 if( !$wgRequest->wasPosted() )
399 if( !$wgTitle->userCanEditCssJsSubpage() )
401 return $wgUser->matchEditToken(
402 $wgRequest->getVal( 'wpEditToken' ) );
405 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
406 function getUserStylesheet() {
407 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
408 $sheet = $this->getStylesheet();
409 $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n";
410 $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n";
411 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
412 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
414 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
415 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
416 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
418 $s .= $this->doGetUserStyles();
423 * This returns MediaWiki:Common.js, and derived classes may add other JS.
424 * Despite its name, it does *not* return any custom user JS from user
425 * subpages. The returned script is sitewide and publicly cacheable and
426 * therefore must not include anything that varies according to user,
427 * interface language, etc. (although it may vary by skin). See
428 * makeGlobalVariablesScript for things that can vary per page view and are
431 * @return string Raw JavaScript to be returned
433 public function getUserJs() {
434 wfProfileIn( __METHOD__
);
437 $s = "/* generated javascript */\n";
438 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
439 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
440 $s .= "\n\n/* MediaWiki:Common.js */\n";
441 $commonJs = wfMsgForContent('common.js');
442 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
445 wfProfileOut( __METHOD__
);
450 * Return html code that include User stylesheets
452 function getUserStyles() {
453 $s = "<style type='text/css'>\n";
454 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
455 $s .= $this->getUserStylesheet();
456 $s .= "/*]]>*/ /* */\n";
462 * Some styles that are set by user through the user settings interface.
464 function doGetUserStyles() {
465 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
469 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
470 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
471 $s .= $wgRequest->getText('wpTextbox1');
473 $userpage = $wgUser->getUserPage();
474 $s.= '@import "'.self
::makeUrl(
475 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
476 'action=raw&ctype=text/css').'";'."\n";
480 return $s . $this->reallyDoGetUserStyles();
483 function reallyDoGetUserStyles() {
486 if (($undopt = $wgUser->getOption("underline")) < 2) {
487 $underline = $undopt ?
'underline' : 'none';
488 $s .= "a { text-decoration: $underline; }\n";
490 if( $wgUser->getOption( 'highlightbroken' ) ) {
491 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
494 a.new, #quickbar a.new,
495 a.stub, #quickbar a.stub {
498 a.new:after, #quickbar a.new:after {
502 a.stub:after, #quickbar a.stub:after {
508 if( $wgUser->getOption( 'justify' ) ) {
509 $s .= "#article, #bodyContent { text-align: justify; }\n";
511 if( !$wgUser->getOption( 'showtoc' ) ) {
512 $s .= "#toc { display: none; }\n";
514 if( !$wgUser->getOption( 'editsection' ) ) {
515 $s .= ".editsection { display: none; }\n";
520 function getBodyOptions() {
521 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
523 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
525 if ( 0 != $wgTitle->getNamespace() ) {
526 $a = array( 'bgcolor' => '#ffffec' );
528 else $a = array( 'bgcolor' => '#FFFFFF' );
529 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
530 $wgTitle->userCan( 'edit' ) ) {
531 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
532 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
533 $a +
= array ('ondblclick' => $s);
536 $a['onload'] = $wgOut->getOnloadHandler();
537 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
538 if( $a['onload'] != '' ) {
541 $a['onload'] .= 'setupRightClickEdit()';
544 'mediawiki ns-'.$wgTitle->getNamespace().
545 ' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
546 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
559 * This will be called immediately after the <body> tag. Split into
560 * two functions to make it easier to subclass.
562 function beforeContent() {
563 return $this->doBeforeContent();
566 function doBeforeContent() {
568 $fname = 'Skin::doBeforeContent';
569 wfProfileIn( $fname );
572 $qb = $this->qbSetting();
574 if( $langlinks = $this->otherLanguages() ) {
580 $borderhack = 'class="top"';
583 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
584 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
587 $left = ($qb == 1 ||
$qb == 3);
588 if($wgContLang->isRTL()) $left = !$left;
591 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
592 $this->logoText() . '</td>';
594 $s .= $this->getQuickbarCompensator( $rows );
596 $l = $wgContLang->isRTL() ?
'right' : 'left';
597 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
599 $s .= $this->topLinks() ;
600 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
602 $r = $wgContLang->isRTL() ?
"left" : "right";
603 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
604 $s .= $this->nameAndLogin();
605 $s .= "\n<br />" . $this->searchForm() . "</td>";
608 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
611 if ( $shove && !$left ) { # Right
612 $s .= $this->getQuickbarCompensator( $rows );
614 $s .= "</tr>\n</table>\n</div>\n";
615 $s .= "\n<div id='article'>\n";
617 $notice = wfGetSiteNotice();
619 $s .= "\n<div id='siteNotice'>$notice</div>\n";
621 $s .= $this->pageTitle();
622 $s .= $this->pageSubtitle() ;
623 $s .= $this->getCategories();
624 wfProfileOut( $fname );
629 function getCategoryLinks() {
630 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
631 global $wgContLang, $wgUser;
633 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
636 $sep = wfMsgHtml( 'catseparator' );
638 // Use Unicode bidi embedding override characters,
639 // to make sure links don't smash each other up in ugly ways.
640 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
641 $embed = "<span dir='$dir'>";
644 $allCats = $wgOut->getCategoryLinks();
646 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
647 if ( !empty( $allCats['normal'] ) ) {
648 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
650 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
651 $s .= '<div id="mw-normal-catlinks">' .
652 $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
653 . $colon . $t . '</div>';
657 if ( isset( $allCats['hidden'] ) ) {
658 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
659 $class ='mw-hidden-cats-user-shown';
660 } elseif ( $wgTitle->getNamespace() == NS_CATEGORY
) {
661 $class = 'mw-hidden-cats-ns-shown';
663 $class = 'mw-hidden-cats-hidden';
665 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
666 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
667 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
671 # optional 'dmoz-like' category browser. Will be shown under the list
672 # of categories an article belong to
673 if($wgUseCategoryBrowser) {
674 $s .= '<br /><hr />';
676 # get a big array of the parents tree
677 $parenttree = $wgTitle->getParentCategoryTree();
678 # Skin object passed by reference cause it can not be
679 # accessed under the method subfunction drawCategoryBrowser
680 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
681 # Clean out bogus first entry and sort them
684 # Output one per line
685 $s .= implode("<br />\n", $tempout);
691 /** Render the array as a serie of links.
692 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
693 * @param &skin Object: skin passed by reference
694 * @return String separated by >, terminate with "\n"
696 function drawCategoryBrowser($tree, &$skin) {
698 foreach ($tree as $element => $parent) {
699 if (empty($parent)) {
700 # element start a new list
703 # grab the others elements
704 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
706 # add our current element to the list
707 $eltitle = Title
::NewFromText($element);
708 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
713 function getCategories() {
714 $catlinks=$this->getCategoryLinks();
716 $classes = 'catlinks';
718 if(FALSE === strpos($catlinks,'<div id="mw-normal-catlinks">')) {
719 $classes .= ' catlinks-allhidden';
722 if(!empty($catlinks)) {
723 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
727 function getQuickbarCompensator( $rows = 1 ) {
728 return "<td width='152' rowspan='{$rows}'> </td>";
732 * This gets called shortly before the \</body\> tag.
733 * @return String HTML to be put before \</body\>
735 function afterContent() {
736 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
737 return $printfooter . $this->doAfterContent();
741 * This gets called shortly before the \</body\> tag.
742 * @return String HTML-wrapped JS code to be put before \</body\>
744 function bottomScripts() {
745 global $wgJsMimeType;
746 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
747 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
748 return $bottomScriptText;
751 /** @return string Retrievied from HTML text */
752 function printSource() {
754 $url = htmlspecialchars( $wgTitle->getFullURL() );
755 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
758 function printFooter() {
759 return "<p>" . $this->printSource() .
760 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
763 /** overloaded by derived classes */
764 function doAfterContent() { }
766 function pageTitleLinks() {
767 global $wgOut, $wgTitle, $wgUser, $wgRequest;
769 $oldid = $wgRequest->getVal( 'oldid' );
770 $diff = $wgRequest->getVal( 'diff' );
771 $action = $wgRequest->getText( 'action' );
773 $s = $this->printableLink();
774 $disclaimer = $this->disclaimerLink(); # may be empty
776 $s .= ' | ' . $disclaimer;
778 $privacy = $this->privacyLink(); # may be empty too
780 $s .= ' | ' . $privacy;
783 if ( $wgOut->isArticleRelated() ) {
784 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
785 $name = $wgTitle->getDBkey();
786 $image = wfFindFile( $wgTitle );
788 $link = htmlspecialchars( $image->getURL() );
789 $style = $this->getInternalLinkAttributes( $link, $name );
790 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
794 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
795 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
796 wfMsg( 'currentrev' ) );
799 if ( $wgUser->getNewtalk() ) {
800 # do not show "You have new messages" text when we are viewing our
802 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
803 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
804 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
805 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
807 $wgOut->setSquidMaxage(0);
808 $wgOut->enableClientCache(false);
812 $undelete = $this->getUndeleteLink();
813 if( !empty( $undelete ) ) {
814 $s .= ' | '.$undelete;
819 function getUndeleteLink() {
820 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
821 if( $wgUser->isAllowed( 'deletedhistory' ) &&
822 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
823 ($n = $wgTitle->isDeleted() ) )
825 if ( $wgUser->isAllowed( 'undelete' ) ) {
826 $msg = 'thisisdeleted';
828 $msg = 'viewdeleted';
831 $this->makeKnownLinkObj(
832 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
833 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
838 function printableLink() {
839 global $wgOut, $wgFeedClasses, $wgRequest;
841 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
843 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
844 if( $wgOut->isSyndicated() ) {
845 foreach( $wgFeedClasses as $format => $class ) {
846 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
847 $s .= " | <a href=\"$feedurl\">{$format}</a>";
853 function pageTitle() {
855 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
859 function pageSubtitle() {
862 $sub = $wgOut->getSubtitle();
864 global $wgExtraSubtitle;
865 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
867 $subpages = $this->subPageSubtitle();
868 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
869 $s = "<p class='subtitle'>{$sub}</p>\n";
873 function subPageSubtitle() {
875 if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
878 global $wgOut, $wgTitle, $wgNamespacesWithSubpages;
879 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
880 $ptext=$wgTitle->getPrefixedText();
881 if(preg_match('/\//',$ptext)) {
882 $links = explode('/',$ptext);
885 foreach($links as $link) {
887 if ($c<count($links)) {
888 $growinglink .= $link;
889 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
890 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
894 $subpages .= '< ';
896 $subpages .= $getlink;
906 * Returns true if the IP should be shown in the header
908 function showIPinHeader() {
909 global $wgShowIPinHeader;
910 return $wgShowIPinHeader && session_id() != '';
913 function nameAndLogin() {
914 global $wgUser, $wgTitle, $wgLang, $wgContLang;
916 $lo = $wgContLang->specialPage( 'Userlogout' );
919 if ( $wgUser->isAnon() ) {
920 if( $this->showIPinHeader() ) {
923 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
924 $wgLang->getNsText( NS_TALK
) );
926 $s .= $n . ' ('.$tl.')';
928 $s .= wfMsg('notloggedin');
931 $rt = $wgTitle->getPrefixedURL();
932 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
934 } else { $q = "returnto={$rt}"; }
936 $s .= "\n<br />" . $this->makeKnownLinkObj(
937 SpecialPage
::getTitleFor( 'Userlogin' ),
938 wfMsg( 'login' ), $q );
940 $n = $wgUser->getName();
941 $rt = $wgTitle->getPrefixedURL();
942 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
943 $wgLang->getNsText( NS_TALK
) );
947 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
948 $n ) . "{$tl}<br />" .
949 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
950 "returnto={$rt}" ) . ' | ' .
951 $this->specialLink( 'preferences' );
953 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
959 function getSearchLink() {
960 $searchPage = SpecialPage
::getTitleFor( 'Search' );
961 return $searchPage->getLocalURL();
964 function escapeSearchLink() {
965 return htmlspecialchars( $this->getSearchLink() );
968 function searchForm() {
970 $search = $wgRequest->getText( 'search' );
972 $s = '<form name="search" class="inline" method="post" action="'
973 . $this->escapeSearchLink() . "\">\n"
974 . '<input type="text" name="search" size="19" value="'
975 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
976 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
977 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
982 function topLinks() {
986 $s = $this->mainPageLink() . $sep
987 . $this->specialLink( 'recentchanges' );
989 if ( $wgOut->isArticleRelated() ) {
990 $s .= $sep . $this->editThisPage()
991 . $sep . $this->historyLink();
993 # Many people don't like this dropdown box
994 #$s .= $sep . $this->specialPagesList();
996 $s .= $this->variantLinks();
998 $s .= $this->extensionTabLinks();
1004 * Compatibility for extensions adding functionality through tabs.
1005 * Eventually these old skins should be replaced with SkinTemplate-based
1009 function extensionTabLinks() {
1012 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1013 foreach( $tabs as $tab ) {
1014 $s .= ' | ' . Xml
::element( 'a',
1015 array( 'href' => $tab['href'] ),
1022 * Language/charset variant links for classic-style skins
1025 function variantLinks() {
1027 /* show links to different language variants */
1028 global $wgDisableLangConversion, $wgContLang, $wgTitle;
1029 $variants = $wgContLang->getVariants();
1030 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1031 foreach( $variants as $code ) {
1032 $varname = $wgContLang->getVariantname( $code );
1033 if( $varname == 'disable' )
1035 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1041 function bottomLinks() {
1042 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1046 if ( $wgOut->isArticleRelated() ) {
1047 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1048 if ( $wgUser->isLoggedIn() ) {
1049 $s .= $sep . $this->watchThisPage();
1051 $s .= $sep . $this->talkLink()
1052 . $sep . $this->historyLink()
1053 . $sep . $this->whatLinksHere()
1054 . $sep . $this->watchPageLinksLink();
1056 if ($wgUseTrackbacks)
1057 $s .= $sep . $this->trackbackLink();
1059 if ( $wgTitle->getNamespace() == NS_USER
1060 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1063 $id=User
::idFromName($wgTitle->getText());
1064 $ip=User
::isIP($wgTitle->getText());
1066 if($id ||
$ip) { # both anons and non-anons have contri list
1067 $s .= $sep . $this->userContribsLink();
1069 if( $this->showEmailUser( $id ) ) {
1070 $s .= $sep . $this->emailUserLink();
1073 if ( $wgTitle->getArticleId() ) {
1075 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1076 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1077 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1079 $s .= "<br />\n" . $this->otherLanguages();
1084 function pageStats() {
1085 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1086 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1088 $oldid = $wgRequest->getVal( 'oldid' );
1089 $diff = $wgRequest->getVal( 'diff' );
1090 if ( ! $wgOut->isArticle() ) { return ''; }
1091 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1092 if ( 0 == $wgArticle->getID() ) { return ''; }
1095 if ( !$wgDisableCounters ) {
1096 $count = $wgLang->formatNum( $wgArticle->getCount() );
1098 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1102 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1103 require_once('Credits.php');
1104 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1106 $s .= $this->lastModified();
1109 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1110 $dbr = wfGetDB( DB_SLAVE
);
1111 $watchlist = $dbr->tableName( 'watchlist' );
1112 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1113 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1114 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1115 $res = $dbr->query( $sql, 'Skin::pageStats');
1116 $x = $dbr->fetchObject( $res );
1118 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1119 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1123 return $s . ' ' . $this->getCopyright();
1126 function getCopyright( $type = 'detect' ) {
1127 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1129 if ( $type == 'detect' ) {
1130 $oldid = $wgRequest->getVal( 'oldid' );
1131 $diff = $wgRequest->getVal( 'diff' );
1133 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1140 if ( $type == 'history' ) {
1141 $msg = 'history_copyright';
1147 if( $wgRightsPage ) {
1148 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1149 } elseif( $wgRightsUrl ) {
1150 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1155 $out .= wfMsgForContent( $msg, $link );
1159 function getCopyrightIcon() {
1160 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1162 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1163 $out = $wgCopyrightIcon;
1164 } else if ( $wgRightsIcon ) {
1165 $icon = htmlspecialchars( $wgRightsIcon );
1166 if ( $wgRightsUrl ) {
1167 $url = htmlspecialchars( $wgRightsUrl );
1168 $out .= '<a href="'.$url.'">';
1170 $text = htmlspecialchars( $wgRightsText );
1171 $out .= "<img src=\"$icon\" alt='$text' />";
1172 if ( $wgRightsUrl ) {
1179 function getPoweredBy() {
1180 global $wgStylePath;
1181 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1182 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1186 function lastModified() {
1187 global $wgLang, $wgArticle, $wgLoadBalancer;
1189 $timestamp = $wgArticle->getTimestamp();
1191 $d = $wgLang->date( $timestamp, true );
1192 $t = $wgLang->time( $timestamp, true );
1193 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1197 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1198 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1203 function logoText( $align = '' ) {
1204 if ( '' != $align ) { $a = " align='{$align}'"; }
1207 $mp = wfMsg( 'mainpage' );
1208 $mptitle = Title
::newMainPage();
1209 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1211 $logourl = $this->getLogo();
1212 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1217 * show a drop-down box of special pages
1219 function specialPagesList() {
1220 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1221 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1222 foreach ( $pages as $name => $page ) {
1223 $pages[$name] = $page->getDescription();
1226 $go = wfMsg( 'go' );
1227 $sp = wfMsg( 'specialpages' );
1228 $spp = $wgContLang->specialPage( 'Specialpages' );
1230 $s = '<form id="specialpages" method="get" class="inline" ' .
1231 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1232 $s .= "<select name=\"wpDropdown\">\n";
1233 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1236 foreach ( $pages as $name => $desc ) {
1237 $p = $wgContLang->specialPage( $name );
1238 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1240 $s .= "</select>\n";
1241 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1246 function mainPageLink() {
1247 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1251 function copyrightLink() {
1252 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1253 wfMsg( 'copyrightpagename' ) );
1257 private function footerLink ( $desc, $page ) {
1258 // if the link description has been set to "-" in the default language,
1259 if ( wfMsgForContent( $desc ) == '-') {
1260 // then it is disabled, for all languages.
1263 // Otherwise, we display the link for the user, described in their
1264 // language (which may or may not be the same as the default language),
1265 // but we make the link target be the one site-wide page.
1266 return $this->makeKnownLink( wfMsgForContent( $page ),
1267 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1271 function privacyLink() {
1272 return $this->footerLink( 'privacy', 'privacypage' );
1275 function aboutLink() {
1276 return $this->footerLink( 'aboutsite', 'aboutpage' );
1279 function disclaimerLink() {
1280 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1283 function editThisPage() {
1284 global $wgOut, $wgTitle;
1286 if ( !$wgOut->isArticleRelated() ) {
1287 $s = wfMsg( 'protectedpage' );
1289 if( $wgTitle->userCan( 'edit' ) && $wgTitle->exists() ) {
1290 $t = wfMsg( 'editthispage' );
1291 } elseif( $wgTitle->userCan( 'create' ) && !$wgTitle->exists() ) {
1292 $t = wfMsg( 'create-this-page' );
1294 $t = wfMsg( 'viewsource' );
1297 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1303 * Return URL options for the 'edit page' link.
1304 * This may include an 'oldid' specifier, if the current page view is such.
1309 function editUrlOptions() {
1312 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1313 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1315 return "action=edit";
1319 function deleteThisPage() {
1320 global $wgUser, $wgTitle, $wgRequest;
1322 $diff = $wgRequest->getVal( 'diff' );
1323 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1324 $t = wfMsg( 'deletethispage' );
1326 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1333 function protectThisPage() {
1334 global $wgUser, $wgTitle, $wgRequest;
1336 $diff = $wgRequest->getVal( 'diff' );
1337 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1338 if ( $wgTitle->isProtected() ) {
1339 $t = wfMsg( 'unprotectthispage' );
1340 $q = 'action=unprotect';
1342 $t = wfMsg( 'protectthispage' );
1343 $q = 'action=protect';
1345 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1352 function watchThisPage() {
1353 global $wgOut, $wgTitle;
1354 ++
$this->mWatchLinkNum
;
1356 if ( $wgOut->isArticleRelated() ) {
1357 if ( $wgTitle->userIsWatching() ) {
1358 $t = wfMsg( 'unwatchthispage' );
1359 $q = 'action=unwatch';
1360 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1362 $t = wfMsg( 'watchthispage' );
1363 $q = 'action=watch';
1364 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1366 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1368 $s = wfMsg( 'notanarticle' );
1373 function moveThisPage() {
1376 if ( $wgTitle->userCan( 'move' ) ) {
1377 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1378 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1380 // no message if page is protected - would be redundant
1385 function historyLink() {
1388 return $this->makeKnownLinkObj( $wgTitle,
1389 wfMsg( 'history' ), 'action=history' );
1392 function whatLinksHere() {
1395 return $this->makeKnownLinkObj(
1396 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1397 wfMsg( 'whatlinkshere' ) );
1400 function userContribsLink() {
1403 return $this->makeKnownLinkObj(
1404 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1405 wfMsg( 'contributions' ) );
1408 function showEmailUser( $id ) {
1409 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1410 return $wgEnableEmail &&
1411 $wgEnableUserEmail &&
1412 $wgUser->isLoggedIn() && # show only to signed in users
1413 0 != $id; # we can only email to non-anons ..
1414 # '' != $id->getEmail() && # who must have an email address stored ..
1415 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1416 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1419 function emailUserLink() {
1422 return $this->makeKnownLinkObj(
1423 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1424 wfMsg( 'emailuser' ) );
1427 function watchPageLinksLink() {
1428 global $wgOut, $wgTitle;
1430 if ( ! $wgOut->isArticleRelated() ) {
1431 return '(' . wfMsg( 'notanarticle' ) . ')';
1433 return $this->makeKnownLinkObj(
1434 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1435 wfMsg( 'recentchangeslinked' ) );
1439 function trackbackLink() {
1442 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1443 . wfMsg('trackbacklink') . "</a>";
1446 function otherLanguages() {
1447 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1449 if ( $wgHideInterlanguageLinks ) {
1453 $a = $wgOut->getLanguageLinks();
1454 if ( 0 == count( $a ) ) {
1458 $s = wfMsg( 'otherlanguages' ) . ': ';
1460 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1461 foreach( $a as $l ) {
1462 if ( ! $first ) { $s .= ' | '; }
1465 $nt = Title
::newFromText( $l );
1466 $url = $nt->escapeFullURL();
1467 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1469 if ( '' == $text ) { $text = $l; }
1470 $style = $this->getExternalLinkAttributes( $l, $text );
1471 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1473 if($wgContLang->isRTL()) $s .= '</span>';
1477 function bugReportsLink() {
1478 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1479 wfMsg( 'bugreports' ) );
1483 function talkLink() {
1486 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1487 # No discussion links for special pages
1491 if( $wgTitle->isTalkPage() ) {
1492 $link = $wgTitle->getSubjectPage();
1493 switch( $link->getNamespace() ) {
1495 $text = wfMsg( 'articlepage' );
1498 $text = wfMsg( 'userpage' );
1501 $text = wfMsg( 'projectpage' );
1504 $text = wfMsg( 'imagepage' );
1507 $text = wfMsg( 'mediawikipage' );
1510 $text = wfMsg( 'templatepage' );
1513 $text = wfMsg( 'viewhelppage' );
1516 $text = wfMsg( 'categorypage' );
1519 $text = wfMsg( 'articlepage' );
1522 $link = $wgTitle->getTalkPage();
1523 $text = wfMsg( 'talkpage' );
1526 $s = $this->makeLinkObj( $link, $text );
1531 function commentLink() {
1532 global $wgTitle, $wgOut;
1534 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1538 # __NEWSECTIONLINK___ changes behaviour here
1539 # If it's present, the link points to this page, otherwise
1540 # it points to the talk page
1541 if( $wgTitle->isTalkPage() ) {
1543 } elseif( $wgOut->showNewSectionLink() ) {
1546 $title = $wgTitle->getTalkPage();
1549 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1552 /* these are used extensively in SkinTemplate, but also some other places */
1553 static function makeMainPageUrl( $urlaction = '' ) {
1554 $title = Title
::newMainPage();
1555 self
::checkTitle( $title, '' );
1556 return $title->getLocalURL( $urlaction );
1559 static function makeSpecialUrl( $name, $urlaction = '' ) {
1560 $title = SpecialPage
::getTitleFor( $name );
1561 return $title->getLocalURL( $urlaction );
1564 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1565 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1566 return $title->getLocalURL( $urlaction );
1569 static function makeI18nUrl( $name, $urlaction = '' ) {
1570 $title = Title
::newFromText( wfMsgForContent( $name ) );
1571 self
::checkTitle( $title, $name );
1572 return $title->getLocalURL( $urlaction );
1575 static function makeUrl( $name, $urlaction = '' ) {
1576 $title = Title
::newFromText( $name );
1577 self
::checkTitle( $title, $name );
1578 return $title->getLocalURL( $urlaction );
1581 # If url string starts with http, consider as external URL, else
1583 static function makeInternalOrExternalUrl( $name ) {
1584 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1587 return self
::makeUrl( $name );
1591 # this can be passed the NS number as defined in Language.php
1592 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1593 $title = Title
::makeTitleSafe( $namespace, $name );
1594 self
::checkTitle( $title, $name );
1595 return $title->getLocalURL( $urlaction );
1598 /* these return an array with the 'href' and boolean 'exists' */
1599 static function makeUrlDetails( $name, $urlaction = '' ) {
1600 $title = Title
::newFromText( $name );
1601 self
::checkTitle( $title, $name );
1603 'href' => $title->getLocalURL( $urlaction ),
1604 'exists' => $title->getArticleID() != 0 ?
true : false
1609 * Make URL details where the article exists (or at least it's convenient to think so)
1611 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1612 $title = Title
::newFromText( $name );
1613 self
::checkTitle( $title, $name );
1615 'href' => $title->getLocalURL( $urlaction ),
1620 # make sure we have some title to operate on
1621 static function checkTitle( &$title, $name ) {
1622 if( !is_object( $title ) ) {
1623 $title = Title
::newFromText( $name );
1624 if( !is_object( $title ) ) {
1625 $title = Title
::newFromText( '--error: link target missing--' );
1631 * Build an array that represents the sidebar(s), the navigation bar among them
1636 function buildSidebar() {
1637 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1638 global $wgLang, $wgContLang;
1640 $fname = 'SkinTemplate::buildSidebar';
1642 wfProfileIn( $fname );
1644 $key = wfMemcKey( 'sidebar' );
1645 $cacheSidebar = $wgEnableSidebarCache &&
1646 ($wgLang->getCode() == $wgContLang->getCode());
1648 if ($cacheSidebar) {
1649 $cachedsidebar = $parserMemc->get( $key );
1650 if ($cachedsidebar!="") {
1651 wfProfileOut($fname);
1652 return $cachedsidebar;
1657 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1659 foreach ($lines as $line) {
1660 if (strpos($line, '*') !== 0)
1662 if (strpos($line, '**') !== 0) {
1663 $line = trim($line, '* ');
1666 if (strpos($line, '|') !== false) { // sanity check
1667 $line = explode( '|' , trim($line, '* '), 2 );
1668 $link = wfMsgForContent( $line[0] );
1671 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1673 if (wfEmptyMsg($line[0], $link))
1676 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1679 $title = Title
::newFromText( $link );
1681 $title = $title->fixSpecialName();
1682 $href = $title->getLocalURL();
1684 $href = 'INVALID-TITLE';
1688 $bar[$heading][] = array(
1691 'id' => 'n-' . strtr($line[1], ' ', '-'),
1694 } else { continue; }
1698 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1699 wfProfileOut( $fname );