f986ae4b6e597cb3c0a434df0084d11c5401eda6
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'));
211 $tpl->set( "sysop", $wgUser->isSysop() );
213 $tpl->set( 'searchaction', $this->escapeSearchLink() );
214 $tpl->setRef( 'stylepath', $wgStylePath );
215 $tpl->setRef( 'logopath', $wgLogo );
216 $tpl->setRef( "lang", $wgContLanguageCode );
217 $tpl->set( 'dir', $wgContLang->isRTL() ?
"rtl" : "ltr" );
218 $tpl->set( 'rtl', $wgContLang->isRTL() );
219 $tpl->set( 'langname', $wgContLang->getLanguageName( $wgContLanguageCode ) );
220 $tpl->setRef( 'username', $this->username
);
221 $tpl->setRef( 'userpage', $this->userpage
);
222 $tpl->setRef( 'userpageurl', $this->userpageUrlDetails
['href']);
223 $tpl->setRef( 'usercss', $this->usercss
);
224 $tpl->setRef( 'userjs', $this->userjs
);
225 $tpl->setRef( 'userjsprev', $this->userjsprev
);
226 if($this->loggedin
) {
227 $tpl->set( 'jsvarurl', $this->makeUrl('-','action=raw&smaxage=0&gen=js') );
229 $tpl->set( 'jsvarurl', $this->makeUrl('-','action=raw&gen=js') );
231 if( $wgUser->getNewtalk() ) {
232 $usertitle = Title
::newFromText( $this->userpage
);
233 $usertalktitle = $usertitle->getTalkPage();
234 if($usertalktitle->getPrefixedDbKey() != $this->thispage
){
236 $ntl = wfMsg( 'newmessages',
237 $this->makeKnownLink(
238 $wgContLang->getNsText( Namespace::getTalk( Namespace::getUser() ) )
239 . ':' . $this->username
,
240 wfMsg('newmessageslink') )
243 $wgOut->setSquidMaxage(0);
249 $tpl->setRef( 'newtalk', $ntl );
250 $tpl->setRef( 'skin', $this);
251 $tpl->set( 'logo', $this->logoText() );
252 if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and 0 != $wgArticle->getID() ) {
253 if ( !$wgDisableCounters ) {
254 $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
256 $tpl->set('viewcount', wfMsg( "viewcount", $viewcount ));
258 $tpl->set('viewcount', false);
261 $tpl->set('lastmod', $this->lastModified());
262 $tpl->set('copyright',$this->getCopyright());
264 $this->credits
= false;
266 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
267 require_once("Credits.php");
268 $this->credits
= getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
271 $tpl->setRef( 'credits', $this->credits
);
273 } elseif ( isset( $oldid ) && !isset( $diff ) ) {
274 $tpl->set('copyright', $this->getCopyright());
275 $tpl->set('viewcount', false);
276 $tpl->set('lastmod', false);
277 $tpl->set('credits', false);
279 $tpl->set('copyright', false);
280 $tpl->set('viewcount', false);
281 $tpl->set('lastmod', false);
282 $tpl->set('credits', false);
285 $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
286 $tpl->set( 'poweredbyico', $this->getPoweredBy() );
287 $tpl->set( 'disclaimer', $this->disclaimerLink() );
288 $tpl->set( 'about', $this->aboutLink() );
290 $tpl->setRef( 'debug', $out->mDebugtext
);
291 $tpl->set( 'reporttime', $out->reportTime() );
292 $tpl->set( 'sitenotice', $wgSiteNotice );
294 $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
295 $out->mBodytext
.= $printfooter ;
296 $tpl->setRef( 'bodytext', $out->mBodytext
);
299 $language_urls = array();
300 foreach( $wgOut->getLanguageLinks() as $l ) {
301 $nt = Title
::newFromText( $l );
302 $language_urls[] = array('href' => $nt->getFullURL(),
303 'text' => ($wgContLang->getLanguageName( $nt->getInterwiki()) != ''?
$wgContLang->getLanguageName( $nt->getInterwiki()) : $l),
304 'class' => $wgContLang->isRTL() ?
'rtl' : 'ltr');
306 if(count($language_urls)) {
307 $tpl->setRef( 'language_urls', $language_urls);
309 $tpl->set('language_urls', false);
313 $tpl->set('personal_urls', $this->buildPersonalUrls());
314 $content_actions = $this->buildContentActionUrls();
315 $tpl->setRef('content_actions', $content_actions);
316 // XXX: attach this from javascript, same with section editing
317 if($this->iseditable
&& $wgUser->getOption("editondblclick") )
319 $tpl->set('body_ondblclick', 'document.location = "' .$content_actions['edit']['href'] .'";');
321 $tpl->set('body_ondblclick', false);
323 $tpl->set( 'navigation_urls', $this->buildNavigationUrls() );
324 $tpl->set( 'nav_urls', $this->buildNavUrls() );
327 $res = $tpl->execute();
328 // result may be an error
329 if (PEAR
::isError($res)) {
330 echo $res->toString(), "\n";
338 * build array of urls for personal toolbar
340 function buildPersonalUrls() {
341 /* set up the default links for the personal toolbar */
342 global $wgShowIPinHeader;
343 $personal_urls = array();
344 if ($this->loggedin
) {
345 $personal_urls['userpage'] = array(
346 'text' => $this->username
,
347 'href' => &$this->userpageUrlDetails
['href'],
348 'class' => $this->userpageUrlDetails
['exists']?
false:'new'
350 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage
);
351 $personal_urls['mytalk'] = array(
352 'text' => wfMsg('mytalk'),
353 'href' => &$usertalkUrlDetails['href'],
354 'class' => $usertalkUrlDetails['exists']?
false:'new'
356 $personal_urls['preferences'] = array(
357 'text' => wfMsg('preferences'),
358 'href' => $this->makeSpecialUrl('Preferences')
360 $personal_urls['watchlist'] = array(
361 'text' => wfMsg('watchlist'),
362 'href' => $this->makeSpecialUrl('Watchlist')
364 $personal_urls['mycontris'] = array(
365 'text' => wfMsg('mycontris'),
366 'href' => $this->makeSpecialUrl('Contributions','target=' . urlencode( $this->username
) )
368 $personal_urls['logout'] = array(
369 'text' => wfMsg('userlogout'),
370 'href' => $this->makeSpecialUrl('Userlogout','returnto=' . $this->thisurl
)
373 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) {
374 $personal_urls['anonuserpage'] = array(
375 'text' => $this->username
,
376 'href' => &$this->userpageUrlDetails
['href'],
377 'class' => $this->userpageUrlDetails
['exists']?
false:'new'
379 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage
);
380 $personal_urls['anontalk'] = array(
381 'text' => wfMsg('anontalk'),
382 'href' => &$usertalkUrlDetails['href'],
383 'class' => $usertalkUrlDetails['exists']?
false:'new'
385 $personal_urls['anonlogin'] = array(
386 'text' => wfMsg('userlogin'),
387 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl
)
391 $personal_urls['login'] = array(
392 'text' => wfMsg('userlogin'),
393 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl
)
398 return $personal_urls;
402 * an array of edit links by default used for the tabs
404 function buildContentActionUrls () {
405 global $wgTitle, $wgUser, $wgOut, $wgRequest, $wgUseValidation;
406 $action = $wgRequest->getText( 'action' );
407 $section = $wgRequest->getText( 'section' );
408 $oldid = $wgRequest->getVal( 'oldid' );
409 $diff = $wgRequest->getVal( 'diff' );
410 $content_actions = array();
412 if( $this->iscontent
and !$wgOut->isQuickbarSuppressed() ) {
414 $nskey = $this->getNameSpaceKey();
415 $is_active = !Namespace::isTalk( $wgTitle->getNamespace()) ;
416 if ( $action == 'validate' ) $is_active = false ; # Show article tab deselected when validating
417 $content_actions[$nskey] = array('class' => ($is_active) ?
'selected' : false,
418 'text' => wfMsg($nskey),
419 'href' => $this->makeArticleUrl($this->thispage
));
421 /* set up the classes for the talk link */
422 $talk_class = (Namespace::isTalk( $wgTitle->getNamespace()) ?
'selected' : false);
423 $talktitle = Title
::newFromText( $this->titletxt
);
424 $talktitle = $talktitle->getTalkPage();
425 $this->checkTitle($talktitle, $this->titletxt
);
426 if($talktitle->getArticleId() != 0) {
427 $content_actions['talk'] = array(
428 'class' => $talk_class,
429 'text' => wfMsg('talk'),
430 'href' => $this->makeTalkUrl($this->titletxt
)
433 $content_actions['talk'] = array(
434 'class' => $talk_class?
$talk_class.' new':'new',
435 'text' => wfMsg('talk'),
436 'href' => $this->makeTalkUrl($this->titletxt
,'action=edit')
440 if ( $wgTitle->userCanEdit() ) {
441 $oid = ( $oldid && ! isset( $diff ) ) ?
'&oldid='.IntVal( $oldid ) : false;
442 $istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) );
443 $istalkclass = $istalk?
' istalk':'';
444 $content_actions['edit'] = array(
445 'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ?
'selected' : '').$istalkclass,
446 'text' => wfMsg('edit'),
447 'href' => $this->makeUrl($this->thispage
, 'action=edit'.$oid)
450 $content_actions['addsection'] = array(
451 'class' => $section == 'new'?
'selected':false,
452 'text' => wfMsg('addsection'),
453 'href' => $this->makeUrl($this->thispage
, 'action=edit§ion=new')
457 $oid = ( $oldid && ! isset( $diff ) ) ?
'&oldid='.IntVal( $oldid ) : '';
458 $content_actions['viewsource'] = array('class' => ($action == 'edit') ?
'selected' : false,
459 'text' => wfMsg('viewsource'),
460 'href' => $this->makeUrl($this->thispage
, 'action=edit'.$oid));
463 if ( $wgTitle->getArticleId() ) {
465 $content_actions['history'] = array('class' => ($action == 'history') ?
'selected' : false,
466 'text' => wfMsg('history_short'),
467 'href' => $this->makeUrl($this->thispage
, 'action=history'));
469 # XXX: is there a rollback action anywhere or is it planned?
470 # Don't recall where i got this from...
471 /*if( $wgUser->getNewtalk() ) {
472 $content_actions['rollback'] = array('class' => ($action == 'rollback') ? 'selected' : false,
473 'text' => wfMsg('rollback_short'),
474 'href' => $this->makeUrl($this->thispage, 'action=rollback'),
475 'ttip' => wfMsg('tooltip-rollback'),
476 'akey' => wfMsg('accesskey-rollback'));
479 if($wgUser->isSysop()){
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')
494 $content_actions['delete'] = array(
495 'class' => ($action == 'delete') ?
'selected' : false,
496 'text' => wfMsg('delete'),
497 'href' => $this->makeUrl($this->thispage
, 'action=delete')
500 if ( $wgUser->getID() != 0 ) {
501 if ( $wgTitle->userCanEdit()) {
502 $content_actions['move'] = array('class' => ($wgTitle->getDbKey() == 'Movepage' and $wgTitle->getNamespace
== Namespace::getSpecial()) ?
'selected' : false,
503 'text' => wfMsg('move'),
504 'href' => $this->makeSpecialUrl('Movepage', 'target='. urlencode( $this->thispage
))
509 //article doesn't exist or is deleted
510 if($wgUser->isSysop()){
511 if( $n = $wgTitle->isDeleted() ) {
512 $content_actions['undelete'] = array(
514 'text' => wfMsg( "undelete_short", $n ),
515 'href' => $this->makeSpecialUrl('Undelete/'.$this->thispage
)
521 if ( $wgUser->getID() != 0 and $action != 'submit' ) {
522 if( !$wgTitle->userIsWatching()) {
523 $content_actions['watch'] = array('class' => ($action == 'watch' or $action == 'unwatch') ?
'selected' : false,
524 'text' => wfMsg('watch'),
525 'href' => $this->makeUrl($this->thispage
, 'action=watch'));
527 $content_actions['unwatch'] = array('class' => ($action == 'unwatch' or $action == 'watch') ?
'selected' : false,
528 'text' => wfMsg('unwatch'),
529 'href' => $this->makeUrl($this->thispage
, 'action=unwatch'));
534 if ( $wgUseValidation && $wgTitle->getArticleId() && $wgTitle->getNamespace() == 0 ) {
536 $article_time = "×tamp=" . $wgArticle->mTimestamp
;
537 $content_actions['validate'] = array('class' => ($action == 'validate') ?
'selected' : false ,
538 'text' => wfMsg('val_tab'),
539 'href' => $this->makeUrl($this->thispage
, 'action=validate'.$article_time));
543 /* show special page tab */
545 $content_actions['article'] = array('class' => 'selected',
546 'text' => wfMsg('specialpage'),
550 return $content_actions;
554 * build array of global navigation links
556 function buildNavigationUrls () {
557 global $wgNavigationLinks;
559 foreach ( $wgNavigationLinks as $link ) {
560 if (wfMsg( $link['text'] ) != '-') {
562 'text' => wfMsg( $link['text'] ),
563 'href' => $this->makeInternalOrExternalUrl( wfMsgForContent( $link['href'] ) ),
564 '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' ) )