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