2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation; either version 2 of the License, or
5 # (at your option) any later version.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License along
13 # with this program; if not, write to the Free Software Foundation, Inc.,
14 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 # http://www.gnu.org/copyleft/gpl.html
18 * Generic PHPTal (http://phptal.sourceforge.net/) skin
19 * Based on Brion's smarty skin
20 * Copyright (C) Gabriel Wicke -- http://www.aulinx.de/
22 * Todo: Needs some serious refactoring into functions that correspond
23 * to the computations individual esi snippets need. Most importantly no body
24 * parsing for most of those of course.
26 * Set this in LocalSettings to enable phptal:
27 * set_include_path(get_include_path() . ":" . $IP.'/PHPTAL-NP-0.7.0/libs');
28 * $wgUsePHPTal = true;
34 * This is not a valid entry point, perform no further processing unless
35 * MEDIAWIKI is defined
37 if( defined( 'MEDIAWIKI' ) ) {
39 require_once 'GlobalFunctions.php';
41 if( version_compare( phpversion(), "5.0", "lt" ) ) {
42 define( 'OLD_PHPTAL', true );
44 require_once $IP.'/PHPTAL-NP-0.7.0/libs/PHPTAL.php';
46 define( 'NEW_PHPTAL', true );
47 # For now, PHPTAL 1.0.x must be installed via PEAR in system dir.
48 require_once 'PEAR.php';
49 require_once 'PHPTAL.php';
56 // PHPTAL 1.0 no longer has the PHPTAL_I18N stub class.
57 //class MediaWiki_I18N extends PHPTAL_I18N {
58 class MediaWiki_I18N
{
59 var $_context = array();
61 function set($varName, $value) {
62 $this->_context
[$varName] = $value;
65 function translate($value) {
66 // Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of 2004-10-23
67 $value = preg_replace( '/^string:/', '', $value );
69 $value = wfMsg( $value );
70 // interpolate variables
71 while (preg_match('/\$([0-9]*?)/sm', $value, $m)) {
72 list($src, $var) = $m;
74 $varValue = $this->_context
[$var];
76 $value = str_replace($src, $varValue, $value);
85 class SkinPHPTal
extends Skin
{
91 * Name of our skin, set in initPage()
92 * It probably need to be all lower case.
97 * Stylesheets set to use
98 * Sub directory in ./skins/ where various stylesheets are located
103 * PHPTal template to be used.
104 * '.pt' will be automaticly added to it on PHPTAL object creation
111 function initPage( &$out ) {
112 parent
::initPage( $out );
113 $this->skinname
= 'monobook';
114 $this->stylename
= 'monobook';
115 $this->template
= 'MonoBook';
119 * If using PHPTAL 0.7 on PHP 4.x, return a PHPTAL template object.
120 * If using PHPTAL 1.0 on PHP 5.x, return a bridge object.
124 function &setupTemplate( $file, $repository=false, $cache_dir=false ) {
125 if( defined( 'NEW_PHPTAL' ) ) {
126 return new PHPTAL_version_bridge( $file, $repository, $cache_dir );
128 return new PHPTAL( $file, $repository, $cache_dir );
133 * initialize various variables and generate the template
135 function outputPage( &$out ) {
136 global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut;
137 global $wgScript, $wgStylePath, $wgLanguageCode, $wgContLanguageCode, $wgUseNewInterlanguage;
138 global $wgMimeType, $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest;
139 global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgSiteNotice;
140 global $wgMaxCredits, $wgShowCreditsIfMax;
142 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
144 $this->initPage( $out );
145 $tpl =& $this->setupTemplate( $this->template
. '.pt', 'skins' );
147 #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
148 $tpl->setTranslator(new MediaWiki_I18N());
151 $this->thispage
= $wgTitle->getPrefixedDbKey();
152 $this->thisurl
= $wgTitle->getPrefixedURL();
153 $this->loggedin
= $wgUser->getID() != 0;
154 $this->iscontent
= ($wgTitle->getNamespace() != Namespace::getSpecial() );
155 $this->iseditable
= ($this->iscontent
and !($action == 'edit' or $action == 'submit'));
156 $this->username
= $wgUser->getName();
157 $this->userpage
= $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
158 $this->userpageUrlDetails
= $this->makeUrlDetails($this->userpage
);
160 $this->usercss
= $this->userjs
= $this->userjsprev
= false;
161 $this->setupUserCssJs();
163 $this->titletxt
= $wgTitle->getPrefixedText();
165 $tpl->set( 'title', $wgOut->getPageTitle() );
166 $tpl->set( 'pagetitle', $wgOut->getHTMLTitle() );
168 $tpl->setRef( "thispage", $this->thispage
);
169 $subpagestr = $this->subPageSubtitle();
171 'subtitle', !empty($subpagestr)?
172 '<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle():
175 $undelete = $this->getUndeleteLink();
177 "undelete", !empty($undelete)?
178 '<span class="subpages">'.$undelete.'</span>':
182 $tpl->set( 'catlinks', $this->getCategories());
183 if( $wgOut->isSyndicated() ) {
185 foreach( $wgFeedClasses as $format => $class ) {
186 $feeds[$format] = array(
188 'href' => $wgRequest->appendQuery( "feed=$format" ),
189 'ttip' => wfMsg('tooltip-'.$format)
192 $tpl->setRef( 'feeds', $feeds );
194 $tpl->set( 'feeds', false );
196 $tpl->setRef( 'mimetype', $wgMimeType );
197 $tpl->setRef( 'charset', $wgOutputEncoding );
198 $tpl->set( 'headlinks', $out->getHeadLinks() );
199 $tpl->setRef( 'wgScript', $wgScript );
200 $tpl->setRef( 'skinname', $this->skinname
);
201 $tpl->setRef( 'stylename', $this->stylename
);
202 $tpl->setRef( 'loggedin', $this->loggedin
);
203 $tpl->set('nsclass', 'ns-'.$wgTitle->getNamespace());
204 $tpl->set('notspecialpage', $wgTitle->getNamespace() != NS_SPECIAL
);
205 /* XXX currently unused, might get useful later
206 $tpl->set( "editable", ($wgTitle->getNamespace() != NS_SPECIAL ) );
207 $tpl->set( "exists", $wgTitle->getArticleID() != 0 );
208 $tpl->set( "watch", $wgTitle->userIsWatching() ? "unwatch" : "watch" );
209 $tpl->set( "protect", count($wgTitle->getRestrictions()) ? "unprotect" : "protect" );
210 $tpl->set( "helppage", wfMsg('helppage'));
212 $tpl->set( 'searchaction', $this->escapeSearchLink() );
213 $tpl->setRef( 'stylepath', $wgStylePath );
214 $tpl->setRef( 'logopath', $wgLogo );
215 $tpl->setRef( "lang", $wgContLanguageCode );
216 $tpl->set( 'dir', $wgContLang->isRTL() ?
"rtl" : "ltr" );
217 $tpl->set( 'rtl', $wgContLang->isRTL() );
218 $tpl->set( 'langname', $wgContLang->getLanguageName( $wgContLanguageCode ) );
219 $tpl->setRef( 'username', $this->username
);
220 $tpl->setRef( 'userpage', $this->userpage
);
221 $tpl->setRef( 'userpageurl', $this->userpageUrlDetails
['href']);
222 $tpl->setRef( 'usercss', $this->usercss
);
223 $tpl->setRef( 'userjs', $this->userjs
);
224 $tpl->setRef( 'userjsprev', $this->userjsprev
);
225 if($this->loggedin
) {
226 $tpl->set( 'jsvarurl', $this->makeUrl('-','action=raw&smaxage=0&gen=js') );
228 $tpl->set( 'jsvarurl', $this->makeUrl('-','action=raw&gen=js') );
230 if( $wgUser->getNewtalk() ) {
231 $usertitle = Title
::newFromText( $this->userpage
);
232 $usertalktitle = $usertitle->getTalkPage();
233 if($usertalktitle->getPrefixedDbKey() != $this->thispage
){
235 $ntl = wfMsg( 'newmessages',
236 $this->makeKnownLink(
237 $wgContLang->getNsText( Namespace::getTalk( Namespace::getUser() ) )
238 . ':' . $this->username
,
239 wfMsg('newmessageslink') )
242 $wgOut->setSquidMaxage(0);
248 $tpl->setRef( 'newtalk', $ntl );
249 $tpl->setRef( 'skin', $this);
250 $tpl->set( 'logo', $this->logoText() );
251 if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and 0 != $wgArticle->getID() ) {
252 if ( !$wgDisableCounters ) {
253 $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
255 $tpl->set('viewcount', wfMsg( "viewcount", $viewcount ));
257 $tpl->set('viewcount', false);
260 $tpl->set('lastmod', $this->lastModified());
261 $tpl->set('copyright',$this->getCopyright());
263 $this->credits
= false;
265 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
266 require_once("Credits.php");
267 $this->credits
= getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
270 $tpl->setRef( 'credits', $this->credits
);
272 } elseif ( isset( $oldid ) && !isset( $diff ) ) {
273 $tpl->set('copyright', $this->getCopyright());
274 $tpl->set('viewcount', false);
275 $tpl->set('lastmod', false);
276 $tpl->set('credits', false);
278 $tpl->set('copyright', false);
279 $tpl->set('viewcount', false);
280 $tpl->set('lastmod', false);
281 $tpl->set('credits', false);
284 $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
285 $tpl->set( 'poweredbyico', $this->getPoweredBy() );
286 $tpl->set( 'disclaimer', $this->disclaimerLink() );
287 $tpl->set( 'about', $this->aboutLink() );
289 $tpl->setRef( 'debug', $out->mDebugtext
);
290 $tpl->set( 'reporttime', $out->reportTime() );
291 $tpl->set( 'sitenotice', $wgSiteNotice );
293 $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
294 $out->mBodytext
.= $printfooter ;
295 $tpl->setRef( 'bodytext', $out->mBodytext
);
298 $language_urls = array();
299 foreach( $wgOut->getLanguageLinks() as $l ) {
300 $nt = Title
::newFromText( $l );
301 $language_urls[] = array('href' => $nt->getFullURL(),
302 'text' => ($wgContLang->getLanguageName( $nt->getInterwiki()) != ''?
$wgContLang->getLanguageName( $nt->getInterwiki()) : $l),
303 'class' => $wgContLang->isRTL() ?
'rtl' : 'ltr');
305 if(count($language_urls)) {
306 $tpl->setRef( 'language_urls', $language_urls);
308 $tpl->set('language_urls', false);
312 $tpl->set('personal_urls', $this->buildPersonalUrls());
313 $content_actions = $this->buildContentActionUrls();
314 $tpl->setRef('content_actions', $content_actions);
315 // XXX: attach this from javascript, same with section editing
316 if($this->iseditable
&& $wgUser->getOption("editondblclick") )
318 $tpl->set('body_ondblclick', 'document.location = "' .$content_actions['edit']['href'] .'";');
320 $tpl->set('body_ondblclick', false);
322 $tpl->set( 'navigation_urls', $this->buildNavigationUrls() );
323 $tpl->set( 'nav_urls', $this->buildNavUrls() );
326 $res = $tpl->execute();
327 // result may be an error
328 if (PEAR
::isError($res)) {
329 echo $res->toString(), "\n";
337 * build array of urls for personal toolbar
339 function buildPersonalUrls() {
340 /* set up the default links for the personal toolbar */
341 global $wgShowIPinHeader;
342 $personal_urls = array();
343 if ($this->loggedin
) {
344 $personal_urls['userpage'] = array(
345 'text' => $this->username
,
346 'href' => &$this->userpageUrlDetails
['href'],
347 'class' => $this->userpageUrlDetails
['exists']?
false:'new'
349 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage
);
350 $personal_urls['mytalk'] = array(
351 'text' => wfMsg('mytalk'),
352 'href' => &$usertalkUrlDetails['href'],
353 'class' => $usertalkUrlDetails['exists']?
false:'new'
355 $personal_urls['preferences'] = array(
356 'text' => wfMsg('preferences'),
357 'href' => $this->makeSpecialUrl('Preferences')
359 $personal_urls['watchlist'] = array(
360 'text' => wfMsg('watchlist'),
361 'href' => $this->makeSpecialUrl('Watchlist')
363 $personal_urls['mycontris'] = array(
364 'text' => wfMsg('mycontris'),
365 'href' => $this->makeSpecialUrl('Contributions','target=' . urlencode( $this->username
) )
367 $personal_urls['logout'] = array(
368 'text' => wfMsg('userlogout'),
369 'href' => $this->makeSpecialUrl('Userlogout','returnto=' . $this->thisurl
)
372 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) {
373 $personal_urls['anonuserpage'] = array(
374 'text' => $this->username
,
375 'href' => &$this->userpageUrlDetails
['href'],
376 'class' => $this->userpageUrlDetails
['exists']?
false:'new'
378 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage
);
379 $personal_urls['anontalk'] = array(
380 'text' => wfMsg('anontalk'),
381 'href' => &$usertalkUrlDetails['href'],
382 'class' => $usertalkUrlDetails['exists']?
false:'new'
384 $personal_urls['anonlogin'] = array(
385 'text' => wfMsg('userlogin'),
386 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl
)
390 $personal_urls['login'] = array(
391 'text' => wfMsg('userlogin'),
392 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl
)
397 return $personal_urls;
401 * an array of edit links by default used for the tabs
403 function buildContentActionUrls () {
404 global $wgTitle, $wgUser, $wgOut, $wgRequest, $wgUseValidation;
405 $action = $wgRequest->getText( 'action' );
406 $section = $wgRequest->getText( 'section' );
407 $oldid = $wgRequest->getVal( 'oldid' );
408 $diff = $wgRequest->getVal( 'diff' );
409 $content_actions = array();
411 if( $this->iscontent
and !$wgOut->isQuickbarSuppressed() ) {
413 $nskey = $this->getNameSpaceKey();
414 $is_active = !Namespace::isTalk( $wgTitle->getNamespace()) ;
415 if ( $action == 'validate' ) $is_active = false ; # Show article tab deselected when validating
416 $content_actions[$nskey] = array('class' => ($is_active) ?
'selected' : false,
417 'text' => wfMsg($nskey),
418 'href' => $this->makeArticleUrl($this->thispage
));
420 /* set up the classes for the talk link */
421 $talk_class = (Namespace::isTalk( $wgTitle->getNamespace()) ?
'selected' : false);
422 $talktitle = Title
::newFromText( $this->titletxt
);
423 $talktitle = $talktitle->getTalkPage();
424 $this->checkTitle($talktitle, $this->titletxt
);
425 if($talktitle->getArticleId() != 0) {
426 $content_actions['talk'] = array(
427 'class' => $talk_class,
428 'text' => wfMsg('talk'),
429 'href' => $this->makeTalkUrl($this->titletxt
)
432 $content_actions['talk'] = array(
433 'class' => $talk_class?
$talk_class.' new':'new',
434 'text' => wfMsg('talk'),
435 'href' => $this->makeTalkUrl($this->titletxt
,'action=edit')
439 if ( $wgTitle->userCanEdit() ) {
440 $oid = ( $oldid && ! isset( $diff ) ) ?
'&oldid='.IntVal( $oldid ) : false;
441 $istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) );
442 $istalkclass = $istalk?
' istalk':'';
443 $content_actions['edit'] = array(
444 'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ?
'selected' : '').$istalkclass,
445 'text' => wfMsg('edit'),
446 'href' => $this->makeUrl($this->thispage
, 'action=edit'.$oid)
449 $content_actions['addsection'] = array(
450 'class' => $section == 'new'?
'selected':false,
451 'text' => wfMsg('addsection'),
452 'href' => $this->makeUrl($this->thispage
, 'action=edit§ion=new')
456 $oid = ( $oldid && ! isset( $diff ) ) ?
'&oldid='.IntVal( $oldid ) : '';
457 $content_actions['viewsource'] = array('class' => ($action == 'edit') ?
'selected' : false,
458 'text' => wfMsg('viewsource'),
459 'href' => $this->makeUrl($this->thispage
, 'action=edit'.$oid));
462 if ( $wgTitle->getArticleId() ) {
464 $content_actions['history'] = array('class' => ($action == 'history') ?
'selected' : false,
465 'text' => wfMsg('history_short'),
466 'href' => $this->makeUrl($this->thispage
, 'action=history'));
468 # XXX: is there a rollback action anywhere or is it planned?
469 # Don't recall where i got this from...
470 /*if( $wgUser->getNewtalk() ) {
471 $content_actions['rollback'] = array('class' => ($action == 'rollback') ? 'selected' : false,
472 'text' => wfMsg('rollback_short'),
473 'href' => $this->makeUrl($this->thispage, 'action=rollback'),
474 'ttip' => wfMsg('tooltip-rollback'),
475 'akey' => wfMsg('accesskey-rollback'));
479 if($wgUser->isAllowed('protect')){
480 if(!$wgTitle->isProtected()){
481 $content_actions['protect'] = array(
482 'class' => ($action == 'protect') ?
'selected' : false,
483 'text' => wfMsg('protect'),
484 'href' => $this->makeUrl($this->thispage
, 'action=protect')
488 $content_actions['unprotect'] = array(
489 'class' => ($action == 'unprotect') ?
'selected' : false,
490 'text' => wfMsg('unprotect'),
491 'href' => $this->makeUrl($this->thispage
, 'action=unprotect')
495 if($wgUser->isAllowed('delete')){
496 $content_actions['delete'] = array(
497 'class' => ($action == 'delete') ?
'selected' : false,
498 'text' => wfMsg('delete'),
499 'href' => $this->makeUrl($this->thispage
, 'action=delete')
502 if ( $wgUser->getID() != 0 ) {
503 if ( $wgTitle->userCanEdit()) {
504 $content_actions['move'] = array('class' => ($wgTitle->getDbKey() == 'Movepage' and $wgTitle->getNamespace
== Namespace::getSpecial()) ?
'selected' : false,
505 'text' => wfMsg('move'),
506 'href' => $this->makeSpecialUrl('Movepage', 'target='. urlencode( $this->thispage
))
511 //article doesn't exist or is deleted
512 if($wgUser->isAllowed('delete')){
513 if( $n = $wgTitle->isDeleted() ) {
514 $content_actions['undelete'] = array(
516 'text' => wfMsg( "undelete_short", $n ),
517 'href' => $this->makeSpecialUrl('Undelete/'.$this->thispage
)
523 if ( $wgUser->getID() != 0 and $action != 'submit' ) {
524 if( !$wgTitle->userIsWatching()) {
525 $content_actions['watch'] = array('class' => ($action == 'watch' or $action == 'unwatch') ?
'selected' : false,
526 'text' => wfMsg('watch'),
527 'href' => $this->makeUrl($this->thispage
, 'action=watch'));
529 $content_actions['unwatch'] = array('class' => ($action == 'unwatch' or $action == 'watch') ?
'selected' : false,
530 'text' => wfMsg('unwatch'),
531 'href' => $this->makeUrl($this->thispage
, 'action=unwatch'));
536 if ( $wgUseValidation && $wgTitle->getArticleId() && $wgTitle->getNamespace() == 0 ) {
538 $article_time = "×tamp=" . $wgArticle->mTimestamp
;
539 $content_actions['validate'] = array('class' => ($action == 'validate') ?
'selected' : false ,
540 'text' => wfMsg('val_tab'),
541 'href' => $this->makeUrl($this->thispage
, 'action=validate'.$article_time));
545 /* show special page tab */
547 $content_actions['article'] = array('class' => 'selected',
548 'text' => wfMsg('specialpage'),
552 return $content_actions;
556 * build array of global navigation links
558 function buildNavigationUrls () {
559 global $wgNavigationLinks;
561 foreach ( $wgNavigationLinks as $link ) {
562 if (wfMsg( $link['text'] ) != '-') {
564 'text' => wfMsg( $link['text'] ),
565 'href' => $this->makeInternalOrExternalUrl( wfMsgForContent( $link['href'] ) ),
566 'id' => 'n-'.$link['text']
574 * build array of common navigation links
576 function buildNavUrls () {
577 global $wgTitle, $wgUser, $wgRequest;
578 global $wgSiteSupportPage, $wgDisableUploads;
580 $action = $wgRequest->getText( 'action' );
581 $oldid = $wgRequest->getVal( 'oldid' );
582 $diff = $wgRequest->getVal( 'diff' );
583 // XXX: remove htmlspecialchars when tal:attributes works with i18n:attributes
585 $nav_urls['mainpage'] = array('href' => $this->makeI18nUrl('mainpage'));
586 $nav_urls['randompage'] = array('href' => $this->makeSpecialUrl('Randompage'));
587 $nav_urls['recentchanges'] = array('href' => $this->makeSpecialUrl('Recentchanges'));
588 $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ?
array('href' => $this->makeI18nUrl('currentevents')) : false;
589 $nav_urls['portal'] = (wfMsg('portal') != '-') ?
array('href' => $this->makeI18nUrl('portal-url')) : false;
590 $nav_urls['bugreports'] = array('href' => $this->makeI18nUrl('bugreportspage'));
591 // $nav_urls['sitesupport'] = array('href' => $this->makeI18nUrl('sitesupportpage'));
592 $nav_urls['sitesupport'] = array('href' => $wgSiteSupportPage);
593 $nav_urls['help'] = array('href' => $this->makeI18nUrl('helppage'));
594 if( $this->loggedin
&& !$wgDisableUploads ) {
595 $nav_urls['upload'] = array('href' => $this->makeSpecialUrl('Upload'));
597 $nav_urls['upload'] = false;
599 $nav_urls['specialpages'] = array('href' => $this->makeSpecialUrl('Specialpages'));
601 if( $wgTitle->getNamespace() != NS_SPECIAL
) {
602 $nav_urls['whatlinkshere'] = array('href' => $this->makeSpecialUrl('Whatlinkshere', 'target='.urlencode( $this->thispage
)));
603 $nav_urls['recentchangeslinked'] = array('href' => $this->makeSpecialUrl('Recentchangeslinked', 'target='.urlencode( $this->thispage
)));
606 if( $wgTitle->getNamespace() == NS_USER ||
$wgTitle->getNamespace() == NS_USER_TALK
) {
607 $id = User
::idFromName($wgTitle->getText());
608 $ip = User
::isIP($wgTitle->getText());
614 if($id ||
$ip) { # both anons and non-anons have contri list
615 $nav_urls['contributions'] = array(
616 'href' => $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() )
619 $nav_urls['contributions'] = false;
621 $nav_urls['emailuser'] = false;
622 if ( 0 != $wgUser->getID() ) { # show only to signed in users
623 if($id) { # can only email non-anons
624 $nav_urls['emailuser'] = array(
625 'href' => $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() )
634 * Generate strings used for xml 'id' names
636 function getNameSpaceKey () {
638 switch ($wgTitle->getNamespace()) {
646 return 'nstab-media';
648 return 'nstab-special';
650 case NS_PROJECT_TALK
:
654 return 'nstab-image';
656 case NS_MEDIAWIKI_TALK
:
657 return 'nstab-mediawiki';
659 case NS_TEMPLATE_TALK
:
660 return 'nstab-template';
665 case NS_CATEGORY_TALK
:
666 return 'nstab-category';
676 function setupUserCssJs () {
677 global $wgRequest, $wgTitle;
678 $action = $wgRequest->getText('action');
680 $this->usercss
= '@import "'.$this->makeUrl('-','action=raw&gen=css').'";'."\n";
682 if( $this->loggedin
) {
683 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
685 $this->usercss
= '@import "'.$this->makeUrl('-','action=raw&smaxage=0&maxage=0&gen=css').'";'."\n";
687 $this->usercss
.= $wgRequest->getText('wpTextbox1');
690 $this->usercss
.= '@import "'.$this->makeUrl('-','action=raw&smaxage=0&gen=css').'";'."\n";
691 # import user stylesheet
692 $this->usercss
.= '@import "'.
693 $this->makeUrl($this->userpage
.'/'.$this->skinname
.'.css', 'action=raw&ctype=text/css').'";'."\n";
695 if($wgTitle->isJsSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
696 # XXX: additional security check/prompt?
697 $this->userjsprev
= $wgRequest->getText('wpTextbox1');
699 $this->userjs
= $this->makeUrl($this->userpage
.'/'.$this->skinname
.'.js', 'action=raw&ctype=text/javascript&dontcountme=s');
702 $this->usercss
= '/*<![CDATA[*/ ' . $this->usercss
. ' /*]]>*/';
703 if( $this->userjsprev
) {
704 $this->userjsprev
= '/*<![CDATA[*/ ' . $this->userjsprev
. ' /*]]>*/';
709 * returns css with user-specific options
711 function getUserStylesheet() {
712 global $wgUser, $wgRequest, $wgTitle, $wgContLang, $wgSquidMaxage, $wgStylePath;
713 $action = $wgRequest->getText('action');
714 $maxage = $wgRequest->getText('maxage');
715 $s = "/* generated user stylesheet */\n";
716 if($wgContLang->isRTL()) $s .= '@import "'.$wgStylePath.'/'.$this->stylename
.'/rtl.css";'."\n";
718 $this->makeNSUrl(ucfirst($this->skinname
).'.css', 'action=raw&ctype=text/css&smaxage='.$wgSquidMaxage, NS_MEDIAWIKI
)."\";\n";
719 if($wgUser->getID() != 0) {
720 if ( 1 == $wgUser->getOption( "underline" ) ) {
721 $s .= "a { text-decoration: underline; }\n";
723 $s .= "a { text-decoration: none; }\n";
726 if ( 1 != $wgUser->getOption( "highlightbroken" ) ) {
727 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
729 if ( 1 == $wgUser->getOption( "justify" ) ) {
730 $s .= "#bodyContent { text-align: justify; }\n";
738 function getUserJs() {
739 global $wgUser, $wgStylePath;
740 $s = '/* generated javascript */';
741 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
742 $s .= '/* MediaWiki:'.ucfirst($this->skinname
)." */\n";
743 $s .= wfMsg(ucfirst($this->skinname
).'.js');
748 class PHPTAL_version_bridge
{
749 function PHPTAL_version_bridge( $file, $repository=false, $cache_dir=false ) {
750 $this->tpl
=& new PHPTAL( $file );
752 $this->tpl
->setTemplateRepository( $repository );
756 function set( $name, $value ) {
757 $this->tpl
->$name = $value;
760 function setRef($name, &$value) {
761 $this->set( $name, $value );
764 function setTranslator( &$t ) {
765 $this->tpl
->setTranslator( $t );
772 return $this->tpl
->execute();
775 catch (Exception $e) {
776 echo "<div class='error' style='background: white; white-space: pre; position: absolute; z-index: 9999; border: solid 2px black; padding: 4px;'>We caught an exception...\n ";
784 } // end of if( defined( 'MEDIAWIKI' ) )