]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/SkinTemplate.php
MediaWiki 1.17.4
[autoinstallsdev/mediawiki.git] / includes / SkinTemplate.php
1 <?php
2 /**
3  * Base class for template-based skins
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  * http://www.gnu.org/copyleft/gpl.html
19  *
20  * @file
21  */
22
23 if ( ! defined( 'MEDIAWIKI' ) )
24         die( 1 );
25
26 /**
27  * Wrapper object for MediaWiki's localization functions,
28  * to be passed to the template engine.
29  *
30  * @private
31  * @ingroup Skins
32  */
33 class MediaWiki_I18N {
34         var $_context = array();
35
36         function set( $varName, $value ) {
37                 $this->_context[$varName] = $value;
38         }
39
40         function translate( $value ) {
41                 wfProfileIn( __METHOD__ );
42
43                 // Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of 2004-10-23
44                 $value = preg_replace( '/^string:/', '', $value );
45
46                 $value = wfMsg( $value );
47                 // interpolate variables
48                 $m = array();
49                 while( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
50                         list( $src, $var ) = $m;
51                         wfSuppressWarnings();
52                         $varValue = $this->_context[$var];
53                         wfRestoreWarnings();
54                         $value = str_replace( $src, $varValue, $value );
55                 }
56                 wfProfileOut( __METHOD__ );
57                 return $value;
58         }
59 }
60
61 /**
62  * Template-filler skin base class
63  * Formerly generic PHPTal (http://phptal.sourceforge.net/) skin
64  * Based on Brion's smarty skin
65  * @copyright Copyright © Gabriel Wicke -- http://www.aulinx.de/
66  *
67  * @todo Needs some serious refactoring into functions that correspond
68  * to the computations individual esi snippets need. Most importantly no body
69  * parsing for most of those of course.
70  *
71  * @ingroup Skins
72  */
73 class SkinTemplate extends Skin {
74         /**#@+
75          * @private
76          */
77
78         /**
79          * Name of our skin, it probably needs to be all lower case.  Child classes
80          * should override the default.
81          */
82         var $skinname = 'monobook';
83
84         /**
85          * Stylesheets set to use.  Subdirectory in skins/ where various stylesheets
86          * are located.  Child classes should override the default.
87          */
88         var $stylename = 'monobook';
89
90         /**
91          * For QuickTemplate, the name of the subclass which will actually fill the
92          * template.  Child classes should override the default.
93          */
94         var $template = 'QuickTemplate';
95
96         /**
97          * Whether this skin use OutputPage::headElement() to generate the <head>
98          * tag
99          */
100         var $useHeadElement = false;
101
102         /**#@-*/
103
104         /**
105          * Add specific styles for this skin
106          *
107          * @param $out OutputPage
108          */
109         function setupSkinUserCss( OutputPage $out ){
110                 $out->addModuleStyles( array( 'mediawiki.legacy.shared', 'mediawiki.legacy.commonPrint' ) );
111         }
112
113         /**
114          * Create the template engine object; we feed it a bunch of data
115          * and eventually it spits out some HTML. Should have interface
116          * roughly equivalent to PHPTAL 0.7.
117          *
118          * @param $classname string (or file)
119          * @param $repository string: subdirectory where we keep template files
120          * @param $cache_dir string
121          * @return object
122          * @private
123          */
124         function setupTemplate( $classname, $repository = false, $cache_dir = false ) {
125                 return new $classname();
126         }
127
128         /**
129          * initialize various variables and generate the template
130          *
131          * @param $out OutputPage
132          */
133         function outputPage( OutputPage $out ) {
134                 global $wgArticle, $wgUser, $wgLang, $wgContLang;
135                 global $wgScript, $wgStylePath, $wgLanguageCode;
136                 global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest;
137                 global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
138                 global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks;
139                 global $wgMaxCredits, $wgShowCreditsIfMax;
140                 global $wgPageShowWatchingUsers;
141                 global $wgUseTrackbacks, $wgUseSiteJs, $wgDebugComments;
142                 global $wgArticlePath, $wgScriptPath, $wgServer, $wgProfiler;
143
144                 wfProfileIn( __METHOD__ );
145                 if ( is_object( $wgProfiler ) ) {
146                         $wgProfiler->setTemplated( true );
147                 }
148
149                 $oldid = $wgRequest->getVal( 'oldid' );
150                 $diff = $wgRequest->getVal( 'diff' );
151                 $action = $wgRequest->getVal( 'action', 'view' );
152
153                 wfProfileIn( __METHOD__ . '-init' );
154                 $this->initPage( $out );
155
156                 $this->setMembers();
157                 $tpl = $this->setupTemplate( $this->template, 'skins' );
158
159                 #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
160                 $tpl->setTranslator( new MediaWiki_I18N() );
161                 #}
162                 wfProfileOut( __METHOD__ . '-init' );
163
164                 wfProfileIn( __METHOD__ . '-stuff' );
165                 $this->thispage = $this->mTitle->getPrefixedDBkey();
166                 $this->thisurl = $this->mTitle->getPrefixedURL();
167                 $query = array();
168                 if ( !$wgRequest->wasPosted() ) {
169                         $query = $wgRequest->getValues();
170                         unset( $query['title'] );
171                         unset( $query['returnto'] );
172                         unset( $query['returntoquery'] );
173                 }
174                 $this->thisquery = wfUrlencode( wfArrayToCGI( $query ) );
175                 $this->loggedin = $wgUser->isLoggedIn();
176                 $this->iscontent = ( $this->mTitle->getNamespace() != NS_SPECIAL );
177                 $this->iseditable = ( $this->iscontent and !( $action == 'edit' or $action == 'submit' ) );
178                 $this->username = $wgUser->getName();
179
180                 if ( $wgUser->isLoggedIn() || $this->showIPinHeader() ) {
181                         $this->userpageUrlDetails = self::makeUrlDetails( $this->userpage );
182                 } else {
183                         # This won't be used in the standard skins, but we define it to preserve the interface
184                         # To save time, we check for existence
185                         $this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage );
186                 }
187
188                 $this->titletxt = $this->mTitle->getPrefixedText();
189                 wfProfileOut( __METHOD__ . '-stuff' );
190
191                 wfProfileIn( __METHOD__ . '-stuff-head' );
192                 if ( $this->useHeadElement ) {
193                         $pagecss = $this->setupPageCss();
194                         if( $pagecss )
195                                 $out->addInlineStyle( $pagecss );
196                 } else {
197                         $this->setupUserCss( $out );
198
199                         $tpl->set( 'pagecss', $this->setupPageCss() );
200                         $tpl->setRef( 'usercss', $this->usercss );
201
202                         $this->userjs = $this->userjsprev = false;
203                         $this->setupUserJs( $out->isUserJsAllowed() );
204                         $tpl->setRef( 'userjs', $this->userjs );
205                         $tpl->setRef( 'userjsprev', $this->userjsprev );
206
207                         if( $wgUseSiteJs ) {
208                                 $jsCache = $this->loggedin ? '&smaxage=0' : '';
209                                 $tpl->set( 'jsvarurl',
210                                                   self::makeUrl( '-',
211                                                                                 "action=raw$jsCache&gen=js&useskin=" .
212                                                                                 urlencode( $this->getSkinName() ) ) );
213                         } else {
214                                 $tpl->set( 'jsvarurl', false );
215                         }
216
217                         $tpl->setRef( 'xhtmldefaultnamespace', $wgXhtmlDefaultNamespace );
218                         $tpl->set( 'xhtmlnamespaces', $wgXhtmlNamespaces );
219                         $tpl->set( 'html5version', $wgHtml5Version );
220                         $tpl->set( 'headlinks', $out->getHeadLinks( $this ) );
221                         $tpl->set( 'csslinks', $out->buildCssLinks( $this ) );
222
223                         if( $wgUseTrackbacks && $out->isArticleRelated() ) {
224                                 $tpl->set( 'trackbackhtml', $out->getTitle()->trackbackRDF() );
225                         } else {
226                                 $tpl->set( 'trackbackhtml', null );
227                         }
228                 }
229                 wfProfileOut( __METHOD__ . '-stuff-head' );
230
231                 wfProfileIn( __METHOD__ . '-stuff2' );
232                 $tpl->set( 'title', $out->getPageTitle() );
233                 $tpl->set( 'pagetitle', $out->getHTMLTitle() );
234                 $tpl->set( 'displaytitle', $out->mPageLinkTitle );
235                 $tpl->set( 'pageclass', $this->getPageClasses( $this->mTitle ) );
236                 $tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) );
237
238                 $nsname = MWNamespace::exists( $this->mTitle->getNamespace() ) ?
239                                         MWNamespace::getCanonicalName( $this->mTitle->getNamespace() ) :
240                                         $this->mTitle->getNsText();
241
242                 $tpl->set( 'nscanonical', $nsname );
243                 $tpl->set( 'nsnumber', $this->mTitle->getNamespace() );
244                 $tpl->set( 'titleprefixeddbkey', $this->mTitle->getPrefixedDBKey() );
245                 $tpl->set( 'titletext', $this->mTitle->getText() );
246                 $tpl->set( 'articleid', $this->mTitle->getArticleId() );
247                 $tpl->set( 'currevisionid', isset( $wgArticle ) ? $wgArticle->getLatest() : 0 );
248
249                 $tpl->set( 'isarticle', $out->isArticle() );
250
251                 $tpl->setRef( 'thispage', $this->thispage );
252                 $subpagestr = $this->subPageSubtitle();
253                 $tpl->set(
254                         'subtitle', !empty( $subpagestr ) ?
255                         '<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle() :
256                         $out->getSubtitle()
257                 );
258                 $undelete = $this->getUndeleteLink();
259                 $tpl->set(
260                         'undelete', !empty( $undelete ) ?
261                         '<span class="subpages">'.$undelete.'</span>' :
262                         ''
263                 );
264
265                 $tpl->set( 'catlinks', $this->getCategories() );
266                 if( $out->isSyndicated() ) {
267                         $feeds = array();
268                         foreach( $out->getSyndicationLinks() as $format => $link ) {
269                                 $feeds[$format] = array(
270                                         'text' => wfMsg( "feed-$format" ),
271                                         'href' => $link
272                                 );
273                         }
274                         $tpl->setRef( 'feeds', $feeds );
275                 } else {
276                         $tpl->set( 'feeds', false );
277                 }
278
279                 $tpl->setRef( 'mimetype', $wgMimeType );
280                 $tpl->setRef( 'jsmimetype', $wgJsMimeType );
281                 $tpl->setRef( 'charset', $wgOutputEncoding );
282                 $tpl->setRef( 'wgScript', $wgScript );
283                 $tpl->setRef( 'skinname', $this->skinname );
284                 $tpl->set( 'skinclass', get_class( $this ) );
285                 $tpl->setRef( 'stylename', $this->stylename );
286                 $tpl->set( 'printable', $out->isPrintable() );
287                 $tpl->set( 'handheld', $wgRequest->getBool( 'handheld' ) );
288                 $tpl->setRef( 'loggedin', $this->loggedin );
289                 $tpl->set( 'notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL );
290                 /* XXX currently unused, might get useful later
291                 $tpl->set( "editable", ($this->mTitle->getNamespace() != NS_SPECIAL ) );
292                 $tpl->set( "exists", $this->mTitle->getArticleID() != 0 );
293                 $tpl->set( "watch", $this->mTitle->userIsWatching() ? "unwatch" : "watch" );
294                 $tpl->set( "protect", count($this->mTitle->isProtected()) ? "unprotect" : "protect" );
295                 $tpl->set( "helppage", wfMsg('helppage'));
296                 */
297                 $tpl->set( 'searchaction', $this->escapeSearchLink() );
298                 $tpl->set( 'searchtitle', SpecialPage::getTitleFor( 'Search' )->getPrefixedDBKey() );
299                 $tpl->set( 'search', trim( $wgRequest->getVal( 'search' ) ) );
300                 $tpl->setRef( 'stylepath', $wgStylePath );
301                 $tpl->setRef( 'articlepath', $wgArticlePath );
302                 $tpl->setRef( 'scriptpath', $wgScriptPath );
303                 $tpl->setRef( 'serverurl', $wgServer );
304                 $tpl->setRef( 'logopath', $wgLogo );
305
306                 $lang = wfUILang();
307                 $tpl->set( 'lang', $lang->getCode() );
308                 $tpl->set( 'dir', $lang->getDir() );
309                 $tpl->set( 'rtl', $lang->isRTL() );
310
311                 $tpl->set( 'capitalizeallnouns', $wgLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
312                 $tpl->set( 'showjumplinks', $wgUser->getOption( 'showjumplinks' ) );
313                 $tpl->set( 'username', $wgUser->isAnon() ? null : $this->username );
314                 $tpl->setRef( 'userpage', $this->userpage );
315                 $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] );
316                 $tpl->set( 'userlang', $wgLang->getCode() );
317
318                 // Users can have their language set differently than the
319                 // content of the wiki. For these users, tell the web browser
320                 // that interface elements are in a different language.
321                 $tpl->set( 'userlangattributes', '' );
322                 $tpl->set( 'specialpageattributes', '' );
323
324                 $lang = $wgLang->getCode();
325                 $dir  = $wgLang->getDir();
326                 if ( $lang !== $wgContLang->getCode() || $dir !== $wgContLang->getDir() ) {
327                         $attrs = " lang='$lang' dir='$dir'";
328
329                         $tpl->set( 'userlangattributes', $attrs );
330
331                         // The content of SpecialPages should be presented in the
332                         // user's language. Content of regular pages should not be touched.
333                         if( $this->mTitle->isSpecialPage() ) {
334                                 $tpl->set( 'specialpageattributes', $attrs );
335                         }
336                 }
337
338                 $newtalks = $this->getNewtalks();
339
340                 wfProfileOut( __METHOD__ . '-stuff2' );
341
342                 wfProfileIn( __METHOD__ . '-stuff3' );
343                 $tpl->setRef( 'newtalk', $newtalks );
344                 $tpl->setRef( 'skin', $this );
345                 $tpl->set( 'logo', $this->logoText() );
346                 if ( $out->isArticle() and ( !isset( $oldid ) or isset( $diff ) ) and
347                         $wgArticle and 0 != $wgArticle->getID() ){
348                         if ( !$wgDisableCounters ) {
349                                 $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
350                                 if ( $viewcount ) {
351                                         $tpl->set( 'viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) );
352                                 } else {
353                                         $tpl->set( 'viewcount', false );
354                                 }
355                         } else {
356                                 $tpl->set( 'viewcount', false );
357                         }
358
359                         if( $wgPageShowWatchingUsers ) {
360                                 $dbr = wfGetDB( DB_SLAVE );
361                                 $res = $dbr->select( 'watchlist',
362                                         array( 'COUNT(*) AS n' ),
363                                         array( 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ), 'wl_namespace' => $this->mTitle->getNamespace() ),
364                                         __METHOD__
365                                 );
366                                 $x = $dbr->fetchObject( $res );
367                                 $numberofwatchingusers = $x->n;
368                                 if( $numberofwatchingusers > 0 ) {
369                                         $tpl->set( 'numberofwatchingusers',
370                                                 wfMsgExt( 'number_of_watching_users_pageview', array( 'parseinline' ),
371                                                 $wgLang->formatNum( $numberofwatchingusers ) )
372                                         );
373                                 } else {
374                                         $tpl->set( 'numberofwatchingusers', false );
375                                 }
376                         } else {
377                                 $tpl->set( 'numberofwatchingusers', false );
378                         }
379
380                         $tpl->set( 'copyright', $this->getCopyright() );
381
382                         $this->credits = false;
383
384                         if( $wgMaxCredits != 0 ){
385                                 $this->credits = Credits::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
386                         } else {
387                                 $tpl->set( 'lastmod', $this->lastModified() );
388                         }
389
390                         $tpl->setRef( 'credits', $this->credits );
391
392                 } elseif ( isset( $oldid ) && !isset( $diff ) ) {
393                         $tpl->set( 'copyright', $this->getCopyright() );
394                         $tpl->set( 'viewcount', false );
395                         $tpl->set( 'lastmod', false );
396                         $tpl->set( 'credits', false );
397                         $tpl->set( 'numberofwatchingusers', false );
398                 } else {
399                         $tpl->set( 'copyright', false );
400                         $tpl->set( 'viewcount', false );
401                         $tpl->set( 'lastmod', false );
402                         $tpl->set( 'credits', false );
403                         $tpl->set( 'numberofwatchingusers', false );
404                 }
405                 wfProfileOut( __METHOD__ . '-stuff3' );
406
407                 wfProfileIn( __METHOD__ . '-stuff4' );
408                 $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
409                 $tpl->set( 'poweredbyico', $this->getPoweredBy() );
410                 $tpl->set( 'disclaimer', $this->disclaimerLink() );
411                 $tpl->set( 'privacy', $this->privacyLink() );
412                 $tpl->set( 'about', $this->aboutLink() );
413
414                 $tpl->set( 'footerlinks', array(
415                         'info' => array(
416                                 'lastmod',
417                                 'viewcount',
418                                 'numberofwatchingusers',
419                                 'credits',
420                                 'copyright',
421                         ),
422                         'places' => array(
423                                 'privacy',
424                                 'about',
425                                 'disclaimer',
426                         ),
427                 ) );
428                 
429                 global $wgFooterIcons;
430                 $tpl->set( 'footericons', $wgFooterIcons );
431                 foreach ( $tpl->data["footericons"] as $footerIconsKey => &$footerIconsBlock ) {
432                         if ( count($footerIconsBlock) > 0 ) {
433                                 foreach ( $footerIconsBlock as &$footerIcon ) {
434                                         if ( isset($footerIcon["src"]) ) {
435                                                 if ( !isset($footerIcon["width"]) ) $footerIcon["width"] = 88;
436                                                 if ( !isset($footerIcon["height"]) ) $footerIcon["height"] = 31;
437                                         }
438                                 }
439                         } else {
440                                 unset($tpl->data["footericons"][$footerIconsKey]);
441                         }
442                 }
443
444                 if ( $wgDebugComments ) {
445                         $tpl->setRef( 'debug', $out->mDebugtext );
446                 } else {
447                         $tpl->set( 'debug', '' );
448                 }
449
450                 $tpl->set( 'reporttime', wfReportTime() );
451                 $tpl->set( 'sitenotice', wfGetSiteNotice() );
452                 $tpl->set( 'bottomscripts', $this->bottomScripts( $out ) );
453
454                 $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
455                 global $wgBetterDirectionality;
456                 if ( $wgBetterDirectionality ) {
457                         $realBodyAttribs = array( 'lang' => $wgLanguageCode, 'dir' => $wgContLang->getDir() );
458                         $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
459                 }
460                 $out->mBodytext .= $printfooter . $this->generateDebugHTML();
461                 $tpl->setRef( 'bodytext', $out->mBodytext );
462
463                 # Language links
464                 $language_urls = array();
465
466                 if ( !$wgHideInterlanguageLinks ) {
467                         foreach( $out->getLanguageLinks() as $l ) {
468                                 $tmp = explode( ':', $l, 2 );
469                                 $class = 'interwiki-' . $tmp[0];
470                                 unset( $tmp );
471                                 $nt = Title::newFromText( $l );
472                                 if ( $nt ) {
473                                         $language_urls[] = array(
474                                                 'href' => $nt->getFullURL(),
475                                                 'text' => ( $wgContLang->getLanguageName( $nt->getInterwiki() ) != '' ?
476                                                                         $wgContLang->getLanguageName( $nt->getInterwiki() ) : $l ),
477                                                 'title' => $nt->getText(),
478                                                 'class' => $class
479                                         );
480                                 }
481                         }
482                 }
483                 if( count( $language_urls ) ) {
484                         $tpl->setRef( 'language_urls', $language_urls );
485                 } else {
486                         $tpl->set( 'language_urls', false );
487                 }
488                 wfProfileOut( __METHOD__ . '-stuff4' );
489
490                 wfProfileIn( __METHOD__ . '-stuff5' );
491                 # Personal toolbar
492                 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
493                 $content_actions = $this->buildContentActionUrls();
494                 $tpl->setRef( 'content_actions', $content_actions );
495
496                 $tpl->set( 'sidebar', $this->buildSidebar() );
497                 $tpl->set( 'nav_urls', $this->buildNavUrls() );
498
499                 // Set the head scripts near the end, in case the above actions resulted in added scripts
500                 if ( $this->useHeadElement ) {
501                         $tpl->set( 'headelement', $out->headElement( $this ) );
502                 } else {
503                         $tpl->set( 'headscripts', $out->getScript() );
504                 }
505
506                 // original version by hansm
507                 if( !wfRunHooks( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ) ) ) {
508                         wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
509                 }
510
511                 // allow extensions adding stuff after the page content.
512                 // See Skin::afterContentHook() for further documentation.
513                 $tpl->set( 'dataAfterContent', $this->afterContentHook() );
514                 wfProfileOut( __METHOD__ . '-stuff5' );
515
516                 // execute template
517                 wfProfileIn( __METHOD__ . '-execute' );
518                 $res = $tpl->execute();
519                 wfProfileOut( __METHOD__ . '-execute' );
520
521                 // result may be an error
522                 $this->printOrError( $res );
523                 wfProfileOut( __METHOD__ );
524         }
525
526         /**
527          * Output the string, or print error message if it's
528          * an error object of the appropriate type.
529          * For the base class, assume strings all around.
530          *
531          * @param $str Mixed
532          * @private
533          */
534         function printOrError( $str ) {
535                 echo $str;
536         }
537
538         /**
539          * build array of urls for personal toolbar
540          * @return array
541          * @private
542          */
543         function buildPersonalUrls() {
544                 global $wgOut, $wgRequest;
545
546                 $title = $wgOut->getTitle();
547                 $pageurl = $title->getLocalURL();
548                 wfProfileIn( __METHOD__ );
549
550                 /* set up the default links for the personal toolbar */
551                 $personal_urls = array();
552
553                 # Due to bug 32276, if a user does not have read permissions, 
554                 # $wgOut->getTitle() will just give Special:Badtitle, which is 
555                 # not especially useful as a returnto parameter. Use the title 
556                 # from the request instead, if there was one.
557                 $page = Title::newFromURL( $wgRequest->getVal( 'title', '' ) );
558                 $page = $wgRequest->getVal( 'returnto', $page );
559                 $returnto = '';
560                 if( strval( $page ) !== '' ) {
561                         $returnto = "returnto=$page";
562                         $query = $wgRequest->getVal( 'returntoquery', $this->thisquery );
563                         if( $query != '' ) {
564                                 $returnto .= "&returntoquery=$query";
565                         }
566                 }
567
568                 if( $this->loggedin ) {
569                         $personal_urls['userpage'] = array(
570                                 'text' => $this->username,
571                                 'href' => &$this->userpageUrlDetails['href'],
572                                 'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
573                                 'active' => ( $this->userpageUrlDetails['href'] == $pageurl )
574                         );
575                         $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
576                         $personal_urls['mytalk'] = array(
577                                 'text' => wfMsg( 'mytalk' ),
578                                 'href' => &$usertalkUrlDetails['href'],
579                                 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
580                                 'active' => ( $usertalkUrlDetails['href'] == $pageurl )
581                         );
582                         $href = self::makeSpecialUrl( 'Preferences' );
583                         $personal_urls['preferences'] = array(
584                                 'text' => wfMsg( 'mypreferences' ),
585                                 'href' => $href,
586                                 'active' => ( $href == $pageurl )
587                         );
588                         $href = self::makeSpecialUrl( 'Watchlist' );
589                         $personal_urls['watchlist'] = array(
590                                 'text' => wfMsg( 'mywatchlist' ),
591                                 'href' => $href,
592                                 'active' => ( $href == $pageurl )
593                         );
594
595                         # We need to do an explicit check for Special:Contributions, as we
596                         # have to match both the title, and the target (which could come
597                         # from request values or be specified in "sub page" form. The plot
598                         # thickens, because $wgTitle is altered for special pages, so doesn't
599                         # contain the original alias-with-subpage.
600                         $origTitle = Title::newFromText( $wgRequest->getText( 'title' ) );
601                         if( $origTitle instanceof Title && $origTitle->getNamespace() == NS_SPECIAL ) {
602                                 list( $spName, $spPar ) =
603                                         SpecialPage::resolveAliasWithSubpage( $origTitle->getText() );
604                                 $active = $spName == 'Contributions'
605                                         && ( ( $spPar && $spPar == $this->username )
606                                                 || $wgRequest->getText( 'target' ) == $this->username );
607                         } else {
608                                 $active = false;
609                         }
610
611                         $href = self::makeSpecialUrlSubpage( 'Contributions', $this->username );
612                         $personal_urls['mycontris'] = array(
613                                 'text' => wfMsg( 'mycontris' ),
614                                 'href' => $href,
615                                 'active' => $active
616                         );
617                         $personal_urls['logout'] = array(
618                                 'text' => wfMsg( 'userlogout' ),
619                                 'href' => self::makeSpecialUrl( 'Userlogout',
620                                         // userlogout link must always contain an & character, otherwise we might not be able
621                                         // to detect a buggy precaching proxy (bug 17790)
622                                         $title->isSpecial( 'Preferences' ) ? 'noreturnto' : $returnto
623                                 ),
624                                 'active' => false
625                         );
626                 } else {
627                         global $wgUser;
628                         $loginlink = $wgUser->isAllowed( 'createaccount' )
629                                 ? 'nav-login-createaccount'
630                                 : 'login';
631
632                         # anonlogin & login are the same
633                         $login_url = array(
634                                 'text' => wfMsg( $loginlink ),
635                                 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
636                                 'active' => $title->isSpecial( 'Userlogin' )
637                         );
638                         global $wgProto, $wgSecureLogin;
639                         if( $wgProto === 'http' && $wgSecureLogin ) {
640                                 $title = SpecialPage::getTitleFor( 'Userlogin' );
641                                 $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL() );
642                                 $login_url['href']  = $https_url;
643                                 $login_url['class'] = 'link-https';  # FIXME class depends on skin
644                         }
645
646                         if( $this->showIPinHeader() ) {
647                                 $href = &$this->userpageUrlDetails['href'];
648                                 $personal_urls['anonuserpage'] = array(
649                                         'text' => $this->username,
650                                         'href' => $href,
651                                         'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
652                                         'active' => ( $pageurl == $href )
653                                 );
654                                 $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
655                                 $href = &$usertalkUrlDetails['href'];
656                                 $personal_urls['anontalk'] = array(
657                                         'text' => wfMsg( 'anontalk' ),
658                                         'href' => $href,
659                                         'class' => $usertalkUrlDetails['exists'] ? false : 'new',
660                                         'active' => ( $pageurl == $href )
661                                 );
662                                 $personal_urls['anonlogin'] = $login_url;
663                         } else {
664                                 $personal_urls['login'] = $login_url;
665                         }
666                 }
667
668                 wfRunHooks( 'PersonalUrls', array( &$personal_urls, &$title ) );
669                 wfProfileOut( __METHOD__ );
670                 return $personal_urls;
671         }
672
673         function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
674                 $classes = array();
675                 if( $selected ) {
676                         $classes[] = 'selected';
677                 }
678                 if( $checkEdit && !$title->isKnown() ) {
679                         $classes[] = 'new';
680                         $query = 'action=edit&redlink=1';
681                 }
682
683                 $text = wfMsg( $message );
684                 if ( wfEmptyMsg( $message, $text ) ) {
685                         global $wgContLang;
686                         $text = $wgContLang->getFormattedNsText( MWNamespace::getSubject( $title->getNamespace() ) );
687                 }
688
689                 $result = array();
690                 if( !wfRunHooks( 'SkinTemplateTabAction', array( &$this,
691                                 $title, $message, $selected, $checkEdit,
692                                 &$classes, &$query, &$text, &$result ) ) ) {
693                         return $result;
694                 }
695
696                 return array(
697                         'class' => implode( ' ', $classes ),
698                         'text' => $text,
699                         'href' => $title->getLocalUrl( $query ) );
700         }
701
702         function makeTalkUrlDetails( $name, $urlaction = '' ) {
703                 $title = Title::newFromText( $name );
704                 if( !is_object( $title ) ) {
705                         throw new MWException( __METHOD__ . " given invalid pagename $name" );
706                 }
707                 $title = $title->getTalkPage();
708                 self::checkTitle( $title, $name );
709                 return array(
710                         'href' => $title->getLocalURL( $urlaction ),
711                         'exists' => $title->getArticleID() != 0,
712                 );
713         }
714
715         function makeArticleUrlDetails( $name, $urlaction = '' ) {
716                 $title = Title::newFromText( $name );
717                 $title= $title->getSubjectPage();
718                 self::checkTitle( $title, $name );
719                 return array(
720                         'href' => $title->getLocalURL( $urlaction ),
721                         'exists' => $title->getArticleID() != 0,
722                 );
723         }
724
725         /**
726          * an array of edit links by default used for the tabs
727          * @return array
728          * @private
729          */
730         function buildContentActionUrls() {
731                 global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle;
732
733                 wfProfileIn( __METHOD__ );
734
735                 $action = $wgRequest->getVal( 'action', 'view' );
736                 $section = $wgRequest->getVal( 'section' );
737                 $content_actions = array();
738                 $userCanRead = $this->mTitle->userCanRead();
739
740                 $prevent_active_tabs = false;
741                 wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$prevent_active_tabs ) );
742
743                 if( $this->iscontent ) {
744                         $subjpage = $this->mTitle->getSubjectPage();
745                         $talkpage = $this->mTitle->getTalkPage();
746
747                         $nskey = $this->mTitle->getNamespaceKey();
748                         $content_actions[$nskey] = $this->tabAction(
749                                 $subjpage,
750                                 $nskey,
751                                 !$this->mTitle->isTalkPage() && !$prevent_active_tabs,
752                                 '', $userCanRead
753                         );
754
755                         $content_actions['talk'] = $this->tabAction(
756                                 $talkpage,
757                                 'talk',
758                                 $this->mTitle->isTalkPage() && !$prevent_active_tabs,
759                                 '',
760                                 $userCanRead
761                         );
762
763                         wfProfileIn( __METHOD__ . '-edit' );
764                         if ( $userCanRead && $this->mTitle->quickUserCan( 'edit' ) && ( $this->mTitle->exists() || $this->mTitle->quickUserCan( 'create' ) ) ) {
765                                 $istalk = $this->mTitle->isTalkPage();
766                                 $istalkclass = $istalk?' istalk':'';
767                                 $content_actions['edit'] = array(
768                                         'class' => ( ( ( $action == 'edit' or $action == 'submit' ) and $section != 'new' ) ? 'selected' : '' ) . $istalkclass,
769                                         'text' => ( $this->mTitle->exists() || ( $this->mTitle->getNamespace() == NS_MEDIAWIKI && !wfEmptyMsg( $this->mTitle->getText() ) ) )
770                                                 ? wfMsg( 'edit' )
771                                                 : wfMsg( 'create' ),
772                                         'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
773                                 );
774
775                                 // adds new section link if page is a current revision of a talk page or
776                                 if ( ( $wgArticle && $wgArticle->isCurrent() && $istalk ) || $wgOut->showNewSectionLink() ) {
777                                         if ( !$wgOut->forceHideNewSectionLink() ) {
778                                                 $content_actions['addsection'] = array(
779                                                         'class' => $section == 'new' ? 'selected' : false,
780                                                         'text' => wfMsg( 'addsection' ),
781                                                         'href' => $this->mTitle->getLocalUrl( 'action=edit&section=new' )
782                                                 );
783                                         }
784                                 }
785                         } elseif ( $this->mTitle->hasSourceText() && $userCanRead ) {
786                                 $content_actions['viewsource'] = array(
787                                         'class' => ($action == 'edit') ? 'selected' : false,
788                                         'text' => wfMsg( 'viewsource' ),
789                                         'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
790                                 );
791                         }
792                         wfProfileOut( __METHOD__ . '-edit' );
793
794                         wfProfileIn( __METHOD__ . '-live' );
795                         if ( $this->mTitle->exists() && $userCanRead ) {
796
797                                 $content_actions['history'] = array(
798                                         'class' => ($action == 'history') ? 'selected' : false,
799                                         'text' => wfMsg( 'history_short' ),
800                                         'href' => $this->mTitle->getLocalUrl( 'action=history' ),
801                                         'rel' => 'archives',
802                                 );
803
804                                 if( $wgUser->isAllowed( 'delete' ) ) {
805                                         $content_actions['delete'] = array(
806                                                 'class' => ($action == 'delete') ? 'selected' : false,
807                                                 'text' => wfMsg( 'delete' ),
808                                                 'href' => $this->mTitle->getLocalUrl( 'action=delete' )
809                                         );
810                                 }
811                                 if ( $this->mTitle->quickUserCan( 'move' ) ) {
812                                         $moveTitle = SpecialPage::getTitleFor( 'Movepage', $this->thispage );
813                                         $content_actions['move'] = array(
814                                                 'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false,
815                                                 'text' => wfMsg( 'move' ),
816                                                 'href' => $moveTitle->getLocalUrl()
817                                         );
818                                 }
819
820                                 if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
821                                         if( !$this->mTitle->isProtected() ){
822                                                 $content_actions['protect'] = array(
823                                                         'class' => ($action == 'protect') ? 'selected' : false,
824                                                         'text' => wfMsg( 'protect' ),
825                                                         'href' => $this->mTitle->getLocalUrl( 'action=protect' )
826                                                 );
827
828                                         } else {
829                                                 $content_actions['unprotect'] = array(
830                                                         'class' => ($action == 'unprotect') ? 'selected' : false,
831                                                         'text' => wfMsg( 'unprotect' ),
832                                                         'href' => $this->mTitle->getLocalUrl( 'action=unprotect' )
833                                                 );
834                                         }
835                                 }
836                         } else {
837                                 //article doesn't exist or is deleted
838                                 if( $wgUser->isAllowed( 'deletedhistory' ) && $wgUser->isAllowed( 'deletedtext' ) ) {
839                                         $n = $this->mTitle->isDeleted();
840                                         if( $n ) {
841                                                 $undelTitle = SpecialPage::getTitleFor( 'Undelete' );
842                                                 $content_actions['undelete'] = array(
843                                                         'class' => false,
844                                                         'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $wgLang->formatNum( $n ) ),
845                                                         'href' => $undelTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
846                                                         #'href' => self::makeSpecialUrl( "Undelete/$this->thispage" )
847                                                 );
848                                         }
849                                 }
850
851                                 if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
852                                         if( !$this->mTitle->getRestrictions( 'create' ) ) {
853                                                 $content_actions['protect'] = array(
854                                                         'class' => ($action == 'protect') ? 'selected' : false,
855                                                         'text' => wfMsg( 'protect' ),
856                                                         'href' => $this->mTitle->getLocalUrl( 'action=protect' )
857                                                 );
858
859                                         } else {
860                                                 $content_actions['unprotect'] = array(
861                                                         'class' => ($action == 'unprotect') ? 'selected' : false,
862                                                         'text' => wfMsg( 'unprotect' ),
863                                                         'href' => $this->mTitle->getLocalUrl( 'action=unprotect' )
864                                                 );
865                                         }
866                                 }
867                         }
868
869                         wfProfileOut( __METHOD__ . '-live' );
870
871                         if( $this->loggedin ) {
872                                 if( !$this->mTitle->userIsWatching()) {
873                                         $content_actions['watch'] = array(
874                                                 'class' => ($action == 'watch' or $action == 'unwatch') ? 'selected' : false,
875                                                 'text' => wfMsg( 'watch' ),
876                                                 'href' => $this->mTitle->getLocalUrl( 'action=watch' )
877                                         );
878                                 } else {
879                                         $content_actions['unwatch'] = array(
880                                                 'class' => ($action == 'unwatch' or $action == 'watch') ? 'selected' : false,
881                                                 'text' => wfMsg( 'unwatch' ),
882                                                 'href' => $this->mTitle->getLocalUrl( 'action=unwatch' )
883                                         );
884                                 }
885                         }
886
887
888                         wfRunHooks( 'SkinTemplateTabs', array( $this, &$content_actions ) );
889                 } else {
890                         /* show special page tab */
891
892                         $content_actions[$this->mTitle->getNamespaceKey()] = array(
893                                 'class' => 'selected',
894                                 'text' => wfMsg('nstab-special'),
895                                 'href' => $wgRequest->getRequestURL(), // @bug 2457, 2510
896                         );
897
898                         wfRunHooks( 'SkinTemplateBuildContentActionUrlsAfterSpecialPage', array( &$this, &$content_actions ) );
899                 }
900
901                 /* show links to different language variants */
902                 global $wgDisableLangConversion;
903                 $variants = $wgContLang->getVariants();
904                 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
905                         $preferred = $wgContLang->getPreferredVariant();
906                         $vcount=0;
907                         foreach( $variants as $code ) {
908                                 $varname = $wgContLang->getVariantname( $code );
909                                 if( $varname == 'disable' )
910                                         continue;
911                                 $selected = ( $code == $preferred )? 'selected' : false;
912                                 $content_actions['varlang-' . $vcount] = array(
913                                         'class' => $selected,
914                                         'text' => $varname,
915                                         'href' => $this->mTitle->getLocalURL( '', $code )
916                                 );
917                                 $vcount ++;
918                         }
919                 }
920
921                 wfRunHooks( 'SkinTemplateContentActions', array( &$content_actions ) );
922
923                 wfProfileOut( __METHOD__ );
924                 return $content_actions;
925         }
926
927         /**
928          * build array of common navigation links
929          * @return array
930          * @private
931          */
932         function buildNavUrls() {
933                 global $wgUseTrackbacks, $wgOut, $wgUser, $wgRequest;
934                 global $wgUploadNavigationUrl;
935
936                 wfProfileIn( __METHOD__ );
937
938                 $action = $wgRequest->getVal( 'action', 'view' );
939
940                 $nav_urls = array();
941                 $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
942                 if( $wgUploadNavigationUrl ) {
943                         $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
944                 } elseif( UploadBase::isEnabled() && UploadBase::isAllowed( $wgUser ) === true ) {
945                         $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
946                 } else {
947                         $nav_urls['upload'] = false;
948                 }
949                 $nav_urls['specialpages'] = array( 'href' => self::makeSpecialUrl( 'Specialpages' ) );
950
951                 // default permalink to being off, will override it as required below.
952                 $nav_urls['permalink'] = false;
953
954                 // A print stylesheet is attached to all pages, but nobody ever
955                 // figures that out. :)  Add a link...
956                 if( $this->iscontent && ( $action == 'view' || $action == 'purge' ) ) {
957                         if ( !$wgOut->isPrintable() ) {
958                                 $nav_urls['print'] = array(
959                                         'text' => wfMsg( 'printableversion' ),
960                                         'href' => $wgRequest->appendQuery( 'printable=yes' )
961                                 );
962                         }
963
964                         // Also add a "permalink" while we're at it
965                         if ( $this->mRevisionId ) {
966                                 $nav_urls['permalink'] = array(
967                                         'text' => wfMsg( 'permalink' ),
968                                         'href' => $wgOut->getTitle()->getLocalURL( "oldid=$this->mRevisionId" )
969                                 );
970                         }
971
972                         // Copy in case this undocumented, shady hook tries to mess with internals
973                         $revid = $this->mRevisionId;
974                         wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( &$this, &$nav_urls, &$revid, &$revid ) );
975                 }
976
977                 if( $this->mTitle->getNamespace() != NS_SPECIAL ) {
978                         $wlhTitle = SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage );
979                         $nav_urls['whatlinkshere'] = array(
980                                 'href' => $wlhTitle->getLocalUrl()
981                         );
982                         if( $this->mTitle->getArticleId() ) {
983                                 $rclTitle = SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage );
984                                 $nav_urls['recentchangeslinked'] = array(
985                                         'href' => $rclTitle->getLocalUrl()
986                                 );
987                         } else {
988                                 $nav_urls['recentchangeslinked'] = false;
989                         }
990                         if( $wgUseTrackbacks )
991                                 $nav_urls['trackbacklink'] = array(
992                                         'href' => $wgOut->getTitle()->trackbackURL()
993                                 );
994                 }
995
996                 if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {
997                         $rootUser = strtok( $this->mTitle->getText(), '/' );
998                         $id = User::idFromName( $rootUser );
999                         $ip = User::isIP( $rootUser );
1000                 } else {
1001                         $id = 0;
1002                         $ip = false;
1003                 }
1004
1005                 if( $id || $ip ) { # both anons and non-anons have contribs list
1006                         $nav_urls['contributions'] = array(
1007                                 'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser )
1008                         );
1009
1010                         if( $id ) {
1011                                 $logPage = SpecialPage::getTitleFor( 'Log' );
1012                                 $nav_urls['log'] = array(
1013                                         'href' => $logPage->getLocalUrl(
1014                                                 array(
1015                                                         'user' => $rootUser
1016                                                 )
1017                                         )
1018                                 );
1019                         } else {
1020                                 $nav_urls['log'] = false;
1021                         }
1022
1023                         if ( $wgUser->isAllowed( 'block' ) ) {
1024                                 $nav_urls['blockip'] = array(
1025                                         'href' => self::makeSpecialUrlSubpage( 'Blockip', $rootUser )
1026                                 );
1027                         } else {
1028                                 $nav_urls['blockip'] = false;
1029                         }
1030                 } else {
1031                         $nav_urls['contributions'] = false;
1032                         $nav_urls['log'] = false;
1033                         $nav_urls['blockip'] = false;
1034                 }
1035                 $nav_urls['emailuser'] = false;
1036                 if( $this->showEmailUser( $id ) ) {
1037                         $nav_urls['emailuser'] = array(
1038                                 'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser )
1039                         );
1040                 }
1041                 wfProfileOut( __METHOD__ );
1042                 return $nav_urls;
1043         }
1044
1045         /**
1046          * Generate strings used for xml 'id' names
1047          * @return string
1048          * @private
1049          */
1050         function getNameSpaceKey() {
1051                 return $this->mTitle->getNamespaceKey();
1052         }
1053
1054         /**
1055          * @private
1056          */
1057         function setupUserJs( $allowUserJs ) {
1058                 global $wgRequest, $wgJsMimeType;
1059                 wfProfileIn( __METHOD__ );
1060
1061                 $action = $wgRequest->getVal( 'action', 'view' );
1062
1063                 if( $allowUserJs && $this->loggedin ) {
1064                         if( $this->mTitle->isJsSubpage() and $this->userCanPreview( $action ) ) {
1065                                 # XXX: additional security check/prompt?
1066                                 $this->userjsprev = '/*<![CDATA[*/ ' . $wgRequest->getText( 'wpTextbox1' ) . ' /*]]>*/';
1067                         } else {
1068                                 $this->userjs = self::makeUrl( $this->userpage . '/' . $this->skinname . '.js', 'action=raw&ctype=' . $wgJsMimeType );
1069                         }
1070                 }
1071                 wfProfileOut( __METHOD__ );
1072         }
1073
1074         /**
1075          * Code for extensions to hook into to provide per-page CSS, see
1076          * extensions/PageCSS/PageCSS.php for an implementation of this.
1077          *
1078          * @private
1079          */
1080         function setupPageCss() {
1081                 wfProfileIn( __METHOD__ );
1082                 $out = false;
1083                 wfRunHooks( 'SkinTemplateSetupPageCss', array( &$out ) );
1084                 wfProfileOut( __METHOD__ );
1085                 return $out;
1086         }
1087
1088         public function commonPrintStylesheet() {
1089                 return false;
1090         }
1091 }
1092
1093 /**
1094  * Generic wrapper for template functions, with interface
1095  * compatible with what we use of PHPTAL 0.7.
1096  * @ingroup Skins
1097  */
1098 abstract class QuickTemplate {
1099         /**
1100          * Constructor
1101          */
1102         public function QuickTemplate() {
1103                 $this->data = array();
1104                 $this->translator = new MediaWiki_I18N();
1105         }
1106
1107         /**
1108          * Sets the value $value to $name
1109          * @param $name
1110          * @param $value
1111          */
1112         public function set( $name, $value ) {
1113                 $this->data[$name] = $value;
1114         }
1115
1116         /**
1117          * @param $name
1118          * @param $value
1119          */
1120         public function setRef( $name, &$value ) {
1121                 $this->data[$name] =& $value;
1122         }
1123
1124         /**
1125          * @param $t
1126          */
1127         public function setTranslator( &$t ) {
1128                 $this->translator = &$t;
1129         }
1130
1131         /**
1132          * Main function, used by classes that subclass QuickTemplate
1133          * to show the actual HTML output
1134          */
1135         abstract public function execute();
1136
1137         /**
1138          * @private
1139          */
1140         function text( $str ) {
1141                 echo htmlspecialchars( $this->data[$str] );
1142         }
1143
1144         /**
1145          * @private
1146          */
1147         function jstext( $str ) {
1148                 echo Xml::escapeJsString( $this->data[$str] );
1149         }
1150
1151         /**
1152          * @private
1153          */
1154         function html( $str ) {
1155                 echo $this->data[$str];
1156         }
1157
1158         /**
1159          * @private
1160          */
1161         function msg( $str ) {
1162                 echo htmlspecialchars( $this->translator->translate( $str ) );
1163         }
1164
1165         /**
1166          * @private
1167          */
1168         function msgHtml( $str ) {
1169                 echo $this->translator->translate( $str );
1170         }
1171
1172         /**
1173          * An ugly, ugly hack.
1174          * @private
1175          */
1176         function msgWiki( $str ) {
1177                 global $wgParser, $wgOut;
1178
1179                 $text = $this->translator->translate( $str );
1180                 $parserOutput = $wgParser->parse( $text, $wgOut->getTitle(),
1181                         $wgOut->parserOptions(), true );
1182                 echo $parserOutput->getText();
1183         }
1184
1185         /**
1186          * @private
1187          */
1188         function haveData( $str ) {
1189                 return isset( $this->data[$str] );
1190         }
1191
1192         /**
1193          * @private
1194          */
1195         function haveMsg( $str ) {
1196                 $msg = $this->translator->translate( $str );
1197                 return ( $msg != '-' ) && ( $msg != '' ); # ????
1198         }
1199 }