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