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