3 * @defgroup Skins Skins
6 if ( ! defined( 'MEDIAWIKI' ) )
10 * The main skin class that provide methods and properties for all other skins.
11 * This base class is also the "Standard" skin.
13 * See docs/skin.txt for more information.
17 class Skin
extends Linker
{
21 var $mWatchLinkNum = 0; // Appended to end of watch link id's
22 // How many search boxes have we made? Avoid duplicate id's.
23 protected $searchboxes = '';
25 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
26 protected $skinname = 'standard' ;
28 /** Constructor, call parent constructor */
29 function Skin() { parent
::__construct(); }
32 * Fetch the set of available skins.
33 * @return array of strings
36 static function getSkinNames() {
37 global $wgValidSkinNames;
38 static $skinsInitialised = false;
39 if ( !$skinsInitialised ) {
40 # Get a list of available skins
41 # Build using the regular expression '^(.*).php$'
42 # Array keys are all lower case, array value keep the case used by filename
44 wfProfileIn( __METHOD__
. '-init' );
45 global $wgStyleDirectory;
46 $skinDir = dir( $wgStyleDirectory );
48 # while code from www.php.net
49 while (false !== ($file = $skinDir->read())) {
50 // Skip non-PHP files, hidden files, and '.dep' includes
52 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
54 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
58 $skinsInitialised = true;
59 wfProfileOut( __METHOD__
. '-init' );
61 return $wgValidSkinNames;
65 * Fetch the list of usable skins in regards to $wgSkipSkins.
66 * Useful for Special:Preferences and other places where you
67 * only want to show skins users _can_ use.
68 * @return array of strings
70 public static function getUsableSkins() {
72 $usableSkins = self
::getSkinNames();
73 foreach ( $wgSkipSkins as $skip ) {
74 unset( $usableSkins[$skip] );
80 * Normalize a skin preference value to a form that can be loaded.
81 * If a skin can't be found, it will fall back to the configured
82 * default (or the old 'Classic' skin if that's broken).
87 static function normalizeKey( $key ) {
88 global $wgDefaultSkin;
89 $skinNames = Skin
::getSkinNames();
92 // Don't return the default immediately;
93 // in a misconfiguration we need to fall back.
94 $key = $wgDefaultSkin;
97 if( isset( $skinNames[$key] ) ) {
101 // Older versions of the software used a numeric setting
102 // in the user preferences.
106 2 => 'cologneblue' );
108 if( isset( $fallback[$key] ) ){
109 $key = $fallback[$key];
112 if( isset( $skinNames[$key] ) ) {
120 * Factory method for loading a skin of a given type
121 * @param string $key 'monobook', 'standard', etc
125 static function &newFromKey( $key ) {
126 global $wgStyleDirectory;
128 $key = Skin
::normalizeKey( $key );
130 $skinNames = Skin
::getSkinNames();
131 $skinName = $skinNames[$key];
132 $className = 'Skin'.ucfirst($key);
134 # Grab the skin class and initialise it.
135 if ( !class_exists( $className ) ) {
136 // Preload base classes to work around APC/PHP5 bug
137 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
138 if( file_exists( $deps ) ) include_once( $deps );
139 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
141 # Check if we got if not failback to default skin
142 if( !class_exists( $className ) ) {
143 # DO NOT die if the class isn't found. This breaks maintenance
144 # scripts and can cause a user account to be unrecoverable
145 # except by SQL manipulation if a previously valid skin name
146 # is no longer valid.
147 wfDebug( "Skin class does not exist: $className\n" );
148 $className = 'SkinMonobook';
149 require_once( "{$wgStyleDirectory}/MonoBook.php" );
152 $skin = new $className;
156 /** @return string path to the skin stylesheet */
157 function getStylesheet() {
158 return 'common/wikistandard.css';
161 /** @return string skin name */
162 public function getSkinName() {
163 return $this->skinname
;
166 function qbSetting() {
167 global $wgOut, $wgUser;
169 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
170 $q = $wgUser->getOption( 'quickbar', 0 );
174 function initPage( &$out ) {
175 global $wgFavicon, $wgAppleTouchIcon;
177 wfProfileIn( __METHOD__
);
179 if( false !== $wgFavicon ) {
180 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
183 if( false !== $wgAppleTouchIcon ) {
184 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
187 # OpenSearch description link
188 $out->addLink( array(
190 'type' => 'application/opensearchdescription+xml',
191 'href' => wfScript( 'opensearch_desc' ),
192 'title' => wfMsgForContent( 'opensearch-desc' ),
195 $this->addMetadataLinks($out);
197 $this->mRevisionId
= $out->mRevisionId
;
199 $this->preloadExistence();
201 wfProfileOut( __METHOD__
);
205 * Preload the existence of three commonly-requested pages in a single query
207 function preloadExistence() {
208 global $wgUser, $wgTitle;
211 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
214 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
216 } elseif ( $wgTitle->isTalkPage() ) {
217 $titles[] = $wgTitle->getSubjectPage();
219 $titles[] = $wgTitle->getTalkPage();
222 $lb = new LinkBatch( $titles );
226 function addMetadataLinks( &$out ) {
227 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
228 global $wgRightsPage, $wgRightsUrl;
230 if( $out->isArticleRelated() ) {
231 # note: buggy CC software only reads first "meta" link
232 if( $wgEnableCreativeCommonsRdf ) {
233 $out->addMetadataLink( array(
234 'title' => 'Creative Commons',
235 'type' => 'application/rdf+xml',
236 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
238 if( $wgEnableDublinCoreRdf ) {
239 $out->addMetadataLink( array(
240 'title' => 'Dublin Core',
241 'type' => 'application/rdf+xml',
242 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
246 if( $wgRightsPage ) {
247 $copy = Title
::newFromText( $wgRightsPage );
249 $copyright = $copy->getLocalURL();
252 if( !$copyright && $wgRightsUrl ) {
253 $copyright = $wgRightsUrl;
256 $out->addLink( array(
257 'rel' => 'copyright',
258 'href' => $copyright ) );
262 function outputPage( &$out ) {
263 global $wgDebugComments;
265 wfProfileIn( __METHOD__
);
266 $this->initPage( $out );
268 $out->out( $out->headElement() );
270 $out->out( "\n<body" );
271 $ops = $this->getBodyOptions();
272 foreach ( $ops as $name => $val ) {
273 $out->out( " $name='$val'" );
276 if ( $wgDebugComments ) {
277 $out->out( "<!-- Wiki debugging output:\n" .
278 $out->mDebugtext
. "-->\n" );
281 $out->out( $this->beforeContent() );
283 $out->out( $out->mBodytext
. "\n" );
285 // See self::afterContentHook() for documentation
286 $out->out ($this->afterContentHook());
288 $out->out( $this->afterContent() );
290 $out->out( $this->bottomScripts() );
292 $out->out( wfReportTime() );
294 $out->out( "\n</body></html>" );
295 wfProfileOut( __METHOD__
);
298 static function makeVariablesScript( $data ) {
299 global $wgJsMimeType;
301 $r = array( "<script type= \"$wgJsMimeType\">/*<![CDATA[*/" );
302 foreach ( $data as $name => $value ) {
303 $encValue = Xml
::encodeJsVar( $value );
304 $r[] = "var $name = $encValue;";
306 $r[] = "/*]]>*/</script>\n";
308 return implode( "\n\t\t", $r );
312 * Make a <script> tag containing global variables
313 * @param array $data Associative array containing one element:
314 * skinname => the skin name
315 * The odd calling convention is for backwards compatibility
317 static function makeGlobalVariablesScript( $data ) {
318 global $wgScript, $wgStylePath, $wgUser;
319 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
320 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
321 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
322 global $wgUseAjax, $wgAjaxWatch;
323 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
324 global $wgRestrictionTypes, $wgLivePreview;
325 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
327 $ns = $wgTitle->getNamespace();
328 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
331 'skin' => $data['skinname'],
332 'stylepath' => $wgStylePath,
333 'wgArticlePath' => $wgArticlePath,
334 'wgScriptPath' => $wgScriptPath,
335 'wgScript' => $wgScript,
336 'wgVariantArticlePath' => $wgVariantArticlePath,
337 'wgActionPaths' => $wgActionPaths,
338 'wgServer' => $wgServer,
339 'wgCanonicalNamespace' => $nsname,
340 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
341 'wgNamespaceNumber' => $wgTitle->getNamespace(),
342 'wgPageName' => $wgTitle->getPrefixedDBKey(),
343 'wgTitle' => $wgTitle->getText(),
344 'wgAction' => $wgRequest->getText( 'action', 'view' ),
345 'wgArticleId' => $wgTitle->getArticleId(),
346 'wgIsArticle' => $wgOut->isArticle(),
347 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
348 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
349 'wgUserLanguage' => $wgLang->getCode(),
350 'wgContentLanguage' => $wgContLang->getCode(),
351 'wgBreakFrames' => $wgBreakFrames,
352 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
353 'wgVersion' => $wgVersion,
354 'wgEnableAPI' => $wgEnableAPI,
355 'wgEnableWriteAPI' => $wgEnableWriteAPI,
358 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){
359 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
360 $vars['wgDBname'] = $wgDBname;
361 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
362 $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
365 foreach( $wgRestrictionTypes as $type )
366 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
368 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
369 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
370 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
371 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
372 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
375 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
376 $msgs = (object)array();
377 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
378 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
380 $vars['wgAjaxWatch'] = $msgs;
383 wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
385 return self
::makeVariablesScript( $vars );
388 function getHeadScripts( $allowUserJs ) {
389 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
391 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
393 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
396 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
397 $r .= "<script type=\"$wgJsMimeType\" src=\"".
398 htmlspecialchars(self
::makeUrl('-',
399 "action=raw$jsCache&gen=js&useskin=" .
400 urlencode( $this->getSkinName() ) ) ) .
401 "\"><!-- site js --></script>\n";
403 if( $allowUserJs && $wgUser->isLoggedIn() ) {
404 $userpage = $wgUser->getUserPage();
405 $userjs = htmlspecialchars( self
::makeUrl(
406 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
407 'action=raw&ctype='.$wgJsMimeType));
408 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
414 * To make it harder for someone to slip a user a fake
415 * user-JavaScript or user-CSS preview, a random token
416 * is associated with the login session. If it's not
417 * passed back with the preview request, we won't render
420 * @param string $action
424 function userCanPreview( $action ) {
425 global $wgTitle, $wgRequest, $wgUser;
427 if( $action != 'submit' )
429 if( !$wgRequest->wasPosted() )
431 if( !$wgTitle->userCanEditCssJsSubpage() )
433 return $wgUser->matchEditToken(
434 $wgRequest->getVal( 'wpEditToken' ) );
437 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
438 function getUserStylesheet() {
439 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
440 $sheet = $this->getStylesheet();
441 $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n";
442 $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n";
443 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
444 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
446 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
447 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
448 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
450 $s .= $this->doGetUserStyles();
455 * This returns MediaWiki:Common.js, and derived classes may add other JS.
456 * Despite its name, it does *not* return any custom user JS from user
457 * subpages. The returned script is sitewide and publicly cacheable and
458 * therefore must not include anything that varies according to user,
459 * interface language, etc. (although it may vary by skin). See
460 * makeGlobalVariablesScript for things that can vary per page view and are
463 * @return string Raw JavaScript to be returned
465 public function getUserJs() {
466 wfProfileIn( __METHOD__
);
469 $s = "/* generated javascript */\n";
470 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
471 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
472 $s .= "\n\n/* MediaWiki:Common.js */\n";
473 $commonJs = wfMsgForContent('common.js');
474 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
477 wfProfileOut( __METHOD__
);
482 * Return html code that include User stylesheets
484 function getUserStyles() {
485 $s = "<style type='text/css'>\n";
486 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
487 $s .= $this->getUserStylesheet();
488 $s .= "/*]]>*/ /* */\n";
494 * Some styles that are set by user through the user settings interface.
496 function doGetUserStyles() {
497 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
501 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
502 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
503 $s .= $wgRequest->getText('wpTextbox1');
505 $userpage = $wgUser->getUserPage();
506 $s.= '@import "'.self
::makeUrl(
507 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
508 'action=raw&ctype=text/css').'";'."\n";
512 return $s . $this->reallyDoGetUserStyles();
515 function reallyDoGetUserStyles() {
518 if (($undopt = $wgUser->getOption("underline")) < 2) {
519 $underline = $undopt ?
'underline' : 'none';
520 $s .= "a { text-decoration: $underline; }\n";
522 if( $wgUser->getOption( 'highlightbroken' ) ) {
523 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
526 a.new, #quickbar a.new,
527 a.stub, #quickbar a.stub {
530 a.new:after, #quickbar a.new:after {
534 a.stub:after, #quickbar a.stub:after {
540 if( $wgUser->getOption( 'justify' ) ) {
541 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
543 if( !$wgUser->getOption( 'showtoc' ) ) {
544 $s .= "#toc { display: none; }\n";
546 if( !$wgUser->getOption( 'editsection' ) ) {
547 $s .= ".editsection { display: none; }\n";
552 function getBodyOptions() {
553 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
555 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
557 if ( 0 != $wgTitle->getNamespace() ) {
558 $a = array( 'bgcolor' => '#ffffec' );
560 else $a = array( 'bgcolor' => '#FFFFFF' );
561 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
562 $wgTitle->userCan( 'edit' ) ) {
563 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
564 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
565 $a +
= array ('ondblclick' => $s);
568 $a['onload'] = $wgOut->getOnloadHandler();
570 'mediawiki ns-'.$wgTitle->getNamespace().
571 ' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
572 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
585 * This will be called immediately after the <body> tag. Split into
586 * two functions to make it easier to subclass.
588 function beforeContent() {
589 return $this->doBeforeContent();
592 function doBeforeContent() {
594 $fname = 'Skin::doBeforeContent';
595 wfProfileIn( $fname );
598 $qb = $this->qbSetting();
600 if( $langlinks = $this->otherLanguages() ) {
606 $borderhack = 'class="top"';
609 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
610 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
613 $left = ($qb == 1 ||
$qb == 3);
614 if($wgContLang->isRTL()) $left = !$left;
617 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
618 $this->logoText() . '</td>';
620 $s .= $this->getQuickbarCompensator( $rows );
622 $l = $wgContLang->isRTL() ?
'right' : 'left';
623 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
625 $s .= $this->topLinks() ;
626 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
628 $r = $wgContLang->isRTL() ?
"left" : "right";
629 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
630 $s .= $this->nameAndLogin();
631 $s .= "\n<br />" . $this->searchForm() . "</td>";
634 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
637 if ( $shove && !$left ) { # Right
638 $s .= $this->getQuickbarCompensator( $rows );
640 $s .= "</tr>\n</table>\n</div>\n";
641 $s .= "\n<div id='article'>\n";
643 $notice = wfGetSiteNotice();
645 $s .= "\n<div id='siteNotice'>$notice</div>\n";
647 $s .= $this->pageTitle();
648 $s .= $this->pageSubtitle() ;
649 $s .= $this->getCategories();
650 wfProfileOut( $fname );
655 function getCategoryLinks() {
656 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
657 global $wgContLang, $wgUser;
659 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
662 $sep = wfMsgHtml( 'catseparator' );
664 // Use Unicode bidi embedding override characters,
665 // to make sure links don't smash each other up in ugly ways.
666 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
667 $embed = "<span dir='$dir'>";
670 $allCats = $wgOut->getCategoryLinks();
672 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
673 if ( !empty( $allCats['normal'] ) ) {
674 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
676 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
677 $s .= '<div id="mw-normal-catlinks">' .
678 $this->link( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
679 . $colon . $t . '</div>';
683 if ( isset( $allCats['hidden'] ) ) {
684 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
685 $class ='mw-hidden-cats-user-shown';
686 } elseif ( $wgTitle->getNamespace() == NS_CATEGORY
) {
687 $class = 'mw-hidden-cats-ns-shown';
689 $class = 'mw-hidden-cats-hidden';
691 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
692 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
693 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
697 # optional 'dmoz-like' category browser. Will be shown under the list
698 # of categories an article belong to
699 if($wgUseCategoryBrowser) {
700 $s .= '<br /><hr />';
702 # get a big array of the parents tree
703 $parenttree = $wgTitle->getParentCategoryTree();
704 # Skin object passed by reference cause it can not be
705 # accessed under the method subfunction drawCategoryBrowser
706 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
707 # Clean out bogus first entry and sort them
710 # Output one per line
711 $s .= implode("<br />\n", $tempout);
717 /** Render the array as a serie of links.
718 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
719 * @param &skin Object: skin passed by reference
720 * @return String separated by >, terminate with "\n"
722 function drawCategoryBrowser($tree, &$skin) {
724 foreach ($tree as $element => $parent) {
725 if (empty($parent)) {
726 # element start a new list
729 # grab the others elements
730 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
732 # add our current element to the list
733 $eltitle = Title
::newFromText($element);
734 $return .= $skin->link( $eltitle, $eltitle->getText() ) ;
739 function getCategories() {
740 $catlinks=$this->getCategoryLinks();
742 $classes = 'catlinks';
744 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
745 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
746 $classes .= ' catlinks-allhidden';
749 if( !empty( $catlinks ) ){
750 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
754 function getQuickbarCompensator( $rows = 1 ) {
755 return "<td width='152' rowspan='{$rows}'> </td>";
759 * This runs a hook to allow extensions placing their stuff after content
760 * and article metadata (e.g. categories).
761 * Note: This function has nothing to do with afterContent().
763 * This hook is placed here in order to allow using the same hook for all
764 * skins, both the SkinTemplate based ones and the older ones, which directly
765 * use this class to get their data.
767 * The output of this function gets processed in SkinTemplate::outputPage() for
768 * the SkinTemplate based skins, all other skins should directly echo it.
770 * Returns an empty string by default, if not changed by any hook function.
772 protected function afterContentHook () {
775 if (wfRunHooks ('SkinAfterContent', array (&$data))) {
776 // adding just some spaces shouldn't toggle the output
777 // of the whole <div/>, so we use trim() here
778 if (trim ($data) != "") {
779 // Doing this here instead of in the skins to
780 // ensure that the div has the same ID in all
782 $data = "<!-- begin SkinAfterContent hook -->\n" .
783 "<div id='mw-data-after-content'>\n" .
786 "<!-- end SkinAfterContent hook -->\n";
789 wfDebug ('Hook SkinAfterContent changed output processing.');
796 * This gets called shortly before the \</body\> tag.
797 * @return String HTML to be put before \</body\>
799 function afterContent() {
800 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
801 return $printfooter . $this->doAfterContent();
805 * This gets called shortly before the \</body\> tag.
806 * @return String HTML-wrapped JS code to be put before \</body\>
808 function bottomScripts() {
809 global $wgJsMimeType;
810 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
811 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
812 return $bottomScriptText;
815 /** @return string Retrievied from HTML text */
816 function printSource() {
818 $url = htmlspecialchars( $wgTitle->getFullURL() );
819 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
822 function printFooter() {
823 return "<p>" . $this->printSource() .
824 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
827 /** overloaded by derived classes */
828 function doAfterContent() { }
830 function pageTitleLinks() {
831 global $wgOut, $wgTitle, $wgUser, $wgRequest;
833 $oldid = $wgRequest->getVal( 'oldid' );
834 $diff = $wgRequest->getVal( 'diff' );
835 $action = $wgRequest->getText( 'action' );
837 $s = $this->printableLink();
838 $disclaimer = $this->disclaimerLink(); # may be empty
840 $s .= ' | ' . $disclaimer;
842 $privacy = $this->privacyLink(); # may be empty too
844 $s .= ' | ' . $privacy;
847 if ( $wgOut->isArticleRelated() ) {
848 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
849 $name = $wgTitle->getDBkey();
850 $image = wfFindFile( $wgTitle );
852 $link = htmlspecialchars( $image->getURL() );
853 $style = $this->getInternalLinkAttributes( $link, $name );
854 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
858 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
859 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
860 wfMsg( 'currentrev' ) );
863 if ( $wgUser->getNewtalk() ) {
864 # do not show "You have new messages" text when we are viewing our
866 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
867 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
868 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
869 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
871 $wgOut->setSquidMaxage(0);
872 $wgOut->enableClientCache(false);
876 $undelete = $this->getUndeleteLink();
877 if( !empty( $undelete ) ) {
878 $s .= ' | '.$undelete;
883 function getUndeleteLink() {
884 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
885 if( $wgUser->isAllowed( 'deletedhistory' ) &&
886 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
887 ($n = $wgTitle->isDeleted() ) )
889 if ( $wgUser->isAllowed( 'undelete' ) ) {
890 $msg = 'thisisdeleted';
892 $msg = 'viewdeleted';
895 $this->makeKnownLinkObj(
896 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
897 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
902 function printableLink() {
903 global $wgOut, $wgFeedClasses, $wgRequest;
905 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
907 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
908 if( $wgOut->isSyndicated() ) {
909 foreach( $wgFeedClasses as $format => $class ) {
910 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
911 $s .= " | <a href=\"$feedurl\">{$format}</a>";
917 function pageTitle() {
919 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
923 function pageSubtitle() {
926 $sub = $wgOut->getSubtitle();
928 global $wgExtraSubtitle;
929 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
931 $subpages = $this->subPageSubtitle();
932 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
933 $s = "<p class='subtitle'>{$sub}</p>\n";
937 function subPageSubtitle() {
939 if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
942 global $wgOut, $wgTitle;
943 if($wgOut->isArticle() && MWNamespace
::hasSubpages( $wgTitle->getNamespace() )) {
944 $ptext=$wgTitle->getPrefixedText();
945 if(preg_match('/\//',$ptext)) {
946 $links = explode('/',$ptext);
951 foreach($links as $link) {
952 $growinglink .= $link;
954 $linkObj = Title
::newFromText( $growinglink );
955 if( is_object( $linkObj ) && $linkObj->exists() ){
956 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
961 $subpages .= '< ';
963 $subpages .= $getlink;
976 * Returns true if the IP should be shown in the header
978 function showIPinHeader() {
979 global $wgShowIPinHeader;
980 return $wgShowIPinHeader && session_id() != '';
983 function nameAndLogin() {
984 global $wgUser, $wgTitle, $wgLang, $wgContLang;
986 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
989 if ( $wgUser->isAnon() ) {
990 if( $this->showIPinHeader() ) {
993 $talkLink = $this->link( $wgUser->getTalkPage(),
994 $wgLang->getNsText( NS_TALK
) );
996 $ret .= "$name ($talkLink)";
998 $ret .= wfMsg( 'notloggedin' );
1001 $returnTo = $wgTitle->getPrefixedDBkey();
1003 if ( $logoutPage != $returnTo ) {
1004 $query['returnto'] = $returnTo;
1007 $loginlink = $wgUser->isAllowed( 'createaccount' )
1008 ?
'nav-login-createaccount'
1010 $ret .= "\n<br />" . $this->link(
1011 SpecialPage
::getTitleFor( 'Userlogin' ),
1012 wfMsg( $loginlink ), array(), $query
1015 $returnTo = $wgTitle->getPrefixedDBkey();
1016 $talkLink = $this->link( $wgUser->getTalkPage(),
1017 $wgLang->getNsText( NS_TALK
) );
1019 $ret .= $this->link( $wgUser->getUserPage(),
1020 htmlspecialchars( $wgUser->getName() ) );
1021 $ret .= " ($talkLink)<br />";
1022 $ret .= $this->link(
1023 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1024 array(), array( 'returnto' => $returnTo )
1026 $ret .= ' | ' . $this->specialLink( 'preferences' );
1028 $ret .= ' | ' . $this->link(
1029 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1036 function getSearchLink() {
1037 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1038 return $searchPage->getLocalURL();
1041 function escapeSearchLink() {
1042 return htmlspecialchars( $this->getSearchLink() );
1045 function searchForm() {
1047 $search = $wgRequest->getText( 'search' );
1049 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1050 . $this->escapeSearchLink() . "\">\n"
1051 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1052 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
1053 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
1054 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
1056 // Ensure unique id's for search boxes made after the first
1057 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1062 function topLinks() {
1066 $s = $this->mainPageLink() . $sep
1067 . $this->specialLink( 'recentchanges' );
1069 if ( $wgOut->isArticleRelated() ) {
1070 $s .= $sep . $this->editThisPage()
1071 . $sep . $this->historyLink();
1073 # Many people don't like this dropdown box
1074 #$s .= $sep . $this->specialPagesList();
1076 $s .= $this->variantLinks();
1078 $s .= $this->extensionTabLinks();
1084 * Compatibility for extensions adding functionality through tabs.
1085 * Eventually these old skins should be replaced with SkinTemplate-based
1089 function extensionTabLinks() {
1092 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1093 foreach( $tabs as $tab ) {
1094 $s .= ' | ' . Xml
::element( 'a',
1095 array( 'href' => $tab['href'] ),
1102 * Language/charset variant links for classic-style skins
1105 function variantLinks() {
1107 /* show links to different language variants */
1108 global $wgDisableLangConversion, $wgContLang, $wgTitle;
1109 $variants = $wgContLang->getVariants();
1110 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1111 foreach( $variants as $code ) {
1112 $varname = $wgContLang->getVariantname( $code );
1113 if( $varname == 'disable' )
1115 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1121 function bottomLinks() {
1122 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1126 if ( $wgOut->isArticleRelated() ) {
1127 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1128 if ( $wgUser->isLoggedIn() ) {
1129 $s .= $sep . $this->watchThisPage();
1131 $s .= $sep . $this->talkLink()
1132 . $sep . $this->historyLink()
1133 . $sep . $this->whatLinksHere()
1134 . $sep . $this->watchPageLinksLink();
1136 if ($wgUseTrackbacks)
1137 $s .= $sep . $this->trackbackLink();
1139 if ( $wgTitle->getNamespace() == NS_USER
1140 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1143 $id=User
::idFromName($wgTitle->getText());
1144 $ip=User
::isIP($wgTitle->getText());
1146 if($id ||
$ip) { # both anons and non-anons have contri list
1147 $s .= $sep . $this->userContribsLink();
1149 if( $this->showEmailUser( $id ) ) {
1150 $s .= $sep . $this->emailUserLink();
1153 if ( $wgTitle->getArticleId() ) {
1155 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1156 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1157 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1159 $s .= "<br />\n" . $this->otherLanguages();
1164 function pageStats() {
1165 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1166 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1168 $oldid = $wgRequest->getVal( 'oldid' );
1169 $diff = $wgRequest->getVal( 'diff' );
1170 if ( ! $wgOut->isArticle() ) { return ''; }
1171 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1172 if ( 0 == $wgArticle->getID() ) { return ''; }
1175 if ( !$wgDisableCounters ) {
1176 $count = $wgLang->formatNum( $wgArticle->getCount() );
1178 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1182 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1183 require_once('Credits.php');
1184 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1186 $s .= $this->lastModified();
1189 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1190 $dbr = wfGetDB( DB_SLAVE
);
1191 $watchlist = $dbr->tableName( 'watchlist' );
1192 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1193 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1194 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1195 $res = $dbr->query( $sql, 'Skin::pageStats');
1196 $x = $dbr->fetchObject( $res );
1198 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1199 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1203 return $s . ' ' . $this->getCopyright();
1206 function getCopyright( $type = 'detect' ) {
1207 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1209 if ( $type == 'detect' ) {
1210 $oldid = $wgRequest->getVal( 'oldid' );
1211 $diff = $wgRequest->getVal( 'diff' );
1213 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1220 if ( $type == 'history' ) {
1221 $msg = 'history_copyright';
1227 if( $wgRightsPage ) {
1228 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1229 } elseif( $wgRightsUrl ) {
1230 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1235 $out .= wfMsgForContent( $msg, $link );
1239 function getCopyrightIcon() {
1240 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1242 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1243 $out = $wgCopyrightIcon;
1244 } else if ( $wgRightsIcon ) {
1245 $icon = htmlspecialchars( $wgRightsIcon );
1246 if ( $wgRightsUrl ) {
1247 $url = htmlspecialchars( $wgRightsUrl );
1248 $out .= '<a href="'.$url.'">';
1250 $text = htmlspecialchars( $wgRightsText );
1251 $out .= "<img src=\"$icon\" alt='$text' />";
1252 if ( $wgRightsUrl ) {
1259 function getPoweredBy() {
1260 global $wgStylePath;
1261 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1262 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1266 function lastModified() {
1267 global $wgLang, $wgArticle;
1268 if( $this->mRevisionId
) {
1269 $timestamp = Revision
::getTimestampFromId( $this->mRevisionId
, $wgArticle->getId() );
1271 $timestamp = $wgArticle->getTimestamp();
1274 $d = $wgLang->date( $timestamp, true );
1275 $t = $wgLang->time( $timestamp, true );
1276 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1280 if ( wfGetLB()->getLaggedSlaveMode() ) {
1281 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1286 function logoText( $align = '' ) {
1287 if ( '' != $align ) { $a = " align='{$align}'"; }
1290 $mp = wfMsg( 'mainpage' );
1291 $mptitle = Title
::newMainPage();
1292 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1294 $logourl = $this->getLogo();
1295 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1300 * show a drop-down box of special pages
1302 function specialPagesList() {
1303 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1304 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1305 foreach ( $pages as $name => $page ) {
1306 $pages[$name] = $page->getDescription();
1309 $go = wfMsg( 'go' );
1310 $sp = wfMsg( 'specialpages' );
1311 $spp = $wgContLang->specialPage( 'Specialpages' );
1313 $s = '<form id="specialpages" method="get" class="inline" ' .
1314 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1315 $s .= "<select name=\"wpDropdown\">\n";
1316 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1319 foreach ( $pages as $name => $desc ) {
1320 $p = $wgContLang->specialPage( $name );
1321 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1323 $s .= "</select>\n";
1324 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1329 function mainPageLink() {
1330 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1334 function copyrightLink() {
1335 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1336 wfMsg( 'copyrightpagename' ) );
1340 private function footerLink ( $desc, $page ) {
1341 // if the link description has been set to "-" in the default language,
1342 if ( wfMsgForContent( $desc ) == '-') {
1343 // then it is disabled, for all languages.
1346 // Otherwise, we display the link for the user, described in their
1347 // language (which may or may not be the same as the default language),
1348 // but we make the link target be the one site-wide page.
1349 return $this->makeKnownLink( wfMsgForContent( $page ),
1350 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1354 function privacyLink() {
1355 return $this->footerLink( 'privacy', 'privacypage' );
1358 function aboutLink() {
1359 return $this->footerLink( 'aboutsite', 'aboutpage' );
1362 function disclaimerLink() {
1363 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1366 function editThisPage() {
1367 global $wgOut, $wgTitle;
1369 if ( !$wgOut->isArticleRelated() ) {
1370 $s = wfMsg( 'protectedpage' );
1372 if( $wgTitle->userCan( 'edit' ) && $wgTitle->exists() ) {
1373 $t = wfMsg( 'editthispage' );
1374 } elseif( $wgTitle->userCan( 'create' ) && !$wgTitle->exists() ) {
1375 $t = wfMsg( 'create-this-page' );
1377 $t = wfMsg( 'viewsource' );
1380 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1386 * Return URL options for the 'edit page' link.
1387 * This may include an 'oldid' specifier, if the current page view is such.
1392 function editUrlOptions() {
1395 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1396 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1398 return "action=edit";
1402 function deleteThisPage() {
1403 global $wgUser, $wgTitle, $wgRequest;
1405 $diff = $wgRequest->getVal( 'diff' );
1406 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1407 $t = wfMsg( 'deletethispage' );
1409 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1416 function protectThisPage() {
1417 global $wgUser, $wgTitle, $wgRequest;
1419 $diff = $wgRequest->getVal( 'diff' );
1420 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1421 if ( $wgTitle->isProtected() ) {
1422 $t = wfMsg( 'unprotectthispage' );
1423 $q = 'action=unprotect';
1425 $t = wfMsg( 'protectthispage' );
1426 $q = 'action=protect';
1428 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1435 function watchThisPage() {
1436 global $wgOut, $wgTitle;
1437 ++
$this->mWatchLinkNum
;
1439 if ( $wgOut->isArticleRelated() ) {
1440 if ( $wgTitle->userIsWatching() ) {
1441 $t = wfMsg( 'unwatchthispage' );
1442 $q = 'action=unwatch';
1443 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1445 $t = wfMsg( 'watchthispage' );
1446 $q = 'action=watch';
1447 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1449 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1451 $s = wfMsg( 'notanarticle' );
1456 function moveThisPage() {
1459 if ( $wgTitle->userCan( 'move' ) ) {
1460 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1461 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1463 // no message if page is protected - would be redundant
1468 function historyLink() {
1471 return $this->makeKnownLinkObj( $wgTitle,
1472 wfMsg( 'history' ), 'action=history' );
1475 function whatLinksHere() {
1478 return $this->makeKnownLinkObj(
1479 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1480 wfMsg( 'whatlinkshere' ) );
1483 function userContribsLink() {
1486 return $this->makeKnownLinkObj(
1487 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1488 wfMsg( 'contributions' ) );
1491 function showEmailUser( $id ) {
1492 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1493 return $wgEnableEmail &&
1494 $wgEnableUserEmail &&
1495 $wgUser->isLoggedIn() && # show only to signed in users
1496 0 != $id; # we can only email to non-anons ..
1497 # '' != $id->getEmail() && # who must have an email address stored ..
1498 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1499 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1502 function emailUserLink() {
1505 return $this->makeKnownLinkObj(
1506 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1507 wfMsg( 'emailuser' ) );
1510 function watchPageLinksLink() {
1511 global $wgOut, $wgTitle;
1513 if ( ! $wgOut->isArticleRelated() ) {
1514 return '(' . wfMsg( 'notanarticle' ) . ')';
1516 return $this->makeKnownLinkObj(
1517 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1518 wfMsg( 'recentchangeslinked' ) );
1522 function trackbackLink() {
1525 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1526 . wfMsg('trackbacklink') . "</a>";
1529 function otherLanguages() {
1530 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1532 if ( $wgHideInterlanguageLinks ) {
1536 $a = $wgOut->getLanguageLinks();
1537 if ( 0 == count( $a ) ) {
1541 $s = wfMsg( 'otherlanguages' ) . ': ';
1543 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1544 foreach( $a as $l ) {
1545 if ( ! $first ) { $s .= ' | '; }
1548 $nt = Title
::newFromText( $l );
1549 $url = $nt->escapeFullURL();
1550 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1552 if ( '' == $text ) { $text = $l; }
1553 $style = $this->getExternalLinkAttributes( $l, $text );
1554 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1556 if($wgContLang->isRTL()) $s .= '</span>';
1560 function bugReportsLink() {
1561 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1562 wfMsg( 'bugreports' ) );
1566 function talkLink() {
1569 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1570 # No discussion links for special pages
1574 if( $wgTitle->isTalkPage() ) {
1575 $link = $wgTitle->getSubjectPage();
1576 switch( $link->getNamespace() ) {
1578 $text = wfMsg( 'articlepage' );
1581 $text = wfMsg( 'userpage' );
1584 $text = wfMsg( 'projectpage' );
1587 $text = wfMsg( 'imagepage' );
1590 $text = wfMsg( 'mediawikipage' );
1593 $text = wfMsg( 'templatepage' );
1596 $text = wfMsg( 'viewhelppage' );
1599 $text = wfMsg( 'categorypage' );
1602 $text = wfMsg( 'articlepage' );
1605 $link = $wgTitle->getTalkPage();
1606 $text = wfMsg( 'talkpage' );
1609 $s = $this->makeLinkObj( $link, $text );
1614 function commentLink() {
1615 global $wgTitle, $wgOut;
1617 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1621 # __NEWSECTIONLINK___ changes behaviour here
1622 # If it's present, the link points to this page, otherwise
1623 # it points to the talk page
1624 if( $wgTitle->isTalkPage() ) {
1626 } elseif( $wgOut->showNewSectionLink() ) {
1629 $title = $wgTitle->getTalkPage();
1632 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1635 /* these are used extensively in SkinTemplate, but also some other places */
1636 static function makeMainPageUrl( $urlaction = '' ) {
1637 $title = Title
::newMainPage();
1638 self
::checkTitle( $title, '' );
1639 return $title->getLocalURL( $urlaction );
1642 static function makeSpecialUrl( $name, $urlaction = '' ) {
1643 $title = SpecialPage
::getTitleFor( $name );
1644 return $title->getLocalURL( $urlaction );
1647 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1648 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1649 return $title->getLocalURL( $urlaction );
1652 static function makeI18nUrl( $name, $urlaction = '' ) {
1653 $title = Title
::newFromText( wfMsgForContent( $name ) );
1654 self
::checkTitle( $title, $name );
1655 return $title->getLocalURL( $urlaction );
1658 static function makeUrl( $name, $urlaction = '' ) {
1659 $title = Title
::newFromText( $name );
1660 self
::checkTitle( $title, $name );
1661 return $title->getLocalURL( $urlaction );
1664 # If url string starts with http, consider as external URL, else
1666 static function makeInternalOrExternalUrl( $name ) {
1667 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1670 return self
::makeUrl( $name );
1674 # this can be passed the NS number as defined in Language.php
1675 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1676 $title = Title
::makeTitleSafe( $namespace, $name );
1677 self
::checkTitle( $title, $name );
1678 return $title->getLocalURL( $urlaction );
1681 /* these return an array with the 'href' and boolean 'exists' */
1682 static function makeUrlDetails( $name, $urlaction = '' ) {
1683 $title = Title
::newFromText( $name );
1684 self
::checkTitle( $title, $name );
1686 'href' => $title->getLocalURL( $urlaction ),
1687 'exists' => $title->getArticleID() != 0 ?
true : false
1692 * Make URL details where the article exists (or at least it's convenient to think so)
1694 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1695 $title = Title
::newFromText( $name );
1696 self
::checkTitle( $title, $name );
1698 'href' => $title->getLocalURL( $urlaction ),
1703 # make sure we have some title to operate on
1704 static function checkTitle( &$title, $name ) {
1705 if( !is_object( $title ) ) {
1706 $title = Title
::newFromText( $name );
1707 if( !is_object( $title ) ) {
1708 $title = Title
::newFromText( '--error: link target missing--' );
1714 * Build an array that represents the sidebar(s), the navigation bar among them
1718 function buildSidebar() {
1719 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1721 wfProfileIn( __METHOD__
);
1723 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
1725 if ( $wgEnableSidebarCache ) {
1726 $cachedsidebar = $parserMemc->get( $key );
1727 if ( $cachedsidebar ) {
1728 wfProfileOut( __METHOD__
);
1729 return $cachedsidebar;
1734 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1736 foreach ($lines as $line) {
1737 if (strpos($line, '*') !== 0)
1739 if (strpos($line, '**') !== 0) {
1740 $line = trim($line, '* ');
1742 if( !array_key_exists($heading, $bar) ) $bar[$heading] = array();
1744 if (strpos($line, '|') !== false) { // sanity check
1745 $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) );
1746 $link = wfMsgForContent( $line[0] );
1749 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1751 if (wfEmptyMsg($line[0], $link))
1754 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1757 $title = Title
::newFromText( $link );
1759 $title = $title->fixSpecialName();
1760 $href = $title->getLocalURL();
1762 $href = 'INVALID-TITLE';
1766 $bar[$heading][] = array(
1769 'id' => 'n-' . strtr($line[1], ' ', '-'),
1772 } else { continue; }
1775 wfRunHooks('SkinBuildSidebar', array($this, &$bar));
1776 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1777 wfProfileOut( __METHOD__
);