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
20 // How many search boxes have we made? Avoid duplicate id's.
21 protected $searchboxes = '';
23 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
24 protected $skinname = 'standard' ;
26 /** Constructor, call parent constructor */
27 function Skin() { parent
::__construct(); }
30 * Fetch the set of available skins.
31 * @return array of strings
34 static function getSkinNames() {
35 global $wgValidSkinNames;
36 static $skinsInitialised = false;
37 if ( !$skinsInitialised ) {
38 # Get a list of available skins
39 # Build using the regular expression '^(.*).php$'
40 # Array keys are all lower case, array value keep the case used by filename
42 wfProfileIn( __METHOD__
. '-init' );
43 global $wgStyleDirectory;
44 $skinDir = dir( $wgStyleDirectory );
46 # while code from www.php.net
47 while (false !== ($file = $skinDir->read())) {
48 // Skip non-PHP files, hidden files, and '.dep' includes
50 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
52 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
56 $skinsInitialised = true;
57 wfProfileOut( __METHOD__
. '-init' );
59 return $wgValidSkinNames;
63 * Normalize a skin preference value to a form that can be loaded.
64 * If a skin can't be found, it will fall back to the configured
65 * default (or the old 'Classic' skin if that's broken).
70 static function normalizeKey( $key ) {
71 global $wgDefaultSkin;
72 $skinNames = Skin
::getSkinNames();
75 // Don't return the default immediately;
76 // in a misconfiguration we need to fall back.
77 $key = $wgDefaultSkin;
80 if( isset( $skinNames[$key] ) ) {
84 // Older versions of the software used a numeric setting
85 // in the user preferences.
91 if( isset( $fallback[$key] ) ){
92 $key = $fallback[$key];
95 if( isset( $skinNames[$key] ) ) {
103 * Factory method for loading a skin of a given type
104 * @param string $key 'monobook', 'standard', etc
108 static function &newFromKey( $key ) {
109 global $wgStyleDirectory;
111 $key = Skin
::normalizeKey( $key );
113 $skinNames = Skin
::getSkinNames();
114 $skinName = $skinNames[$key];
115 $className = 'Skin'.ucfirst($key);
117 # Grab the skin class and initialise it.
118 if ( !class_exists( $className ) ) {
119 // Preload base classes to work around APC/PHP5 bug
120 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
121 if( file_exists( $deps ) ) include_once( $deps );
122 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
124 # Check if we got if not failback to default skin
125 if( !class_exists( $className ) ) {
126 # DO NOT die if the class isn't found. This breaks maintenance
127 # scripts and can cause a user account to be unrecoverable
128 # except by SQL manipulation if a previously valid skin name
129 # is no longer valid.
130 wfDebug( "Skin class does not exist: $className\n" );
131 $className = 'SkinMonobook';
132 require_once( "{$wgStyleDirectory}/MonoBook.php" );
135 $skin = new $className;
139 /** @return string path to the skin stylesheet */
140 function getStylesheet() {
141 return 'common/wikistandard.css';
144 /** @return string skin name */
145 public function getSkinName() {
146 return $this->skinname
;
149 function qbSetting() {
150 global $wgOut, $wgUser;
152 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
153 $q = $wgUser->getOption( 'quickbar', 0 );
157 function initPage( &$out ) {
158 global $wgFavicon, $wgAppleTouchIcon, $wgScriptPath, $wgScriptExtension;
160 wfProfileIn( __METHOD__
);
162 if( false !== $wgFavicon ) {
163 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
166 if( false !== $wgAppleTouchIcon ) {
167 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
170 # OpenSearch description link
171 $out->addLink( array(
173 'type' => 'application/opensearchdescription+xml',
174 'href' => "$wgScriptPath/opensearch_desc{$wgScriptExtension}",
175 'title' => wfMsgForContent( 'opensearch-desc' ),
178 $this->addMetadataLinks($out);
180 $this->mRevisionId
= $out->mRevisionId
;
182 $this->preloadExistence();
184 wfProfileOut( __METHOD__
);
188 * Preload the existence of three commonly-requested pages in a single query
190 function preloadExistence() {
191 global $wgUser, $wgTitle;
194 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
197 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
199 } elseif ( $wgTitle->isTalkPage() ) {
200 $titles[] = $wgTitle->getSubjectPage();
202 $titles[] = $wgTitle->getTalkPage();
205 $lb = new LinkBatch( $titles );
209 function addMetadataLinks( &$out ) {
210 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
211 global $wgRightsPage, $wgRightsUrl;
213 if( $out->isArticleRelated() ) {
214 # note: buggy CC software only reads first "meta" link
215 if( $wgEnableCreativeCommonsRdf ) {
216 $out->addMetadataLink( array(
217 'title' => 'Creative Commons',
218 'type' => 'application/rdf+xml',
219 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
221 if( $wgEnableDublinCoreRdf ) {
222 $out->addMetadataLink( array(
223 'title' => 'Dublin Core',
224 'type' => 'application/rdf+xml',
225 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
229 if( $wgRightsPage ) {
230 $copy = Title
::newFromText( $wgRightsPage );
232 $copyright = $copy->getLocalURL();
235 if( !$copyright && $wgRightsUrl ) {
236 $copyright = $wgRightsUrl;
239 $out->addLink( array(
240 'rel' => 'copyright',
241 'href' => $copyright ) );
245 function outputPage( &$out ) {
246 global $wgDebugComments;
248 wfProfileIn( __METHOD__
);
249 $this->initPage( $out );
251 $out->out( $out->headElement() );
253 $out->out( "\n<body" );
254 $ops = $this->getBodyOptions();
255 foreach ( $ops as $name => $val ) {
256 $out->out( " $name='$val'" );
259 if ( $wgDebugComments ) {
260 $out->out( "<!-- Wiki debugging output:\n" .
261 $out->mDebugtext
. "-->\n" );
264 $out->out( $this->beforeContent() );
266 $out->out( $out->mBodytext
. "\n" );
268 $out->out( $this->afterContent() );
270 $out->out( $this->bottomScripts() );
272 $out->out( wfReportTime() );
274 $out->out( "\n</body></html>" );
275 wfProfileOut( __METHOD__
);
278 static function makeVariablesScript( $data ) {
279 global $wgJsMimeType;
281 $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n";
282 foreach ( $data as $name => $value ) {
283 $encValue = Xml
::encodeJsVar( $value );
284 $r .= "var $name = $encValue;\n";
286 $r .= "/*]]>*/</script>\n";
292 * Make a <script> tag containing global variables
293 * @param array $data Associative array containing one element:
294 * skinname => the skin name
295 * The odd calling convention is for backwards compatibility
297 static function makeGlobalVariablesScript( $data ) {
298 global $wgScript, $wgStylePath, $wgUser;
299 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
300 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
301 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
302 global $wgUseAjax, $wgAjaxWatch;
303 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
304 global $wgRestrictionTypes, $wgLivePreview;
305 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
307 $ns = $wgTitle->getNamespace();
308 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
311 'skin' => $data['skinname'],
312 'stylepath' => $wgStylePath,
313 'wgArticlePath' => $wgArticlePath,
314 'wgScriptPath' => $wgScriptPath,
315 'wgScript' => $wgScript,
316 'wgVariantArticlePath' => $wgVariantArticlePath,
317 'wgActionPaths' => $wgActionPaths,
318 'wgServer' => $wgServer,
319 'wgCanonicalNamespace' => $nsname,
320 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
321 'wgNamespaceNumber' => $wgTitle->getNamespace(),
322 'wgPageName' => $wgTitle->getPrefixedDBKey(),
323 'wgTitle' => $wgTitle->getText(),
324 'wgAction' => $wgRequest->getText( 'action', 'view' ),
325 'wgArticleId' => $wgTitle->getArticleId(),
326 'wgIsArticle' => $wgOut->isArticle(),
327 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
328 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
329 'wgUserLanguage' => $wgLang->getCode(),
330 'wgContentLanguage' => $wgContLang->getCode(),
331 'wgBreakFrames' => $wgBreakFrames,
332 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
333 'wgVersion' => $wgVersion,
334 'wgEnableAPI' => $wgEnableAPI,
335 'wgEnableWriteAPI' => $wgEnableWriteAPI,
338 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){
339 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
340 $vars['wgDBname'] = $wgDBname;
341 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
342 $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
345 foreach( $wgRestrictionTypes as $type )
346 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
348 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
349 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
350 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
351 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
352 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
355 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
356 $msgs = (object)array();
357 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
358 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
360 $vars['wgAjaxWatch'] = $msgs;
363 return self
::makeVariablesScript( $vars );
366 function getHeadScripts( $allowUserJs ) {
367 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
369 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
371 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
374 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
375 $r .= "<script type=\"$wgJsMimeType\" src=\"".
376 htmlspecialchars(self
::makeUrl('-',
377 "action=raw$jsCache&gen=js&useskin=" .
378 urlencode( $this->getSkinName() ) ) ) .
379 "\"><!-- site js --></script>\n";
381 if( $allowUserJs && $wgUser->isLoggedIn() ) {
382 $userpage = $wgUser->getUserPage();
383 $userjs = htmlspecialchars( self
::makeUrl(
384 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
385 'action=raw&ctype='.$wgJsMimeType));
386 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
392 * To make it harder for someone to slip a user a fake
393 * user-JavaScript or user-CSS preview, a random token
394 * is associated with the login session. If it's not
395 * passed back with the preview request, we won't render
398 * @param string $action
402 function userCanPreview( $action ) {
403 global $wgTitle, $wgRequest, $wgUser;
405 if( $action != 'submit' )
407 if( !$wgRequest->wasPosted() )
409 if( !$wgTitle->userCanEditCssJsSubpage() )
411 return $wgUser->matchEditToken(
412 $wgRequest->getVal( 'wpEditToken' ) );
415 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
416 function getUserStylesheet() {
417 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
418 $sheet = $this->getStylesheet();
419 $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n";
420 $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n";
421 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
422 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
424 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
425 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
426 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
428 $s .= $this->doGetUserStyles();
433 * This returns MediaWiki:Common.js, and derived classes may add other JS.
434 * Despite its name, it does *not* return any custom user JS from user
435 * subpages. The returned script is sitewide and publicly cacheable and
436 * therefore must not include anything that varies according to user,
437 * interface language, etc. (although it may vary by skin). See
438 * makeGlobalVariablesScript for things that can vary per page view and are
441 * @return string Raw JavaScript to be returned
443 public function getUserJs() {
444 wfProfileIn( __METHOD__
);
447 $s = "/* generated javascript */\n";
448 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
449 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
450 $s .= "\n\n/* MediaWiki:Common.js */\n";
451 $commonJs = wfMsgForContent('common.js');
452 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
455 wfProfileOut( __METHOD__
);
460 * Return html code that include User stylesheets
462 function getUserStyles() {
463 $s = "<style type='text/css'>\n";
464 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
465 $s .= $this->getUserStylesheet();
466 $s .= "/*]]>*/ /* */\n";
472 * Some styles that are set by user through the user settings interface.
474 function doGetUserStyles() {
475 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
479 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
480 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
481 $s .= $wgRequest->getText('wpTextbox1');
483 $userpage = $wgUser->getUserPage();
484 $s.= '@import "'.self
::makeUrl(
485 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
486 'action=raw&ctype=text/css').'";'."\n";
490 return $s . $this->reallyDoGetUserStyles();
493 function reallyDoGetUserStyles() {
496 if (($undopt = $wgUser->getOption("underline")) < 2) {
497 $underline = $undopt ?
'underline' : 'none';
498 $s .= "a { text-decoration: $underline; }\n";
500 if( $wgUser->getOption( 'highlightbroken' ) ) {
501 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
504 a.new, #quickbar a.new,
505 a.stub, #quickbar a.stub {
508 a.new:after, #quickbar a.new:after {
512 a.stub:after, #quickbar a.stub:after {
518 if( $wgUser->getOption( 'justify' ) ) {
519 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
521 if( !$wgUser->getOption( 'showtoc' ) ) {
522 $s .= "#toc { display: none; }\n";
524 if( !$wgUser->getOption( 'editsection' ) ) {
525 $s .= ".editsection { display: none; }\n";
530 function getBodyOptions() {
531 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
533 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
535 if ( 0 != $wgTitle->getNamespace() ) {
536 $a = array( 'bgcolor' => '#ffffec' );
538 else $a = array( 'bgcolor' => '#FFFFFF' );
539 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
540 $wgTitle->userCan( 'edit' ) ) {
541 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
542 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
543 $a +
= array ('ondblclick' => $s);
546 $a['onload'] = $wgOut->getOnloadHandler();
547 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
548 if( $a['onload'] != '' ) {
551 $a['onload'] .= 'setupRightClickEdit()';
554 'mediawiki ns-'.$wgTitle->getNamespace().
555 ' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
556 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
569 * This will be called immediately after the <body> tag. Split into
570 * two functions to make it easier to subclass.
572 function beforeContent() {
573 return $this->doBeforeContent();
576 function doBeforeContent() {
578 $fname = 'Skin::doBeforeContent';
579 wfProfileIn( $fname );
582 $qb = $this->qbSetting();
584 if( $langlinks = $this->otherLanguages() ) {
590 $borderhack = 'class="top"';
593 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
594 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
597 $left = ($qb == 1 ||
$qb == 3);
598 if($wgContLang->isRTL()) $left = !$left;
601 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
602 $this->logoText() . '</td>';
604 $s .= $this->getQuickbarCompensator( $rows );
606 $l = $wgContLang->isRTL() ?
'right' : 'left';
607 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
609 $s .= $this->topLinks() ;
610 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
612 $r = $wgContLang->isRTL() ?
"left" : "right";
613 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
614 $s .= $this->nameAndLogin();
615 $s .= "\n<br />" . $this->searchForm() . "</td>";
618 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
621 if ( $shove && !$left ) { # Right
622 $s .= $this->getQuickbarCompensator( $rows );
624 $s .= "</tr>\n</table>\n</div>\n";
625 $s .= "\n<div id='article'>\n";
627 $notice = wfGetSiteNotice();
629 $s .= "\n<div id='siteNotice'>$notice</div>\n";
631 $s .= $this->pageTitle();
632 $s .= $this->pageSubtitle() ;
633 $s .= $this->getCategories();
634 wfProfileOut( $fname );
639 function getCategoryLinks() {
640 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
641 global $wgContLang, $wgUser;
643 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
646 $sep = wfMsgHtml( 'catseparator' );
648 // Use Unicode bidi embedding override characters,
649 // to make sure links don't smash each other up in ugly ways.
650 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
651 $embed = "<span dir='$dir'>";
654 $allCats = $wgOut->getCategoryLinks();
656 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
657 if ( !empty( $allCats['normal'] ) ) {
658 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
660 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
661 $s .= '<div id="mw-normal-catlinks">' .
662 $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
663 . $colon . $t . '</div>';
667 if ( isset( $allCats['hidden'] ) ) {
668 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
669 $class ='mw-hidden-cats-user-shown';
670 } elseif ( $wgTitle->getNamespace() == NS_CATEGORY
) {
671 $class = 'mw-hidden-cats-ns-shown';
673 $class = 'mw-hidden-cats-hidden';
675 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
676 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
677 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
681 # optional 'dmoz-like' category browser. Will be shown under the list
682 # of categories an article belong to
683 if($wgUseCategoryBrowser) {
684 $s .= '<br /><hr />';
686 # get a big array of the parents tree
687 $parenttree = $wgTitle->getParentCategoryTree();
688 # Skin object passed by reference cause it can not be
689 # accessed under the method subfunction drawCategoryBrowser
690 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
691 # Clean out bogus first entry and sort them
694 # Output one per line
695 $s .= implode("<br />\n", $tempout);
701 /** Render the array as a serie of links.
702 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
703 * @param &skin Object: skin passed by reference
704 * @return String separated by >, terminate with "\n"
706 function drawCategoryBrowser($tree, &$skin) {
708 foreach ($tree as $element => $parent) {
709 if (empty($parent)) {
710 # element start a new list
713 # grab the others elements
714 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
716 # add our current element to the list
717 $eltitle = Title
::NewFromText($element);
718 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
723 function getCategories() {
724 $catlinks=$this->getCategoryLinks();
726 $classes = 'catlinks';
728 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
729 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
730 $classes .= ' catlinks-allhidden';
733 if( !empty( $catlinks ) ){
734 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
738 function getQuickbarCompensator( $rows = 1 ) {
739 return "<td width='152' rowspan='{$rows}'> </td>";
743 * This gets called shortly before the \</body\> tag.
744 * @return String HTML to be put before \</body\>
746 function afterContent() {
747 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
748 return $printfooter . $this->doAfterContent();
752 * This gets called shortly before the \</body\> tag.
753 * @return String HTML-wrapped JS code to be put before \</body\>
755 function bottomScripts() {
756 global $wgJsMimeType;
757 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
758 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
759 return $bottomScriptText;
762 /** @return string Retrievied from HTML text */
763 function printSource() {
765 $url = htmlspecialchars( $wgTitle->getFullURL() );
766 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
769 function printFooter() {
770 return "<p>" . $this->printSource() .
771 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
774 /** overloaded by derived classes */
775 function doAfterContent() { }
777 function pageTitleLinks() {
778 global $wgOut, $wgTitle, $wgUser, $wgRequest;
780 $oldid = $wgRequest->getVal( 'oldid' );
781 $diff = $wgRequest->getVal( 'diff' );
782 $action = $wgRequest->getText( 'action' );
784 $s = $this->printableLink();
785 $disclaimer = $this->disclaimerLink(); # may be empty
787 $s .= ' | ' . $disclaimer;
789 $privacy = $this->privacyLink(); # may be empty too
791 $s .= ' | ' . $privacy;
794 if ( $wgOut->isArticleRelated() ) {
795 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
796 $name = $wgTitle->getDBkey();
797 $image = wfFindFile( $wgTitle );
799 $link = htmlspecialchars( $image->getURL() );
800 $style = $this->getInternalLinkAttributes( $link, $name );
801 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
805 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
806 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
807 wfMsg( 'currentrev' ) );
810 if ( $wgUser->getNewtalk() ) {
811 # do not show "You have new messages" text when we are viewing our
813 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
814 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
815 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
816 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
818 $wgOut->setSquidMaxage(0);
819 $wgOut->enableClientCache(false);
823 $undelete = $this->getUndeleteLink();
824 if( !empty( $undelete ) ) {
825 $s .= ' | '.$undelete;
830 function getUndeleteLink() {
831 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
832 if( $wgUser->isAllowed( 'deletedhistory' ) &&
833 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
834 ($n = $wgTitle->isDeleted() ) )
836 if ( $wgUser->isAllowed( 'undelete' ) ) {
837 $msg = 'thisisdeleted';
839 $msg = 'viewdeleted';
842 $this->makeKnownLinkObj(
843 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
844 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
849 function printableLink() {
850 global $wgOut, $wgFeedClasses, $wgRequest;
852 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
854 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
855 if( $wgOut->isSyndicated() ) {
856 foreach( $wgFeedClasses as $format => $class ) {
857 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
858 $s .= " | <a href=\"$feedurl\">{$format}</a>";
864 function pageTitle() {
866 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
870 function pageSubtitle() {
873 $sub = $wgOut->getSubtitle();
875 global $wgExtraSubtitle;
876 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
878 $subpages = $this->subPageSubtitle();
879 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
880 $s = "<p class='subtitle'>{$sub}</p>\n";
884 function subPageSubtitle() {
886 if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
889 global $wgOut, $wgTitle, $wgNamespacesWithSubpages;
890 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
891 $ptext=$wgTitle->getPrefixedText();
892 if(preg_match('/\//',$ptext)) {
893 $links = explode('/',$ptext);
898 foreach($links as $link) {
899 $growinglink .= $link;
901 $linkObj = Title
::newFromText( $growinglink );
902 if( is_object( $linkObj ) && $linkObj->exists() ){
903 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
908 $subpages .= '< ';
910 $subpages .= $getlink;
923 * Returns true if the IP should be shown in the header
925 function showIPinHeader() {
926 global $wgShowIPinHeader;
927 return $wgShowIPinHeader && session_id() != '';
930 function nameAndLogin() {
931 global $wgUser, $wgTitle, $wgLang, $wgContLang;
933 $lo = $wgContLang->specialPage( 'Userlogout' );
936 if ( $wgUser->isAnon() ) {
937 if( $this->showIPinHeader() ) {
940 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
941 $wgLang->getNsText( NS_TALK
) );
943 $s .= $n . ' ('.$tl.')';
945 $s .= wfMsg('notloggedin');
948 $rt = $wgTitle->getPrefixedURL();
949 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
951 } else { $q = "returnto={$rt}"; }
953 $loginlink = $wgUser->isAllowed( 'createaccount' )
954 ?
'nav-login-createaccount'
956 $s .= "\n<br />" . $this->makeKnownLinkObj(
957 SpecialPage
::getTitleFor( 'Userlogin' ),
958 wfMsg( $loginlink ), $q );
960 $n = $wgUser->getName();
961 $rt = $wgTitle->getPrefixedURL();
962 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
963 $wgLang->getNsText( NS_TALK
) );
967 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
968 $n ) . "{$tl}<br />" .
969 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
970 "returnto={$rt}" ) . ' | ' .
971 $this->specialLink( 'preferences' );
973 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
979 function getSearchLink() {
980 $searchPage = SpecialPage
::getTitleFor( 'Search' );
981 return $searchPage->getLocalURL();
984 function escapeSearchLink() {
985 return htmlspecialchars( $this->getSearchLink() );
988 function searchForm() {
990 $search = $wgRequest->getText( 'search' );
992 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
993 . $this->escapeSearchLink() . "\">\n"
994 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
995 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
996 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
997 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
999 // Ensure unique id's for search boxes made after the first
1000 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1005 function topLinks() {
1009 $s = $this->mainPageLink() . $sep
1010 . $this->specialLink( 'recentchanges' );
1012 if ( $wgOut->isArticleRelated() ) {
1013 $s .= $sep . $this->editThisPage()
1014 . $sep . $this->historyLink();
1016 # Many people don't like this dropdown box
1017 #$s .= $sep . $this->specialPagesList();
1019 $s .= $this->variantLinks();
1021 $s .= $this->extensionTabLinks();
1027 * Compatibility for extensions adding functionality through tabs.
1028 * Eventually these old skins should be replaced with SkinTemplate-based
1032 function extensionTabLinks() {
1035 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1036 foreach( $tabs as $tab ) {
1037 $s .= ' | ' . Xml
::element( 'a',
1038 array( 'href' => $tab['href'] ),
1045 * Language/charset variant links for classic-style skins
1048 function variantLinks() {
1050 /* show links to different language variants */
1051 global $wgDisableLangConversion, $wgContLang, $wgTitle;
1052 $variants = $wgContLang->getVariants();
1053 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1054 foreach( $variants as $code ) {
1055 $varname = $wgContLang->getVariantname( $code );
1056 if( $varname == 'disable' )
1058 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1064 function bottomLinks() {
1065 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1069 if ( $wgOut->isArticleRelated() ) {
1070 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1071 if ( $wgUser->isLoggedIn() ) {
1072 $s .= $sep . $this->watchThisPage();
1074 $s .= $sep . $this->talkLink()
1075 . $sep . $this->historyLink()
1076 . $sep . $this->whatLinksHere()
1077 . $sep . $this->watchPageLinksLink();
1079 if ($wgUseTrackbacks)
1080 $s .= $sep . $this->trackbackLink();
1082 if ( $wgTitle->getNamespace() == NS_USER
1083 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1086 $id=User
::idFromName($wgTitle->getText());
1087 $ip=User
::isIP($wgTitle->getText());
1089 if($id ||
$ip) { # both anons and non-anons have contri list
1090 $s .= $sep . $this->userContribsLink();
1092 if( $this->showEmailUser( $id ) ) {
1093 $s .= $sep . $this->emailUserLink();
1096 if ( $wgTitle->getArticleId() ) {
1098 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1099 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1100 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1102 $s .= "<br />\n" . $this->otherLanguages();
1107 function pageStats() {
1108 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1109 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1111 $oldid = $wgRequest->getVal( 'oldid' );
1112 $diff = $wgRequest->getVal( 'diff' );
1113 if ( ! $wgOut->isArticle() ) { return ''; }
1114 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1115 if ( 0 == $wgArticle->getID() ) { return ''; }
1118 if ( !$wgDisableCounters ) {
1119 $count = $wgLang->formatNum( $wgArticle->getCount() );
1121 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1125 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1126 require_once('Credits.php');
1127 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1129 $s .= $this->lastModified();
1132 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1133 $dbr = wfGetDB( DB_SLAVE
);
1134 $watchlist = $dbr->tableName( 'watchlist' );
1135 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1136 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1137 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1138 $res = $dbr->query( $sql, 'Skin::pageStats');
1139 $x = $dbr->fetchObject( $res );
1141 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1142 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1146 return $s . ' ' . $this->getCopyright();
1149 function getCopyright( $type = 'detect' ) {
1150 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1152 if ( $type == 'detect' ) {
1153 $oldid = $wgRequest->getVal( 'oldid' );
1154 $diff = $wgRequest->getVal( 'diff' );
1156 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1163 if ( $type == 'history' ) {
1164 $msg = 'history_copyright';
1170 if( $wgRightsPage ) {
1171 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1172 } elseif( $wgRightsUrl ) {
1173 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1178 $out .= wfMsgForContent( $msg, $link );
1182 function getCopyrightIcon() {
1183 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1185 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1186 $out = $wgCopyrightIcon;
1187 } else if ( $wgRightsIcon ) {
1188 $icon = htmlspecialchars( $wgRightsIcon );
1189 if ( $wgRightsUrl ) {
1190 $url = htmlspecialchars( $wgRightsUrl );
1191 $out .= '<a href="'.$url.'">';
1193 $text = htmlspecialchars( $wgRightsText );
1194 $out .= "<img src=\"$icon\" alt='$text' />";
1195 if ( $wgRightsUrl ) {
1202 function getPoweredBy() {
1203 global $wgStylePath;
1204 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1205 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1209 function lastModified() {
1210 global $wgLang, $wgArticle;
1212 $timestamp = $wgArticle->getTimestamp();
1214 $d = $wgLang->date( $timestamp, true );
1215 $t = $wgLang->time( $timestamp, true );
1216 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1220 if ( wfGetLB()->getLaggedSlaveMode() ) {
1221 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1226 function logoText( $align = '' ) {
1227 if ( '' != $align ) { $a = " align='{$align}'"; }
1230 $mp = wfMsg( 'mainpage' );
1231 $mptitle = Title
::newMainPage();
1232 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1234 $logourl = $this->getLogo();
1235 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1240 * show a drop-down box of special pages
1242 function specialPagesList() {
1243 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1244 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1245 foreach ( $pages as $name => $page ) {
1246 $pages[$name] = $page->getDescription();
1249 $go = wfMsg( 'go' );
1250 $sp = wfMsg( 'specialpages' );
1251 $spp = $wgContLang->specialPage( 'Specialpages' );
1253 $s = '<form id="specialpages" method="get" class="inline" ' .
1254 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1255 $s .= "<select name=\"wpDropdown\">\n";
1256 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1259 foreach ( $pages as $name => $desc ) {
1260 $p = $wgContLang->specialPage( $name );
1261 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1263 $s .= "</select>\n";
1264 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1269 function mainPageLink() {
1270 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1274 function copyrightLink() {
1275 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1276 wfMsg( 'copyrightpagename' ) );
1280 private function footerLink ( $desc, $page ) {
1281 // if the link description has been set to "-" in the default language,
1282 if ( wfMsgForContent( $desc ) == '-') {
1283 // then it is disabled, for all languages.
1286 // Otherwise, we display the link for the user, described in their
1287 // language (which may or may not be the same as the default language),
1288 // but we make the link target be the one site-wide page.
1289 return $this->makeKnownLink( wfMsgForContent( $page ),
1290 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1294 function privacyLink() {
1295 return $this->footerLink( 'privacy', 'privacypage' );
1298 function aboutLink() {
1299 return $this->footerLink( 'aboutsite', 'aboutpage' );
1302 function disclaimerLink() {
1303 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1306 function editThisPage() {
1307 global $wgOut, $wgTitle;
1309 if ( !$wgOut->isArticleRelated() ) {
1310 $s = wfMsg( 'protectedpage' );
1312 if( $wgTitle->userCan( 'edit' ) && $wgTitle->exists() ) {
1313 $t = wfMsg( 'editthispage' );
1314 } elseif( $wgTitle->userCan( 'create' ) && !$wgTitle->exists() ) {
1315 $t = wfMsg( 'create-this-page' );
1317 $t = wfMsg( 'viewsource' );
1320 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1326 * Return URL options for the 'edit page' link.
1327 * This may include an 'oldid' specifier, if the current page view is such.
1332 function editUrlOptions() {
1335 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1336 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1338 return "action=edit";
1342 function deleteThisPage() {
1343 global $wgUser, $wgTitle, $wgRequest;
1345 $diff = $wgRequest->getVal( 'diff' );
1346 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1347 $t = wfMsg( 'deletethispage' );
1349 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1356 function protectThisPage() {
1357 global $wgUser, $wgTitle, $wgRequest;
1359 $diff = $wgRequest->getVal( 'diff' );
1360 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1361 if ( $wgTitle->isProtected() ) {
1362 $t = wfMsg( 'unprotectthispage' );
1363 $q = 'action=unprotect';
1365 $t = wfMsg( 'protectthispage' );
1366 $q = 'action=protect';
1368 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1375 function watchThisPage() {
1376 global $wgOut, $wgTitle;
1377 ++
$this->mWatchLinkNum
;
1379 if ( $wgOut->isArticleRelated() ) {
1380 if ( $wgTitle->userIsWatching() ) {
1381 $t = wfMsg( 'unwatchthispage' );
1382 $q = 'action=unwatch';
1383 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1385 $t = wfMsg( 'watchthispage' );
1386 $q = 'action=watch';
1387 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1389 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1391 $s = wfMsg( 'notanarticle' );
1396 function moveThisPage() {
1399 if ( $wgTitle->userCan( 'move' ) ) {
1400 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1401 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1403 // no message if page is protected - would be redundant
1408 function historyLink() {
1411 return $this->makeKnownLinkObj( $wgTitle,
1412 wfMsg( 'history' ), 'action=history' );
1415 function whatLinksHere() {
1418 return $this->makeKnownLinkObj(
1419 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1420 wfMsg( 'whatlinkshere' ) );
1423 function userContribsLink() {
1426 return $this->makeKnownLinkObj(
1427 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1428 wfMsg( 'contributions' ) );
1431 function showEmailUser( $id ) {
1432 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1433 return $wgEnableEmail &&
1434 $wgEnableUserEmail &&
1435 $wgUser->isLoggedIn() && # show only to signed in users
1436 0 != $id; # we can only email to non-anons ..
1437 # '' != $id->getEmail() && # who must have an email address stored ..
1438 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1439 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1442 function emailUserLink() {
1445 return $this->makeKnownLinkObj(
1446 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1447 wfMsg( 'emailuser' ) );
1450 function watchPageLinksLink() {
1451 global $wgOut, $wgTitle;
1453 if ( ! $wgOut->isArticleRelated() ) {
1454 return '(' . wfMsg( 'notanarticle' ) . ')';
1456 return $this->makeKnownLinkObj(
1457 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1458 wfMsg( 'recentchangeslinked' ) );
1462 function trackbackLink() {
1465 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1466 . wfMsg('trackbacklink') . "</a>";
1469 function otherLanguages() {
1470 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1472 if ( $wgHideInterlanguageLinks ) {
1476 $a = $wgOut->getLanguageLinks();
1477 if ( 0 == count( $a ) ) {
1481 $s = wfMsg( 'otherlanguages' ) . ': ';
1483 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1484 foreach( $a as $l ) {
1485 if ( ! $first ) { $s .= ' | '; }
1488 $nt = Title
::newFromText( $l );
1489 $url = $nt->escapeFullURL();
1490 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1492 if ( '' == $text ) { $text = $l; }
1493 $style = $this->getExternalLinkAttributes( $l, $text );
1494 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1496 if($wgContLang->isRTL()) $s .= '</span>';
1500 function bugReportsLink() {
1501 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1502 wfMsg( 'bugreports' ) );
1506 function talkLink() {
1509 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1510 # No discussion links for special pages
1514 if( $wgTitle->isTalkPage() ) {
1515 $link = $wgTitle->getSubjectPage();
1516 switch( $link->getNamespace() ) {
1518 $text = wfMsg( 'articlepage' );
1521 $text = wfMsg( 'userpage' );
1524 $text = wfMsg( 'projectpage' );
1527 $text = wfMsg( 'imagepage' );
1530 $text = wfMsg( 'mediawikipage' );
1533 $text = wfMsg( 'templatepage' );
1536 $text = wfMsg( 'viewhelppage' );
1539 $text = wfMsg( 'categorypage' );
1542 $text = wfMsg( 'articlepage' );
1545 $link = $wgTitle->getTalkPage();
1546 $text = wfMsg( 'talkpage' );
1549 $s = $this->makeLinkObj( $link, $text );
1554 function commentLink() {
1555 global $wgTitle, $wgOut;
1557 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1561 # __NEWSECTIONLINK___ changes behaviour here
1562 # If it's present, the link points to this page, otherwise
1563 # it points to the talk page
1564 if( $wgTitle->isTalkPage() ) {
1566 } elseif( $wgOut->showNewSectionLink() ) {
1569 $title = $wgTitle->getTalkPage();
1572 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1575 /* these are used extensively in SkinTemplate, but also some other places */
1576 static function makeMainPageUrl( $urlaction = '' ) {
1577 $title = Title
::newMainPage();
1578 self
::checkTitle( $title, '' );
1579 return $title->getLocalURL( $urlaction );
1582 static function makeSpecialUrl( $name, $urlaction = '' ) {
1583 $title = SpecialPage
::getTitleFor( $name );
1584 return $title->getLocalURL( $urlaction );
1587 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1588 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1589 return $title->getLocalURL( $urlaction );
1592 static function makeI18nUrl( $name, $urlaction = '' ) {
1593 $title = Title
::newFromText( wfMsgForContent( $name ) );
1594 self
::checkTitle( $title, $name );
1595 return $title->getLocalURL( $urlaction );
1598 static function makeUrl( $name, $urlaction = '' ) {
1599 $title = Title
::newFromText( $name );
1600 self
::checkTitle( $title, $name );
1601 return $title->getLocalURL( $urlaction );
1604 # If url string starts with http, consider as external URL, else
1606 static function makeInternalOrExternalUrl( $name ) {
1607 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1610 return self
::makeUrl( $name );
1614 # this can be passed the NS number as defined in Language.php
1615 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1616 $title = Title
::makeTitleSafe( $namespace, $name );
1617 self
::checkTitle( $title, $name );
1618 return $title->getLocalURL( $urlaction );
1621 /* these return an array with the 'href' and boolean 'exists' */
1622 static function makeUrlDetails( $name, $urlaction = '' ) {
1623 $title = Title
::newFromText( $name );
1624 self
::checkTitle( $title, $name );
1626 'href' => $title->getLocalURL( $urlaction ),
1627 'exists' => $title->getArticleID() != 0 ?
true : false
1632 * Make URL details where the article exists (or at least it's convenient to think so)
1634 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1635 $title = Title
::newFromText( $name );
1636 self
::checkTitle( $title, $name );
1638 'href' => $title->getLocalURL( $urlaction ),
1643 # make sure we have some title to operate on
1644 static function checkTitle( &$title, $name ) {
1645 if( !is_object( $title ) ) {
1646 $title = Title
::newFromText( $name );
1647 if( !is_object( $title ) ) {
1648 $title = Title
::newFromText( '--error: link target missing--' );
1654 * Build an array that represents the sidebar(s), the navigation bar among them
1659 function buildSidebar() {
1660 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1661 global $wgLang, $wgContLang;
1663 $fname = 'SkinTemplate::buildSidebar';
1665 wfProfileIn( $fname );
1667 $key = wfMemcKey( 'sidebar' );
1668 $cacheSidebar = $wgEnableSidebarCache &&
1669 ($wgLang->getCode() == $wgContLang->getCode());
1671 if ($cacheSidebar) {
1672 $cachedsidebar = $parserMemc->get( $key );
1673 if ($cachedsidebar!="") {
1674 wfProfileOut($fname);
1675 return $cachedsidebar;
1680 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1682 foreach ($lines as $line) {
1683 if (strpos($line, '*') !== 0)
1685 if (strpos($line, '**') !== 0) {
1686 $line = trim($line, '* ');
1689 if (strpos($line, '|') !== false) { // sanity check
1690 $line = 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; }
1721 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1722 wfProfileOut( $fname );