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 $value = wfMsg( $value );
67 // interpolate variables
68 while (preg_match('/\$([0-9]*?)/sm', $value, $m)) {
69 list($src, $var) = $m;
71 $varValue = $this->_context
[$var];
73 $value = str_replace($src, $varValue, $value);
82 class SkinPHPTal
extends Skin
{
88 * Name of our skin, set in initPage()
89 * It probably need to be all lower case.
94 * Stylesheets set to use
95 * Sub directory in ./skins/ where various stylesheets are located
100 * PHPTal template to be used.
101 * '.pt' will be automaticly added to it on PHPTAL object creation
108 function initPage( &$out ) {
109 parent
::initPage( $out );
110 $this->skinname
= 'monobook';
111 $this->stylename
= 'monobook';
112 $this->template
= 'MonoBook';
116 * If using PHPTAL 0.7 on PHP 4.x, return a PHPTAL template object.
117 * If using PHPTAL 1.0 on PHP 5.x, return a bridge object.
121 function &setupTemplate( $file, $repository=false, $cache_dir=false ) {
122 if( defined( 'NEW_PHPTAL' ) ) {
123 return new PHPTAL_version_bridge( $file, $repository, $cache_dir );
125 return new PHPTAL( $file, $repository, $cache_dir );
130 * initialize various variables and generate the template
132 function outputPage( &$out ) {
133 global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut;
134 global $wgScript, $wgStylePath, $wgLanguageCode, $wgContLanguageCode, $wgUseNewInterlanguage;
135 global $wgMimeType, $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest;
136 global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgSiteNotice;
137 global $wgMaxCredits, $wgShowCreditsIfMax;
139 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
141 $this->initPage( $out );
142 $tpl =& $this->setupTemplate( $this->template
. '.pt', 'skins' );
144 #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
145 $tpl->setTranslator(new MediaWiki_I18N());
148 $this->thispage
= $wgTitle->getPrefixedDbKey();
149 $this->thisurl
= $wgTitle->getPrefixedURL();
150 $this->loggedin
= $wgUser->getID() != 0;
151 $this->iscontent
= ($wgTitle->getNamespace() != Namespace::getSpecial() );
152 $this->iseditable
= ($this->iscontent
and !($action == 'edit' or $action == 'submit'));
153 $this->username
= $wgUser->getName();
154 $this->userpage
= $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
155 $this->userpageUrlDetails
= $this->makeUrlDetails($this->userpage
);
157 $this->usercss
= $this->userjs
= $this->userjsprev
= false;
158 $this->setupUserCssJs();
160 $this->titletxt
= $wgTitle->getPrefixedText();
162 $tpl->set( 'title', $wgOut->getPageTitle() );
163 $tpl->set( 'pagetitle', $wgOut->getHTMLTitle() );
165 $tpl->setRef( "thispage", $this->thispage
);
166 $subpagestr = $this->subPageSubtitle();
168 'subtitle', !empty($subpagestr)?
169 '<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle():
172 $undelete = $this->getUndeleteLink();
174 "undelete", !empty($undelete)?
175 '<span class="subpages">'.$undelete.'</span>':
179 $tpl->set( 'catlinks', $this->getCategories());
180 if( $wgOut->isSyndicated() ) {
182 foreach( $wgFeedClasses as $format => $class ) {
183 $feeds[$format] = array(
185 'href' => $wgRequest->appendQuery( "feed=$format" ),
186 'ttip' => wfMsg('tooltip-'.$format)
189 $tpl->setRef( 'feeds', $feeds );
191 $tpl->set( 'feeds', false );
193 $tpl->setRef( 'mimetype', $wgMimeType );
194 $tpl->setRef( 'charset', $wgOutputEncoding );
195 $tpl->set( 'headlinks', $out->getHeadLinks() );
196 $tpl->setRef( 'wgScript', $wgScript );
197 $tpl->setRef( 'skinname', $this->skinname
);
198 $tpl->setRef( 'stylename', $this->stylename
);
199 $tpl->setRef( 'loggedin', $this->loggedin
);
200 $tpl->set('nsclass', 'ns-'.$wgTitle->getNamespace());
201 $tpl->set('notspecialpage', $wgTitle->getNamespace() != NS_SPECIAL
);
202 /* XXX currently unused, might get useful later
203 $tpl->set( "editable", ($wgTitle->getNamespace() != NS_SPECIAL ) );
204 $tpl->set( "exists", $wgTitle->getArticleID() != 0 );
205 $tpl->set( "watch", $wgTitle->userIsWatching() ? "unwatch" : "watch" );
206 $tpl->set( "protect", count($wgTitle->getRestrictions()) ? "unprotect" : "protect" );
207 $tpl->set( "helppage", wfMsg('helppage'));
208 $tpl->set( "sysop", $wgUser->isSysop() );
210 $tpl->set( 'searchaction', $this->escapeSearchLink() );
211 $tpl->setRef( 'stylepath', $wgStylePath );
212 $tpl->setRef( 'logopath', $wgLogo );
213 $tpl->setRef( "lang", $wgContLanguageCode );
214 $tpl->set( 'dir', $wgContLang->isRTL() ?
"rtl" : "ltr" );
215 $tpl->set( 'rtl', $wgContLang->isRTL() );
216 $tpl->set( 'langname', $wgContLang->getLanguageName( $wgContLanguageCode ) );
217 $tpl->setRef( 'username', $this->username
);
218 $tpl->setRef( 'userpage', $this->userpage
);
219 $tpl->setRef( 'userpageurl', $this->userpageUrlDetails
['href']);
220 $tpl->setRef( 'usercss', $this->usercss
);
221 $tpl->setRef( 'userjs', $this->userjs
);
222 $tpl->setRef( 'userjsprev', $this->userjsprev
);
223 if($this->loggedin
) {
224 $tpl->set( 'jsvarurl', $this->makeUrl('-','action=raw&smaxage=0&gen=js') );
226 $tpl->set( 'jsvarurl', $this->makeUrl('-','action=raw&gen=js') );
228 if( $wgUser->getNewtalk() ) {
229 $usertitle = Title
::newFromText( $this->userpage
);
230 $usertalktitle = $usertitle->getTalkPage();
231 if($usertalktitle->getPrefixedDbKey() != $this->thispage
){
233 $ntl = wfMsg( 'newmessages',
234 $this->makeKnownLink(
235 $wgContLang->getNsText( Namespace::getTalk( Namespace::getUser() ) )
236 . ':' . $this->username
,
237 wfMsg('newmessageslink') )
240 $wgOut->setSquidMaxage(0);
246 $tpl->setRef( 'newtalk', $ntl );
247 $tpl->setRef( 'skin', $this);
248 $tpl->set( 'logo', $this->logoText() );
249 if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and 0 != $wgArticle->getID() ) {
250 if ( !$wgDisableCounters ) {
251 $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
253 $tpl->set('viewcount', wfMsg( "viewcount", $viewcount ));
255 $tpl->set('viewcount', false);
258 $tpl->set('lastmod', $this->lastModified());
259 $tpl->set('copyright',$this->getCopyright());
261 $this->credits
= false;
263 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
264 require_once("Credits.php");
265 $this->credits
= getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
268 $tpl->setRef( 'credits', $this->credits
);
270 } elseif ( isset( $oldid ) && !isset( $diff ) ) {
271 $tpl->set('copyright', $this->getCopyright());
272 $tpl->set('viewcount', false);
273 $tpl->set('lastmod', false);
274 $tpl->set('credits', false);
276 $tpl->set('copyright', false);
277 $tpl->set('viewcount', false);
278 $tpl->set('lastmod', false);
279 $tpl->set('credits', false);
282 $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
283 $tpl->set( 'poweredbyico', $this->getPoweredBy() );
284 $tpl->set( 'disclaimer', $this->disclaimerLink() );
285 $tpl->set( 'about', $this->aboutLink() );
287 $tpl->setRef( 'debug', $out->mDebugtext
);
288 $tpl->set( 'reporttime', $out->reportTime() );
289 $tpl->set( 'sitenotice', $wgSiteNotice );
291 $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
292 $out->mBodytext
.= $printfooter ;
293 $tpl->setRef( 'bodytext', $out->mBodytext
);
296 $language_urls = array();
297 foreach( $wgOut->getLanguageLinks() as $l ) {
298 $nt = Title
::newFromText( $l );
299 $language_urls[] = array('href' => $nt->getFullURL(),
300 'text' => ($wgContLang->getLanguageName( $nt->getInterwiki()) != ''?
$wgContLang->getLanguageName( $nt->getInterwiki()) : $l),
301 'class' => $wgContLang->isRTL() ?
'rtl' : 'ltr');
303 if(count($language_urls)) {
304 $tpl->setRef( 'language_urls', $language_urls);
306 $tpl->set('language_urls', false);
310 $tpl->set('personal_urls', $this->buildPersonalUrls());
311 $content_actions = $this->buildContentActionUrls();
312 $tpl->setRef('content_actions', $content_actions);
313 // XXX: attach this from javascript, same with section editing
314 if($this->iseditable
&& $wgUser->getOption("editondblclick") )
316 $tpl->set('body_ondblclick', 'document.location = "' .$content_actions['edit']['href'] .'";');
318 $tpl->set('body_ondblclick', false);
320 $tpl->set( 'navigation_urls', $this->buildNavigationUrls() );
321 $tpl->set( 'nav_urls', $this->buildNavUrls() );
324 $res = $tpl->execute();
325 // result may be an error
326 if (PEAR
::isError($res)) {
327 echo $res->toString(), "\n";
335 * build array of urls for personal toolbar
337 function buildPersonalUrls() {
338 /* set up the default links for the personal toolbar */
339 global $wgShowIPinHeader;
340 $personal_urls = array();
341 if ($this->loggedin
) {
342 $personal_urls['userpage'] = array(
343 'text' => $this->username
,
344 'href' => &$this->userpageUrlDetails
['href'],
345 'class' => $this->userpageUrlDetails
['exists']?
false:'new'
347 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage
);
348 $personal_urls['mytalk'] = array(
349 'text' => wfMsg('mytalk'),
350 'href' => &$usertalkUrlDetails['href'],
351 'class' => $usertalkUrlDetails['exists']?
false:'new'
353 $personal_urls['preferences'] = array(
354 'text' => wfMsg('preferences'),
355 'href' => $this->makeSpecialUrl('Preferences')
357 $personal_urls['watchlist'] = array(
358 'text' => wfMsg('watchlist'),
359 'href' => $this->makeSpecialUrl('Watchlist')
361 $personal_urls['mycontris'] = array(
362 'text' => wfMsg('mycontris'),
363 'href' => $this->makeSpecialUrl('Contributions','target=' . urlencode( $this->username
) )
365 $personal_urls['logout'] = array(
366 'text' => wfMsg('userlogout'),
367 'href' => $this->makeSpecialUrl('Userlogout','returnto=' . $this->thisurl
)
370 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) {
371 $personal_urls['anonuserpage'] = array(
372 'text' => $this->username
,
373 'href' => &$this->userpageUrlDetails
['href'],
374 'class' => $this->userpageUrlDetails
['exists']?
false:'new'
376 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage
);
377 $personal_urls['anontalk'] = array(
378 'text' => wfMsg('anontalk'),
379 'href' => &$usertalkUrlDetails['href'],
380 'class' => $usertalkUrlDetails['exists']?
false:'new'
382 $personal_urls['anonlogin'] = array(
383 'text' => wfMsg('userlogin'),
384 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl
)
388 $personal_urls['login'] = array(
389 'text' => wfMsg('userlogin'),
390 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl
)
395 return $personal_urls;
399 * an array of edit links by default used for the tabs
401 function buildContentActionUrls () {
402 global $wgTitle, $wgUser, $wgOut, $wgRequest, $wgUseValidation;
403 $action = $wgRequest->getText( 'action' );
404 $section = $wgRequest->getText( 'section' );
405 $oldid = $wgRequest->getVal( 'oldid' );
406 $diff = $wgRequest->getVal( 'diff' );
407 $content_actions = array();
409 if( $this->iscontent
and !$wgOut->isQuickbarSuppressed() ) {
411 $nskey = $this->getNameSpaceKey();
412 $is_active = !Namespace::isTalk( $wgTitle->getNamespace()) ;
413 if ( $action == 'validate' ) $is_active = false ; # Show article tab deselected when validating
414 $content_actions[$nskey] = array('class' => ($is_active) ?
'selected' : false,
415 'text' => wfMsg($nskey),
416 'href' => $this->makeArticleUrl($this->thispage
));
418 /* set up the classes for the talk link */
419 $talk_class = (Namespace::isTalk( $wgTitle->getNamespace()) ?
'selected' : false);
420 $talktitle = Title
::newFromText( $this->titletxt
);
421 $talktitle = $talktitle->getTalkPage();
422 $this->checkTitle($talktitle, $this->titletxt
);
423 if($talktitle->getArticleId() != 0) {
424 $content_actions['talk'] = array(
425 'class' => $talk_class,
426 'text' => wfMsg('talk'),
427 'href' => $this->makeTalkUrl($this->titletxt
)
430 $content_actions['talk'] = array(
431 'class' => $talk_class?
$talk_class.' new':'new',
432 'text' => wfMsg('talk'),
433 'href' => $this->makeTalkUrl($this->titletxt
,'action=edit')
437 if ( $wgTitle->userCanEdit() ) {
438 $oid = ( $oldid && ! isset( $diff ) ) ?
'&oldid='.$oldid : false;
439 $istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) );
440 $istalkclass = $istalk?
' istalk':'';
441 $content_actions['edit'] = array(
442 'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ?
'selected' : '').$istalkclass,
443 'text' => wfMsg('edit'),
444 'href' => $this->makeUrl($this->thispage
, 'action=edit'.$oid)
447 $content_actions['addsection'] = array(
448 'class' => $section == 'new'?
'selected':false,
449 'text' => wfMsg('addsection'),
450 'href' => $this->makeUrl($this->thispage
, 'action=edit§ion=new')
454 $oid = ( $oldid && ! isset( $diff ) ) ?
'&oldid='.$oldid : '';
455 $content_actions['viewsource'] = array('class' => ($action == 'edit') ?
'selected' : false,
456 'text' => wfMsg('viewsource'),
457 'href' => $this->makeUrl($this->thispage
, 'action=edit'.$oid));
460 if ( $wgTitle->getArticleId() ) {
462 $content_actions['history'] = array('class' => ($action == 'history') ?
'selected' : false,
463 'text' => wfMsg('history_short'),
464 'href' => $this->makeUrl($this->thispage
, 'action=history'));
466 # XXX: is there a rollback action anywhere or is it planned?
467 # Don't recall where i got this from...
468 /*if( $wgUser->getNewtalk() ) {
469 $content_actions['rollback'] = array('class' => ($action == 'rollback') ? 'selected' : false,
470 'text' => wfMsg('rollback_short'),
471 'href' => $this->makeUrl($this->thispage, 'action=rollback'),
472 'ttip' => wfMsg('tooltip-rollback'),
473 'akey' => wfMsg('accesskey-rollback'));
476 if($wgUser->isSysop()){
477 if(!$wgTitle->isProtected()){
478 $content_actions['protect'] = array(
479 'class' => ($action == 'protect') ?
'selected' : false,
480 'text' => wfMsg('protect'),
481 'href' => $this->makeUrl($this->thispage
, 'action=protect')
485 $content_actions['unprotect'] = array(
486 'class' => ($action == 'unprotect') ?
'selected' : false,
487 'text' => wfMsg('unprotect'),
488 'href' => $this->makeUrl($this->thispage
, 'action=unprotect')
491 $content_actions['delete'] = array(
492 'class' => ($action == 'delete') ?
'selected' : false,
493 'text' => wfMsg('delete'),
494 'href' => $this->makeUrl($this->thispage
, 'action=delete')
497 if ( $wgUser->getID() != 0 ) {
498 if ( $wgTitle->userCanEdit()) {
499 $content_actions['move'] = array('class' => ($wgTitle->getDbKey() == 'Movepage' and $wgTitle->getNamespace
== Namespace::getSpecial()) ?
'selected' : false,
500 'text' => wfMsg('move'),
501 'href' => $this->makeSpecialUrl('Movepage', 'target='. urlencode( $this->thispage
))
504 $content_actions['move'] = array('class' => 'inactive',
505 'text' => wfMsg('move'),
511 //article doesn't exist or is deleted
512 if($wgUser->isSysop()){
513 if( $n = $wgTitle->isDeleted() ) {
514 $content_actions['delete'] = 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 ) {
563 'text' => wfMsg( $link['text'] ),
564 'href' => $this->makeInternalOrExternalUrl( wfMsgForContent( $link['href'] ) ),
565 'id' => 'n-'.$link['text']
572 * build array of common navigation links
574 function buildNavUrls () {
575 global $wgTitle, $wgUser, $wgRequest;
576 global $wgSiteSupportPage, $wgDisableUploads;
578 $action = $wgRequest->getText( 'action' );
579 $oldid = $wgRequest->getVal( 'oldid' );
580 $diff = $wgRequest->getVal( 'diff' );
581 // XXX: remove htmlspecialchars when tal:attributes works with i18n:attributes
583 $nav_urls['mainpage'] = array('href' => $this->makeI18nUrl('mainpage'));
584 $nav_urls['randompage'] = array('href' => $this->makeSpecialUrl('Randompage'));
585 $nav_urls['recentchanges'] = array('href' => $this->makeSpecialUrl('Recentchanges'));
586 $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ?
array('href' => $this->makeI18nUrl('currentevents')) : false;
587 $nav_urls['portal'] = (wfMsg('portal') != '-') ?
array('href' => $this->makeI18nUrl('portal-url')) : false;
588 $nav_urls['bugreports'] = array('href' => $this->makeI18nUrl('bugreportspage'));
589 // $nav_urls['sitesupport'] = array('href' => $this->makeI18nUrl('sitesupportpage'));
590 $nav_urls['sitesupport'] = array('href' => $wgSiteSupportPage);
591 $nav_urls['help'] = array('href' => $this->makeI18nUrl('helppage'));
592 if( $this->loggedin
&& !$wgDisableUploads ) {
593 $nav_urls['upload'] = array('href' => $this->makeSpecialUrl('Upload'));
595 $nav_urls['upload'] = false;
597 $nav_urls['specialpages'] = array('href' => $this->makeSpecialUrl('Specialpages'));
599 if( $wgTitle->getNamespace() != NS_SPECIAL
) {
600 $nav_urls['whatlinkshere'] = array('href' => $this->makeSpecialUrl('Whatlinkshere', 'target='.urlencode( $this->thispage
)));
601 $nav_urls['recentchangeslinked'] = array('href' => $this->makeSpecialUrl('Recentchangeslinked', 'target='.urlencode( $this->thispage
)));
604 if( $wgTitle->getNamespace() == NS_USER ||
$wgTitle->getNamespace() == NS_USER_TALK
) {
605 $id = User
::idFromName($wgTitle->getText());
606 $ip = User
::isIP($wgTitle->getText());
612 if($id ||
$ip) { # both anons and non-anons have contri list
613 $nav_urls['contributions'] = array(
614 'href' => $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() )
617 $nav_urls['contributions'] = false;
619 $nav_urls['emailuser'] = false;
620 if ( 0 != $wgUser->getID() ) { # show only to signed in users
621 if($id) { # can only email non-anons
622 $nav_urls['emailuser'] = array(
623 'href' => $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() )
632 * Generate strings used for xml 'id' names
634 function getNameSpaceKey () {
636 switch ($wgTitle->getNamespace()) {
644 return 'nstab-media';
646 return 'nstab-special';
648 case NS_PROJECT_TALK
:
652 return 'nstab-image';
654 case NS_MEDIAWIKI_TALK
:
655 return 'nstab-mediawiki';
657 case NS_TEMPLATE_TALK
:
658 return 'nstab-template';
663 case NS_CATEGORY_TALK
:
664 return 'nstab-category';
674 function setupUserCssJs () {
675 global $wgRequest, $wgTitle;
676 $action = $wgRequest->getText('action');
678 $this->usercss
= '@import "'.$this->makeUrl('-','action=raw&gen=css').'";'."\n";
680 if( $this->loggedin
) {
681 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
683 $this->usercss
= '@import "'.$this->makeUrl('-','action=raw&smaxage=0&maxage=0&gen=css').'";'."\n";
685 $this->usercss
.= $wgRequest->getText('wpTextbox1');
688 $this->usercss
.= '@import "'.$this->makeUrl('-','action=raw&smaxage=0&gen=css').'";'."\n";
689 # import user stylesheet
690 $this->usercss
.= '@import "'.
691 $this->makeUrl($this->userpage
.'/'.$this->skinname
.'.css', 'action=raw&ctype=text/css').'";'."\n";
693 if($wgTitle->isJsSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
694 # XXX: additional security check/prompt?
695 $this->userjsprev
= $wgRequest->getText('wpTextbox1');
697 $this->userjs
= $this->makeUrl($this->userpage
.'/'.$this->skinname
.'.js', 'action=raw&ctype=text/javascript&dontcountme=s');
700 $this->usercss
= '/*<![CDATA[*/ ' . $this->usercss
. ' /*]]>*/';
701 if( $this->userjsprev
) {
702 $this->userjsprev
= '/*<![CDATA[*/ ' . $this->userjsprev
. ' /*]]>*/';
707 * returns css with user-specific options
709 function getUserStylesheet() {
710 global $wgUser, $wgRequest, $wgTitle, $wgContLang, $wgSquidMaxage, $wgStylePath;
711 $action = $wgRequest->getText('action');
712 $maxage = $wgRequest->getText('maxage');
713 $s = "/* generated user stylesheet */\n";
714 if($wgContLang->isRTL()) $s .= '@import "'.$wgStylePath.'/'.$this->stylename
.'/rtl.css";'."\n";
716 $this->makeNSUrl(ucfirst($this->skinname
).'.css', 'action=raw&ctype=text/css&smaxage='.$wgSquidMaxage, NS_MEDIAWIKI
)."\";\n";
717 if($wgUser->getID() != 0) {
718 if ( 1 == $wgUser->getOption( "underline" ) ) {
719 $s .= "a { text-decoration: underline; }\n";
721 $s .= "a { text-decoration: none; }\n";
724 if ( 1 != $wgUser->getOption( "highlightbroken" ) ) {
725 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
727 if ( 1 == $wgUser->getOption( "justify" ) ) {
728 $s .= "#bodyContent { text-align: justify; }\n";
736 function getUserJs() {
737 global $wgUser, $wgStylePath;
738 $s = '/* generated javascript */';
739 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
740 $s .= '/* MediaWiki:'.ucfirst($this->skinname
)." */\n";
741 $s .= wfMsg(ucfirst($this->skinname
).'.js');
746 class PHPTAL_version_bridge
{
747 function PHPTAL_version_bridge( $file, $repository=false, $cache_dir=false ) {
748 $this->tpl
=& new PHPTAL( $file );
750 $this->tpl
->setTemplateRepository( $repository );
754 function set( $name, $value ) {
755 $this->tpl
->$name = $value;
758 function setRef($name, &$value) {
759 $this->set( $name, $value );
762 function setTranslator( &$t ) {
763 $this->tpl
->setTranslator( $t );
770 return $this->tpl
->execute();
773 catch (Exception $e) {
774 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 ";
782 } // end of if( defined( 'MEDIAWIKI' ) )