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 $this->printOrError( $res );
325 * Output the string, or print error message if it's
326 * an error object of the appropriate type.
331 function printOrError( &$str ) {
336 * build array of urls for personal toolbar
338 function buildPersonalUrls() {
339 /* set up the default links for the personal toolbar */
340 global $wgShowIPinHeader;
341 $personal_urls = array();
342 if ($this->loggedin
) {
343 $personal_urls['userpage'] = array(
344 'text' => $this->username
,
345 'href' => &$this->userpageUrlDetails
['href'],
346 'class' => $this->userpageUrlDetails
['exists']?
false:'new'
348 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage
);
349 $personal_urls['mytalk'] = array(
350 'text' => wfMsg('mytalk'),
351 'href' => &$usertalkUrlDetails['href'],
352 'class' => $usertalkUrlDetails['exists']?
false:'new'
354 $personal_urls['preferences'] = array(
355 'text' => wfMsg('preferences'),
356 'href' => $this->makeSpecialUrl('Preferences')
358 $personal_urls['watchlist'] = array(
359 'text' => wfMsg('watchlist'),
360 'href' => $this->makeSpecialUrl('Watchlist')
362 $personal_urls['mycontris'] = array(
363 'text' => wfMsg('mycontris'),
364 'href' => $this->makeSpecialUrl('Contributions','target=' . urlencode( $this->username
) )
366 $personal_urls['logout'] = array(
367 'text' => wfMsg('userlogout'),
368 'href' => $this->makeSpecialUrl('Userlogout','returnto=' . $this->thisurl
)
371 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) {
372 $personal_urls['anonuserpage'] = array(
373 'text' => $this->username
,
374 'href' => &$this->userpageUrlDetails
['href'],
375 'class' => $this->userpageUrlDetails
['exists']?
false:'new'
377 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage
);
378 $personal_urls['anontalk'] = array(
379 'text' => wfMsg('anontalk'),
380 'href' => &$usertalkUrlDetails['href'],
381 'class' => $usertalkUrlDetails['exists']?
false:'new'
383 $personal_urls['anonlogin'] = array(
384 'text' => wfMsg('userlogin'),
385 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl
)
389 $personal_urls['login'] = array(
390 'text' => wfMsg('userlogin'),
391 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl
)
396 return $personal_urls;
400 * an array of edit links by default used for the tabs
402 function buildContentActionUrls () {
403 global $wgTitle, $wgUser, $wgOut, $wgRequest, $wgUseValidation;
404 $action = $wgRequest->getText( 'action' );
405 $section = $wgRequest->getText( 'section' );
406 $oldid = $wgRequest->getVal( 'oldid' );
407 $diff = $wgRequest->getVal( 'diff' );
408 $content_actions = array();
410 if( $this->iscontent
and !$wgOut->isQuickbarSuppressed() ) {
412 $nskey = $this->getNameSpaceKey();
413 $is_active = !Namespace::isTalk( $wgTitle->getNamespace()) ;
414 if ( $action == 'validate' ) $is_active = false ; # Show article tab deselected when validating
415 $content_actions[$nskey] = array('class' => ($is_active) ?
'selected' : false,
416 'text' => wfMsg($nskey),
417 'href' => $this->makeArticleUrl($this->thispage
));
419 /* set up the classes for the talk link */
420 $talk_class = (Namespace::isTalk( $wgTitle->getNamespace()) ?
'selected' : false);
421 $talktitle = Title
::newFromText( $this->titletxt
);
422 $talktitle = $talktitle->getTalkPage();
423 $this->checkTitle($talktitle, $this->titletxt
);
424 if($talktitle->getArticleId() != 0) {
425 $content_actions['talk'] = array(
426 'class' => $talk_class,
427 'text' => wfMsg('talk'),
428 'href' => $this->makeTalkUrl($this->titletxt
)
431 $content_actions['talk'] = array(
432 'class' => $talk_class?
$talk_class.' new':'new',
433 'text' => wfMsg('talk'),
434 'href' => $this->makeTalkUrl($this->titletxt
,'action=edit')
438 if ( $wgTitle->userCanEdit() ) {
439 $oid = ( $oldid && ! isset( $diff ) ) ?
'&oldid='.IntVal( $oldid ) : false;
440 $istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) );
441 $istalkclass = $istalk?
' istalk':'';
442 $content_actions['edit'] = array(
443 'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ?
'selected' : '').$istalkclass,
444 'text' => wfMsg('edit'),
445 'href' => $this->makeUrl($this->thispage
, 'action=edit'.$oid)
448 $content_actions['addsection'] = array(
449 'class' => $section == 'new'?
'selected':false,
450 'text' => wfMsg('addsection'),
451 'href' => $this->makeUrl($this->thispage
, 'action=edit§ion=new')
455 $oid = ( $oldid && ! isset( $diff ) ) ?
'&oldid='.IntVal( $oldid ) : '';
456 $content_actions['viewsource'] = array('class' => ($action == 'edit') ?
'selected' : false,
457 'text' => wfMsg('viewsource'),
458 'href' => $this->makeUrl($this->thispage
, 'action=edit'.$oid));
461 if ( $wgTitle->getArticleId() ) {
463 $content_actions['history'] = array('class' => ($action == 'history') ?
'selected' : false,
464 'text' => wfMsg('history_short'),
465 'href' => $this->makeUrl($this->thispage
, 'action=history'));
467 # XXX: is there a rollback action anywhere or is it planned?
468 # Don't recall where i got this from...
469 /*if( $wgUser->getNewtalk() ) {
470 $content_actions['rollback'] = array('class' => ($action == 'rollback') ? 'selected' : false,
471 'text' => wfMsg('rollback_short'),
472 'href' => $this->makeUrl($this->thispage, 'action=rollback'),
473 'ttip' => wfMsg('tooltip-rollback'),
474 'akey' => wfMsg('accesskey-rollback'));
478 if($wgUser->isAllowed('protect')){
479 if(!$wgTitle->isProtected()){
480 $content_actions['protect'] = array(
481 'class' => ($action == 'protect') ?
'selected' : false,
482 'text' => wfMsg('protect'),
483 'href' => $this->makeUrl($this->thispage
, 'action=protect')
487 $content_actions['unprotect'] = array(
488 'class' => ($action == 'unprotect') ?
'selected' : false,
489 'text' => wfMsg('unprotect'),
490 'href' => $this->makeUrl($this->thispage
, 'action=unprotect')
494 if($wgUser->isAllowed('delete')){
495 $content_actions['delete'] = array(
496 'class' => ($action == 'delete') ?
'selected' : false,
497 'text' => wfMsg('delete'),
498 'href' => $this->makeUrl($this->thispage
, 'action=delete')
501 if ( $wgUser->getID() != 0 ) {
502 if ( $wgTitle->userCanEdit()) {
503 $content_actions['move'] = array('class' => ($wgTitle->getDbKey() == 'Movepage' and $wgTitle->getNamespace
== Namespace::getSpecial()) ?
'selected' : false,
504 'text' => wfMsg('move'),
505 'href' => $this->makeSpecialUrl('Movepage', 'target='. urlencode( $this->thispage
))
510 //article doesn't exist or is deleted
511 if($wgUser->isAllowed('delete')){
512 if( $n = $wgTitle->isDeleted() ) {
513 $content_actions['undelete'] = array(
515 'text' => wfMsg( "undelete_short", $n ),
516 'href' => $this->makeSpecialUrl('Undelete/'.$this->thispage
)
522 if ( $wgUser->getID() != 0 and $action != 'submit' ) {
523 if( !$wgTitle->userIsWatching()) {
524 $content_actions['watch'] = array('class' => ($action == 'watch' or $action == 'unwatch') ?
'selected' : false,
525 'text' => wfMsg('watch'),
526 'href' => $this->makeUrl($this->thispage
, 'action=watch'));
528 $content_actions['unwatch'] = array('class' => ($action == 'unwatch' or $action == 'watch') ?
'selected' : false,
529 'text' => wfMsg('unwatch'),
530 'href' => $this->makeUrl($this->thispage
, 'action=unwatch'));
535 if ( $wgUseValidation && $wgTitle->getArticleId() && $wgTitle->getNamespace() == 0 ) {
537 $article_time = "×tamp=" . $wgArticle->mTimestamp
;
538 $content_actions['validate'] = array('class' => ($action == 'validate') ?
'selected' : false ,
539 'text' => wfMsg('val_tab'),
540 'href' => $this->makeUrl($this->thispage
, 'action=validate'.$article_time));
544 /* show special page tab */
546 $content_actions['article'] = array('class' => 'selected',
547 'text' => wfMsg('specialpage'),
551 return $content_actions;
555 * build array of global navigation links
557 function buildNavigationUrls () {
558 global $wgNavigationLinks;
560 foreach ( $wgNavigationLinks as $link ) {
561 if (wfMsg( $link['text'] ) != '-') {
563 'text' => wfMsg( $link['text'] ),
564 'href' => $this->makeInternalOrExternalUrl( wfMsgForContent( $link['href'] ) ),
565 'id' => 'n-'.$link['text']
573 * build array of common navigation links
575 function buildNavUrls () {
576 global $wgTitle, $wgUser, $wgRequest;
577 global $wgSiteSupportPage, $wgDisableUploads;
579 $action = $wgRequest->getText( 'action' );
580 $oldid = $wgRequest->getVal( 'oldid' );
581 $diff = $wgRequest->getVal( 'diff' );
582 // XXX: remove htmlspecialchars when tal:attributes works with i18n:attributes
584 $nav_urls['mainpage'] = array('href' => $this->makeI18nUrl('mainpage'));
585 $nav_urls['randompage'] = array('href' => $this->makeSpecialUrl('Randompage'));
586 $nav_urls['recentchanges'] = array('href' => $this->makeSpecialUrl('Recentchanges'));
587 $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ?
array('href' => $this->makeI18nUrl('currentevents')) : false;
588 $nav_urls['portal'] = (wfMsg('portal') != '-') ?
array('href' => $this->makeI18nUrl('portal-url')) : false;
589 $nav_urls['bugreports'] = array('href' => $this->makeI18nUrl('bugreportspage'));
590 // $nav_urls['sitesupport'] = array('href' => $this->makeI18nUrl('sitesupportpage'));
591 $nav_urls['sitesupport'] = array('href' => $wgSiteSupportPage);
592 $nav_urls['help'] = array('href' => $this->makeI18nUrl('helppage'));
593 if( $this->loggedin
&& !$wgDisableUploads ) {
594 $nav_urls['upload'] = array('href' => $this->makeSpecialUrl('Upload'));
596 $nav_urls['upload'] = false;
598 $nav_urls['specialpages'] = array('href' => $this->makeSpecialUrl('Specialpages'));
600 if( $wgTitle->getNamespace() != NS_SPECIAL
) {
601 $nav_urls['whatlinkshere'] = array('href' => $this->makeSpecialUrl('Whatlinkshere', 'target='.urlencode( $this->thispage
)));
602 $nav_urls['recentchangeslinked'] = array('href' => $this->makeSpecialUrl('Recentchangeslinked', 'target='.urlencode( $this->thispage
)));
605 if( $wgTitle->getNamespace() == NS_USER ||
$wgTitle->getNamespace() == NS_USER_TALK
) {
606 $id = User
::idFromName($wgTitle->getText());
607 $ip = User
::isIP($wgTitle->getText());
613 if($id ||
$ip) { # both anons and non-anons have contri list
614 $nav_urls['contributions'] = array(
615 'href' => $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() )
618 $nav_urls['contributions'] = false;
620 $nav_urls['emailuser'] = false;
621 if ( 0 != $wgUser->getID() ) { # show only to signed in users
622 if($id) { # can only email non-anons
623 $nav_urls['emailuser'] = array(
624 'href' => $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() )
633 * Generate strings used for xml 'id' names
635 function getNameSpaceKey () {
637 switch ($wgTitle->getNamespace()) {
645 return 'nstab-media';
647 return 'nstab-special';
649 case NS_PROJECT_TALK
:
653 return 'nstab-image';
655 case NS_MEDIAWIKI_TALK
:
656 return 'nstab-mediawiki';
658 case NS_TEMPLATE_TALK
:
659 return 'nstab-template';
664 case NS_CATEGORY_TALK
:
665 return 'nstab-category';
675 function setupUserCss () {
677 global $wgRequest, $wgTitle, $wgAllowUserCss, $wgUseSiteCss;
683 # Add user-specific code if this is a user and we allow that kind of thing
685 if ( $wgAllowUserCss && $this->loggedin
) {
686 $action = $wgRequest->getText('action');
688 # if we're previewing the CSS page, use it
689 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
690 $siteargs .= "&smaxage=0&maxage=0";
691 $usercss = $wgRequest->getText('wpTextbox1');
693 $siteargs .= "&maxage=0";
694 $usercss = '@import "' .
695 $this->makeUrl($this->userpage
. '/'.$this->skinname
.'.css',
696 'action=raw&ctype=text/css') . '";' ."\n";
700 # If we use the site's dynamic CSS, throw that in, too
702 if ( $wgUseSiteCss ) {
703 $sitecss = '@import "'.$this->makeUrl('-','action=raw&gen=css' . $siteargs).'";'."\n";
706 # If we use any dynamic CSS, make a little CDATA block out of it.
708 if ( !empty($sitecss) ||
!empty($usercss) ) {
709 $this->usercss
= '/*<![CDATA[*/ ' . $sitecss . ' ' . $usercss . ' /*]]>*/';
716 function setupUserJs () {
717 global $wgRequest, $wgTitle, $wgAllowUserJs;
718 $action = $wgRequest->getText('action');
720 if( $wgAllowUserJs && $this->loggedin
) {
721 if($wgTitle->isJsSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
722 # XXX: additional security check/prompt?
723 $this->userjsprev
= '/*<![CDATA[*/ ' . $wgRequest->getText('wpTextbox1') . ' /*]]>*/';
725 $this->userjs
= $this->makeUrl($this->userpage
.'/'.$this->skinname
.'.js', 'action=raw&ctype=text/javascript&dontcountme=s');
731 * returns css with user-specific options
733 function getUserStylesheet() {
734 global $wgUser, $wgRequest, $wgTitle, $wgContLang, $wgSquidMaxage, $wgStylePath;
735 $action = $wgRequest->getText('action');
736 $maxage = $wgRequest->getText('maxage');
737 $s = "/* generated user stylesheet */\n";
738 if($wgContLang->isRTL()) $s .= '@import "'.$wgStylePath.'/'.$this->stylename
.'/rtl.css";'."\n";
740 $this->makeNSUrl(ucfirst($this->skinname
).'.css', 'action=raw&ctype=text/css&smaxage='.$wgSquidMaxage, NS_MEDIAWIKI
)."\";\n";
741 if($wgUser->getID() != 0) {
742 if ( 1 == $wgUser->getOption( "underline" ) ) {
743 $s .= "a { text-decoration: underline; }\n";
745 $s .= "a { text-decoration: none; }\n";
748 if ( 1 != $wgUser->getOption( "highlightbroken" ) ) {
749 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
751 if ( 1 == $wgUser->getOption( "justify" ) ) {
752 $s .= "#bodyContent { text-align: justify; }\n";
760 function getUserJs() {
761 global $wgUser, $wgStylePath;
762 $s = '/* generated javascript */';
763 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
764 $s .= '/* MediaWiki:'.ucfirst($this->skinname
)." */\n";
765 $s .= wfMsg(ucfirst($this->skinname
).'.js');
770 class QuickTemplate
{
771 function QuickTemplate( $file, $repository=false, $cache_dir=false ) {
772 $this->outputCallback
= $file;
773 $this->data
= array();
774 $this->translator
= null;
777 function set( $name, $value ) {
778 $this->data
[$name] = $value;
781 function setRef($name, &$value) {
782 $this->data
[$name] =& $value;
785 function setTranslator( &$t ) {
786 $this->translator
= &$t;
790 return call_user_func_array( $this->outputCallback
,
791 array( &$this->data
, &$this->translator
) );
795 } // end of if( defined( 'MEDIAWIKI' ) )