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