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;
35 * This is not a valid entry point, perform no further processing unless
36 * MEDIAWIKI is defined
38 if( defined( 'MEDIAWIKI' ) ) {
40 require_once 'GlobalFunctions.php';
46 // PHPTAL 1.0 no longer has the PHPTAL_I18N stub class.
47 //class MediaWiki_I18N extends PHPTAL_I18N {
48 class MediaWiki_I18N
{
49 var $_context = array();
51 function set($varName, $value) {
52 $this->_context
[$varName] = $value;
55 function translate($value) {
56 // Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of 2004-10-23
57 $value = preg_replace( '/^string:/', '', $value );
59 $value = wfMsg( $value );
60 // interpolate variables
61 while (preg_match('/\$([0-9]*?)/sm', $value, $m)) {
62 list($src, $var) = $m;
64 $varValue = $this->_context
[$var];
66 $value = str_replace($src, $varValue, $value);
75 class SkinTemplate
extends Skin
{
81 * Name of our skin, set in initPage()
82 * It probably need to be all lower case.
87 * Stylesheets set to use
88 * Sub directory in ./skins/ where various stylesheets are located
93 * PHPTal template to be used.
94 * '.pt' will be automaticly added to it on PHPTAL object creation
101 function initPage( &$out ) {
102 parent
::initPage( $out );
103 $this->skinname
= 'monobook';
104 $this->stylename
= 'monobook';
105 $this->template
= 'MonoBookTemplate';
109 * If using PHPTAL 0.7 on PHP 4.x, return a PHPTAL template object.
110 * If using PHPTAL 1.0 on PHP 5.x, return a bridge object.
114 function &setupTemplate( $file, $repository=false, $cache_dir=false ) {
115 return new QuickTemplate( $file );
119 * initialize various variables and generate the template
121 function outputPage( &$out ) {
122 global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut;
123 global $wgScript, $wgStylePath, $wgLanguageCode, $wgContLanguageCode, $wgUseNewInterlanguage;
124 global $wgMimeType, $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest;
125 global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgSiteNotice;
126 global $wgMaxCredits, $wgShowCreditsIfMax;
128 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
130 $this->initPage( $out );
131 $tpl =& $this->setupTemplate( $this->template
, 'skins' );
133 #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
134 $tpl->setTranslator(new MediaWiki_I18N());
137 $this->thispage
= $wgTitle->getPrefixedDbKey();
138 $this->thisurl
= $wgTitle->getPrefixedURL();
139 $this->loggedin
= $wgUser->getID() != 0;
140 $this->iscontent
= ($wgTitle->getNamespace() != Namespace::getSpecial() );
141 $this->iseditable
= ($this->iscontent
and !($action == 'edit' or $action == 'submit'));
142 $this->username
= $wgUser->getName();
143 $this->userpage
= $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
144 $this->userpageUrlDetails
= $this->makeUrlDetails($this->userpage
);
146 $this->usercss
= $this->userjs
= $this->userjsprev
= false;
147 $this->setupUserCss();
148 $this->setupUserJs();
149 $this->titletxt
= $wgTitle->getPrefixedText();
151 $tpl->set( 'title', $wgOut->getPageTitle() );
152 $tpl->set( 'pagetitle', $wgOut->getHTMLTitle() );
154 $tpl->setRef( "thispage", $this->thispage
);
155 $subpagestr = $this->subPageSubtitle();
157 'subtitle', !empty($subpagestr)?
158 '<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle():
161 $undelete = $this->getUndeleteLink();
163 "undelete", !empty($undelete)?
164 '<span class="subpages">'.$undelete.'</span>':
168 $tpl->set( 'catlinks', $this->getCategories());
169 if( $wgOut->isSyndicated() ) {
171 foreach( $wgFeedClasses as $format => $class ) {
172 $feeds[$format] = array(
174 'href' => $wgRequest->appendQuery( "feed=$format" ),
175 'ttip' => wfMsg('tooltip-'.$format)
178 $tpl->setRef( 'feeds', $feeds );
180 $tpl->set( 'feeds', false );
182 $tpl->setRef( 'mimetype', $wgMimeType );
183 $tpl->setRef( 'charset', $wgOutputEncoding );
184 $tpl->set( 'headlinks', $out->getHeadLinks() );
185 $tpl->setRef( 'wgScript', $wgScript );
186 $tpl->setRef( 'skinname', $this->skinname
);
187 $tpl->setRef( 'stylename', $this->stylename
);
188 $tpl->setRef( 'loggedin', $this->loggedin
);
189 $tpl->set('nsclass', 'ns-'.$wgTitle->getNamespace());
190 $tpl->set('notspecialpage', $wgTitle->getNamespace() != NS_SPECIAL
);
191 /* XXX currently unused, might get useful later
192 $tpl->set( "editable", ($wgTitle->getNamespace() != NS_SPECIAL ) );
193 $tpl->set( "exists", $wgTitle->getArticleID() != 0 );
194 $tpl->set( "watch", $wgTitle->userIsWatching() ? "unwatch" : "watch" );
195 $tpl->set( "protect", count($wgTitle->getRestrictions()) ? "unprotect" : "protect" );
196 $tpl->set( "helppage", wfMsg('helppage'));
198 $tpl->set( 'searchaction', $this->escapeSearchLink() );
199 $tpl->setRef( 'stylepath', $wgStylePath );
200 $tpl->setRef( 'logopath', $wgLogo );
201 $tpl->setRef( "lang", $wgContLanguageCode );
202 $tpl->set( 'dir', $wgContLang->isRTL() ?
"rtl" : "ltr" );
203 $tpl->set( 'rtl', $wgContLang->isRTL() );
204 $tpl->set( 'langname', $wgContLang->getLanguageName( $wgContLanguageCode ) );
205 $tpl->setRef( 'username', $this->username
);
206 $tpl->setRef( 'userpage', $this->userpage
);
207 $tpl->setRef( 'userpageurl', $this->userpageUrlDetails
['href']);
208 $tpl->setRef( 'usercss', $this->usercss
);
209 $tpl->setRef( 'userjs', $this->userjs
);
210 $tpl->setRef( 'userjsprev', $this->userjsprev
);
213 if($this->loggedin
) {
214 $tpl->set( 'jsvarurl', $this->makeUrl('-','action=raw&smaxage=0&gen=js') );
216 $tpl->set( 'jsvarurl', $this->makeUrl('-','action=raw&gen=js') );
219 $tpl->set('jsvarurl', false);
221 if( $wgUser->getNewtalk() ) {
222 $usertitle = Title
::newFromText( $this->userpage
);
223 $usertalktitle = $usertitle->getTalkPage();
224 if($usertalktitle->getPrefixedDbKey() != $this->thispage
){
226 $ntl = wfMsg( 'newmessages',
227 $this->makeKnownLink(
228 $wgContLang->getNsText( Namespace::getTalk( Namespace::getUser() ) )
229 . ':' . $this->username
,
230 wfMsg('newmessageslink') )
233 $wgOut->setSquidMaxage(0);
239 $tpl->setRef( 'newtalk', $ntl );
240 $tpl->setRef( 'skin', $this);
241 $tpl->set( 'logo', $this->logoText() );
242 if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and 0 != $wgArticle->getID() ) {
243 if ( !$wgDisableCounters ) {
244 $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
246 $tpl->set('viewcount', wfMsg( "viewcount", $viewcount ));
248 $tpl->set('viewcount', false);
251 $tpl->set('lastmod', $this->lastModified());
252 $tpl->set('copyright',$this->getCopyright());
254 $this->credits
= false;
256 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
257 require_once("Credits.php");
258 $this->credits
= getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
261 $tpl->setRef( 'credits', $this->credits
);
263 } elseif ( isset( $oldid ) && !isset( $diff ) ) {
264 $tpl->set('copyright', $this->getCopyright());
265 $tpl->set('viewcount', false);
266 $tpl->set('lastmod', false);
267 $tpl->set('credits', false);
269 $tpl->set('copyright', false);
270 $tpl->set('viewcount', false);
271 $tpl->set('lastmod', false);
272 $tpl->set('credits', false);
275 $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
276 $tpl->set( 'poweredbyico', $this->getPoweredBy() );
277 $tpl->set( 'disclaimer', $this->disclaimerLink() );
278 $tpl->set( 'about', $this->aboutLink() );
280 $tpl->setRef( 'debug', $out->mDebugtext
);
281 $tpl->set( 'reporttime', $out->reportTime() );
282 $tpl->set( 'sitenotice', $wgSiteNotice );
284 $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
285 $out->mBodytext
.= $printfooter ;
286 $tpl->setRef( 'bodytext', $out->mBodytext
);
289 $language_urls = array();
290 foreach( $wgOut->getLanguageLinks() as $l ) {
291 $nt = Title
::newFromText( $l );
292 $language_urls[] = array('href' => $nt->getFullURL(),
293 'text' => ($wgContLang->getLanguageName( $nt->getInterwiki()) != ''?
$wgContLang->getLanguageName( $nt->getInterwiki()) : $l),
294 'class' => $wgContLang->isRTL() ?
'rtl' : 'ltr');
296 if(count($language_urls)) {
297 $tpl->setRef( 'language_urls', $language_urls);
299 $tpl->set('language_urls', false);
303 $tpl->set('personal_urls', $this->buildPersonalUrls());
304 $content_actions = $this->buildContentActionUrls();
305 $tpl->setRef('content_actions', $content_actions);
306 // XXX: attach this from javascript, same with section editing
307 if($this->iseditable
&& $wgUser->getOption("editondblclick") )
309 $tpl->set('body_ondblclick', 'document.location = "' .$content_actions['edit']['href'] .'";');
311 $tpl->set('body_ondblclick', false);
313 $tpl->set( 'navigation_urls', $this->buildNavigationUrls() );
314 $tpl->set( 'nav_urls', $this->buildNavUrls() );
317 $res = $tpl->execute();
319 // result may be an error
320 #if (PEAR::isError($res)) {
321 # echo $res->toString(), "\n";
329 * build array of urls for personal toolbar
331 function buildPersonalUrls() {
332 /* set up the default links for the personal toolbar */
333 global $wgShowIPinHeader;
334 $personal_urls = array();
335 if ($this->loggedin
) {
336 $personal_urls['userpage'] = array(
337 'text' => $this->username
,
338 'href' => &$this->userpageUrlDetails
['href'],
339 'class' => $this->userpageUrlDetails
['exists']?
false:'new'
341 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage
);
342 $personal_urls['mytalk'] = array(
343 'text' => wfMsg('mytalk'),
344 'href' => &$usertalkUrlDetails['href'],
345 'class' => $usertalkUrlDetails['exists']?
false:'new'
347 $personal_urls['preferences'] = array(
348 'text' => wfMsg('preferences'),
349 'href' => $this->makeSpecialUrl('Preferences')
351 $personal_urls['watchlist'] = array(
352 'text' => wfMsg('watchlist'),
353 'href' => $this->makeSpecialUrl('Watchlist')
355 $personal_urls['mycontris'] = array(
356 'text' => wfMsg('mycontris'),
357 'href' => $this->makeSpecialUrl('Contributions','target=' . urlencode( $this->username
) )
359 $personal_urls['logout'] = array(
360 'text' => wfMsg('userlogout'),
361 'href' => $this->makeSpecialUrl('Userlogout','returnto=' . $this->thisurl
)
364 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) {
365 $personal_urls['anonuserpage'] = array(
366 'text' => $this->username
,
367 'href' => &$this->userpageUrlDetails
['href'],
368 'class' => $this->userpageUrlDetails
['exists']?
false:'new'
370 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage
);
371 $personal_urls['anontalk'] = array(
372 'text' => wfMsg('anontalk'),
373 'href' => &$usertalkUrlDetails['href'],
374 'class' => $usertalkUrlDetails['exists']?
false:'new'
376 $personal_urls['anonlogin'] = array(
377 'text' => wfMsg('userlogin'),
378 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl
)
382 $personal_urls['login'] = array(
383 'text' => wfMsg('userlogin'),
384 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl
)
389 return $personal_urls;
393 * an array of edit links by default used for the tabs
395 function buildContentActionUrls () {
396 global $wgTitle, $wgUser, $wgOut, $wgRequest, $wgUseValidation;
397 $action = $wgRequest->getText( 'action' );
398 $section = $wgRequest->getText( 'section' );
399 $oldid = $wgRequest->getVal( 'oldid' );
400 $diff = $wgRequest->getVal( 'diff' );
401 $content_actions = array();
403 if( $this->iscontent
and !$wgOut->isQuickbarSuppressed() ) {
405 $nskey = $this->getNameSpaceKey();
406 $is_active = !Namespace::isTalk( $wgTitle->getNamespace()) ;
407 if ( $action == 'validate' ) $is_active = false ; # Show article tab deselected when validating
408 $content_actions[$nskey] = array('class' => ($is_active) ?
'selected' : false,
409 'text' => wfMsg($nskey),
410 'href' => $this->makeArticleUrl($this->thispage
));
412 /* set up the classes for the talk link */
413 $talk_class = (Namespace::isTalk( $wgTitle->getNamespace()) ?
'selected' : false);
414 $talktitle = Title
::newFromText( $this->titletxt
);
415 $talktitle = $talktitle->getTalkPage();
416 $this->checkTitle($talktitle, $this->titletxt
);
417 if($talktitle->getArticleId() != 0) {
418 $content_actions['talk'] = array(
419 'class' => $talk_class,
420 'text' => wfMsg('talk'),
421 'href' => $this->makeTalkUrl($this->titletxt
)
424 $content_actions['talk'] = array(
425 'class' => $talk_class?
$talk_class.' new':'new',
426 'text' => wfMsg('talk'),
427 'href' => $this->makeTalkUrl($this->titletxt
,'action=edit')
431 if ( $wgTitle->userCanEdit() ) {
432 $oid = ( $oldid && ! isset( $diff ) ) ?
'&oldid='.IntVal( $oldid ) : false;
433 $istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) );
434 $istalkclass = $istalk?
' istalk':'';
435 $content_actions['edit'] = array(
436 'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ?
'selected' : '').$istalkclass,
437 'text' => wfMsg('edit'),
438 'href' => $this->makeUrl($this->thispage
, 'action=edit'.$oid)
441 $content_actions['addsection'] = array(
442 'class' => $section == 'new'?
'selected':false,
443 'text' => wfMsg('addsection'),
444 'href' => $this->makeUrl($this->thispage
, 'action=edit§ion=new')
448 $oid = ( $oldid && ! isset( $diff ) ) ?
'&oldid='.IntVal( $oldid ) : '';
449 $content_actions['viewsource'] = array('class' => ($action == 'edit') ?
'selected' : false,
450 'text' => wfMsg('viewsource'),
451 'href' => $this->makeUrl($this->thispage
, 'action=edit'.$oid));
454 if ( $wgTitle->getArticleId() ) {
456 $content_actions['history'] = array('class' => ($action == 'history') ?
'selected' : false,
457 'text' => wfMsg('history_short'),
458 'href' => $this->makeUrl($this->thispage
, 'action=history'));
460 # XXX: is there a rollback action anywhere or is it planned?
461 # Don't recall where i got this from...
462 /*if( $wgUser->getNewtalk() ) {
463 $content_actions['rollback'] = array('class' => ($action == 'rollback') ? 'selected' : false,
464 'text' => wfMsg('rollback_short'),
465 'href' => $this->makeUrl($this->thispage, 'action=rollback'),
466 'ttip' => wfMsg('tooltip-rollback'),
467 'akey' => wfMsg('accesskey-rollback'));
471 if($wgUser->isAllowed('protect')){
472 if(!$wgTitle->isProtected()){
473 $content_actions['protect'] = array(
474 'class' => ($action == 'protect') ?
'selected' : false,
475 'text' => wfMsg('protect'),
476 'href' => $this->makeUrl($this->thispage
, 'action=protect')
480 $content_actions['unprotect'] = array(
481 'class' => ($action == 'unprotect') ?
'selected' : false,
482 'text' => wfMsg('unprotect'),
483 'href' => $this->makeUrl($this->thispage
, 'action=unprotect')
487 if($wgUser->isAllowed('delete')){
488 $content_actions['delete'] = array(
489 'class' => ($action == 'delete') ?
'selected' : false,
490 'text' => wfMsg('delete'),
491 'href' => $this->makeUrl($this->thispage
, 'action=delete')
494 if ( $wgUser->getID() != 0 ) {
495 if ( $wgTitle->userCanEdit()) {
496 $content_actions['move'] = array('class' => ($wgTitle->getDbKey() == 'Movepage' and $wgTitle->getNamespace
== Namespace::getSpecial()) ?
'selected' : false,
497 'text' => wfMsg('move'),
498 'href' => $this->makeSpecialUrl('Movepage', 'target='. urlencode( $this->thispage
))
503 //article doesn't exist or is deleted
504 if($wgUser->isAllowed('delete')){
505 if( $n = $wgTitle->isDeleted() ) {
506 $content_actions['undelete'] = array(
508 'text' => wfMsg( "undelete_short", $n ),
509 'href' => $this->makeSpecialUrl('Undelete/'.$this->thispage
)
515 if ( $wgUser->getID() != 0 and $action != 'submit' ) {
516 if( !$wgTitle->userIsWatching()) {
517 $content_actions['watch'] = array('class' => ($action == 'watch' or $action == 'unwatch') ?
'selected' : false,
518 'text' => wfMsg('watch'),
519 'href' => $this->makeUrl($this->thispage
, 'action=watch'));
521 $content_actions['unwatch'] = array('class' => ($action == 'unwatch' or $action == 'watch') ?
'selected' : false,
522 'text' => wfMsg('unwatch'),
523 'href' => $this->makeUrl($this->thispage
, 'action=unwatch'));
528 if ( $wgUseValidation && $wgTitle->getArticleId() && $wgTitle->getNamespace() == 0 ) {
530 $article_time = "×tamp=" . $wgArticle->mTimestamp
;
531 $content_actions['validate'] = array('class' => ($action == 'validate') ?
'selected' : false ,
532 'text' => wfMsg('val_tab'),
533 'href' => $this->makeUrl($this->thispage
, 'action=validate'.$article_time));
537 /* show special page tab */
539 $content_actions['article'] = array('class' => 'selected',
540 'text' => wfMsg('specialpage'),
544 return $content_actions;
548 * build array of global navigation links
550 function buildNavigationUrls () {
551 global $wgNavigationLinks;
553 foreach ( $wgNavigationLinks as $link ) {
554 if (wfMsg( $link['text'] ) != '-') {
556 'text' => wfMsg( $link['text'] ),
557 'href' => $this->makeInternalOrExternalUrl( wfMsgForContent( $link['href'] ) ),
558 'id' => 'n-'.$link['text']
566 * build array of common navigation links
568 function buildNavUrls () {
569 global $wgTitle, $wgUser, $wgRequest;
570 global $wgSiteSupportPage, $wgDisableUploads;
572 $action = $wgRequest->getText( 'action' );
573 $oldid = $wgRequest->getVal( 'oldid' );
574 $diff = $wgRequest->getVal( 'diff' );
575 // XXX: remove htmlspecialchars when tal:attributes works with i18n:attributes
577 $nav_urls['mainpage'] = array('href' => $this->makeI18nUrl('mainpage'));
578 $nav_urls['randompage'] = array('href' => $this->makeSpecialUrl('Randompage'));
579 $nav_urls['recentchanges'] = array('href' => $this->makeSpecialUrl('Recentchanges'));
580 $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ?
array('href' => $this->makeI18nUrl('currentevents')) : false;
581 $nav_urls['portal'] = (wfMsg('portal') != '-') ?
array('href' => $this->makeI18nUrl('portal-url')) : false;
582 $nav_urls['bugreports'] = array('href' => $this->makeI18nUrl('bugreportspage'));
583 // $nav_urls['sitesupport'] = array('href' => $this->makeI18nUrl('sitesupportpage'));
584 $nav_urls['sitesupport'] = array('href' => $wgSiteSupportPage);
585 $nav_urls['help'] = array('href' => $this->makeI18nUrl('helppage'));
586 if( $this->loggedin
&& !$wgDisableUploads ) {
587 $nav_urls['upload'] = array('href' => $this->makeSpecialUrl('Upload'));
589 $nav_urls['upload'] = false;
591 $nav_urls['specialpages'] = array('href' => $this->makeSpecialUrl('Specialpages'));
593 if( $wgTitle->getNamespace() != NS_SPECIAL
) {
594 $nav_urls['whatlinkshere'] = array('href' => $this->makeSpecialUrl('Whatlinkshere', 'target='.urlencode( $this->thispage
)));
595 $nav_urls['recentchangeslinked'] = array('href' => $this->makeSpecialUrl('Recentchangeslinked', 'target='.urlencode( $this->thispage
)));
598 if( $wgTitle->getNamespace() == NS_USER ||
$wgTitle->getNamespace() == NS_USER_TALK
) {
599 $id = User
::idFromName($wgTitle->getText());
600 $ip = User
::isIP($wgTitle->getText());
606 if($id ||
$ip) { # both anons and non-anons have contri list
607 $nav_urls['contributions'] = array(
608 'href' => $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() )
611 $nav_urls['contributions'] = false;
613 $nav_urls['emailuser'] = false;
614 if ( 0 != $wgUser->getID() ) { # show only to signed in users
615 if($id) { # can only email non-anons
616 $nav_urls['emailuser'] = array(
617 'href' => $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() )
626 * Generate strings used for xml 'id' names
628 function getNameSpaceKey () {
630 switch ($wgTitle->getNamespace()) {
638 return 'nstab-media';
640 return 'nstab-special';
642 case NS_PROJECT_TALK
:
646 return 'nstab-image';
648 case NS_MEDIAWIKI_TALK
:
649 return 'nstab-mediawiki';
651 case NS_TEMPLATE_TALK
:
652 return 'nstab-template';
657 case NS_CATEGORY_TALK
:
658 return 'nstab-category';
668 function setupUserCss () {
670 global $wgRequest, $wgTitle, $wgAllowUserCss, $wgUseSiteCss;
676 # Add user-specific code if this is a user and we allow that kind of thing
678 if ( $wgAllowUserCss && $this->loggedin
) {
679 $action = $wgRequest->getText('action');
681 # if we're previewing the CSS page, use it
682 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
683 $siteargs .= "&smaxage=0&maxage=0";
684 $usercss = $wgRequest->getText('wpTextbox1');
686 $siteargs .= "&maxage=0";
687 $usercss = '@import "' .
688 $this->makeUrl($this->userpage
. '/'.$this->skinname
.'.css',
689 'action=raw&ctype=text/css') . '";' ."\n";
693 # If we use the site's dynamic CSS, throw that in, too
695 if ( $wgUseSiteCss ) {
696 $sitecss = '@import "'.$this->makeUrl('-','action=raw&gen=css' . $siteargs).'";'."\n";
699 # If we use any dynamic CSS, make a little CDATA block out of it.
701 if ( !empty($sitecss) ||
!empty($usercss) ) {
702 $this->usercss
= '/*<![CDATA[*/ ' . $sitecss . ' ' . $usercss . ' /*]]>*/';
709 function setupUserJs () {
710 global $wgRequest, $wgTitle, $wgAllowUserJs;
711 $action = $wgRequest->getText('action');
713 if( $wgAllowUserJs && $this->loggedin
) {
714 if($wgTitle->isJsSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
715 # XXX: additional security check/prompt?
716 $this->userjsprev
= '/*<![CDATA[*/ ' . $wgRequest->getText('wpTextbox1') . ' /*]]>*/';
718 $this->userjs
= $this->makeUrl($this->userpage
.'/'.$this->skinname
.'.js', 'action=raw&ctype=text/javascript&dontcountme=s');
724 * returns css with user-specific options
726 function getUserStylesheet() {
727 global $wgUser, $wgRequest, $wgTitle, $wgContLang, $wgSquidMaxage, $wgStylePath;
728 $action = $wgRequest->getText('action');
729 $maxage = $wgRequest->getText('maxage');
730 $s = "/* generated user stylesheet */\n";
731 if($wgContLang->isRTL()) $s .= '@import "'.$wgStylePath.'/'.$this->stylename
.'/rtl.css";'."\n";
733 $this->makeNSUrl(ucfirst($this->skinname
).'.css', 'action=raw&ctype=text/css&smaxage='.$wgSquidMaxage, NS_MEDIAWIKI
)."\";\n";
734 if($wgUser->getID() != 0) {
735 if ( 1 == $wgUser->getOption( "underline" ) ) {
736 $s .= "a { text-decoration: underline; }\n";
738 $s .= "a { text-decoration: none; }\n";
741 if ( 1 != $wgUser->getOption( "highlightbroken" ) ) {
742 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
744 if ( 1 == $wgUser->getOption( "justify" ) ) {
745 $s .= "#bodyContent { text-align: justify; }\n";
753 function getUserJs() {
754 global $wgUser, $wgStylePath;
755 $s = '/* generated javascript */';
756 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
757 $s .= '/* MediaWiki:'.ucfirst($this->skinname
)." */\n";
758 $s .= wfMsg(ucfirst($this->skinname
).'.js');
763 class QuickTemplate
{
764 function QuickTemplate( $file, $repository=false, $cache_dir=false ) {
765 $this->outputCallback
= $file;
766 $this->data
= array();
767 $this->translator
= null;
770 function set( $name, $value ) {
771 $this->data
[$name] = $value;
774 function setRef($name, &$value) {
775 $this->data
[$name] =& $value;
778 function setTranslator( &$t ) {
779 $this->translator
= &$t;
783 return call_user_func_array( $this->outputCallback
,
784 array( &$this->data
, &$this->translator
) );
788 } // end of if( defined( 'MEDIAWIKI' ) )