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