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