(bug 1553) Lowercase navigation headings in German
[lhc/web/wiklou.git] / includes / Skin.php
1 <?php
2 /**
3 * @defgroup Skins Skins
4 */
5
6 if ( ! defined( 'MEDIAWIKI' ) )
7 die( 1 );
8
9 /**
10 * The main skin class that provide methods and properties for all other skins.
11 * This base class is also the "Standard" skin.
12 *
13 * See docs/skin.txt for more information.
14 *
15 * @ingroup Skins
16 */
17 class Skin extends Linker {
18 /**#@+
19 * @private
20 */
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 = '';
24 /**#@-*/
25 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
26 protected $skinname = 'standard';
27
28 /** Constructor, call parent constructor */
29 function Skin() { parent::__construct(); }
30
31 /**
32 * Fetch the set of available skins.
33 * @return array of strings
34 * @static
35 */
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
43 #
44 wfProfileIn( __METHOD__ . '-init' );
45 global $wgStyleDirectory;
46 $skinDir = dir( $wgStyleDirectory );
47
48 # while code from www.php.net
49 while( false !== ( $file = $skinDir->read() ) ) {
50 // Skip non-PHP files, hidden files, and '.dep' includes
51 $matches = array();
52 if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
53 $aSkin = $matches[1];
54 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
55 }
56 }
57 $skinDir->close();
58 $skinsInitialised = true;
59 wfProfileOut( __METHOD__ . '-init' );
60 }
61 return $wgValidSkinNames;
62 }
63
64 /**
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
69 */
70 public static function getUsableSkins() {
71 global $wgSkipSkins;
72 $usableSkins = self::getSkinNames();
73 foreach ( $wgSkipSkins as $skip ) {
74 unset( $usableSkins[$skip] );
75 }
76 return $usableSkins;
77 }
78
79 /**
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).
83 * @param string $key
84 * @return string
85 * @static
86 */
87 static function normalizeKey( $key ) {
88 global $wgDefaultSkin;
89 $skinNames = Skin::getSkinNames();
90
91 if( $key == '' ) {
92 // Don't return the default immediately;
93 // in a misconfiguration we need to fall back.
94 $key = $wgDefaultSkin;
95 }
96
97 if( isset( $skinNames[$key] ) ) {
98 return $key;
99 }
100
101 // Older versions of the software used a numeric setting
102 // in the user preferences.
103 $fallback = array(
104 0 => $wgDefaultSkin,
105 1 => 'nostalgia',
106 2 => 'cologneblue' );
107
108 if( isset( $fallback[$key] ) ){
109 $key = $fallback[$key];
110 }
111
112 if( isset( $skinNames[$key] ) ) {
113 return $key;
114 } else {
115 return 'monobook';
116 }
117 }
118
119 /**
120 * Factory method for loading a skin of a given type
121 * @param string $key 'monobook', 'standard', etc
122 * @return Skin
123 * @static
124 */
125 static function &newFromKey( $key ) {
126 global $wgStyleDirectory;
127
128 $key = Skin::normalizeKey( $key );
129
130 $skinNames = Skin::getSkinNames();
131 $skinName = $skinNames[$key];
132 $className = 'Skin'.ucfirst($key);
133
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" );
140
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" );
150 }
151 }
152 $skin = new $className;
153 return $skin;
154 }
155
156 /** @return string path to the skin stylesheet */
157 function getStylesheet() {
158 return 'common/wikistandard.css';
159 }
160
161 /** @return string skin name */
162 public function getSkinName() {
163 return $this->skinname;
164 }
165
166 function qbSetting() {
167 global $wgOut, $wgUser;
168
169 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
170 $q = $wgUser->getOption( 'quickbar', 0 );
171 return $q;
172 }
173
174 function initPage( OutputPage $out ) {
175 global $wgFavicon, $wgAppleTouchIcon;
176
177 wfProfileIn( __METHOD__ );
178
179 $this->mTitle = $out->getTitle();
180
181 # Generally the order of the favicon and apple-touch-icon links
182 # should not matter, but Konqueror (3.5.9 at least) incorrectly
183 # uses whichever one appears later in the HTML source. Make sure
184 # apple-touch-icon is specified first to avoid this.
185 if( false !== $wgAppleTouchIcon ) {
186 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
187 }
188
189 if( false !== $wgFavicon ) {
190 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
191 }
192
193 # OpenSearch description link
194 $out->addLink( array(
195 'rel' => 'search',
196 'type' => 'application/opensearchdescription+xml',
197 'href' => wfScript( 'opensearch_desc' ),
198 'title' => wfMsgForContent( 'opensearch-desc' ),
199 ));
200
201 $this->addMetadataLinks( $out );
202
203 $this->mRevisionId = $out->mRevisionId;
204
205 $this->preloadExistence();
206
207 wfProfileOut( __METHOD__ );
208 }
209
210 /**
211 * Preload the existence of three commonly-requested pages in a single query
212 */
213 function preloadExistence() {
214 global $wgUser;
215
216 // User/talk link
217 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
218
219 // Other tab link
220 if ( $this->mTitle->getNamespace() == NS_SPECIAL ) {
221 // nothing
222 } elseif ( $this->mTitle->isTalkPage() ) {
223 $titles[] = $this->mTitle->getSubjectPage();
224 } else {
225 $titles[] = $this->mTitle->getTalkPage();
226 }
227
228 $lb = new LinkBatch( $titles );
229 $lb->execute();
230 }
231
232 function addMetadataLinks( OutputPage $out ) {
233 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
234 global $wgRightsPage, $wgRightsUrl;
235
236 if( $out->isArticleRelated() ) {
237 # note: buggy CC software only reads first "meta" link
238 if( $wgEnableCreativeCommonsRdf ) {
239 $out->addMetadataLink( array(
240 'title' => 'Creative Commons',
241 'type' => 'application/rdf+xml',
242 'href' => $this->mTitle->getLocalURL( 'action=creativecommons' ) )
243 );
244 }
245 if( $wgEnableDublinCoreRdf ) {
246 $out->addMetadataLink( array(
247 'title' => 'Dublin Core',
248 'type' => 'application/rdf+xml',
249 'href' => $this->mTitle->getLocalURL( 'action=dublincore' ) )
250 );
251 }
252 }
253 $copyright = '';
254 if( $wgRightsPage ) {
255 $copy = Title::newFromText( $wgRightsPage );
256 if( $copy ) {
257 $copyright = $copy->getLocalURL();
258 }
259 }
260 if( !$copyright && $wgRightsUrl ) {
261 $copyright = $wgRightsUrl;
262 }
263 if( $copyright ) {
264 $out->addLink( array(
265 'rel' => 'copyright',
266 'href' => $copyright )
267 );
268 }
269 }
270
271 function setMembers(){
272 global $wgUser;
273 $this->mUser = $wgUser;
274 $this->userpage = $wgUser->getUserPage()->getPrefixedText();
275 $this->usercss = false;
276 }
277
278 function outputPage( OutputPage $out ) {
279 global $wgDebugComments;
280 wfProfileIn( __METHOD__ );
281
282 $this->setMembers();
283 $this->initPage( $out );
284
285 // See self::afterContentHook() for documentation
286 $afterContent = $this->afterContentHook();
287
288 $out->out( $out->headElement( $this ) );
289
290 $out->out( "\n<body" );
291 $ops = $this->getBodyOptions();
292 foreach ( $ops as $name => $val ) {
293 $out->out( " $name='$val'" );
294 }
295 $out->out( ">\n" );
296 if ( $wgDebugComments ) {
297 $out->out( "<!-- Wiki debugging output:\n" .
298 $out->mDebugtext . "-->\n" );
299 }
300
301 $out->out( $this->beforeContent() );
302
303 $out->out( $out->mBodytext . "\n" );
304
305 $out->out( $this->afterContent() );
306
307 $out->out( $afterContent );
308
309 $out->out( $this->bottomScripts() );
310
311 $out->out( wfReportTime() );
312
313 $out->out( "\n</body></html>" );
314 wfProfileOut( __METHOD__ );
315 }
316
317 static function makeVariablesScript( $data ) {
318 global $wgJsMimeType;
319
320 $r = array( "<script type=\"$wgJsMimeType\">/*<![CDATA[*/" );
321 foreach ( $data as $name => $value ) {
322 $encValue = Xml::encodeJsVar( $value );
323 $r[] = "var $name = $encValue;";
324 }
325 $r[] = "/*]]>*/</script>\n";
326
327 return implode( "\n\t\t", $r );
328 }
329
330 /**
331 * Make a <script> tag containing global variables
332 * @param array $data Associative array containing one element:
333 * skinname => the skin name
334 * The odd calling convention is for backwards compatibility
335 * @TODO @FIXME Make this not depend on $wgTitle!
336 */
337 static function makeGlobalVariablesScript( $data ) {
338 global $wgScript, $wgTitle, $wgStylePath, $wgUser;
339 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
340 global $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
341 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
342 global $wgUseAjax, $wgAjaxWatch;
343 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
344 global $wgRestrictionTypes, $wgLivePreview;
345 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
346
347 $ns = $wgTitle->getNamespace();
348 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ? $wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
349 $separatorTransTable = $wgContLang->separatorTransformTable();
350 $separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
351 $compactSeparatorTransTable = array(
352 implode( "\t", array_keys( $separatorTransTable ) ),
353 implode( "\t", $separatorTransTable ),
354 );
355 $digitTransTable = $wgContLang->digitTransformTable();
356 $digitTransTable = $digitTransTable ? $digitTransTable : array();
357 $compactDigitTransTable = array(
358 implode( "\t", array_keys( $digitTransTable ) ),
359 implode( "\t", $digitTransTable ),
360 );
361
362 $vars = array(
363 'skin' => $data['skinname'],
364 'stylepath' => $wgStylePath,
365 'wgArticlePath' => $wgArticlePath,
366 'wgScriptPath' => $wgScriptPath,
367 'wgScript' => $wgScript,
368 'wgVariantArticlePath' => $wgVariantArticlePath,
369 'wgActionPaths' => (object)$wgActionPaths,
370 'wgServer' => $wgServer,
371 'wgCanonicalNamespace' => $nsname,
372 'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias( $wgTitle->getDBkey() ),
373 'wgNamespaceNumber' => $wgTitle->getNamespace(),
374 'wgPageName' => $wgTitle->getPrefixedDBKey(),
375 'wgTitle' => $wgTitle->getText(),
376 'wgAction' => $wgRequest->getText( 'action', 'view' ),
377 'wgArticleId' => $wgTitle->getArticleId(),
378 'wgIsArticle' => $wgOut->isArticle(),
379 'wgUserName' => $wgUser->isAnon() ? NULL : $wgUser->getName(),
380 'wgUserGroups' => $wgUser->isAnon() ? NULL : $wgUser->getEffectiveGroups(),
381 'wgUserLanguage' => $wgLang->getCode(),
382 'wgContentLanguage' => $wgContLang->getCode(),
383 'wgBreakFrames' => $wgBreakFrames,
384 'wgCurRevisionId' => isset( $wgArticle ) ? $wgArticle->getLatest() : 0,
385 'wgVersion' => $wgVersion,
386 'wgEnableAPI' => $wgEnableAPI,
387 'wgEnableWriteAPI' => $wgEnableWriteAPI,
388 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
389 'wgDigitTransformTable' => $compactDigitTransTable,
390 );
391
392 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
393 $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
394 $vars['wgDBname'] = $wgDBname;
395 $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser );
396 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
397 }
398
399 foreach( $wgRestrictionTypes as $type )
400 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
401
402 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
403 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
404 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
405 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
406 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
407 }
408
409 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
410 $msgs = (object)array();
411 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
412 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
413 }
414 $vars['wgAjaxWatch'] = $msgs;
415 }
416
417 // Allow extensions to add their custom variables to the global JS variables
418 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
419
420 return self::makeVariablesScript( $vars );
421 }
422
423 function getHeadScripts( $allowUserJs ) {
424 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
425
426 $vars = self::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
427
428 $r = array( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>" );
429 global $wgUseSiteJs;
430 if( $wgUseSiteJs ) {
431 $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
432 $r[] = "<script type=\"$wgJsMimeType\" src=\"".
433 htmlspecialchars( self::makeUrl( '-',
434 "action=raw$jsCache&gen=js&useskin=" .
435 urlencode( $this->getSkinName() ) ) ) .
436 "\"><!-- site js --></script>";
437 }
438 if( $allowUserJs && $wgUser->isLoggedIn() ) {
439 $userpage = $wgUser->getUserPage();
440 $userjs = htmlspecialchars( self::makeUrl(
441 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
442 'action=raw&ctype='.$wgJsMimeType ) );
443 $r[] = '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>";
444 }
445 return $vars . "\t\t" . implode ( "\n\t\t", $r );
446 }
447
448 /**
449 * To make it harder for someone to slip a user a fake
450 * user-JavaScript or user-CSS preview, a random token
451 * is associated with the login session. If it's not
452 * passed back with the preview request, we won't render
453 * the code.
454 *
455 * @param string $action
456 * @return bool
457 * @private
458 */
459 function userCanPreview( $action ) {
460 global $wgRequest, $wgUser;
461
462 if( $action != 'submit' )
463 return false;
464 if( !$wgRequest->wasPosted() )
465 return false;
466 if( !$this->mTitle->userCanEditCssJsSubpage() )
467 return false;
468 return $wgUser->matchEditToken(
469 $wgRequest->getVal( 'wpEditToken' ) );
470 }
471
472 /**
473 * generated JavaScript action=raw&gen=js
474 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
475 * nated together. For some bizarre reason, it does *not* return any
476 * custom user JS from subpages. Huh?
477 *
478 * There's absolutely no reason to have separate Monobook/Common JSes.
479 * Any JS that cares can just check the skin variable generated at the
480 * top. For now Monobook.js will be maintained, but it should be consi-
481 * dered deprecated.
482 *
483 * @return string
484 */
485 public function generateUserJs() {
486 global $wgStylePath;
487
488 wfProfileIn( __METHOD__ );
489
490 $s = "/* generated javascript */\n";
491 $s .= "var skin = '" . Xml::escapeJsString( $this->getSkinName() ) . "';\n";
492 $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';";
493 $s .= "\n\n/* MediaWiki:Common.js */\n";
494 $commonJs = wfMsgForContent( 'common.js' );
495 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
496 $s .= $commonJs;
497 }
498
499 $s .= "\n\n/* MediaWiki:".ucfirst( $this->getSkinName() ).".js */\n";
500 // avoid inclusion of non defined user JavaScript (with custom skins only)
501 // by checking for default message content
502 $msgKey = ucfirst( $this->getSkinName() ).'.js';
503 $userJS = wfMsgForContent( $msgKey );
504 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
505 $s .= $userJS;
506 }
507
508 wfProfileOut( __METHOD__ );
509 return $s;
510 }
511
512 /**
513 * Generate user stylesheet for action=raw&gen=css
514 */
515 public function generateUserStylesheet() {
516 wfProfileIn( __METHOD__ );
517 $s = "/* generated user stylesheet */\n" .
518 $this->reallyGenerateUserStylesheet();
519 wfProfileOut( __METHOD__ );
520 return $s;
521 }
522
523 /**
524 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
525 */
526 protected function reallyGenerateUserStylesheet(){
527 global $wgUser;
528 $s = '';
529 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
530 $underline = $undopt ? 'underline' : 'none';
531 $s .= "a { text-decoration: $underline; }\n";
532 }
533 if( $wgUser->getOption( 'highlightbroken' ) ) {
534 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
535 } else {
536 $s .= <<<END
537 a.new, #quickbar a.new,
538 a.stub, #quickbar a.stub {
539 color: inherit;
540 }
541 a.new:after, #quickbar a.new:after {
542 content: "?";
543 color: #CC2200;
544 }
545 a.stub:after, #quickbar a.stub:after {
546 content: "!";
547 color: #772233;
548 }
549 END;
550 }
551 if( $wgUser->getOption( 'justify' ) ) {
552 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
553 }
554 if( !$wgUser->getOption( 'showtoc' ) ) {
555 $s .= "#toc { display: none; }\n";
556 }
557 if( !$wgUser->getOption( 'editsection' ) ) {
558 $s .= ".editsection { display: none; }\n";
559 }
560 return $s;
561 }
562
563 /**
564 * @private
565 */
566 function setupUserCss( OutputPage $out ) {
567 global $wgRequest, $wgContLang, $wgUser;
568 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
569
570 wfProfileIn( __METHOD__ );
571
572 $this->setupSkinUserCss( $out );
573
574 $siteargs = array(
575 'action' => 'raw',
576 'maxage' => $wgSquidMaxage,
577 );
578
579 // Add any extension CSS
580 foreach( $out->getExtStyle() as $tag ) {
581 $out->addStyle( $tag['href'] );
582 }
583
584 // If we use the site's dynamic CSS, throw that in, too
585 // Per-site custom styles
586 if( $wgUseSiteCss ) {
587 global $wgHandheldStyle;
588 $query = wfArrayToCGI( array(
589 'usemsgcache' => 'yes',
590 'ctype' => 'text/css',
591 'smaxage' => $wgSquidMaxage
592 ) + $siteargs );
593 # Site settings must override extension css! (bug 15025)
594 $out->addStyle( self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) );
595 $out->addStyle( self::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI ), 'print' );
596 if( $wgHandheldStyle ) {
597 $out->addStyle( self::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI ), 'handheld' );
598 }
599 $out->addStyle( self::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI ) );
600 }
601
602 if( $wgUser->isLoggedIn() ) {
603 // Ensure that logged-in users' generated CSS isn't clobbered
604 // by anons' publicly cacheable generated CSS.
605 $siteargs['smaxage'] = '0';
606 $siteargs['ts'] = $wgUser->mTouched;
607 }
608 // Per-user styles based on preferences
609 $siteargs['gen'] = 'css';
610 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
611 $siteargs['useskin'] = $us;
612 }
613 $out->addStyle( self::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
614
615 // Per-user custom style pages
616 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
617 $action = $wgRequest->getVal( 'action' );
618 # If we're previewing the CSS page, use it
619 if( $this->mTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
620 $previewCss = $wgRequest->getText( 'wpTextbox1' );
621 // @FIXME: properly escape the cdata!
622 $this->usercss = "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
623 } else {
624 $out->addStyle( self::makeUrl( $this->userpage . '/' . $this->getSkinName() .'.css',
625 'action=raw&ctype=text/css' ) );
626 }
627 }
628
629 wfProfileOut( __METHOD__ );
630 }
631
632 /**
633 * Add skin specific stylesheets
634 * @param $out OutputPage
635 */
636 function setupSkinUserCss( OutputPage $out ) {
637 $out->addStyle( 'common/shared.css' );
638 $out->addStyle( 'common/oldshared.css' );
639 $out->addStyle( $this->getStylesheet() );
640 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
641 }
642
643 function getBodyOptions() {
644 global $wgUser, $wgOut, $wgRequest, $wgContLang;
645
646 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
647
648 if ( 0 != $this->mTitle->getNamespace() ) {
649 $a = array( 'bgcolor' => '#ffffec' );
650 }
651 else $a = array( 'bgcolor' => '#FFFFFF' );
652 if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
653 $this->mTitle->quickUserCan( 'edit' ) ) {
654 $s = $this->mTitle->getFullURL( $this->editUrlOptions() );
655 $s = 'document.location = "' .Xml::escapeJsString( $s ) .'";';
656 $a += array( 'ondblclick' => $s );
657 }
658 $a['onload'] = $wgOut->getOnloadHandler();
659 $a['class'] =
660 'mediawiki' .
661 ' '.( $wgContLang->isRTL() ? 'rtl' : 'ltr' ).
662 ' '.$this->getPageClasses( $this->mTitle ) .
663 ' skin-'. Sanitizer::escapeClass( $this->getSkinName() );
664 return $a;
665 }
666
667 function getPageClasses( $title ) {
668 $numeric = 'ns-'.$title->getNamespace();
669 if( $title->getNamespace() == NS_SPECIAL ) {
670 $type = 'ns-special';
671 } elseif( $title->isTalkPage() ) {
672 $type = 'ns-talk';
673 } else {
674 $type = 'ns-subject';
675 }
676 $name = Sanitizer::escapeClass( 'page-'.$title->getPrefixedText() );
677 return "$numeric $type $name";
678 }
679
680 /**
681 * URL to the logo
682 */
683 function getLogo() {
684 global $wgLogo;
685 return $wgLogo;
686 }
687
688 /**
689 * This will be called immediately after the <body> tag. Split into
690 * two functions to make it easier to subclass.
691 */
692 function beforeContent() {
693 return $this->doBeforeContent();
694 }
695
696 function doBeforeContent() {
697 global $wgContLang;
698 wfProfileIn( __METHOD__ );
699
700 $s = '';
701 $qb = $this->qbSetting();
702
703 if( $langlinks = $this->otherLanguages() ) {
704 $rows = 2;
705 $borderhack = '';
706 } else {
707 $rows = 1;
708 $langlinks = false;
709 $borderhack = 'class="top"';
710 }
711
712 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
713 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
714
715 $shove = ( $qb != 0 );
716 $left = ( $qb == 1 || $qb == 3 );
717 if( $wgContLang->isRTL() ) $left = !$left;
718
719 if( !$shove ) {
720 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
721 $this->logoText() . '</td>';
722 } elseif( $left ) {
723 $s .= $this->getQuickbarCompensator( $rows );
724 }
725 $l = $wgContLang->isRTL() ? 'right' : 'left';
726 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
727
728 $s .= $this->topLinks();
729 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
730
731 $r = $wgContLang->isRTL() ? 'left' : 'right';
732 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
733 $s .= $this->nameAndLogin();
734 $s .= "\n<br />" . $this->searchForm() . "</td>";
735
736 if ( $langlinks ) {
737 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
738 }
739
740 if ( $shove && !$left ) { # Right
741 $s .= $this->getQuickbarCompensator( $rows );
742 }
743 $s .= "</tr>\n</table>\n</div>\n";
744 $s .= "\n<div id='article'>\n";
745
746 $notice = wfGetSiteNotice();
747 if( $notice ) {
748 $s .= "\n<div id='siteNotice'>$notice</div>\n";
749 }
750 $s .= $this->pageTitle();
751 $s .= $this->pageSubtitle();
752 $s .= $this->getCategories();
753 wfProfileOut( __METHOD__ );
754 return $s;
755 }
756
757
758 function getCategoryLinks() {
759 global $wgOut, $wgUseCategoryBrowser;
760 global $wgContLang, $wgUser;
761
762 if( count( $wgOut->mCategoryLinks ) == 0 ) return '';
763
764 # Separator
765 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
766
767 // Use Unicode bidi embedding override characters,
768 // to make sure links don't smash each other up in ugly ways.
769 $dir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
770 $embed = "<span dir='$dir'>";
771 $pop = '</span>';
772
773 $allCats = $wgOut->getCategoryLinks();
774 $s = '';
775 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
776 if ( !empty( $allCats['normal'] ) ) {
777 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
778
779 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
780 $s .= '<div id="mw-normal-catlinks">' .
781 $this->link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
782 . $colon . $t . '</div>';
783 }
784
785 # Hidden categories
786 if ( isset( $allCats['hidden'] ) ) {
787 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
788 $class ='mw-hidden-cats-user-shown';
789 } elseif ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
790 $class = 'mw-hidden-cats-ns-shown';
791 } else {
792 $class = 'mw-hidden-cats-hidden';
793 }
794 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
795 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
796 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
797 "</div>";
798 }
799
800 # optional 'dmoz-like' category browser. Will be shown under the list
801 # of categories an article belong to
802 if( $wgUseCategoryBrowser ){
803 $s .= '<br /><hr />';
804
805 # get a big array of the parents tree
806 $parenttree = $this->mTitle->getParentCategoryTree();
807 # Skin object passed by reference cause it can not be
808 # accessed under the method subfunction drawCategoryBrowser
809 $tempout = explode( "\n", Skin::drawCategoryBrowser( $parenttree, $this ) );
810 # Clean out bogus first entry and sort them
811 unset( $tempout[0] );
812 asort( $tempout );
813 # Output one per line
814 $s .= implode( "<br />\n", $tempout );
815 }
816
817 return $s;
818 }
819
820 /**
821 * Render the array as a serie of links.
822 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
823 * @param &skin Object: skin passed by reference
824 * @return String separated by &gt;, terminate with "\n"
825 */
826 function drawCategoryBrowser( $tree, &$skin ){
827 $return = '';
828 foreach( $tree as $element => $parent ) {
829 if( empty( $parent ) ) {
830 # element start a new list
831 $return .= "\n";
832 } else {
833 # grab the others elements
834 $return .= Skin::drawCategoryBrowser( $parent, $skin ) . ' &gt; ';
835 }
836 # add our current element to the list
837 $eltitle = Title::newFromText( $element );
838 $return .= $skin->link( $eltitle, $eltitle->getText() );
839 }
840 return $return;
841 }
842
843 function getCategories() {
844 $catlinks=$this->getCategoryLinks();
845
846 $classes = 'catlinks';
847
848 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
849 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
850 $classes .= ' catlinks-allhidden';
851 }
852
853 if( !empty( $catlinks ) ){
854 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
855 }
856 }
857
858 function getQuickbarCompensator( $rows = 1 ) {
859 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
860 }
861
862 /**
863 * This runs a hook to allow extensions placing their stuff after content
864 * and article metadata (e.g. categories).
865 * Note: This function has nothing to do with afterContent().
866 *
867 * This hook is placed here in order to allow using the same hook for all
868 * skins, both the SkinTemplate based ones and the older ones, which directly
869 * use this class to get their data.
870 *
871 * The output of this function gets processed in SkinTemplate::outputPage() for
872 * the SkinTemplate based skins, all other skins should directly echo it.
873 *
874 * Returns an empty string by default, if not changed by any hook function.
875 */
876 protected function afterContentHook() {
877 $data = '';
878
879 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
880 // adding just some spaces shouldn't toggle the output
881 // of the whole <div/>, so we use trim() here
882 if( trim( $data ) != '' ){
883 // Doing this here instead of in the skins to
884 // ensure that the div has the same ID in all
885 // skins
886 $data = "<div id='mw-data-after-content'>\n" .
887 "\t$data\n" .
888 "</div>\n";
889 }
890 } else {
891 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
892 }
893
894 return $data;
895 }
896
897 /**
898 * Generate debug data HTML for displaying at the bottom of the main content
899 * area.
900 * @return String HTML containing debug data, if enabled (otherwise empty).
901 */
902 protected function generateDebugHTML() {
903 global $wgShowDebug, $wgOut;
904 if ( $wgShowDebug ) {
905 $listInternals = str_replace( "\n", "</li>\n<li>", htmlspecialchars( $wgOut->mDebugtext ) );
906 return "\n<hr>\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\"><li>" .
907 $listInternals . "</li></ul>\n";
908 }
909 return '';
910 }
911
912 /**
913 * This gets called shortly before the </body> tag.
914 * @return String HTML to be put before </body>
915 */
916 function afterContent() {
917 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
918 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
919 }
920
921 /**
922 * This gets called shortly before the </body> tag.
923 * @return String HTML-wrapped JS code to be put before </body>
924 */
925 function bottomScripts() {
926 global $wgJsMimeType;
927 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
928 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
929 return $bottomScriptText;
930 }
931
932 /** @return string Retrievied from HTML text */
933 function printSource() {
934 $url = htmlspecialchars( $this->mTitle->getFullURL() );
935 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
936 }
937
938 function printFooter() {
939 return "<p>" . $this->printSource() .
940 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
941 }
942
943 /** overloaded by derived classes */
944 function doAfterContent() { return '</div></div>'; }
945
946 function pageTitleLinks() {
947 global $wgOut, $wgUser, $wgRequest, $wgLang;
948
949 $oldid = $wgRequest->getVal( 'oldid' );
950 $diff = $wgRequest->getVal( 'diff' );
951 $action = $wgRequest->getText( 'action' );
952
953 $s[] = $this->printableLink();
954 $disclaimer = $this->disclaimerLink(); # may be empty
955 if( $disclaimer ) {
956 $s[] = $disclaimer;
957 }
958 $privacy = $this->privacyLink(); # may be empty too
959 if( $privacy ) {
960 $s[] = $privacy;
961 }
962
963 if ( $wgOut->isArticleRelated() ) {
964 if ( $this->mTitle->getNamespace() == NS_FILE ) {
965 $name = $this->mTitle->getDBkey();
966 $image = wfFindFile( $this->mTitle );
967 if( $image ) {
968 $link = htmlspecialchars( $image->getURL() );
969 $style = $this->getInternalLinkAttributes( $link, $name );
970 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
971 }
972 }
973 }
974 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
975 $s[] .= $this->makeKnownLinkObj( $this->mTitle,
976 wfMsg( 'currentrev' ) );
977 }
978
979 if ( $wgUser->getNewtalk() ) {
980 # do not show "You have new messages" text when we are viewing our
981 # own talk page
982 if( !$this->mTitle->equals( $wgUser->getTalkPage() ) ) {
983 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
984 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
985 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
986 # disable caching
987 $wgOut->setSquidMaxage( 0 );
988 $wgOut->enableClientCache( false );
989 }
990 }
991
992 $undelete = $this->getUndeleteLink();
993 if( !empty( $undelete ) ) {
994 $s[] = $undelete;
995 }
996 return $wgLang->pipeList( $s );
997 }
998
999 function getUndeleteLink() {
1000 global $wgUser, $wgContLang, $wgLang, $action;
1001 if( $wgUser->isAllowed( 'deletedhistory' ) &&
1002 ( ( $this->mTitle->getArticleId() == 0 ) || ( $action == 'history' ) ) &&
1003 ( $n = $this->mTitle->isDeleted() ) ){
1004 if ( $wgUser->isAllowed( 'undelete' ) ) {
1005 $msg = 'thisisdeleted';
1006 } else {
1007 $msg = 'viewdeleted';
1008 }
1009 return wfMsg( $msg,
1010 $this->makeKnownLinkObj(
1011 SpecialPage::getTitleFor( 'Undelete', $this->mTitle->getPrefixedDBkey() ),
1012 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
1013 }
1014 return '';
1015 }
1016
1017 function printableLink() {
1018 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1019
1020 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1021
1022 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1023 if( $wgOut->isSyndicated() ) {
1024 foreach( $wgFeedClasses as $format => $class ) {
1025 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1026 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1027 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1028 }
1029 }
1030 return $wgLang->pipeList( $s );
1031 }
1032
1033 function pageTitle() {
1034 global $wgOut;
1035 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1036 return $s;
1037 }
1038
1039 function pageSubtitle() {
1040 global $wgOut;
1041
1042 $sub = $wgOut->getSubtitle();
1043 if ( '' == $sub ) {
1044 global $wgExtraSubtitle;
1045 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1046 }
1047 $subpages = $this->subPageSubtitle();
1048 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
1049 $s = "<p class='subtitle'>{$sub}</p>\n";
1050 return $s;
1051 }
1052
1053 function subPageSubtitle() {
1054 $subpages = '';
1055 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
1056 return $subpages;
1057
1058 global $wgOut;
1059 if( $wgOut->isArticle() && MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) {
1060 $ptext = $this->mTitle->getPrefixedText();
1061 if( preg_match( '/\//', $ptext ) ) {
1062 $links = explode( '/', $ptext );
1063 array_pop( $links );
1064 $c = 0;
1065 $growinglink = '';
1066 $display = '';
1067 foreach( $links as $link ) {
1068 $growinglink .= $link;
1069 $display .= $link;
1070 $linkObj = Title::newFromText( $growinglink );
1071 if( is_object( $linkObj ) && $linkObj->exists() ){
1072 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
1073 $c++;
1074 if( $c > 1 ) {
1075 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1076 } else {
1077 $subpages .= '&lt; ';
1078 }
1079 $subpages .= $getlink;
1080 $display = '';
1081 } else {
1082 $display .= '/';
1083 }
1084 $growinglink .= '/';
1085 }
1086 }
1087 }
1088 return $subpages;
1089 }
1090
1091 /**
1092 * Returns true if the IP should be shown in the header
1093 */
1094 function showIPinHeader() {
1095 global $wgShowIPinHeader;
1096 return $wgShowIPinHeader && session_id() != '';
1097 }
1098
1099 function nameAndLogin() {
1100 global $wgUser, $wgLang, $wgContLang;
1101
1102 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1103
1104 $ret = '';
1105 if ( $wgUser->isAnon() ) {
1106 if( $this->showIPinHeader() ) {
1107 $name = wfGetIP();
1108
1109 $talkLink = $this->link( $wgUser->getTalkPage(),
1110 $wgLang->getNsText( NS_TALK ) );
1111
1112 $ret .= "$name ($talkLink)";
1113 } else {
1114 $ret .= wfMsg( 'notloggedin' );
1115 }
1116
1117 $returnTo = $this->mTitle->getPrefixedDBkey();
1118 $query = array();
1119 if ( $logoutPage != $returnTo ) {
1120 $query['returnto'] = $returnTo;
1121 }
1122
1123 $loginlink = $wgUser->isAllowed( 'createaccount' )
1124 ? 'nav-login-createaccount'
1125 : 'login';
1126 $ret .= "\n<br />" . $this->link(
1127 SpecialPage::getTitleFor( 'Userlogin' ),
1128 wfMsg( $loginlink ), array(), $query
1129 );
1130 } else {
1131 $returnTo = $this->mTitle->getPrefixedDBkey();
1132 $talkLink = $this->link( $wgUser->getTalkPage(),
1133 $wgLang->getNsText( NS_TALK ) );
1134
1135 $ret .= $this->link( $wgUser->getUserPage(),
1136 htmlspecialchars( $wgUser->getName() ) );
1137 $ret .= " ($talkLink)<br />";
1138 $ret .= $wgLang->pipeList( array(
1139 $this->link(
1140 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1141 array(), array( 'returnto' => $returnTo )
1142 ),
1143 $this->specialLink( 'preferences' ),
1144 ) );
1145 }
1146 $ret = $wgLang->pipeList( array(
1147 $ret,
1148 $this->link(
1149 Title::newFromText( wfMsgForContent( 'helppage' ) ),
1150 wfMsg( 'help' )
1151 ),
1152 ) );
1153
1154 return $ret;
1155 }
1156
1157 function getSearchLink() {
1158 $searchPage = SpecialPage::getTitleFor( 'Search' );
1159 return $searchPage->getLocalURL();
1160 }
1161
1162 function escapeSearchLink() {
1163 return htmlspecialchars( $this->getSearchLink() );
1164 }
1165
1166 function searchForm() {
1167 global $wgRequest, $wgUseTwoButtonsSearchForm;
1168 $search = $wgRequest->getText( 'search' );
1169
1170 $s = '<form id="searchform'.$this->searchboxes.'" name="search" class="inline" method="post" action="'
1171 . $this->escapeSearchLink() . "\">\n"
1172 . '<input type="text" id="searchInput'.$this->searchboxes.'" name="search" size="19" value="'
1173 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1174 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1175
1176 if( $wgUseTwoButtonsSearchForm )
1177 $s .= '&nbsp;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1178 else
1179 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1180
1181 $s .= '</form>';
1182
1183 // Ensure unique id's for search boxes made after the first
1184 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
1185
1186 return $s;
1187 }
1188
1189 function topLinks() {
1190 global $wgOut;
1191
1192 $s = array(
1193 $this->mainPageLink(),
1194 $this->specialLink( 'recentchanges' )
1195 );
1196
1197 if ( $wgOut->isArticleRelated() ) {
1198 $s[] = $this->editThisPage();
1199 $s[] = $this->historyLink();
1200 }
1201 # Many people don't like this dropdown box
1202 #$s[] = $this->specialPagesList();
1203
1204 if( $this->variantLinks() ) {
1205 $s[] = $this->variantLinks();
1206 }
1207
1208 if( $this->extensionTabLinks() ) {
1209 $s[] = $this->extensionTabLinks();
1210 }
1211
1212 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1213 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1214 }
1215
1216 /**
1217 * Compatibility for extensions adding functionality through tabs.
1218 * Eventually these old skins should be replaced with SkinTemplate-based
1219 * versions, sigh...
1220 * @return string
1221 */
1222 function extensionTabLinks() {
1223 $tabs = array();
1224 $out = '';
1225 $s = array();
1226 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1227 foreach( $tabs as $tab ) {
1228 $s[] = Xml::element( 'a',
1229 array( 'href' => $tab['href'] ),
1230 $tab['text'] );
1231 }
1232
1233 if( count( $s ) ) {
1234 global $wgLang;
1235
1236 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1237 $out .= $wgLang->pipeList( $s );
1238 }
1239
1240 return $out;
1241 }
1242
1243 /**
1244 * Language/charset variant links for classic-style skins
1245 * @return string
1246 */
1247 function variantLinks() {
1248 $s = '';
1249 /* show links to different language variants */
1250 global $wgDisableLangConversion, $wgLang, $wgContLang;
1251 $variants = $wgContLang->getVariants();
1252 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1253 foreach( $variants as $code ) {
1254 $varname = $wgContLang->getVariantname( $code );
1255 if( $varname == 'disable' )
1256 continue;
1257 $s = $wgLang->pipeList( array(
1258 $s,
1259 '<a href="' . $this->mTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1260 ) );
1261 }
1262 }
1263 return $s;
1264 }
1265
1266 function bottomLinks() {
1267 global $wgOut, $wgUser, $wgUseTrackbacks;
1268 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1269
1270 $s = '';
1271 if ( $wgOut->isArticleRelated() ) {
1272 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1273 if ( $wgUser->isLoggedIn() ) {
1274 $element[] = $this->watchThisPage();
1275 }
1276 $element[] = $this->talkLink();
1277 $element[] = $this->historyLink();
1278 $element[] = $this->whatLinksHere();
1279 $element[] = $this->watchPageLinksLink();
1280
1281 if( $wgUseTrackbacks )
1282 $element[] = $this->trackbackLink();
1283
1284 if ( $this->mTitle->getNamespace() == NS_USER
1285 || $this->mTitle->getNamespace() == NS_USER_TALK ){
1286 $id = User::idFromName( $this->mTitle->getText() );
1287 $ip = User::isIP( $this->mTitle->getText() );
1288
1289 if( $id || $ip ) { # both anons and non-anons have contri list
1290 $element[] = $this->userContribsLink();
1291 }
1292 if( $this->showEmailUser( $id ) ) {
1293 $element[] = $this->emailUserLink();
1294 }
1295 }
1296
1297 $s = implode( $element, $sep );
1298
1299 if ( $this->mTitle->getArticleId() ) {
1300 $s .= "\n<br />";
1301 if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1302 if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1303 if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
1304 }
1305 $s .= "<br />\n" . $this->otherLanguages();
1306 }
1307
1308 return $s;
1309 }
1310
1311 function pageStats() {
1312 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1313 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1314
1315 $oldid = $wgRequest->getVal( 'oldid' );
1316 $diff = $wgRequest->getVal( 'diff' );
1317 if ( ! $wgOut->isArticle() ) { return ''; }
1318 if( !$wgArticle instanceOf Article ) { return ''; }
1319 if ( isset( $oldid ) || isset( $diff ) ) { return ''; }
1320 if ( 0 == $wgArticle->getID() ) { return ''; }
1321
1322 $s = '';
1323 if ( !$wgDisableCounters ) {
1324 $count = $wgLang->formatNum( $wgArticle->getCount() );
1325 if ( $count ) {
1326 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1327 }
1328 }
1329
1330 if( $wgMaxCredits != 0 ){
1331 $s .= ' ' . Credits::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1332 } else {
1333 $s .= $this->lastModified();
1334 }
1335
1336 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1337 $dbr = wfGetDB( DB_SLAVE );
1338 $res = $dbr->select( 'watchlist',
1339 array( 'COUNT(*) AS n' ),
1340 array( 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ), 'wl_namespace' => $this->mTitle->getNamespace() ),
1341 __METHOD__
1342 );
1343 $x = $dbr->fetchObject( $res );
1344
1345 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1346 array( 'parseinline' ), $wgLang->formatNum( $x->n )
1347 );
1348 }
1349
1350 return $s . ' ' . $this->getCopyright();
1351 }
1352
1353 function getCopyright( $type = 'detect' ) {
1354 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1355
1356 if ( $type == 'detect' ) {
1357 $diff = $wgRequest->getVal( 'diff' );
1358 $isCur = $wgArticle && $wgArticle->isCurrent();
1359 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1360 $type = 'history';
1361 } else {
1362 $type = 'normal';
1363 }
1364 }
1365
1366 if ( $type == 'history' ) {
1367 $msg = 'history_copyright';
1368 } else {
1369 $msg = 'copyright';
1370 }
1371
1372 $out = '';
1373 if( $wgRightsPage ) {
1374 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1375 } elseif( $wgRightsUrl ) {
1376 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1377 } elseif( $wgRightsText ) {
1378 $link = $wgRightsText;
1379 } else {
1380 # Give up now
1381 return $out;
1382 }
1383 $out .= wfMsgForContent( $msg, $link );
1384 return $out;
1385 }
1386
1387 function getCopyrightIcon() {
1388 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1389 $out = '';
1390 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1391 $out = $wgCopyrightIcon;
1392 } else if ( $wgRightsIcon ) {
1393 $icon = htmlspecialchars( $wgRightsIcon );
1394 if ( $wgRightsUrl ) {
1395 $url = htmlspecialchars( $wgRightsUrl );
1396 $out .= '<a href="'.$url.'">';
1397 }
1398 $text = htmlspecialchars( $wgRightsText );
1399 $out .= "<img src=\"$icon\" alt='$text' />";
1400 if ( $wgRightsUrl ) {
1401 $out .= '</a>';
1402 }
1403 }
1404 return $out;
1405 }
1406
1407 function getPoweredBy() {
1408 global $wgStylePath;
1409 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1410 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1411 return $img;
1412 }
1413
1414 function lastModified() {
1415 global $wgLang, $wgArticle;
1416 if( $this->mRevisionId ) {
1417 $timestamp = Revision::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId );
1418 } else {
1419 $timestamp = $wgArticle->getTimestamp();
1420 }
1421 if ( $timestamp ) {
1422 $d = $wgLang->date( $timestamp, true );
1423 $t = $wgLang->time( $timestamp, true );
1424 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1425 } else {
1426 $s = '';
1427 }
1428 if ( wfGetLB()->getLaggedSlaveMode() ) {
1429 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1430 }
1431 return $s;
1432 }
1433
1434 function logoText( $align = '' ) {
1435 if ( '' != $align ) {
1436 $a = " align='{$align}'";
1437 } else {
1438 $a = '';
1439 }
1440
1441 $mp = wfMsg( 'mainpage' );
1442 $mptitle = Title::newMainPage();
1443 $url = ( is_object( $mptitle ) ? $mptitle->escapeLocalURL() : '' );
1444
1445 $logourl = $this->getLogo();
1446 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1447 return $s;
1448 }
1449
1450 /**
1451 * show a drop-down box of special pages
1452 */
1453 function specialPagesList() {
1454 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1455 $pages = array_merge( SpecialPage::getRegularPages(), SpecialPage::getRestrictedPages() );
1456 foreach ( $pages as $name => $page ) {
1457 $pages[$name] = $page->getDescription();
1458 }
1459
1460 $go = wfMsg( 'go' );
1461 $sp = wfMsg( 'specialpages' );
1462 $spp = $wgContLang->specialPage( 'Specialpages' );
1463
1464 $s = '<form id="specialpages" method="get" ' .
1465 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1466 $s .= "<select name=\"wpDropdown\">\n";
1467 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1468
1469
1470 foreach ( $pages as $name => $desc ) {
1471 $p = $wgContLang->specialPage( $name );
1472 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1473 }
1474 $s .= "</select>\n";
1475 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1476 $s .= "</form>\n";
1477 return $s;
1478 }
1479
1480 function mainPageLink() {
1481 $s = $this->makeKnownLinkObj( Title::newMainPage(), wfMsg( 'mainpage' ) );
1482 return $s;
1483 }
1484
1485 function copyrightLink() {
1486 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1487 wfMsg( 'copyrightpagename' ) );
1488 return $s;
1489 }
1490
1491 private function footerLink ( $desc, $page ) {
1492 // if the link description has been set to "-" in the default language,
1493 if ( wfMsgForContent( $desc ) == '-') {
1494 // then it is disabled, for all languages.
1495 return '';
1496 } else {
1497 // Otherwise, we display the link for the user, described in their
1498 // language (which may or may not be the same as the default language),
1499 // but we make the link target be the one site-wide page.
1500 return $this->makeKnownLink( wfMsgForContent( $page ),
1501 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1502 }
1503 }
1504
1505 function privacyLink() {
1506 return $this->footerLink( 'privacy', 'privacypage' );
1507 }
1508
1509 function aboutLink() {
1510 return $this->footerLink( 'aboutsite', 'aboutpage' );
1511 }
1512
1513 function disclaimerLink() {
1514 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1515 }
1516
1517 function editThisPage() {
1518 global $wgOut;
1519
1520 if ( !$wgOut->isArticleRelated() ) {
1521 $s = wfMsg( 'protectedpage' );
1522 } else {
1523 if( $this->mTitle->quickUserCan( 'edit' ) && $this->mTitle->exists() ) {
1524 $t = wfMsg( 'editthispage' );
1525 } elseif( $this->mTitle->quickUserCan( 'create' ) && !$this->mTitle->exists() ) {
1526 $t = wfMsg( 'create-this-page' );
1527 } else {
1528 $t = wfMsg( 'viewsource' );
1529 }
1530
1531 $s = $this->makeKnownLinkObj( $this->mTitle, $t, $this->editUrlOptions() );
1532 }
1533 return $s;
1534 }
1535
1536 /**
1537 * Return URL options for the 'edit page' link.
1538 * This may include an 'oldid' specifier, if the current page view is such.
1539 *
1540 * @return string
1541 * @private
1542 */
1543 function editUrlOptions() {
1544 global $wgArticle;
1545
1546 if( $this->mRevisionId && ! $wgArticle->isCurrent() ) {
1547 return 'action=edit&oldid=' . intval( $this->mRevisionId );
1548 } else {
1549 return 'action=edit';
1550 }
1551 }
1552
1553 function deleteThisPage() {
1554 global $wgUser, $wgRequest;
1555
1556 $diff = $wgRequest->getVal( 'diff' );
1557 if ( $this->mTitle->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1558 $t = wfMsg( 'deletethispage' );
1559
1560 $s = $this->makeKnownLinkObj( $this->mTitle, $t, 'action=delete' );
1561 } else {
1562 $s = '';
1563 }
1564 return $s;
1565 }
1566
1567 function protectThisPage() {
1568 global $wgUser, $wgRequest;
1569
1570 $diff = $wgRequest->getVal( 'diff' );
1571 if ( $this->mTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1572 if ( $this->mTitle->isProtected() ) {
1573 $t = wfMsg( 'unprotectthispage' );
1574 $q = 'action=unprotect';
1575 } else {
1576 $t = wfMsg( 'protectthispage' );
1577 $q = 'action=protect';
1578 }
1579 $s = $this->makeKnownLinkObj( $this->mTitle, $t, $q );
1580 } else {
1581 $s = '';
1582 }
1583 return $s;
1584 }
1585
1586 function watchThisPage() {
1587 global $wgOut;
1588 ++$this->mWatchLinkNum;
1589
1590 if ( $wgOut->isArticleRelated() ) {
1591 if ( $this->mTitle->userIsWatching() ) {
1592 $t = wfMsg( 'unwatchthispage' );
1593 $q = 'action=unwatch';
1594 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
1595 } else {
1596 $t = wfMsg( 'watchthispage' );
1597 $q = 'action=watch';
1598 $id = 'mw-watch-link' . $this->mWatchLinkNum;
1599 }
1600 $s = $this->makeKnownLinkObj( $this->mTitle, $t, $q, '', '', " id=\"$id\"" );
1601 } else {
1602 $s = wfMsg( 'notanarticle' );
1603 }
1604 return $s;
1605 }
1606
1607 function moveThisPage() {
1608 if ( $this->mTitle->quickUserCan( 'move' ) ) {
1609 return $this->makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ),
1610 wfMsg( 'movethispage' ), 'target=' . $this->mTitle->getPrefixedURL() );
1611 } else {
1612 // no message if page is protected - would be redundant
1613 return '';
1614 }
1615 }
1616
1617 function historyLink() {
1618 return $this->link( $this->mTitle, wfMsg( 'history' ),
1619 array( 'rel' => 'archives' ), array( 'action' => 'history' ) );
1620 }
1621
1622 function whatLinksHere() {
1623 return $this->makeKnownLinkObj(
1624 SpecialPage::getTitleFor( 'Whatlinkshere', $this->mTitle->getPrefixedDBkey() ),
1625 wfMsg( 'whatlinkshere' ) );
1626 }
1627
1628 function userContribsLink() {
1629 return $this->makeKnownLinkObj(
1630 SpecialPage::getTitleFor( 'Contributions', $this->mTitle->getDBkey() ),
1631 wfMsg( 'contributions' ) );
1632 }
1633
1634 function showEmailUser( $id ) {
1635 global $wgUser;
1636 $targetUser = User::newFromId( $id );
1637 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1638 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1639 }
1640
1641 function emailUserLink() {
1642 return $this->makeKnownLinkObj(
1643 SpecialPage::getTitleFor( 'Emailuser', $this->mTitle->getDBkey() ),
1644 wfMsg( 'emailuser' ) );
1645 }
1646
1647 function watchPageLinksLink() {
1648 global $wgOut;
1649 if ( ! $wgOut->isArticleRelated() ) {
1650 return '(' . wfMsg( 'notanarticle' ) . ')';
1651 } else {
1652 return $this->makeKnownLinkObj(
1653 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->mTitle->getPrefixedDBkey() ),
1654 wfMsg( 'recentchangeslinked' ) );
1655 }
1656 }
1657
1658 function trackbackLink() {
1659 return '<a href="' . $this->mTitle->trackbackURL() . '">'
1660 . wfMsg( 'trackbacklink' ) . '</a>';
1661 }
1662
1663 function otherLanguages() {
1664 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1665
1666 if ( $wgHideInterlanguageLinks ) {
1667 return '';
1668 }
1669
1670 $a = $wgOut->getLanguageLinks();
1671 if ( 0 == count( $a ) ) {
1672 return '';
1673 }
1674
1675 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1676 $first = true;
1677 if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
1678 foreach( $a as $l ) {
1679 if ( !$first ) {
1680 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1681 }
1682 $first = false;
1683
1684 $nt = Title::newFromText( $l );
1685 $url = $nt->escapeFullURL();
1686 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1687
1688 if ( '' == $text ) { $text = $l; }
1689 $style = $this->getExternalLinkAttributes( $l, $text );
1690 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1691 }
1692 if( $wgContLang->isRTL() ) $s .= '</span>';
1693 return $s;
1694 }
1695
1696 function talkLink() {
1697 if ( NS_SPECIAL == $this->mTitle->getNamespace() ) {
1698 # No discussion links for special pages
1699 return '';
1700 }
1701
1702 $linkOptions = array();
1703
1704 if( $this->mTitle->isTalkPage() ) {
1705 $link = $this->mTitle->getSubjectPage();
1706 switch( $link->getNamespace() ) {
1707 case NS_MAIN:
1708 $text = wfMsg( 'articlepage' );
1709 break;
1710 case NS_USER:
1711 $text = wfMsg( 'userpage' );
1712 break;
1713 case NS_PROJECT:
1714 $text = wfMsg( 'projectpage' );
1715 break;
1716 case NS_FILE:
1717 $text = wfMsg( 'imagepage' );
1718 # Make link known if image exists, even if the desc. page doesn't.
1719 if( wfFindFile( $link ) )
1720 $linkOptions[] = 'known';
1721 break;
1722 case NS_MEDIAWIKI:
1723 $text = wfMsg( 'mediawikipage' );
1724 break;
1725 case NS_TEMPLATE:
1726 $text = wfMsg( 'templatepage' );
1727 break;
1728 case NS_HELP:
1729 $text = wfMsg( 'viewhelppage' );
1730 break;
1731 case NS_CATEGORY:
1732 $text = wfMsg( 'categorypage' );
1733 break;
1734 default:
1735 $text = wfMsg( 'articlepage' );
1736 }
1737 } else {
1738 $link = $this->mTitle->getTalkPage();
1739 $text = wfMsg( 'talkpage' );
1740 }
1741
1742 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1743
1744 return $s;
1745 }
1746
1747 function commentLink() {
1748 global $wgOut;
1749
1750 if ( $this->mTitle->getNamespace() == NS_SPECIAL ) {
1751 return '';
1752 }
1753
1754 # __NEWSECTIONLINK___ changes behaviour here
1755 # If it's present, the link points to this page, otherwise
1756 # it points to the talk page
1757 if( $this->mTitle->isTalkPage() ) {
1758 $title = $this->mTitle;
1759 } elseif( $wgOut->showNewSectionLink() ) {
1760 $title = $this->mTitle;
1761 } else {
1762 $title = $this->mTitle->getTalkPage();
1763 }
1764
1765 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit&section=new' );
1766 }
1767
1768 /* these are used extensively in SkinTemplate, but also some other places */
1769 static function makeMainPageUrl( $urlaction = '' ) {
1770 $title = Title::newMainPage();
1771 self::checkTitle( $title, '' );
1772 return $title->getLocalURL( $urlaction );
1773 }
1774
1775 static function makeSpecialUrl( $name, $urlaction = '' ) {
1776 $title = SpecialPage::getTitleFor( $name );
1777 return $title->getLocalURL( $urlaction );
1778 }
1779
1780 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1781 $title = SpecialPage::getSafeTitleFor( $name, $subpage );
1782 return $title->getLocalURL( $urlaction );
1783 }
1784
1785 static function makeI18nUrl( $name, $urlaction = '' ) {
1786 $title = Title::newFromText( wfMsgForContent( $name ) );
1787 self::checkTitle( $title, $name );
1788 return $title->getLocalURL( $urlaction );
1789 }
1790
1791 static function makeUrl( $name, $urlaction = '' ) {
1792 $title = Title::newFromText( $name );
1793 self::checkTitle( $title, $name );
1794 return $title->getLocalURL( $urlaction );
1795 }
1796
1797 # If url string starts with http, consider as external URL, else
1798 # internal
1799 static function makeInternalOrExternalUrl( $name ) {
1800 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1801 return $name;
1802 } else {
1803 return self::makeUrl( $name );
1804 }
1805 }
1806
1807 # this can be passed the NS number as defined in Language.php
1808 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
1809 $title = Title::makeTitleSafe( $namespace, $name );
1810 self::checkTitle( $title, $name );
1811 return $title->getLocalURL( $urlaction );
1812 }
1813
1814 /* these return an array with the 'href' and boolean 'exists' */
1815 static function makeUrlDetails( $name, $urlaction = '' ) {
1816 $title = Title::newFromText( $name );
1817 self::checkTitle( $title, $name );
1818 return array(
1819 'href' => $title->getLocalURL( $urlaction ),
1820 'exists' => $title->getArticleID() != 0 ? true : false
1821 );
1822 }
1823
1824 /**
1825 * Make URL details where the article exists (or at least it's convenient to think so)
1826 */
1827 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1828 $title = Title::newFromText( $name );
1829 self::checkTitle( $title, $name );
1830 return array(
1831 'href' => $title->getLocalURL( $urlaction ),
1832 'exists' => true
1833 );
1834 }
1835
1836 # make sure we have some title to operate on
1837 static function checkTitle( &$title, $name ) {
1838 if( !is_object( $title ) ) {
1839 $title = Title::newFromText( $name );
1840 if( !is_object( $title ) ) {
1841 $title = Title::newFromText( '--error: link target missing--' );
1842 }
1843 }
1844 }
1845
1846 /**
1847 * Build an array that represents the sidebar(s), the navigation bar among them
1848 *
1849 * @return array
1850 */
1851 function buildSidebar() {
1852 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1853 global $wgLang;
1854 wfProfileIn( __METHOD__ );
1855
1856 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
1857
1858 if ( $wgEnableSidebarCache ) {
1859 $cachedsidebar = $parserMemc->get( $key );
1860 if ( $cachedsidebar ) {
1861 wfProfileOut( __METHOD__ );
1862 return $cachedsidebar;
1863 }
1864 }
1865
1866 $bar = array();
1867 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1868 $heading = '';
1869 foreach( $lines as $line ) {
1870 if( strpos( $line, '*' ) !== 0 )
1871 continue;
1872 if( strpos( $line, '**') !== 0 ) {
1873 $heading = trim( $line, '* ' );
1874 if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
1875 } else {
1876 if( strpos( $line, '|' ) !== false ) { // sanity check
1877 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
1878 $link = wfMsgForContent( $line[0] );
1879 if( $link == '-' )
1880 continue;
1881
1882 $text = wfMsgExt( $line[1], 'parsemag' );
1883 if( wfEmptyMsg( $line[1], $text ) )
1884 $text = $line[1];
1885 if( wfEmptyMsg( $line[0], $link ) )
1886 $link = $line[0];
1887
1888 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1889 $href = $link;
1890 } else {
1891 $title = Title::newFromText( $link );
1892 if ( $title ) {
1893 $title = $title->fixSpecialName();
1894 $href = $title->getLocalURL();
1895 } else {
1896 $href = 'INVALID-TITLE';
1897 }
1898 }
1899
1900 $bar[$heading][] = array(
1901 'text' => $text,
1902 'href' => $href,
1903 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
1904 'active' => false
1905 );
1906 } else { continue; }
1907 }
1908 }
1909 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
1910 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1911 wfProfileOut( __METHOD__ );
1912 return $bar;
1913 }
1914 }