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