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';
50 require_once 'PHPTAL/Attribute.php';
51 require_once 'PHPTAL/Attribute/I18N/Attributes.php';
58 //class MediaWiki_I18N extends PHPTAL_I18N {
59 class MediaWiki_I18N
{
60 var $_context = array();
62 function set($varName, $value) {
63 $this->_context
[$varName] = $value;
66 function translate($value) {
67 $value = wfMsg( $value );
68 // interpolate variables
69 while (preg_match('/\$([0-9]*?)/sm', $value, $m)) {
70 list($src, $var) = $m;
72 $varValue = $this->_context
[$var];
74 $value = str_replace($src, $varValue, $value);
80 function setLanguage( $langCode ) {
83 function setDomain( $domain ) {
86 function setVar( $key, $value ) {
87 $this->set( $key, $value );
94 class SkinPHPTal
extends Skin
{
100 * Name of our skin, set in initPage()
101 * It probably need to be all lower case.
106 * Stylesheets set to use
107 * Sub directory in ./skins/ where various stylesheets are located
112 * PHPTal template to be used.
113 * '.pt' will be automaticly added to it on PHPTAL object creation
120 function initPage( &$out ) {
121 parent
::initPage( $out );
122 $this->skinname
= 'monobook';
123 $this->stylename
= 'monobook';
124 $this->template
= 'MonoBook';
128 * If using PHPTAL 0.7 on PHP 4.x, return a PHPTAL template object.
129 * If using PHPTAL 1.0 on PHP 5.x, return a bridge object.
133 function &setupTemplate( $file, $repository=false, $cache_dir=false ) {
134 if( defined( 'NEW_PHPTAL' ) && NEW_PHPTAL
) {
135 return new PHPTAL_version_bridge( $file, $repository, $cache_dir );
137 return new PHPTAL( $file, $repository, $cache_dir );
142 * initialize various variables and generate the template
144 function outputPage( &$out ) {
145 global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut;
146 global $wgScript, $wgStylePath, $wgLanguageCode, $wgContLanguageCode, $wgUseNewInterlanguage;
147 global $wgMimeType, $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest;
148 global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgSiteNotice;
149 global $wgMaxCredits, $wgShowCreditsIfMax;
151 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
153 $this->initPage( $out );
154 $tpl =& $this->setupTemplate( $this->template
. '.pt', 'skins' );
156 #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
157 $tpl->setTranslator(new MediaWiki_I18N());
160 $this->thispage
= $wgTitle->getPrefixedDbKey();
161 $this->thisurl
= $wgTitle->getPrefixedURL();
162 $this->loggedin
= $wgUser->getID() != 0;
163 $this->iscontent
= ($wgTitle->getNamespace() != Namespace::getSpecial() );
164 $this->iseditable
= ($this->iscontent
and !($action == 'edit' or $action == 'submit'));
165 $this->username
= $wgUser->getName();
166 $this->userpage
= $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
167 $this->userpageUrlDetails
= $this->makeUrlDetails($this->userpage
);
169 $this->usercss
= $this->userjs
= $this->userjsprev
= false;
170 $this->setupUserCssJs();
172 $this->titletxt
= $wgTitle->getPrefixedText();
174 $tpl->set( 'title', $wgOut->getPageTitle() );
175 $tpl->set( 'pagetitle', $wgOut->getHTMLTitle() );
177 $tpl->setRef( "thispage", $this->thispage
);
178 $subpagestr = $this->subPageSubtitle();
180 'subtitle', !empty($subpagestr)?
181 '<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle():
184 $undelete = $this->getUndeleteLink();
186 "undelete", !empty($undelete)?
187 '<span class="subpages">'.$undelete.'</span>':
191 $tpl->set( 'catlinks', $this->getCategories());
192 if( $wgOut->isSyndicated() ) {
194 foreach( $wgFeedClasses as $format => $class ) {
195 $feeds[$format] = array(
197 'href' => $wgRequest->appendQuery( "feed=$format" ),
198 'ttip' => wfMsg('tooltip-'.$format)
201 $tpl->setRef( 'feeds', $feeds );
203 $tpl->set( 'feeds', false );
205 $tpl->setRef( 'mimetype', $wgMimeType );
206 $tpl->setRef( 'charset', $wgOutputEncoding );
207 $tpl->set( 'headlinks', $out->getHeadLinks() );
208 $tpl->setRef( 'wgScript', $wgScript );
209 $tpl->setRef( 'skinname', $this->skinname
);
210 $tpl->setRef( 'stylename', $this->stylename
);
211 $tpl->setRef( 'loggedin', $this->loggedin
);
212 $tpl->set('nsclass', 'ns-'.$wgTitle->getNamespace());
213 $tpl->set('notspecialpage', $wgTitle->getNamespace() != NS_SPECIAL
);
214 /* XXX currently unused, might get useful later
215 $tpl->set( "editable", ($wgTitle->getNamespace() != NS_SPECIAL ) );
216 $tpl->set( "exists", $wgTitle->getArticleID() != 0 );
217 $tpl->set( "watch", $wgTitle->userIsWatching() ? "unwatch" : "watch" );
218 $tpl->set( "protect", count($wgTitle->getRestrictions()) ? "unprotect" : "protect" );
219 $tpl->set( "helppage", wfMsg('helppage'));
220 $tpl->set( "sysop", $wgUser->isSysop() );
222 $tpl->set( 'searchaction', $this->escapeSearchLink() );
223 $tpl->setRef( 'stylepath', $wgStylePath );
224 $tpl->setRef( 'logopath', $wgLogo );
225 $tpl->setRef( "lang", $wgContLanguageCode );
226 $tpl->set( 'dir', $wgContLang->isRTL() ?
"rtl" : "ltr" );
227 $tpl->set( 'rtl', $wgContLang->isRTL() );
228 $tpl->set( 'langname', $wgContLang->getLanguageName( $wgContLanguageCode ) );
229 $tpl->setRef( 'username', $this->username
);
230 $tpl->setRef( 'userpage', $this->userpage
);
231 $tpl->setRef( 'userpageurl', $this->userpageUrlDetails
['href']);
232 $tpl->setRef( 'usercss', $this->usercss
);
233 $tpl->setRef( 'userjs', $this->userjs
);
234 $tpl->setRef( 'userjsprev', $this->userjsprev
);
235 if($this->loggedin
) {
236 $tpl->set( 'jsvarurl', $this->makeUrl('-','action=raw&smaxage=0&gen=js') );
238 $tpl->set( 'jsvarurl', $this->makeUrl('-','action=raw&gen=js') );
240 if( $wgUser->getNewtalk() ) {
241 $usertitle = Title
::newFromText( $this->userpage
);
242 $usertalktitle = $usertitle->getTalkPage();
243 if($usertalktitle->getPrefixedDbKey() != $this->thispage
){
245 $ntl = wfMsg( 'newmessages',
246 $this->makeKnownLink(
247 $wgContLang->getNsText( Namespace::getTalk( Namespace::getUser() ) )
248 . ':' . $this->username
,
249 wfMsg('newmessageslink') )
252 $wgOut->setSquidMaxage(0);
258 $tpl->setRef( 'newtalk', $ntl );
259 $tpl->setRef( 'skin', $this);
260 $tpl->set( 'logo', $this->logoText() );
261 if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and 0 != $wgArticle->getID() ) {
262 if ( !$wgDisableCounters ) {
263 $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
265 $tpl->set('viewcount', wfMsg( "viewcount", $viewcount ));
267 $tpl->set('viewcount', false);
270 $tpl->set('lastmod', $this->lastModified());
271 $tpl->set('copyright',$this->getCopyright());
273 $this->credits
= false;
275 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
276 require_once("Credits.php");
277 $this->credits
= getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
280 $tpl->setRef( 'credits', $this->credits
);
282 } elseif ( isset( $oldid ) && !isset( $diff ) ) {
283 $tpl->set('copyright', $this->getCopyright());
284 $tpl->set('viewcount', false);
285 $tpl->set('lastmod', false);
286 $tpl->set('credits', false);
288 $tpl->set('copyright', false);
289 $tpl->set('viewcount', false);
290 $tpl->set('lastmod', false);
291 $tpl->set('credits', false);
294 $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
295 $tpl->set( 'poweredbyico', $this->getPoweredBy() );
296 $tpl->set( 'disclaimer', $this->disclaimerLink() );
297 $tpl->set( 'about', $this->aboutLink() );
299 $tpl->setRef( 'debug', $out->mDebugtext
);
300 $tpl->set( 'reporttime', $out->reportTime() );
301 $tpl->set( 'sitenotice', $wgSiteNotice );
303 $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
304 $out->mBodytext
.= $printfooter ;
305 $tpl->setRef( 'bodytext', $out->mBodytext
);
308 $language_urls = array();
309 foreach( $wgOut->getLanguageLinks() as $l ) {
310 $nt = Title
::newFromText( $l );
311 $language_urls[] = array('href' => $nt->getFullURL(),
312 'text' => ($wgContLang->getLanguageName( $nt->getInterwiki()) != ''?
$wgContLang->getLanguageName( $nt->getInterwiki()) : $l),
313 'class' => $wgContLang->isRTL() ?
'rtl' : 'ltr');
315 if(count($language_urls)) {
316 $tpl->setRef( 'language_urls', $language_urls);
318 $tpl->set('language_urls', false);
322 $tpl->set('personal_urls', $this->buildPersonalUrls());
323 $content_actions = $this->buildContentActionUrls();
324 $tpl->setRef('content_actions', $content_actions);
325 // XXX: attach this from javascript, same with section editing
326 if($this->iseditable
&& $wgUser->getOption("editondblclick") )
328 $tpl->set('body_ondblclick', 'document.location = "' .$content_actions['edit']['href'] .'";');
330 $tpl->set('body_ondblclick', false);
332 $tpl->set( 'navigation_urls', $this->buildNavigationUrls() );
333 $tpl->set( 'nav_urls', $this->buildNavUrls() );
336 $res = $tpl->execute();
337 // result may be an error
338 if (PEAR
::isError($res)) {
339 echo $res->toString(), "\n";
347 * build array of urls for personal toolbar
349 function buildPersonalUrls() {
350 /* set up the default links for the personal toolbar */
351 global $wgShowIPinHeader;
352 $personal_urls = array();
353 if ($this->loggedin
) {
354 $personal_urls['userpage'] = array(
355 'text' => $this->username
,
356 'href' => &$this->userpageUrlDetails
['href'],
357 'class' => $this->userpageUrlDetails
['exists']?
false:'new'
359 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage
);
360 $personal_urls['mytalk'] = array(
361 'text' => wfMsg('mytalk'),
362 'href' => &$usertalkUrlDetails['href'],
363 'class' => $usertalkUrlDetails['exists']?
false:'new'
365 $personal_urls['preferences'] = array(
366 'text' => wfMsg('preferences'),
367 'href' => $this->makeSpecialUrl('Preferences')
369 $personal_urls['watchlist'] = array(
370 'text' => wfMsg('watchlist'),
371 'href' => $this->makeSpecialUrl('Watchlist')
373 $personal_urls['mycontris'] = array(
374 'text' => wfMsg('mycontris'),
375 'href' => $this->makeSpecialUrl('Contributions','target=' . urlencode( $this->username
) )
377 $personal_urls['logout'] = array(
378 'text' => wfMsg('userlogout'),
379 'href' => $this->makeSpecialUrl('Userlogout','returnto=' . $this->thisurl
)
382 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) {
383 $personal_urls['anonuserpage'] = array(
384 'text' => $this->username
,
385 'href' => &$this->userpageUrlDetails
['href'],
386 'class' => $this->userpageUrlDetails
['exists']?
false:'new'
388 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage
);
389 $personal_urls['anontalk'] = array(
390 'text' => wfMsg('anontalk'),
391 'href' => &$usertalkUrlDetails['href'],
392 'class' => $usertalkUrlDetails['exists']?
false:'new'
394 $personal_urls['anonlogin'] = array(
395 'text' => wfMsg('userlogin'),
396 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl
)
400 $personal_urls['login'] = array(
401 'text' => wfMsg('userlogin'),
402 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl
)
407 return $personal_urls;
411 * an array of edit links by default used for the tabs
413 function buildContentActionUrls () {
414 global $wgTitle, $wgUser, $wgOut, $wgRequest, $wgUseValidation;
415 $action = $wgRequest->getText( 'action' );
416 $section = $wgRequest->getText( 'section' );
417 $oldid = $wgRequest->getVal( 'oldid' );
418 $diff = $wgRequest->getVal( 'diff' );
419 $content_actions = array();
421 if( $this->iscontent
and !$wgOut->isQuickbarSuppressed() ) {
423 $nskey = $this->getNameSpaceKey();
424 $is_active = !Namespace::isTalk( $wgTitle->getNamespace()) ;
425 if ( $action == 'validate' ) $is_active = false ; # Show article tab deselected when validating
426 $content_actions[$nskey] = array('class' => ($is_active) ?
'selected' : false,
427 'text' => wfMsg($nskey),
428 'href' => $this->makeArticleUrl($this->thispage
));
430 /* set up the classes for the talk link */
431 $talk_class = (Namespace::isTalk( $wgTitle->getNamespace()) ?
'selected' : false);
432 $talktitle = Title
::newFromText( $this->titletxt
);
433 $talktitle = $talktitle->getTalkPage();
434 $this->checkTitle($talktitle, $this->titletxt
);
435 if($talktitle->getArticleId() != 0) {
436 $content_actions['talk'] = array(
437 'class' => $talk_class,
438 'text' => wfMsg('talk'),
439 'href' => $this->makeTalkUrl($this->titletxt
)
442 $content_actions['talk'] = array(
443 'class' => $talk_class?
$talk_class.' new':'new',
444 'text' => wfMsg('talk'),
445 'href' => $this->makeTalkUrl($this->titletxt
,'action=edit')
449 if ( $wgTitle->userCanEdit() ) {
450 $oid = ( $oldid && ! isset( $diff ) ) ?
'&oldid='.$oldid : false;
451 $istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) );
452 $istalkclass = $istalk?
' istalk':'';
453 $content_actions['edit'] = array(
454 'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ?
'selected' : '').$istalkclass,
455 'text' => wfMsg('edit'),
456 'href' => $this->makeUrl($this->thispage
, 'action=edit'.$oid)
459 $content_actions['addsection'] = array(
460 'class' => $section == 'new'?
'selected':false,
461 'text' => wfMsg('addsection'),
462 'href' => $this->makeUrl($this->thispage
, 'action=edit§ion=new')
466 $oid = ( $oldid && ! isset( $diff ) ) ?
'&oldid='.$oldid : '';
467 $content_actions['viewsource'] = array('class' => ($action == 'edit') ?
'selected' : false,
468 'text' => wfMsg('viewsource'),
469 'href' => $this->makeUrl($this->thispage
, 'action=edit'.$oid));
472 if ( $wgTitle->getArticleId() ) {
474 $content_actions['history'] = array('class' => ($action == 'history') ?
'selected' : false,
475 'text' => wfMsg('history_short'),
476 'href' => $this->makeUrl($this->thispage
, 'action=history'));
478 # XXX: is there a rollback action anywhere or is it planned?
479 # Don't recall where i got this from...
480 /*if( $wgUser->getNewtalk() ) {
481 $content_actions['rollback'] = array('class' => ($action == 'rollback') ? 'selected' : false,
482 'text' => wfMsg('rollback_short'),
483 'href' => $this->makeUrl($this->thispage, 'action=rollback'),
484 'ttip' => wfMsg('tooltip-rollback'),
485 'akey' => wfMsg('accesskey-rollback'));
488 if($wgUser->isSysop()){
489 if(!$wgTitle->isProtected()){
490 $content_actions['protect'] = array(
491 'class' => ($action == 'protect') ?
'selected' : false,
492 'text' => wfMsg('protect'),
493 'href' => $this->makeUrl($this->thispage
, 'action=protect')
497 $content_actions['unprotect'] = array(
498 'class' => ($action == 'unprotect') ?
'selected' : false,
499 'text' => wfMsg('unprotect'),
500 'href' => $this->makeUrl($this->thispage
, 'action=unprotect')
503 $content_actions['delete'] = array(
504 'class' => ($action == 'delete') ?
'selected' : false,
505 'text' => wfMsg('delete'),
506 'href' => $this->makeUrl($this->thispage
, 'action=delete')
509 if ( $wgUser->getID() != 0 ) {
510 if ( $wgTitle->userCanEdit()) {
511 $content_actions['move'] = array('class' => ($wgTitle->getDbKey() == 'Movepage' and $wgTitle->getNamespace
== Namespace::getSpecial()) ?
'selected' : false,
512 'text' => wfMsg('move'),
513 'href' => $this->makeSpecialUrl('Movepage', 'target='. urlencode( $this->thispage
))
516 $content_actions['move'] = array('class' => 'inactive',
517 'text' => wfMsg('move'),
523 //article doesn't exist or is deleted
524 if($wgUser->isSysop()){
525 if( $n = $wgTitle->isDeleted() ) {
526 $content_actions['delete'] = array(
528 'text' => wfMsg( "undelete_short", $n ),
529 'href' => $this->makeSpecialUrl('Undelete/'.$this->thispage
)
535 if ( $wgUser->getID() != 0 and $action != 'submit' ) {
536 if( !$wgTitle->userIsWatching()) {
537 $content_actions['watch'] = array('class' => ($action == 'watch' or $action == 'unwatch') ?
'selected' : false,
538 'text' => wfMsg('watch'),
539 'href' => $this->makeUrl($this->thispage
, 'action=watch'));
541 $content_actions['unwatch'] = array('class' => ($action == 'unwatch' or $action == 'watch') ?
'selected' : false,
542 'text' => wfMsg('unwatch'),
543 'href' => $this->makeUrl($this->thispage
, 'action=unwatch'));
548 if ( $wgUseValidation && $wgTitle->getArticleId() && $wgTitle->getNamespace() == 0 ) {
550 $article_time = "×tamp=" . $wgArticle->mTimestamp
;
551 $content_actions['validate'] = array('class' => ($action == 'validate') ?
'selected' : false ,
552 'text' => wfMsg('val_tab'),
553 'href' => $this->makeUrl($this->thispage
, 'action=validate'.$article_time));
557 /* show special page tab */
559 $content_actions['article'] = array('class' => 'selected',
560 'text' => wfMsg('specialpage'),
564 return $content_actions;
568 * build array of global navigation links
570 function buildNavigationUrls () {
571 global $wgNavigationLinks;
573 foreach ( $wgNavigationLinks as $link ) {
575 'text' => wfMsg( $link['text'] ),
576 'href' => $this->makeInternalOrExternalUrl( wfMsgForContent( $link['href'] ) ),
577 'id' => 'n-'.$link['text']
584 * build array of common navigation links
586 function buildNavUrls () {
587 global $wgTitle, $wgUser, $wgRequest;
588 global $wgSiteSupportPage, $wgDisableUploads;
590 $action = $wgRequest->getText( 'action' );
591 $oldid = $wgRequest->getVal( 'oldid' );
592 $diff = $wgRequest->getVal( 'diff' );
593 // XXX: remove htmlspecialchars when tal:attributes works with i18n:attributes
595 $nav_urls['mainpage'] = array('href' => $this->makeI18nUrl('mainpage'));
596 $nav_urls['randompage'] = array('href' => $this->makeSpecialUrl('Randompage'));
597 $nav_urls['recentchanges'] = array('href' => $this->makeSpecialUrl('Recentchanges'));
598 $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ?
array('href' => $this->makeI18nUrl('currentevents')) : false;
599 $nav_urls['portal'] = (wfMsg('portal') != '-') ?
array('href' => $this->makeI18nUrl('portal-url')) : false;
600 $nav_urls['bugreports'] = array('href' => $this->makeI18nUrl('bugreportspage'));
601 // $nav_urls['sitesupport'] = array('href' => $this->makeI18nUrl('sitesupportpage'));
602 $nav_urls['sitesupport'] = array('href' => $wgSiteSupportPage);
603 $nav_urls['help'] = array('href' => $this->makeI18nUrl('helppage'));
604 if( $this->loggedin
&& !$wgDisableUploads ) {
605 $nav_urls['upload'] = array('href' => $this->makeSpecialUrl('Upload'));
607 $nav_urls['upload'] = false;
609 $nav_urls['specialpages'] = array('href' => $this->makeSpecialUrl('Specialpages'));
611 if( $wgTitle->getNamespace() != NS_SPECIAL
) {
612 $nav_urls['whatlinkshere'] = array('href' => $this->makeSpecialUrl('Whatlinkshere', 'target='.urlencode( $this->thispage
)));
613 $nav_urls['recentchangeslinked'] = array('href' => $this->makeSpecialUrl('Recentchangeslinked', 'target='.urlencode( $this->thispage
)));
616 if( $wgTitle->getNamespace() == NS_USER ||
$wgTitle->getNamespace() == NS_USER_TALK
) {
617 $id = User
::idFromName($wgTitle->getText());
618 $ip = User
::isIP($wgTitle->getText());
624 if($id ||
$ip) { # both anons and non-anons have contri list
625 $nav_urls['contributions'] = array(
626 'href' => $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() )
629 $nav_urls['contributions'] = false;
631 $nav_urls['emailuser'] = false;
632 if ( 0 != $wgUser->getID() ) { # show only to signed in users
633 if($id) { # can only email non-anons
634 $nav_urls['emailuser'] = array(
635 'href' => $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() )
644 * Generate strings used for xml 'id' names
646 function getNameSpaceKey () {
648 switch ($wgTitle->getNamespace()) {
656 return 'nstab-media';
658 return 'nstab-special';
660 case NS_PROJECT_TALK
:
664 return 'nstab-image';
666 case NS_MEDIAWIKI_TALK
:
667 return 'nstab-mediawiki';
669 case NS_TEMPLATE_TALK
:
670 return 'nstab-template';
675 case NS_CATEGORY_TALK
:
676 return 'nstab-category';
686 function setupUserCssJs () {
687 global $wgRequest, $wgTitle;
688 $action = $wgRequest->getText('action');
690 $this->usercss
= '@import "'.$this->makeUrl('-','action=raw&gen=css').'";'."\n";
692 if( $this->loggedin
) {
693 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
695 $this->usercss
= '@import "'.$this->makeUrl('-','action=raw&smaxage=0&maxage=0&gen=css').'";'."\n";
697 $this->usercss
.= $wgRequest->getText('wpTextbox1');
700 $this->usercss
.= '@import "'.$this->makeUrl('-','action=raw&smaxage=0&gen=css').'";'."\n";
701 # import user stylesheet
702 $this->usercss
.= '@import "'.
703 $this->makeUrl($this->userpage
.'/'.$this->skinname
.'.css', 'action=raw&ctype=text/css').'";'."\n";
705 if($wgTitle->isJsSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
706 # XXX: additional security check/prompt?
707 $this->userjsprev
= $wgRequest->getText('wpTextbox1');
709 $this->userjs
= $this->makeUrl($this->userpage
.'/'.$this->skinname
.'.js', 'action=raw&ctype=text/javascript&dontcountme=s');
712 $this->usercss
= '/*<![CDATA[*/ ' . $this->usercss
. ' /*]]>*/';
713 if( $this->userjsprev
) {
714 $this->userjsprev
= '/*<![CDATA[*/ ' . $this->userjsprev
. ' /*]]>*/';
719 * returns css with user-specific options
721 function getUserStylesheet() {
722 global $wgUser, $wgRequest, $wgTitle, $wgContLang, $wgSquidMaxage, $wgStylePath;
723 $action = $wgRequest->getText('action');
724 $maxage = $wgRequest->getText('maxage');
725 $s = "/* generated user stylesheet */\n";
726 if($wgContLang->isRTL()) $s .= '@import "'.$wgStylePath.'/'.$this->stylename
.'/rtl.css";'."\n";
728 $this->makeNSUrl(ucfirst($this->skinname
).'.css', 'action=raw&ctype=text/css&smaxage='.$wgSquidMaxage, NS_MEDIAWIKI
)."\";\n";
729 if($wgUser->getID() != 0) {
730 if ( 1 == $wgUser->getOption( "underline" ) ) {
731 $s .= "a { text-decoration: underline; }\n";
733 $s .= "a { text-decoration: none; }\n";
736 if ( 1 != $wgUser->getOption( "highlightbroken" ) ) {
737 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
739 if ( 1 == $wgUser->getOption( "justify" ) ) {
740 $s .= "#bodyContent { text-align: justify; }\n";
748 function getUserJs() {
749 global $wgUser, $wgStylePath;
750 $s = '/* generated javascript */';
751 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
752 $s .= '/* MediaWiki:'.ucfirst($this->skinname
)." */\n";
753 $s .= wfMsg(ucfirst($this->skinname
).'.js');
758 class PHPTAL_version_bridge
{
759 function PHPTAL_version_bridge( $file, $repository=false, $cache_dir=false ) {
760 $this->tpl
=& new PHPTAL( $file );
762 $this->tpl
->setTemplateRepository( $repository );
766 function set( $name, $value ) {
767 $this->tpl
->$name = $value;
770 function setRef($name, &$value) {
771 $this->set( $name, $value );
774 function setTranslator( &$t ) {
775 $this->tpl
->setTranslator( $t );
782 return $this->tpl
->execute();
785 catch (Exception $e) {
786 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 ";
794 } // end of if( defined( 'MEDIAWIKI' ) )