Disable $wgUseGzip by default since it's wildly incompatible with
[lhc/web/wiklou.git] / includes / SkinPHPTal.php
1 <?php
2 # Generic PHPTal (http://phptal.sourceforge.net/) skin
3 # Based on Brion's smarty skin
4 # Copyright (C) Gabriel Wicke -- http://www.aulinx.de/
5 #
6 # Todo: Needs some serious refactoring into functions that correspond
7 # to the computations individual esi snippets need. Most importantly no body
8 # parsing for most of those of course.
9 #
10 # Set this in LocalSettings to enable phptal:
11 # set_include_path(get_include_path() . ":" . $IP.'/PHPTAL-NP-0.7.0/libs');
12 # $wgUsePHPTal = true;
13 #
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License along
25 # with this program; if not, write to the Free Software Foundation, Inc.,
26 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 # http://www.gnu.org/copyleft/gpl.html
28
29
30 # This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
31 if( defined( "MEDIAWIKI" ) ) {
32 require_once "GlobalFunctions.php";
33 global $IP;
34 require_once $IP."/PHPTAL-NP-0.7.0/libs/PHPTAL.php";
35
36 class MediaWiki_I18N extends PHPTAL_I18N
37 {
38 var $_context = array();
39
40 function set($varName, $value) {
41 $this->_context[$varName] = $value;
42 }
43
44 function translate($value) {
45 $value = wfMsg( $value );
46 // interpolate variables
47 while (preg_match('/\$([0-9]*?)/sm', $value, $m)) {
48 list($src, $var) = $m;
49 wfSuppressWarnings();
50 $varValue = $this->_context[$var];
51 wfRestoreWarnings();
52 $value = str_replace($src, $varValue, $value);
53 }
54 return $value;
55 }
56 }
57
58 class SkinPHPTal extends Skin {
59 var $template;
60
61 function initPage( &$out ) {
62 parent::initPage( $out );
63 $this->skinname = "davinci";
64 $this->template = "xhtml_slim";
65 }
66
67 function outputPage( &$out ) {
68 global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgOut;
69 global $wgScript, $wgStylePath, $wgLanguageCode, $wgUseNewInterlanguage;
70 global $wgMimeType, $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest;
71 global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgSiteNotice;
72 global $wgMaxCredits, $wgShowCreditsIfMax;
73
74 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
75
76 $this->initPage( $out );
77 $tpl = new PHPTAL($this->template . '.pt', 'templates');
78
79 #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
80 $tpl->setTranslator(new MediaWiki_I18N());
81 #}
82
83 $this->thispage = $wgTitle->getPrefixedDbKey();
84 $this->thisurl = $wgTitle->getPrefixedURL();
85 $this->loggedin = $wgUser->getID() != 0;
86 $this->iscontent = ($wgTitle->getNamespace() != Namespace::getSpecial() );
87 $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit'));
88 $this->username = $wgUser->getName();
89 $this->userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
90 $this->userpageUrlDetails = $this->makeUrlDetails($this->userpage);
91
92 $this->usercss = $this->userjs = $this->userjsprev = false;
93 $this->setupUserCssJs();
94
95 $this->titletxt = $wgTitle->getPrefixedText();
96
97 $tpl->set( "title", $wgOut->getPageTitle() );
98 $tpl->set( "pagetitle", $wgOut->getHTMLTitle() );
99
100 $tpl->setRef( "thispage", $this->thispage );
101 $subpagestr = $this->subPageSubtitle();
102 $tpl->set(
103 "subtitle", !empty($subpagestr)?
104 '<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle():
105 $out->getSubtitle()
106 );
107 $undelete = $this->getUndeleteLink();
108 $tpl->set(
109 "undelete", !empty($undelete)?
110 '<span class="subpages">'.$undelete.'</span>':
111 ''
112 );
113
114 $tpl->set( 'catlinks', $this->getCategories());
115 if( $wgOut->isSyndicated() ) {
116 $feeds = array();
117 foreach( $wgFeedClasses as $format => $class ) {
118 $feeds[$format] = array(
119 'text' => $format,
120 'href' => $wgRequest->appendQuery( "feed=$format" ),
121 'ttip' => wfMsg('tooltip-'.$format)
122 );
123 }
124 $tpl->setRef( 'feeds', $feeds );
125 }
126 $tpl->setRef( 'mimetype', $wgMimeType );
127 $tpl->setRef( 'charset', $wgOutputEncoding );
128 $tpl->set( 'headlinks', $out->getHeadLinks() );
129 $tpl->setRef( 'skinname', $this->skinname );
130 $tpl->setRef( "loggedin", $this->loggedin );
131 $tpl->set('nsclass', 'ns-'.$wgTitle->getNamespace());
132 /* XXX currently unused, might get useful later
133 $tpl->set( "editable", ($wgTitle->getNamespace() != NS_SPECIAL ) );
134 $tpl->set( "exists", $wgTitle->getArticleID() != 0 );
135 $tpl->set( "watch", $wgTitle->userIsWatching() ? "unwatch" : "watch" );
136 $tpl->set( "protect", count($wgTitle->getRestrictions()) ? "unprotect" : "protect" );
137 $tpl->set( "helppage", wfMsg('helppage'));
138 $tpl->set( "sysop", $wgUser->isSysop() );
139 */
140 $tpl->set( "searchaction", $this->escapeSearchLink() );
141 $tpl->setRef( "stylepath", $wgStylePath );
142 $tpl->setRef( "logopath", $wgLogo );
143 $tpl->setRef( "lang", $wgLanguageCode );
144 $tpl->set( "dir", $wgLang->isRTL() ? "rtl" : "ltr" );
145 $tpl->set( "rtl", $wgLang->isRTL() );
146 $tpl->set( "langname", $wgLang->getLanguageName( $wgLanguageCode ) );
147 $tpl->setRef( "username", $this->username );
148 $tpl->setRef( "userpage", $this->userpage);
149 $tpl->setRef( "userpageurl", $this->userpageUrlDetails['href']);
150 $tpl->setRef( "usercss", $this->usercss);
151 $tpl->setRef( "userjs", $this->userjs);
152 $tpl->setRef( "userjsprev", $this->userjsprev);
153 if($this->loggedin) {
154 $tpl->set( "jsvarurl", $this->makeUrl('-','action=raw&smaxage=0&gen=js') );
155 } else {
156 $tpl->set( "jsvarurl", $this->makeUrl('-','action=raw&gen=js') );
157 }
158 if( $wgUser->getNewtalk() ) {
159 $usertitle = Title::newFromText( $this->userpage );
160 $usertalktitle = $usertitle->getTalkPage();
161 if($usertalktitle->getPrefixedDbKey() != $this->thispage){
162
163 $ntl = wfMsg( "newmessages",
164 $this->makeKnownLink(
165 $wgLang->getNsText( Namespace::getTalk( Namespace::getUser() ) )
166 . ":" . $this->username,
167 wfMsg("newmessageslink") )
168 );
169 }
170 } else {
171 $ntl = "";
172 }
173
174 $tpl->setRef( "newtalk", $ntl );
175 $tpl->setRef( "skin", $this);
176 $tpl->set( "logo", $this->logoText() );
177 if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and 0 != $wgArticle->getID() ) {
178 if ( !$wgDisableCounters ) {
179 $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
180 if ( $viewcount ) {
181 $tpl->set('viewcount', wfMsg( "viewcount", $viewcount ));
182 }
183 }
184 $tpl->set('lastmod', $this->lastModified());
185 $tpl->set('copyright',$this->getCopyright());
186
187 $this->credits = false;
188
189 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
190 require_once("Credits.php");
191 $this->credits = getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
192 }
193
194 $tpl->setRef( "credits", $this->credits );
195
196 } elseif ( isset( $oldid ) && !isset( $diff ) ) {
197 $tpl->set('copyright', $this->getCopyright());
198 }
199
200 $tpl->set( "copyrightico", $this->getCopyrightIcon() );
201 $tpl->set( "poweredbyico", $this->getPoweredBy() );
202 $tpl->set( "disclaimer", $this->disclaimerLink() );
203 $tpl->set( "about", $this->aboutLink() );
204
205 $tpl->setRef( "debug", $out->mDebugtext );
206 $tpl->set( "reporttime", $out->reportTime() );
207 $tpl->set( "sitenotice", $wgSiteNotice );
208
209 $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
210 $out->mBodytext .= $printfooter ;
211 $tpl->setRef( "bodytext", $out->mBodytext );
212
213 $language_urls = array();
214 foreach( $wgOut->getLanguageLinks() as $l ) {
215 $nt = Title::newFromText( $l );
216 $language_urls[] = array('href' => $nt->getFullURL(),
217 'text' => ($wgLang->getLanguageName( $nt->getInterwiki()) != ''?$wgLang->getLanguageName( $nt->getInterwiki()) : $l),
218 'class' => $wgLang->isRTL() ? 'rtl' : 'ltr');
219 }
220 if(count($language_urls)) {
221 $tpl->setRef( 'language_urls', $language_urls);
222 } else {
223 $tpl->set('language_urls', false);
224 }
225 $tpl->set('personal_urls', $this->buildPersonalUrls());
226 $content_actions = $this->buildContentActionUrls();
227 $tpl->setRef('content_actions', $content_actions);
228 // XXX: attach this from javascript, same with section editing
229 if($this->iseditable && $wgUser->getOption("editondblclick") )
230 {
231 $tpl->set('body-ondblclick', 'document.location = "' .$content_actions['edit']['href'] .'";');
232 } else {
233 $tpl->set('body-ondblclick', false);
234 }
235 $tpl->set( "nav_urls", $this->buildNavUrls() );
236
237 // execute template
238 $res = $tpl->execute();
239 // result may be an error
240 if (PEAR::isError($res)) {
241 echo $res->toString(), "\n";
242 } else {
243 echo $res;
244 }
245
246 }
247
248 # build array of urls for personal toolbar
249 function buildPersonalUrls() {
250 /* set up the default links for the personal toolbar */
251 global $wgShowIPinHeader;
252 $personal_urls = array();
253 if ($this->loggedin) {
254 $personal_urls['userpage'] = array(
255 'text' => $this->username,
256 'href' => &$this->userpageUrlDetails['href'],
257 'class' => $this->userpageUrlDetails['exists']?false:'new'
258 );
259 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
260 $personal_urls['mytalk'] = array(
261 'text' => wfMsg('mytalk'),
262 'href' => &$usertalkUrlDetails['href'],
263 'class' => $usertalkUrlDetails['exists']?false:'new'
264 );
265 $personal_urls['preferences'] = array(
266 'text' => wfMsg('preferences'),
267 'href' => $this->makeSpecialUrl('Preferences')
268 );
269 $personal_urls['watchlist'] = array(
270 'text' => wfMsg('watchlist'),
271 'href' => $this->makeSpecialUrl('Watchlist')
272 );
273 $personal_urls['mycontris'] = array(
274 'text' => wfMsg('mycontris'),
275 'href' => $this->makeSpecialUrl('Contributions','target=' . urlencode( $this->username ) )
276 );
277 $personal_urls['logout'] = array(
278 'text' => wfMsg('userlogout'),
279 'href' => $this->makeSpecialUrl('Userlogout','returnto=' . $this->thisurl )
280 );
281 } else {
282 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) {
283 $personal_urls['anonuserpage'] = array(
284 'text' => $this->username,
285 'href' => &$this->userpageUrlDetails['href'],
286 'class' => $this->userpageUrlDetails['exists']?false:'new'
287 );
288 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
289 $personal_urls['anontalk'] = array(
290 'text' => wfMsg('anontalk'),
291 'href' => &$usertalkUrlDetails['href'],
292 'class' => $usertalkUrlDetails['exists']?false:'new'
293 );
294 $personal_urls['anonlogin'] = array(
295 'text' => wfMsg('userlogin'),
296 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl )
297 );
298 } else {
299
300 $personal_urls['login'] = array(
301 'text' => wfMsg('userlogin'),
302 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl )
303 );
304 }
305 }
306
307 return $personal_urls;
308 }
309
310 # an array of edit links by default used for the tabs
311 function buildContentActionUrls () {
312 global $wgTitle, $wgUser, $wgRequest, $wgUseValidation;
313 $action = $wgRequest->getText( 'action' );
314 $section = $wgRequest->getText( 'section' );
315 $oldid = $wgRequest->getVal( 'oldid' );
316 $diff = $wgRequest->getVal( 'diff' );
317 $content_actions = array();
318
319 if( $this->iscontent ) {
320
321 $nskey = $this->getNameSpaceKey();
322 $is_active = !Namespace::isTalk( $wgTitle->getNamespace()) ;
323 if ( $action == 'validate' ) $is_active = false ; # Show article tab deselected when validating
324 $content_actions[$nskey] = array('class' => ($is_active) ? 'selected' : false,
325 'text' => wfMsg($nskey),
326 'href' => $this->makeArticleUrl($this->thispage));
327
328 /* set up the classes for the talk link */
329 $talk_class = (Namespace::isTalk( $wgTitle->getNamespace()) ? 'selected' : false);
330 $talktitle = Title::newFromText( $this->titletxt );
331 $talktitle = $talktitle->getTalkPage();
332 $this->checkTitle($talktitle, $this->titletxt);
333 if($talktitle->getArticleId() != 0) {
334 $content_actions['talk'] = array(
335 'class' => $talk_class,
336 'text' => wfMsg('talk'),
337 'href' => $this->makeTalkUrl($this->titletxt)
338 );
339 } else {
340 $content_actions['talk'] = array(
341 'class' => $talk_class?$talk_class.' new':'new',
342 'text' => wfMsg('talk'),
343 'href' => $this->makeTalkUrl($this->titletxt,'action=edit')
344 );
345 }
346
347 if ( $wgTitle->userCanEdit() ) {
348 $oid = ( $oldid && ! isset( $diff ) ) ? "&oldid={$oldid}" : false;
349 $istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) );
350 $istalkclass = $istalk?' istalk':'';
351 $content_actions['edit'] = array(
352 'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ? 'selected' : '').$istalkclass,
353 'text' => wfMsg('edit'),
354 'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid)
355 );
356 if ( $istalk ) {
357 $content_actions['addsection'] = array(
358 'class' => $section == 'new'?'selected':false,
359 'text' => wfMsg('addsection'),
360 'href' => $this->makeUrl($this->thispage, 'action=edit&section=new')
361 );
362 }
363 } else {
364 $oid = ( $oldid && ! isset( $diff ) ) ? "&oldid={$oldid}" : '';
365 $content_actions['viewsource'] = array('class' => ($action == 'edit') ? 'selected' : false,
366 'text' => wfMsg('viewsource'),
367 'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid));
368 }
369
370 if ( $wgTitle->getArticleId() ) {
371
372 $content_actions['history'] = array('class' => ($action == 'history') ? 'selected' : false,
373 'text' => wfMsg('history_short'),
374 'href' => $this->makeUrl($this->thispage, 'action=history'));
375
376 # XXX: is there a rollback action anywhere or is it planned?
377 # Don't recall where i got this from...
378 /*if( $wgUser->getNewtalk() ) {
379 $content_actions['rollback'] = array('class' => ($action == 'rollback') ? 'selected' : false,
380 'text' => wfMsg('rollback_short'),
381 'href' => $this->makeUrl($this->thispage, 'action=rollback'),
382 'ttip' => wfMsg('tooltip-rollback'),
383 'akey' => wfMsg('accesskey-rollback'));
384 }*/
385
386 if($wgUser->isSysop()){
387 if(!$wgTitle->isProtected()){
388 $content_actions['protect'] = array(
389 'class' => ($action == 'protect') ? 'selected' : false,
390 'text' => wfMsg('protect'),
391 'href' => $this->makeUrl($this->thispage, 'action=protect')
392 );
393
394 } else {
395 $content_actions['unprotect'] = array(
396 'class' => ($action == 'unprotect') ? 'selected' : false,
397 'text' => wfMsg('unprotect'),
398 'href' => $this->makeUrl($this->thispage, 'action=unprotect')
399 );
400 }
401 $content_actions['delete'] = array(
402 'class' => ($action == 'delete') ? 'selected' : false,
403 'text' => wfMsg('delete'),
404 'href' => $this->makeUrl($this->thispage, 'action=delete')
405 );
406 }
407 if ( $wgUser->getID() != 0 ) {
408 if ( $wgTitle->userCanEdit()) {
409 $content_actions['move'] = array('class' => ($wgTitle->getDbKey() == 'Movepage' and $wgTitle->getNamespace == Namespace::getSpecial()) ? 'selected' : false,
410 'text' => wfMsg('move'),
411 'href' => $this->makeSpecialUrl('Movepage', 'target='. urlencode( $this->thispage ))
412 );
413 } else {
414 $content_actions['move'] = array('class' => 'inactive',
415 'text' => wfMsg('move'),
416 'href' => false);
417
418 }
419 }
420 } else {
421 //article doesn't exist or is deleted
422 if($wgUser->isSysop()){
423 if( $n = $wgTitle->isDeleted() ) {
424 $content_actions['delete'] = array(
425 'class' => false,
426 'text' => wfMsg( "undelete_short", $n ),
427 'href' => $this->makeSpecialUrl('Undelete/'.$this->thispage)
428 );
429 }
430 }
431 }
432
433 if ( $wgUser->getID() != 0 and $action != 'edit' and $action != 'submit' ) {
434 if( !$wgTitle->userIsWatching()) {
435 $content_actions['watch'] = array('class' => ($action == 'watch' or $action == 'unwatch') ? 'selected' : false,
436 'text' => wfMsg('watch'),
437 'href' => $this->makeUrl($this->thispage, 'action=watch'));
438 } else {
439 $content_actions['unwatch'] = array('class' => ($action == 'unwatch' or $action == 'watch') ? 'selected' : false,
440 'text' => wfMsg('unwatch'),
441 'href' => $this->makeUrl($this->thispage, 'action=unwatch'));
442 }
443 }
444
445 # Show validate tab
446 if ( $wgUseValidation && $wgTitle->getArticleId() && $wgTitle->getNamespace() == 0 ) {
447 global $wgArticle ;
448 $article_time = "&timestamp=" . $wgArticle->mTimestamp ;
449 $content_actions['validate'] = array('class' => ($action == 'validate') ? 'selected' : false ,
450 'text' => wfMsg('val_tab'),
451 'href' => $this->makeUrl($this->thispage, "action=validate{$article_time}"));
452 }
453
454 } else {
455 /* show special page tab */
456
457 $content_actions['article'] = array('class' => 'selected',
458 'text' => wfMsg('specialpage'),
459 'href' => false);
460 }
461
462 return $content_actions;
463 }
464
465 # build array of common navigation links
466 function buildNavUrls () {
467 global $wgTitle, $wgUser, $wgRequest;
468 global $wgSiteSupportPage;
469
470 $action = $wgRequest->getText( 'action' );
471 $oldid = $wgRequest->getVal( 'oldid' );
472 $diff = $wgRequest->getVal( 'diff' );
473 // XXX: remove htmlspecialchars when tal:attributes works with i18n:attributes
474 $nav_urls = array();
475 $nav_urls['mainpage'] = array('href' => htmlspecialchars( $this->makeI18nUrl('mainpage')));
476 $nav_urls['randompage'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Randompage')));
477 $nav_urls['recentchanges'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchanges')));
478 $nav_urls['whatlinkshere'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Whatlinkshere', 'target='.urlencode( $this->thispage ))));
479 $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('currentevents'))) : false;
480 $nav_urls['portal'] = (wfMsg('portal') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('portal-url'))) : false;
481 $nav_urls['recentchangeslinked'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchangeslinked', 'target='.urlencode( $this->thispage ))));
482 $nav_urls['bugreports'] = array('href' => htmlspecialchars( $this->makeI18nUrl('bugreportspage')));
483 // $nav_urls['sitesupport'] = array('href' => htmlspecialchars( $this->makeI18nUrl('sitesupportpage')));
484 $nav_urls['sitesupport'] = array('href' => htmlspecialchars( $wgSiteSupportPage));
485 $nav_urls['help'] = array('href' => htmlspecialchars( $this->makeI18nUrl('helppage')));
486 $nav_urls['upload'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Upload')));
487 $nav_urls['specialpages'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Specialpages')));
488
489 if( $wgTitle->getNamespace() == NS_USER || $wgTitle->getNamespace() == NS_USER_TALK ) {
490 $id = User::idFromName($wgTitle->getText());
491 $ip = User::isIP($wgTitle->getText());
492 } else {
493 $id = 0;
494 $ip = false;
495 }
496
497 if($id || $ip) { # both anons and non-anons have contri list
498 $nav_urls['contributions'] = array(
499 'href' => htmlspecialchars( $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() ) )
500 );
501 }
502 if ( 0 != $wgUser->getID() ) { # show only to signed in users
503 if($id) { # can only email non-anons
504 $nav_urls['emailuser'] = array(
505 'href' => htmlspecialchars( $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() ) )
506 );
507 }
508 }
509
510
511 return $nav_urls;
512 }
513
514 function getNameSpaceKey () {
515 global $wgTitle;
516 switch ($wgTitle->getNamespace()) {
517 case NS_MAIN:
518 case NS_TALK:
519 return 'nstab-main';
520 case NS_USER:
521 case NS_USER_TALK:
522 return 'nstab-user';
523 case NS_MEDIA:
524 return 'nstab-media';
525 case NS_SPECIAL:
526 return 'nstab-special';
527 case NS_WP:
528 case NS_WP_TALK:
529 return 'nstab-wp';
530 case NS_IMAGE:
531 case NS_IMAGE_TALK:
532 return 'nstab-image';
533 case NS_MEDIAWIKI:
534 case NS_MEDIAWIKI_TALK:
535 return 'nstab-mediawiki';
536 case NS_TEMPLATE:
537 case NS_TEMPLATE_TALK:
538 return 'nstab-template';
539 case NS_HELP:
540 case NS_HELP_TALK:
541 return 'nstab-help';
542 case NS_CATEGORY:
543 case NS_CATEGORY_TALK:
544 return 'nstab-category';
545 default:
546 return 'nstab-main';
547 }
548 }
549 /* private */ function setupUserCssJs () {
550 global $wgRequest, $wgTitle;
551 $action = $wgRequest->getText('action');
552 # generated css
553 $this->usercss = '@import "'.$this->makeUrl('-','action=raw&gen=css').'";'."\n";
554
555 if( $this->loggedin ) {
556 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
557 # generated css
558 $this->usercss = '@import "'.$this->makeUrl('-','action=raw&smaxage=0&maxage=0&gen=css').'";'."\n";
559 // css preview
560 $this->usercss .= $wgRequest->getText('wpTextbox1');
561 } else {
562 # generated css
563 $this->usercss .= '@import "'.$this->makeUrl('-','action=raw&smaxage=0&gen=css').'";'."\n";
564 # import user stylesheet
565 $this->usercss .= '@import "'.
566 $this->makeUrl($this->userpage.'/'.$this->skinname.'.css', 'action=raw&ctype=text/css').'";'."\n";
567 }
568 if($wgTitle->isJsSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
569 # XXX: additional security check/prompt?
570 $this->userjsprev = $wgRequest->getText('wpTextbox1');
571 } else {
572 $this->userjs = $this->makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype=text/javascript&dontcountme=s');
573 }
574 }
575 }
576 # returns css with user-specific options
577 function getUserStylesheet() {
578 global $wgUser, $wgRequest, $wgTitle, $wgLang, $wgSquidMaxage, $wgStylePath;
579 $action = $wgRequest->getText('action');
580 $maxage = $wgRequest->getText('maxage');
581 $s = "/* generated user stylesheet */\n";
582 if($wgLang->isRTL()) $s .= '@import "'.$wgStylePath.'/'.$this->skinname.'/rtl.css";'."\n";
583 $s .= '@import "'.
584 $this->makeNSUrl(ucfirst($this->skinname).'.css', 'action=raw&ctype=text/css&smaxage='.$wgSquidMaxage, NS_MEDIAWIKI)."\";\n";
585 if($wgUser->getID() != 0) {
586 if ( 1 == $wgUser->getOption( "underline" ) ) {
587 $s .= "a { text-decoration: underline; }\n";
588 } else {
589 $s .= "a { text-decoration: none; }\n";
590 }
591 }
592 if ( 1 != $wgUser->getOption( "highlightbroken" ) ) {
593 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
594 }
595 if ( 1 == $wgUser->getOption( "justify" ) ) {
596 $s .= "#bodyContent { text-align: justify; }\n";
597 }
598 return $s;
599 }
600 function getUserJs() {
601 global $wgUser, $wgStylePath;
602 $s = "/* generated javascript */";
603 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
604 $s .= '/* MediaWiki:'.ucfirst($this->skinname)." */\n";
605 $s .= wfMsg(ucfirst($this->skinname).'.js');
606 return $s;
607 }
608 }
609
610 class SkinDaVinci extends SkinPHPTal {
611 function initPage( &$out ) {
612 SkinPHPTal::initPage( $out );
613 $this->skinname = "davinci";
614 }
615 }
616
617 class SkinMono extends SkinPHPTal {
618 function initPage( &$out ) {
619 SkinPHPTal::initPage( $out );
620 $this->skinname = "mono";
621 }
622 }
623
624 class SkinMonoBook extends SkinPHPTal {
625 function initPage( &$out ) {
626 SkinPHPTal::initPage( $out );
627 $this->skinname = "monobook";
628 }
629 }
630
631 class SkinMySkin extends SkinPHPTal {
632 function initPage( &$out ) {
633 SkinPHPTal::initPage( $out );
634 $this->skinname = "myskin";
635 }
636 }
637
638 class SkinChick extends SkinPHPTal {
639 function initPage( &$out ) {
640 SkinPHPTal::initPage( $out );
641 $this->skinname = "chick";
642 $this->template = "xhtml_minimal";
643 }
644 function suppressUrlExpansion() { return true; }
645 function printSource() { return ""; }
646 }
647 }
648 ?>