Remove stupid id that makes clean merges impossible and doesn't help anyone
[lhc/web/wiklou.git] / skins / disabled / MonoBookCBT.php
1 <?php
2
3 if ( !defined( 'MEDIAWIKI' ) ) {
4 die( "This file is part of MediaWiki, it is not a valid entry point\n" );
5 }
6
7 require_once( 'includes/cbt/CBTProcessor.php' );
8 require_once( 'includes/cbt/CBTCompiler.php' );
9 require_once( 'includes/SkinTemplate.php' );
10
11 /**
12 * MonoBook clone using the new dependency-tracking template processor.
13 * EXPERIMENTAL - use only for testing and profiling at this stage.
14 *
15 * See includes/cbt/README for an explanation.
16 *
17 * The main thing that's missing is cache invalidation, on change of:
18 * * messages
19 * * user preferences
20 * * source template
21 * * source code and configuration files
22 *
23 * The other thing is that lots of dependencies that are declared in the callbacks
24 * are not intelligently handled. There's some room for improvement there.
25 *
26 * The class is derived from SkinTemplate, but that's only temporary. Eventually
27 * it'll be derived from Skin, and I've avoided using SkinTemplate functions as
28 * much as possible. In fact, the only SkinTemplate dependencies I know of at the
29 * moment are the functions to generate the gen=css and gen=js files.
30 *
31 */
32 class SkinMonoBookCBT extends SkinTemplate {
33 var $mOut, $mTitle;
34 var $mStyleName = 'monobook';
35 var $mCompiling = false;
36 var $mFunctionCache = array();
37
38 /******************************************************
39 * General functions *
40 ******************************************************/
41
42 /** Execute the template and write out the result */
43 function outputPage( &$out ) {
44 echo $this->execute( $out );
45 }
46
47 function execute( &$out ) {
48 global $wgTitle, $wgStyleDirectory, $wgParserCacheType;
49 $fname = 'SkinMonoBookCBT::execute';
50 wfProfileIn( $fname );
51 wfProfileIn( "$fname-setup" );
52 Skin::initPage( $out );
53
54 $this->mOut =& $out;
55 $this->mTitle =& $wgTitle;
56
57 $sourceFile = "$wgStyleDirectory/MonoBook.tpl";
58
59 wfProfileOut( "$fname-setup" );
60
61 if ( $wgParserCacheType == CACHE_NONE ) {
62 $template = file_get_contents( $sourceFile );
63 $text = $this->executeTemplate( $template );
64 } else {
65 $compiled = $this->getCompiledTemplate( $sourceFile );
66
67 wfProfileIn( "$fname-eval" );
68 $text = eval( $compiled );
69 wfProfileOut( "$fname-eval" );
70 }
71 wfProfileOut( $fname );
72 return $text;
73 }
74
75 function getCompiledTemplate( $sourceFile ) {
76 global $wgDBname, $wgMemc, $wgRequest, $wgUser, $parserMemc;
77 $fname = 'SkinMonoBookCBT::getCompiledTemplate';
78
79 $expiry = 3600;
80
81 // Sandbox template execution
82 if ( $this->mCompiling ) {
83 return;
84 }
85
86 wfProfileIn( $fname );
87
88 // Is the request an ordinary page view?
89 if ( $wgRequest->wasPosted() ||
90 count( array_diff( array_keys( $_GET ), array( 'title', 'useskin', 'recompile' ) ) ) != 0 )
91 {
92 $type = 'nonview';
93 } else {
94 $type = 'view';
95 }
96
97 // Per-user compiled template
98 // Put all logged-out users on the same cache key
99 $cacheKey = "$wgDBname:monobookcbt:$type:" . $wgUser->getId();
100
101 $recompile = $wgRequest->getVal( 'recompile' );
102 if ( $recompile == 'user' ) {
103 $recompileUser = true;
104 $recompileGeneric = false;
105 } elseif ( $recompile ) {
106 $recompileUser = true;
107 $recompileGeneric = true;
108 } else {
109 $recompileUser = false;
110 $recompileGeneric = false;
111 }
112
113 if ( !$recompileUser ) {
114 $php = $parserMemc->get( $cacheKey );
115 }
116 if ( $recompileUser || !$php ) {
117 if ( $wgUser->isLoggedIn() ) {
118 // Perform staged compilation
119 // First compile a generic template for all logged-in users
120 $genericKey = "$wgDBname:monobookcbt:$type:loggedin";
121 if ( !$recompileGeneric ) {
122 $template = $parserMemc->get( $genericKey );
123 }
124 if ( $recompileGeneric || !$template ) {
125 $template = file_get_contents( $sourceFile );
126 $ignore = array( 'loggedin', '!loggedin dynamic' );
127 if ( $type == 'view' ) {
128 $ignore[] = 'nonview dynamic';
129 }
130 $template = $this->compileTemplate( $template, $ignore );
131 $parserMemc->set( $genericKey, $template, $expiry );
132 }
133 } else {
134 $template = file_get_contents( $sourceFile );
135 }
136
137 $ignore = array( 'lang', 'loggedin', 'user' );
138 if ( $wgUser->isLoggedIn() ) {
139 $ignore[] = '!loggedin dynamic';
140 } else {
141 $ignore[] = 'loggedin dynamic';
142 }
143 if ( $type == 'view' ) {
144 $ignore[] = 'nonview dynamic';
145 }
146 $compiled = $this->compileTemplate( $template, $ignore );
147
148 // Reduce whitespace
149 // This is done here instead of in CBTProcessor because we can be
150 // more sure it is safe here.
151 $compiled = preg_replace( '/^[ \t]+/m', '', $compiled );
152 $compiled = preg_replace( '/[\r\n]+/', "\n", $compiled );
153
154 // Compile to PHP
155 $compiler = new CBTCompiler( $compiled );
156 $ret = $compiler->compile();
157 if ( $ret !== true ) {
158 echo $ret;
159 wfErrorExit();
160 }
161 $php = $compiler->generatePHP( '$this' );
162
163 $parserMemc->set( $cacheKey, $php, $expiry );
164 }
165 wfProfileOut( $fname );
166 return $php;
167 }
168
169 function compileTemplate( $template, $ignore ) {
170 $tp = new CBTProcessor( $template, $this, $ignore );
171 $tp->mFunctionCache = $this->mFunctionCache;
172
173 $this->mCompiling = true;
174 $compiled = $tp->compile();
175 $this->mCompiling = false;
176
177 if ( $tp->getLastError() ) {
178 // If there was a compile error, don't save the template
179 // Instead just print the error and exit
180 echo $compiled;
181 wfErrorExit();
182 }
183 $this->mFunctionCache = $tp->mFunctionCache;
184 return $compiled;
185 }
186
187 function executeTemplate( $template ) {
188 $fname = 'SkinMonoBookCBT::executeTemplate';
189 wfProfileIn( $fname );
190 $tp = new CBTProcessor( $template, $this );
191 $tp->mFunctionCache = $this->mFunctionCache;
192
193 $this->mCompiling = true;
194 $text = $tp->execute();
195 $this->mCompiling = false;
196
197 $this->mFunctionCache = $tp->mFunctionCache;
198 wfProfileOut( $fname );
199 return $text;
200 }
201
202 /******************************************************
203 * Callbacks *
204 ******************************************************/
205
206 function lang() { return $GLOBALS['wgContLanguageCode']; }
207
208 function dir() {
209 global $wgContLang;
210 return $wgContLang->isRTL() ? 'rtl' : 'ltr';
211 }
212
213 function mimetype() { return $GLOBALS['wgMimeType']; }
214 function charset() { return $GLOBALS['wgOutputEncoding']; }
215 function headlinks() {
216 return cbt_value( $this->mOut->getHeadLinks(), 'dynamic' );
217 }
218 function headscripts() {
219 return cbt_value( $this->mOut->getScript(), 'dynamic' );
220 }
221
222 function pagetitle() {
223 return cbt_value( $this->mOut->getHTMLTitle(), array( 'title', 'lang' ) );
224 }
225
226 function stylepath() { return $GLOBALS['wgStylePath']; }
227 function stylename() { return $this->mStyleName; }
228
229 function notprintable() {
230 global $wgRequest;
231 return cbt_value( !$wgRequest->getBool( 'printable' ), 'nonview dynamic' );
232 }
233
234 function jsmimetype() { return $GLOBALS['wgJsMimeType']; }
235
236 function jsvarurl() {
237 global $wgUseSiteJs, $wgUser;
238 if ( !$wgUseSiteJs ) return '';
239
240 if ( $wgUser->isLoggedIn() ) {
241 $url = self::makeUrl( '-','action=raw&smaxage=0&gen=js' );
242 } else {
243 $url = self::makeUrl( '-','action=raw&gen=js' );
244 }
245 return cbt_value( $url, 'loggedin' );
246 }
247
248 function pagecss() {
249 global $wgHooks;
250
251 $out = false;
252 wfRunHooks( 'SkinTemplateSetupPageCss', array( &$out ) );
253
254 // Unknown dependencies
255 return cbt_value( $out, 'dynamic' );
256 }
257
258 function usercss() {
259 if ( $this->isCssPreview() ) {
260 global $wgRequest;
261 $usercss = $this->makeStylesheetCdata( $wgRequest->getText('wpTextbox1') );
262 } else {
263 $usercss = $this->makeStylesheetLink( self::makeUrl($this->getUserPageText() .
264 '/'.$this->mStyleName.'.css', 'action=raw&ctype=text/css' ) );
265 }
266
267 // Dynamic when not an ordinary page view, also depends on the username
268 return cbt_value( $usercss, array( 'nonview dynamic', 'user' ) );
269 }
270
271 function sitecss() {
272 global $wgUseSiteCss;
273 if ( !$wgUseSiteCss ) {
274 return '';
275 }
276
277 global $wgSquidMaxage, $wgContLang, $wgStylePath;
278
279 $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
280
281 $sitecss = '';
282 if ( $wgContLang->isRTL() ) {
283 $sitecss .= $this->makeStylesheetLink( $wgStylePath . '/' . $this->mStyleName . '/rtl.css' ) . "\n";
284 }
285
286 $sitecss .= $this->makeStylesheetLink( self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) ) . "\n";
287 $sitecss .= $this->makeStylesheetLink( self::makeNSUrl( ucfirst( $this->mStyleName ) . '.css', $query, NS_MEDIAWIKI ) ) . "\n";
288
289 // No deps
290 return $sitecss;
291 }
292
293 function gencss() {
294 global $wgUseSiteCss;
295 if ( !$wgUseSiteCss ) return '';
296
297 global $wgSquidMaxage, $wgUser, $wgAllowUserCss;
298 if ( $this->isCssPreview() ) {
299 $siteargs = '&smaxage=0&maxage=0';
300 } else {
301 $siteargs = '&maxage=' . $wgSquidMaxage;
302 }
303 if ( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
304 $siteargs .= '&ts={user_touched}';
305 $isTemplate = true;
306 } else {
307 $isTemplate = false;
308 }
309
310 $link = $this->makeStylesheetLink( self::makeUrl('-','action=raw&gen=css' . $siteargs) ) . "\n";
311
312 if ( $wgAllowUserCss ) {
313 $deps = 'loggedin';
314 } else {
315 $deps = array();
316 }
317 return cbt_value( $link, $deps, $isTemplate );
318 }
319
320 function user_touched() {
321 global $wgUser;
322 return cbt_value( $wgUser->mTouched, 'dynamic' );
323 }
324
325 function userjs() {
326 global $wgAllowUserJs, $wgJsMimeType;
327 if ( !$wgAllowUserJs ) return '';
328
329 if ( $this->isJsPreview() ) {
330 $url = '';
331 } else {
332 $url = self::makeUrl($this->getUserPageText().'/'.$this->mStyleName.'.js', 'action=raw&ctype='.$wgJsMimeType.'&dontcountme=s');
333 }
334 return cbt_value( $url, array( 'nonview dynamic', 'user' ) );
335 }
336
337 function userjsprev() {
338 global $wgAllowUserJs, $wgRequest;
339 if ( !$wgAllowUserJs ) return '';
340 if ( $this->isJsPreview() ) {
341 $js = '/*<![CDATA[*/ ' . $wgRequest->getText('wpTextbox1') . ' /*]]>*/';
342 } else {
343 $js = '';
344 }
345 return cbt_value( $js, array( 'nonview dynamic' ) );
346 }
347
348 function trackbackhtml() {
349 global $wgUseTrackbacks;
350 if ( !$wgUseTrackbacks ) return '';
351
352 if ( $this->mOut->isArticleRelated() ) {
353 $tb = $this->mTitle->trackbackRDF();
354 } else {
355 $tb = '';
356 }
357 return cbt_value( $tb, 'dynamic' );
358 }
359
360 function body_ondblclick() {
361 global $wgUser;
362 if( $this->isEditable() && $wgUser->getOption("editondblclick") ) {
363 $js = 'document.location = "' . $this->getEditUrl() .'";';
364 } else {
365 $js = '';
366 }
367
368 if ( User::getDefaultOption('editondblclick') ) {
369 return cbt_value( $js, 'user', 'title' );
370 } else {
371 // Optimise away for logged-out users
372 return cbt_value( $js, 'loggedin dynamic' );
373 }
374 }
375
376 function body_onload() {
377 global $wgUser;
378 if ( $this->isEditable() && $wgUser->getOption( 'editsectiononrightclick' ) ) {
379 $js = 'setupRightClickEdit()';
380 } else {
381 $js = '';
382 }
383 return cbt_value( $js, 'loggedin dynamic' );
384 }
385
386 function nsclass() {
387 return cbt_value( 'ns-' . $this->mTitle->getNamespace(), 'title' );
388 }
389
390 function sitenotice() {
391 // Perhaps this could be given special dependencies using our knowledge of what
392 // wfGetSiteNotice() depends on.
393 return cbt_value( wfGetSiteNotice(), 'dynamic' );
394 }
395
396 function title() {
397 return cbt_value( $this->mOut->getPageTitle(), array( 'title', 'lang' ) );
398 }
399
400 function title_urlform() {
401 return cbt_value( $this->getThisTitleUrlForm(), 'title' );
402 }
403
404 function title_userurl() {
405 return cbt_value( urlencode( $this->mTitle->getDBkey() ), 'title' );
406 }
407
408 function subtitle() {
409 $subpagestr = $this->subPageSubtitle();
410 if ( !empty( $subpagestr ) ) {
411 $s = '<span class="subpages">'.$subpagestr.'</span>'.$this->mOut->getSubtitle();
412 } else {
413 $s = $this->mOut->getSubtitle();
414 }
415 return cbt_value( $s, array( 'title', 'nonview dynamic' ) );
416 }
417
418 function undelete() {
419 return cbt_value( $this->getUndeleteLink(), array( 'title', 'lang' ) );
420 }
421
422 function newtalk() {
423 global $wgUser, $wgDBname;
424 $newtalks = $wgUser->getNewMessageLinks();
425
426 if (count($newtalks) == 1 && $newtalks[0]["wiki"] === $wgDBname) {
427 $usertitle = $this->getUserPageTitle();
428 $usertalktitle = $usertitle->getTalkPage();
429
430 if( !$usertalktitle->equals( $this->mTitle ) ) {
431 $newmessageslink = $this->link(
432 $usertalktitle,
433 wfMsgHtml( 'newmessageslink' ),
434 array(),
435 array( 'redirect' => 'no' ),
436 array( 'known', 'noclasses' )
437 );
438
439 $newmessagesdifflink = $this->link(
440 $usertalktitle,
441 wfMsgHtml( 'newmessagesdifflink' ),
442 array(),
443 array( 'diff' => 'cur' ),
444 array( 'known', 'noclasses' )
445 );
446
447 $ntl = wfMsg(
448 'youhavenewmessages',
449 $newmessageslink,
450 $newmessagesdifflink
451 );
452
453 # Disable Cache
454 $this->mOut->setSquidMaxage(0);
455 }
456 } else if (count($newtalks)) {
457 $sep = str_replace("_", " ", wfMsgHtml("newtalkseparator"));
458 $msgs = array();
459 foreach ($newtalks as $newtalk) {
460 $msgs[] = wfElement("a",
461 array('href' => $newtalk["link"]), $newtalk["wiki"]);
462 }
463 $parts = implode($sep, $msgs);
464 $ntl = wfMsgHtml('youhavenewmessagesmulti', $parts);
465 $this->mOut->setSquidMaxage(0);
466 } else {
467 $ntl = '';
468 }
469 return cbt_value( $ntl, 'dynamic' );
470 }
471
472 function showjumplinks() {
473 global $wgUser;
474 return cbt_value( $wgUser->getOption( 'showjumplinks' ) ? 'true' : '', 'user' );
475 }
476
477 function bodytext() {
478 return cbt_value( $this->mOut->getHTML(), 'dynamic' );
479 }
480
481 function catlinks() {
482 if ( !isset( $this->mCatlinks ) ) {
483 $this->mCatlinks = $this->getCategories();
484 }
485 return cbt_value( $this->mCatlinks, 'dynamic' );
486 }
487
488 function extratabs( $itemTemplate ) {
489 global $wgContLang, $wgDisableLangConversion;
490
491 $etpl = cbt_escape( $itemTemplate );
492
493 /* show links to different language variants */
494 $variants = $wgContLang->getVariants();
495 $s = '';
496 if ( !$wgDisableLangConversion && count( $wgContLang->getVariants() ) > 1 ) {
497 $vcount=0;
498 foreach ( $variants as $code ) {
499 $name = $wgContLang->getVariantname( $code );
500 if ( $name == 'disable' ) {
501 continue;
502 }
503 $code = cbt_escape( $code );
504 $name = cbt_escape( $name );
505 $s .= "{ca_variant {{$code}} {{$name}} {{$vcount}} {{$etpl}}}\n";
506 $vcount ++;
507 }
508 }
509 return cbt_value( $s, array(), true );
510 }
511
512 function is_special() { return cbt_value( $this->mTitle->getNamespace() == NS_SPECIAL, 'title' ); }
513 function can_edit() { return cbt_value( (string)($this->mTitle->userCan( 'edit' )), 'dynamic' ); }
514 function can_move() { return cbt_value( (string)($this->mTitle->userCan( 'move' )), 'dynamic' ); }
515 function is_talk() { return cbt_value( (string)($this->mTitle->isTalkPage()), 'title' ); }
516 function is_protected() { return cbt_value( (string)$this->mTitle->isProtected(), 'dynamic' ); }
517 function nskey() { return cbt_value( $this->mTitle->getNamespaceKey(), 'title' ); }
518
519 function request_url() {
520 global $wgRequest;
521 return cbt_value( $wgRequest->getRequestURL(), 'dynamic' );
522 }
523
524 function subject_url() {
525 $title = $this->getSubjectPage();
526 if ( $title->exists() ) {
527 $url = $title->getLocalUrl();
528 } else {
529 $url = $title->getLocalUrl( 'action=edit' );
530 }
531 return cbt_value( $url, 'title' );
532 }
533
534 function talk_url() {
535 $title = $this->getTalkPage();
536 if ( $title->exists() ) {
537 $url = $title->getLocalUrl();
538 } else {
539 $url = $title->getLocalUrl( 'action=edit' );
540 }
541 return cbt_value( $url, 'title' );
542 }
543
544 function edit_url() {
545 return cbt_value( $this->getEditUrl(), array( 'title', 'nonview dynamic' ) );
546 }
547
548 function move_url() {
549 return cbt_value( $this->makeSpecialParamUrl( 'Movepage' ), array(), true );
550 }
551
552 function localurl( $query ) {
553 return cbt_value( $this->mTitle->getLocalURL( $query ), 'title' );
554 }
555
556 function selecttab( $tab, $extraclass = '' ) {
557 if ( !isset( $this->mSelectedTab ) ) {
558 $prevent_active_tabs = false ;
559 wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this , &$preventActiveTabs ) );
560
561 $actionTabs = array(
562 'edit' => 'edit',
563 'submit' => 'edit',
564 'history' => 'history',
565 'protect' => 'protect',
566 'unprotect' => 'protect',
567 'delete' => 'delete',
568 'watch' => 'watch',
569 'unwatch' => 'watch',
570 );
571 if ( $preventActiveTabs ) {
572 $this->mSelectedTab = false;
573 } else {
574 $action = $this->getAction();
575 $section = $this->getSection();
576
577 if ( isset( $actionTabs[$action] ) ) {
578 $this->mSelectedTab = $actionTabs[$action];
579
580 if ( $this->mSelectedTab == 'edit' && $section == 'new' ) {
581 $this->mSelectedTab = 'addsection';
582 }
583 } elseif ( $this->mTitle->isTalkPage() ) {
584 $this->mSelectedTab = 'talk';
585 } else {
586 $this->mSelectedTab = 'subject';
587 }
588 }
589 }
590 if ( $extraclass ) {
591 if ( $this->mSelectedTab == $tab ) {
592 $s = 'class="selected ' . htmlspecialchars( $extraclass ) . '"';
593 } else {
594 $s = 'class="' . htmlspecialchars( $extraclass ) . '"';
595 }
596 } else {
597 if ( $this->mSelectedTab == $tab ) {
598 $s = 'class="selected"';
599 } else {
600 $s = '';
601 }
602 }
603 return cbt_value( $s, array( 'nonview dynamic', 'title' ) );
604 }
605
606 function subject_newclass() {
607 $title = $this->getSubjectPage();
608 $class = $title->exists() ? '' : 'new';
609 return cbt_value( $class, 'dynamic' );
610 }
611
612 function talk_newclass() {
613 $title = $this->getTalkPage();
614 $class = $title->exists() ? '' : 'new';
615 return cbt_value( $class, 'dynamic' );
616 }
617
618 function ca_variant( $code, $name, $index, $template ) {
619 global $wgContLang;
620 $selected = ($code == $wgContLang->getPreferredVariant());
621 $action = $this->getAction();
622 $actstr = '';
623 if( $action )
624 $actstr = 'action=' . $action . '&';
625 $s = strtr( $template, array(
626 '$id' => htmlspecialchars( 'varlang-' . $index ),
627 '$class' => $selected ? 'class="selected"' : '',
628 '$text' => $name,
629 '$href' => htmlspecialchars( $this->mTitle->getLocalUrl( $actstr . 'variant=' . $code ) )
630 ));
631 return cbt_value( $s, 'dynamic' );
632 }
633
634 function is_watching() {
635 return cbt_value( (string)$this->mTitle->userIsWatching(), array( 'dynamic' ) );
636 }
637
638
639 function personal_urls( $itemTemplate ) {
640 global $wgShowIPinHeader, $wgContLang;
641
642 # Split this function up into many small functions, to obtain the
643 # best specificity in the dependencies of each one. The template below
644 # has no dependencies, so its generation, and any static subfunctions,
645 # can be optimised away.
646 $etpl = cbt_escape( $itemTemplate );
647 $s = "
648 {userpage {{$etpl}}}
649 {mytalk {{$etpl}}}
650 {preferences {{$etpl}}}
651 {watchlist {{$etpl}}}
652 {mycontris {{$etpl}}}
653 {logout {{$etpl}}}
654 ";
655
656 if ( $wgShowIPinHeader ) {
657 $s .= "
658 {anonuserpage {{$etpl}}}
659 {anontalk {{$etpl}}}
660 {anonlogin {{$etpl}}}
661 ";
662 } else {
663 $s .= "{login {{$etpl}}}\n";
664 }
665 // No dependencies
666 return cbt_value( $s, array(), true /*this is a template*/ );
667 }
668
669 function userpage( $itemTemplate ) {
670 global $wgUser;
671 if ( $this->isLoggedIn() ) {
672 $userPage = $this->getUserPageTitle();
673 $s = $this->makeTemplateLink( $itemTemplate, 'userpage', $userPage, $wgUser->getName() );
674 } else {
675 $s = '';
676 }
677 return cbt_value( $s, 'user' );
678 }
679
680 function mytalk( $itemTemplate ) {
681 global $wgUser;
682 if ( $this->isLoggedIn() ) {
683 $userPage = $this->getUserPageTitle();
684 $talkPage = $userPage->getTalkPage();
685 $s = $this->makeTemplateLink( $itemTemplate, 'mytalk', $talkPage, wfMsg('mytalk') );
686 } else {
687 $s = '';
688 }
689 return cbt_value( $s, 'user' );
690 }
691
692 function preferences( $itemTemplate ) {
693 if ( $this->isLoggedIn() ) {
694 $s = $this->makeSpecialTemplateLink( $itemTemplate, 'preferences',
695 'Preferences', wfMsg( 'preferences' ) );
696 } else {
697 $s = '';
698 }
699 return cbt_value( $s, array( 'loggedin', 'lang' ) );
700 }
701
702 function watchlist( $itemTemplate ) {
703 if ( $this->isLoggedIn() ) {
704 $s = $this->makeSpecialTemplateLink( $itemTemplate, 'watchlist',
705 'Watchlist', wfMsg( 'watchlist' ) );
706 } else {
707 $s = '';
708 }
709 return cbt_value( $s, array( 'loggedin', 'lang' ) );
710 }
711
712 function mycontris( $itemTemplate ) {
713 if ( $this->isLoggedIn() ) {
714 global $wgUser;
715 $s = $this->makeSpecialTemplateLink( $itemTemplate, 'mycontris',
716 "Contributions/" . $wgUser->getTitleKey(), wfMsg('mycontris') );
717 } else {
718 $s = '';
719 }
720 return cbt_value( $s, 'user' );
721 }
722
723 function logout( $itemTemplate ) {
724 if ( $this->isLoggedIn() ) {
725 $s = $this->makeSpecialTemplateLink( $itemTemplate, 'logout',
726 'Userlogout', wfMsg( 'userlogout' ),
727 $this->mTitle->getNamespace() === NS_SPECIAL && $this->mTitle->getText() === 'Preferences'
728 ? '' : "returnto=" . $this->mTitle->getPrefixedURL() );
729 } else {
730 $s = '';
731 }
732 return cbt_value( $s, 'loggedin dynamic' );
733 }
734
735 function anonuserpage( $itemTemplate ) {
736 if ( $this->isLoggedIn() ) {
737 $s = '';
738 } else {
739 global $wgUser;
740 $userPage = $this->getUserPageTitle();
741 $s = $this->makeTemplateLink( $itemTemplate, 'userpage', $userPage, $wgUser->getName() );
742 }
743 return cbt_value( $s, '!loggedin dynamic' );
744 }
745
746 function anontalk( $itemTemplate ) {
747 if ( $this->isLoggedIn() ) {
748 $s = '';
749 } else {
750 $userPage = $this->getUserPageTitle();
751 $talkPage = $userPage->getTalkPage();
752 $s = $this->makeTemplateLink( $itemTemplate, 'mytalk', $talkPage, wfMsg('anontalk') );
753 }
754 return cbt_value( $s, '!loggedin dynamic' );
755 }
756
757 function anonlogin( $itemTemplate ) {
758 if ( $this->isLoggedIn() ) {
759 $s = '';
760 } else {
761 $s = $this->makeSpecialTemplateLink( $itemTemplate, 'anonlogin', 'Userlogin',
762 wfMsg( 'userlogin' ), 'returnto=' . urlencode( $this->getThisPDBK() ) );
763 }
764 return cbt_value( $s, '!loggedin dynamic' );
765 }
766
767 function login( $itemTemplate ) {
768 if ( $this->isLoggedIn() ) {
769 $s = '';
770 } else {
771 $s = $this->makeSpecialTemplateLink( $itemTemplate, 'login', 'Userlogin',
772 wfMsg( 'userlogin' ), 'returnto=' . urlencode( $this->getThisPDBK() ) );
773 }
774 return cbt_value( $s, '!loggedin dynamic' );
775 }
776
777 function logopath() { return $GLOBALS['wgLogo']; }
778 function mainpage() { return self::makeMainPageUrl(); }
779
780 function sidebar( $startSection, $endSection, $innerTpl ) {
781 $s = '';
782 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
783 $firstSection = true;
784 foreach ($lines as $line) {
785 if (strpos($line, '*') !== 0)
786 continue;
787 if (strpos($line, '**') !== 0) {
788 $bar = trim($line, '* ');
789 $name = wfMsg( $bar );
790 if (wfEmptyMsg($bar, $name)) {
791 $name = $bar;
792 }
793 if ( $firstSection ) {
794 $firstSection = false;
795 } else {
796 $s .= $endSection;
797 }
798 $s .= strtr( $startSection,
799 array(
800 '$bar' => htmlspecialchars( $bar ),
801 '$barname' => $name
802 ) );
803 } else {
804 if (strpos($line, '|') !== false) { // sanity check
805 $line = explode( '|' , trim($line, '* '), 2 );
806 $link = wfMsgForContent( $line[0] );
807 if ($link == '-')
808 continue;
809 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
810 $text = $line[1];
811 if (wfEmptyMsg($line[0], $link))
812 $link = $line[0];
813 $href = self::makeInternalOrExternalUrl( $link );
814
815 $s .= strtr( $innerTpl,
816 array(
817 '$text' => htmlspecialchars( $text ),
818 '$href' => htmlspecialchars( $href ),
819 '$id' => htmlspecialchars( 'n-' . strtr($line[1], ' ', '-') ),
820 '$classactive' => ''
821 ) );
822 } else { continue; }
823 }
824 }
825 if ( !$firstSection ) {
826 $s .= $endSection;
827 }
828
829 // Depends on user language only
830 return cbt_value( $s, 'lang' );
831 }
832
833 function searchaction() {
834 // Static link
835 return $this->getSearchLink();
836 }
837
838 function search() {
839 global $wgRequest;
840 return cbt_value( trim( $this->getSearch() ), 'special dynamic' );
841 }
842
843 function notspecialpage() {
844 return cbt_value( $this->mTitle->getNamespace() != NS_SPECIAL, 'special' );
845 }
846
847 function nav_whatlinkshere() {
848 return cbt_value( $this->makeSpecialParamUrl('Whatlinkshere' ), array(), true );
849 }
850
851 function article_exists() {
852 return cbt_value( (string)($this->mTitle->getArticleId() !== 0), 'title' );
853 }
854
855 function nav_recentchangeslinked() {
856 return cbt_value( $this->makeSpecialParamUrl('Recentchangeslinked' ), array(), true );
857 }
858
859 function feeds( $itemTemplate = '' ) {
860 if ( !$this->mOut->isSyndicated() ) {
861 $feeds = '';
862 } elseif ( $itemTemplate == '' ) {
863 // boolean only required
864 $feeds = 'true';
865 } else {
866 $feeds = '';
867 global $wgFeedClasses, $wgRequest;
868 foreach( $wgFeedClasses as $format => $class ) {
869 $feeds .= strtr( $itemTemplate,
870 array(
871 '$key' => htmlspecialchars( $format ),
872 '$text' => $format,
873 '$href' => $wgRequest->appendQuery( "feed=$format" )
874 ) );
875 }
876 }
877 return cbt_value( $feeds, 'special dynamic' );
878 }
879
880 function is_userpage() {
881 list( $id, $ip ) = $this->getUserPageIdIp();
882 return cbt_value( (string)($id || $ip), 'title' );
883 }
884
885 function is_ns_mediawiki() {
886 return cbt_value( (string)$this->mTitle->getNamespace() == NS_MEDIAWIKI, 'title' );
887 }
888
889 function is_loggedin() {
890 global $wgUser;
891 return cbt_value( (string)($wgUser->isLoggedIn()), 'loggedin' );
892 }
893
894 function nav_contributions() {
895 $url = $this->makeSpecialParamUrl( 'Contributions', '', '{title_userurl}' );
896 return cbt_value( $url, array(), true );
897 }
898
899 function is_allowed( $right ) {
900 global $wgUser;
901 return cbt_value( (string)$wgUser->isAllowed( $right ), 'user' );
902 }
903
904 function nav_blockip() {
905 $url = $this->makeSpecialParamUrl( 'Blockip', '', '{title_userurl}' );
906 return cbt_value( $url, array(), true );
907 }
908
909 function nav_emailuser() {
910 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
911 if ( !$wgEnableEmail || !$wgEnableUserEmail ) return '';
912
913 $url = $this->makeSpecialParamUrl( 'Emailuser', '', '{title_userurl}' );
914 return cbt_value( $url, array(), true );
915 }
916
917 function nav_upload() {
918 global $wgEnableUploads, $wgUploadNavigationUrl;
919 if ( !$wgEnableUploads ) {
920 return '';
921 } elseif ( $wgUploadNavigationUrl ) {
922 return $wgUploadNavigationUrl;
923 } else {
924 return self::makeSpecialUrl('Upload');
925 }
926 }
927
928 function nav_specialpages() {
929 return self::makeSpecialUrl('Specialpages');
930 }
931
932 function nav_print() {
933 global $wgRequest, $wgArticle;
934 $action = $this->getAction();
935 $url = '';
936 if( $this->mTitle->getNamespace() !== NS_SPECIAL
937 && ($action == '' || $action == 'view' || $action == 'purge' ) )
938 {
939 $revid = $wgArticle->getLatest();
940 if ( $revid != 0 ) {
941 $url = $wgRequest->appendQuery( 'printable=yes' );
942 }
943 }
944 return cbt_value( $url, array( 'nonview dynamic', 'title' ) );
945 }
946
947 function nav_permalink() {
948 $url = (string)$this->getPermalink();
949 return cbt_value( $url, 'dynamic' );
950 }
951
952 function nav_trackbacklink() {
953 global $wgUseTrackbacks;
954 if ( !$wgUseTrackbacks ) return '';
955
956 return cbt_value( $this->mTitle->trackbackURL(), 'title' );
957 }
958
959 function is_permalink() {
960 return cbt_value( (string)($this->getPermalink() === false), 'nonview dynamic' );
961 }
962
963 function toolboxend() {
964 // This is where the MonoBookTemplateToolboxEnd hook went in the old skin
965 return '';
966 }
967
968 function language_urls( $outer, $inner ) {
969 global $wgHideInterlanguageLinks, $wgOut, $wgContLang;
970 if ( $wgHideInterlanguageLinks ) return '';
971
972 $links = $wgOut->getLanguageLinks();
973 $s = '';
974 if ( count( $links ) ) {
975 foreach( $links as $l ) {
976 $tmp = explode( ':', $l, 2 );
977 $nt = Title::newFromText( $l );
978 $s .= strtr( $inner,
979 array(
980 '$class' => htmlspecialchars( 'interwiki-' . $tmp[0] ),
981 '$href' => htmlspecialchars( $nt->getFullURL() ),
982 '$text' => ($wgContLang->getLanguageName( $nt->getInterwiki() ) != ''?
983 $wgContLang->getLanguageName( $nt->getInterwiki() ) : $l ),
984 )
985 );
986 }
987 $s = str_replace( '$body', $s, $outer );
988 }
989 return cbt_value( $s, 'dynamic' );
990 }
991
992 function poweredbyico() { return $this->getPoweredBy(); }
993 function copyrightico() { return $this->getCopyrightIcon(); }
994
995 function lastmod() {
996 global $wgMaxCredits;
997 if ( $wgMaxCredits ) return '';
998
999 if ( !isset( $this->mLastmod ) ) {
1000 if ( $this->isCurrentArticleView() ) {
1001 $this->mLastmod = $this->lastModified();
1002 } else {
1003 $this->mLastmod = '';
1004 }
1005 }
1006 return cbt_value( $this->mLastmod, 'dynamic' );
1007 }
1008
1009 function viewcount() {
1010 global $wgDisableCounters;
1011 if ( $wgDisableCounters ) return '';
1012
1013 global $wgLang, $wgArticle;
1014 if ( is_object( $wgArticle ) ) {
1015 $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
1016 if ( $viewcount ) {
1017 $viewcount = wfMsg( "viewcount", $viewcount );
1018 } else {
1019 $viewcount = '';
1020 }
1021 } else {
1022 $viewcount = '';
1023 }
1024 return cbt_value( $viewcount, 'dynamic' );
1025 }
1026
1027 function numberofwatchingusers() {
1028 global $wgPageShowWatchingUsers;
1029 if ( !$wgPageShowWatchingUsers ) return '';
1030
1031 $dbr = wfGetDB( DB_SLAVE );
1032 extract( $dbr->tableNames( 'watchlist' ) );
1033 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1034 WHERE wl_title='" . $dbr->strencode($this->mTitle->getDBkey()) .
1035 "' AND wl_namespace=" . $this->mTitle->getNamespace() ;
1036 $res = $dbr->query( $sql, 'SkinTemplate::outputPage');
1037 $row = $dbr->fetchObject( $res );
1038 $num = $row->n;
1039 if ($num > 0) {
1040 $s = wfMsg('number_of_watching_users_pageview', $num);
1041 } else {
1042 $s = '';
1043 }
1044 return cbt_value( $s, 'dynamic' );
1045 }
1046
1047 function credits() {
1048 global $wgMaxCredits;
1049 if ( !$wgMaxCredits ) return '';
1050
1051 if ( $this->isCurrentArticleView() ) {
1052 require_once("Credits.php");
1053 global $wgArticle, $wgShowCreditsIfMax;
1054 $credits = getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1055 } else {
1056 $credits = '';
1057 }
1058 return cbt_value( $credits, 'view dynamic' );
1059 }
1060
1061 function normalcopyright() {
1062 return $this->getCopyright( 'normal' );
1063 }
1064
1065 function historycopyright() {
1066 return $this->getCopyright( 'history' );
1067 }
1068
1069 function is_currentview() {
1070 global $wgRequest;
1071 return cbt_value( (string)$this->isCurrentArticleView(), 'view' );
1072 }
1073
1074 function usehistorycopyright() {
1075 global $wgRequest;
1076 if ( wfMsgForContent( 'history_copyright' ) == '-' ) return '';
1077
1078 $oldid = $this->getOldId();
1079 $diff = $this->getDiff();
1080 $use = (string)(!is_null( $oldid ) && is_null( $diff ));
1081 return cbt_value( $use, 'nonview dynamic' );
1082 }
1083
1084 function privacy() {
1085 return cbt_value( $this->privacyLink(), 'lang' );
1086 }
1087 function about() {
1088 return cbt_value( $this->aboutLink(), 'lang' );
1089 }
1090 function disclaimer() {
1091 return cbt_value( $this->disclaimerLink(), 'lang' );
1092 }
1093 function tagline() {
1094 # A reference to this tag existed in the old MonoBook.php, but the
1095 # template data wasn't set anywhere
1096 return '';
1097 }
1098 function reporttime() {
1099 return cbt_value( $this->mOut->reportTime(), 'dynamic' );
1100 }
1101
1102 function msg( $name ) {
1103 return cbt_value( wfMsg( $name ), 'lang' );
1104 }
1105
1106 function fallbackmsg( $name, $fallback ) {
1107 $text = wfMsg( $name );
1108 if ( wfEmptyMsg( $name, $text ) ) {
1109 $text = $fallback;
1110 }
1111 return cbt_value( $text, 'lang' );
1112 }
1113
1114 /******************************************************
1115 * Utility functions *
1116 ******************************************************/
1117
1118 /** Return true if this request is a valid, secure CSS preview */
1119 function isCssPreview() {
1120 if ( !isset( $this->mCssPreview ) ) {
1121 global $wgRequest, $wgAllowUserCss, $wgUser;
1122 $this->mCssPreview =
1123 $wgAllowUserCss &&
1124 $wgUser->isLoggedIn() &&
1125 $this->mTitle->isCssSubpage() &&
1126 $this->userCanPreview( $this->getAction() );
1127 }
1128 return $this->mCssPreview;
1129 }
1130
1131 /** Return true if this request is a valid, secure JS preview */
1132 function isJsPreview() {
1133 if ( !isset( $this->mJsPreview ) ) {
1134 global $wgRequest, $wgAllowUserJs, $wgUser;
1135 $this->mJsPreview =
1136 $wgAllowUserJs &&
1137 $wgUser->isLoggedIn() &&
1138 $this->mTitle->isJsSubpage() &&
1139 $this->userCanPreview( $this->getAction() );
1140 }
1141 return $this->mJsPreview;
1142 }
1143
1144 /** Get the title of the $wgUser's user page */
1145 function getUserPageTitle() {
1146 if ( !isset( $this->mUserPageTitle ) ) {
1147 global $wgUser;
1148 $this->mUserPageTitle = $wgUser->getUserPage();
1149 }
1150 return $this->mUserPageTitle;
1151 }
1152
1153 /** Get the text of the user page title */
1154 function getUserPageText() {
1155 if ( !isset( $this->mUserPageText ) ) {
1156 $userPage = $this->getUserPageTitle();
1157 $this->mUserPageText = $userPage->getPrefixedText();
1158 }
1159 return $this->mUserPageText;
1160 }
1161
1162 /** Make an HTML element for a stylesheet link */
1163 function makeStylesheetLink( $url ) {
1164 return '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars( $url ) . "\"/>";
1165 }
1166
1167 /** Make an XHTML element for inline CSS */
1168 function makeStylesheetCdata( $style ) {
1169 return "<style type=\"text/css\"> /*<![CDATA[*/ {$style} /*]]>*/ </style>";
1170 }
1171
1172 /** Get the edit URL for this page */
1173 function getEditUrl() {
1174 if ( !isset( $this->mEditUrl ) ) {
1175 $this->mEditUrl = $this->mTitle->getLocalUrl( $this->editUrlOptions() );
1176 }
1177 return $this->mEditUrl;
1178 }
1179
1180 /** Get the prefixed DB key for this page */
1181 function getThisPDBK() {
1182 if ( !isset( $this->mThisPDBK ) ) {
1183 $this->mThisPDBK = $this->mTitle->getPrefixedDbKey();
1184 }
1185 return $this->mThisPDBK;
1186 }
1187
1188 function getThisTitleUrlForm() {
1189 if ( !isset( $this->mThisTitleUrlForm ) ) {
1190 $this->mThisTitleUrlForm = $this->mTitle->getPrefixedURL();
1191 }
1192 return $this->mThisTitleUrlForm;
1193 }
1194
1195 /**
1196 * If the current page is a user page, get the user's ID and IP. Otherwise return array(0,false)
1197 */
1198 function getUserPageIdIp() {
1199 if ( !isset( $this->mUserPageId ) ) {
1200 if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {
1201 $this->mUserPageId = User::idFromName($this->mTitle->getText());
1202 $this->mUserPageIp = User::isIP($this->mTitle->getText());
1203 } else {
1204 $this->mUserPageId = 0;
1205 $this->mUserPageIp = false;
1206 }
1207 }
1208 return array( $this->mUserPageId, $this->mUserPageIp );
1209 }
1210
1211 /**
1212 * Returns a permalink URL, or false if the current page is already a
1213 * permalink, or blank if a permalink shouldn't be displayed
1214 */
1215 function getPermalink() {
1216 if ( !isset( $this->mPermalink ) ) {
1217 global $wgRequest, $wgArticle;
1218 $action = $this->getAction();
1219 $oldid = $this->getOldId();
1220 $url = '';
1221 if( $this->mTitle->getNamespace() !== NS_SPECIAL
1222 && $this->mTitle->getArticleId() != 0
1223 && ($action == '' || $action == 'view' || $action == 'purge' ) )
1224 {
1225 if ( !$oldid ) {
1226 $revid = $wgArticle->getLatest();
1227 $url = $this->mTitle->getLocalURL( "oldid=$revid" );
1228 } else {
1229 $url = false;
1230 }
1231 } else {
1232 $url = '';
1233 }
1234 }
1235 return $url;
1236 }
1237
1238 /**
1239 * Returns true if the current page is an article, not a special page,
1240 * and we are viewing a revision, not a diff
1241 */
1242 function isArticleView() {
1243 global $wgOut, $wgArticle, $wgRequest;
1244 if ( !isset( $this->mIsArticleView ) ) {
1245 $oldid = $this->getOldId();
1246 $diff = $this->getDiff();
1247 $this->mIsArticleView = $wgOut->isArticle() and
1248 (!is_null( $oldid ) or is_null( $diff )) and 0 != $wgArticle->getID();
1249 }
1250 return $this->mIsArticleView;
1251 }
1252
1253 function isCurrentArticleView() {
1254 if ( !isset( $this->mIsCurrentArticleView ) ) {
1255 global $wgOut, $wgArticle, $wgRequest;
1256 $oldid = $this->getOldId();
1257 $this->mIsCurrentArticleView = $wgOut->isArticle() && is_null( $oldid ) && 0 != $wgArticle->getID();
1258 }
1259 return $this->mIsCurrentArticleView;
1260 }
1261
1262
1263 /**
1264 * Return true if the current page is editable; if edit section on right
1265 * click should be enabled.
1266 */
1267 function isEditable() {
1268 global $wgRequest;
1269 $action = $this->getAction();
1270 return ($this->mTitle->getNamespace() != NS_SPECIAL and !($action == 'edit' or $action == 'submit'));
1271 }
1272
1273 /** Return true if the user is logged in */
1274 function isLoggedIn() {
1275 global $wgUser;
1276 return $wgUser->isLoggedIn();
1277 }
1278
1279 /** Get the local URL of the current page */
1280 function getPageUrl() {
1281 if ( !isset( $this->mPageUrl ) ) {
1282 $this->mPageUrl = $this->mTitle->getLocalURL();
1283 }
1284 return $this->mPageUrl;
1285 }
1286
1287 /** Make a link to a title using a template */
1288 function makeTemplateLink( $template, $key, $title, $text ) {
1289 $url = $title->getLocalUrl();
1290 return strtr( $template,
1291 array(
1292 '$key' => $key,
1293 '$classactive' => ($url == $this->getPageUrl()) ? 'class="active"' : '',
1294 '$class' => $title->getArticleID() == 0 ? 'class="new"' : '',
1295 '$href' => htmlspecialchars( $url ),
1296 '$text' => $text
1297 ) );
1298 }
1299
1300 /** Make a link to a URL using a template */
1301 function makeTemplateLinkUrl( $template, $key, $url, $text ) {
1302 return strtr( $template,
1303 array(
1304 '$key' => $key,
1305 '$classactive' => ($url == $this->getPageUrl()) ? 'class="active"' : '',
1306 '$class' => '',
1307 '$href' => htmlspecialchars( $url ),
1308 '$text' => $text
1309 ) );
1310 }
1311
1312 /** Make a link to a special page using a template */
1313 function makeSpecialTemplateLink( $template, $key, $specialName, $text, $query = '' ) {
1314 $url = self::makeSpecialUrl( $specialName, $query );
1315 // Ignore the query when comparing
1316 $active = ($this->mTitle->getNamespace() == NS_SPECIAL && $this->mTitle->getDBkey() == $specialName);
1317 return strtr( $template,
1318 array(
1319 '$key' => $key,
1320 '$classactive' => $active ? 'class="active"' : '',
1321 '$class' => '',
1322 '$href' => htmlspecialchars( $url ),
1323 '$text' => $text
1324 ) );
1325 }
1326
1327 function loadRequestValues() {
1328 global $wgRequest;
1329 $this->mAction = $wgRequest->getText( 'action' );
1330 $this->mOldId = $wgRequest->getVal( 'oldid' );
1331 $this->mDiff = $wgRequest->getVal( 'diff' );
1332 $this->mSection = $wgRequest->getVal( 'section' );
1333 $this->mSearch = $wgRequest->getVal( 'search' );
1334 $this->mRequestValuesLoaded = true;
1335 }
1336
1337
1338
1339 /** Get the action parameter of the request */
1340 function getAction() {
1341 if ( !isset( $this->mRequestValuesLoaded ) ) {
1342 $this->loadRequestValues();
1343 }
1344 return $this->mAction;
1345 }
1346
1347 /** Get the oldid parameter */
1348 function getOldId() {
1349 if ( !isset( $this->mRequestValuesLoaded ) ) {
1350 $this->loadRequestValues();
1351 }
1352 return $this->mOldId;
1353 }
1354
1355 /** Get the diff parameter */
1356 function getDiff() {
1357 if ( !isset( $this->mRequestValuesLoaded ) ) {
1358 $this->loadRequestValues();
1359 }
1360 return $this->mDiff;
1361 }
1362
1363 function getSection() {
1364 if ( !isset( $this->mRequestValuesLoaded ) ) {
1365 $this->loadRequestValues();
1366 }
1367 return $this->mSection;
1368 }
1369
1370 function getSearch() {
1371 if ( !isset( $this->mRequestValuesLoaded ) ) {
1372 $this->loadRequestValues();
1373 }
1374 return $this->mSearch;
1375 }
1376
1377 /** Make a special page URL of the form [[Special:Somepage/{title_urlform}]] */
1378 function makeSpecialParamUrl( $name, $query = '', $param = '{title_urlform}' ) {
1379 // Abuse makeTitle's lax validity checking to slip a control character into the URL
1380 $title = Title::makeTitle( NS_SPECIAL, "$name/\x1a" );
1381 $url = cbt_escape( $title->getLocalURL( $query ) );
1382 // Now replace it with the parameter
1383 return str_replace( '%1A', $param, $url );
1384 }
1385
1386 function getSubjectPage() {
1387 if ( !isset( $this->mSubjectPage ) ) {
1388 $this->mSubjectPage = $this->mTitle->getSubjectPage();
1389 }
1390 return $this->mSubjectPage;
1391 }
1392
1393 function getTalkPage() {
1394 if ( !isset( $this->mTalkPage ) ) {
1395 $this->mTalkPage = $this->mTitle->getTalkPage();
1396 }
1397 return $this->mTalkPage;
1398 }
1399 }
1400