Remove trailing space which breaks XML output
[mediawiki.git] / includes / SkinPHPTal.php
blobad717d56f8dd67b0f525800bc823d12b1307c154
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/
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.
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;
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.
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.
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
29 require_once "GlobalFunctions.php";
30 global $IP;
31 require_once $IP."/PHPTAL-NP-0.7.0/libs/PHPTAL.php";
33 class MediaWiki_I18N extends PHPTAL_I18N
35 var $_context = array();
37 function set($varName, $value) {
38 $this->_context[$varName] = $value;
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);
51 return $value;
55 class SkinPHPTal extends Skin {
56 var $template;
58 function initPage( &$out ) {
59 parent::initPage( $out );
60 $this->skinname = "davinci";
61 $this->template = "xhtml_slim";
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;
71 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
73 $this->initPage( $out );
74 $tpl = new PHPTAL($this->template . '.pt', 'templates');
76 #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
77 $tpl->setTranslator(new MediaWiki_I18N());
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);
89 $this->usercss = $this->userjs = $this->userjsprev = false;
90 $this->setupUserCssJs();
92 $this->titletxt = $wgTitle->getPrefixedText();
94 $tpl->set( "title", $wgOut->getPageTitle() );
95 $tpl->set( "pagetitle", $wgOut->getHTMLTitle() );
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()
104 $undelete = $this->getUndeleteLink();
105 $tpl->set(
106 "undelete", !empty($undelete)?
107 '<span class="subpages">'.$undelete.'</span>':
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)
121 $tpl->setRef( 'feeds', $feeds );
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() );
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') );
155 if( $wgUser->getNewtalk() ) {
156 $usertitle = Title::newFromText( $this->userpage );
157 $usertalktitle = $usertitle->getTalkPage();
158 if($usertalktitle->getPrefixedDbKey() != $this->thispage){
160 $ntl = wfMsg( "newmessages",
161 $this->makeKnownLink(
162 $wgLang->getNsText( Namespace::getTalk( Namespace::getUser() ) )
163 . ":" . $this->username,
164 wfMsg("newmessageslink") )
167 } else {
168 $ntl = "";
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 ));
181 $tpl->set('lastmod', $this->lastModified());
182 $tpl->set('copyright',$this->getCopyright());
184 $this->credits = false;
186 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
187 require_once("Credits.php");
188 $this->credits = getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
191 $tpl->setRef( "credits", $this->credits );
193 } elseif ( isset( $oldid ) && !isset( $diff ) ) {
194 $tpl->set('copyright', $this->getCopyright());
197 $tpl->set( "copyrightico", $this->getCopyrightIcon() );
198 $tpl->set( "poweredbyico", $this->getPoweredBy() );
199 $tpl->set( "disclaimer", $this->disclaimerLink() );
200 $tpl->set( "about", $this->aboutLink() );
202 $tpl->setRef( "debug", $out->mDebugtext );
203 $tpl->set( "reporttime", $out->reportTime() );
204 $tpl->set( "sitenotice", $wgSiteNotice );
206 $tpl->setRef( "bodytext", $out->mBodytext );
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');
215 if(count($language_urls)) {
216 $tpl->setRef( 'language_urls', $language_urls);
217 } else {
218 $tpl->set('language_urls', false);
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") )
226 $tpl->set('body-ondblclick', 'document.location = "' .$content_actions['edit']['href'] .'";');
227 } else {
228 $tpl->set('body-ondblclick', false);
230 $tpl->set( "nav_urls", $this->buildNavUrls() );
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;
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'
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'
260 $personal_urls['preferences'] = array(
261 'text' => wfMsg('preferences'),
262 'href' => $this->makeSpecialUrl('Preferences')
264 $personal_urls['watchlist'] = array(
265 'text' => wfMsg('watchlist'),
266 'href' => $this->makeSpecialUrl('Watchlist')
268 $personal_urls['mycontris'] = array(
269 'text' => wfMsg('mycontris'),
270 'href' => $this->makeSpecialUrl('Contributions','target=' . urlencode( $this->username ) )
272 $personal_urls['logout'] = array(
273 'text' => wfMsg('userlogout'),
274 'href' => $this->makeSpecialUrl('Userlogout','returnto=' . $this->thisurl )
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'
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'
289 $personal_urls['anonlogin'] = array(
290 'text' => wfMsg('userlogin'),
291 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl )
293 } else {
295 $personal_urls['login'] = array(
296 'text' => wfMsg('userlogin'),
297 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl )
302 return $personal_urls;
305 # an array of edit links by default used for the tabs
306 function buildContentActionUrls () {
307 global $wgTitle, $wgUser, $wgRequest, $wgUseValidation;
308 $action = $wgRequest->getText( 'action' );
309 $section = $wgRequest->getText( 'section' );
310 $oldid = $wgRequest->getVal( 'oldid' );
311 $diff = $wgRequest->getVal( 'diff' );
312 $content_actions = array();
314 if( $this->iscontent ) {
316 $nskey = $this->getNameSpaceKey();
317 $is_active = !Namespace::isTalk( $wgTitle->getNamespace()) ;
318 if ( $action == 'validate' ) $is_active = false ; # Show article tab deselected when validating
319 $content_actions[$nskey] = array('class' => ($is_active) ? 'selected' : false,
320 'text' => wfMsg($nskey),
321 'href' => $this->makeArticleUrl($this->thispage));
323 /* set up the classes for the talk link */
324 $talk_class = (Namespace::isTalk( $wgTitle->getNamespace()) ? 'selected' : false);
325 $talktitle = Title::newFromText( $this->titletxt );
326 $talktitle = $talktitle->getTalkPage();
327 $this->checkTitle($talktitle, $this->titletxt);
328 if($talktitle->getArticleId() != 0) {
329 $content_actions['talk'] = array(
330 'class' => $talk_class,
331 'text' => wfMsg('talk'),
332 'href' => $this->makeTalkUrl($this->titletxt)
334 } else {
335 $content_actions['talk'] = array(
336 'class' => $talk_class?$talk_class.' new':'new',
337 'text' => wfMsg('talk'),
338 'href' => $this->makeTalkUrl($this->titletxt,'action=edit')
342 if ( $wgTitle->userCanEdit() ) {
343 $oid = ( $oldid && ! isset( $diff ) ) ? "&oldid={$oldid}" : false;
344 $istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) );
345 $istalkclass = $istalk?' istalk':'';
346 $content_actions['edit'] = array(
347 'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ? 'selected' : '').$istalkclass,
348 'text' => wfMsg('edit'),
349 'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid)
351 if ( $istalk ) {
352 $content_actions['addsection'] = array(
353 'class' => $section == 'new'?'selected':false,
354 'text' => wfMsg('addsection'),
355 'href' => $this->makeUrl($this->thispage, 'action=edit&section=new')
358 } else {
359 $oid = ( $oldid && ! isset( $diff ) ) ? "&oldid={$oldid}" : '';
360 $content_actions['viewsource'] = array('class' => ($action == 'edit') ? 'selected' : false,
361 'text' => wfMsg('viewsource'),
362 'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid));
365 if ( $wgTitle->getArticleId() ) {
367 $content_actions['history'] = array('class' => ($action == 'history') ? 'selected' : false,
368 'text' => wfMsg('history_short'),
369 'href' => $this->makeUrl($this->thispage, 'action=history'));
371 # XXX: is there a rollback action anywhere or is it planned?
372 # Don't recall where i got this from...
373 /*if( $wgUser->getNewtalk() ) {
374 $content_actions['rollback'] = array('class' => ($action == 'rollback') ? 'selected' : false,
375 'text' => wfMsg('rollback_short'),
376 'href' => $this->makeUrl($this->thispage, 'action=rollback'),
377 'ttip' => wfMsg('tooltip-rollback'),
378 'akey' => wfMsg('accesskey-rollback'));
381 if($wgUser->isSysop()){
382 if(!$wgTitle->isProtected()){
383 $content_actions['protect'] = array(
384 'class' => ($action == 'protect') ? 'selected' : false,
385 'text' => wfMsg('protect'),
386 'href' => $this->makeUrl($this->thispage, 'action=protect')
389 } else {
390 $content_actions['unprotect'] = array(
391 'class' => ($action == 'unprotect') ? 'selected' : false,
392 'text' => wfMsg('unprotect'),
393 'href' => $this->makeUrl($this->thispage, 'action=unprotect')
396 $content_actions['delete'] = array(
397 'class' => ($action == 'delete') ? 'selected' : false,
398 'text' => wfMsg('delete'),
399 'href' => $this->makeUrl($this->thispage, 'action=delete')
402 if ( $wgUser->getID() != 0 ) {
403 if ( $wgTitle->userCanEdit()) {
404 $content_actions['move'] = array('class' => ($wgTitle->getDbKey() == 'Movepage' and $wgTitle->getNamespace == Namespace::getSpecial()) ? 'selected' : false,
405 'text' => wfMsg('move'),
406 'href' => $this->makeSpecialUrl('Movepage', 'target='. urlencode( $this->thispage ))
408 } else {
409 $content_actions['move'] = array('class' => 'inactive',
410 'text' => wfMsg('move'),
411 'href' => false);
415 } else {
416 //article doesn't exist or is deleted
417 if($wgUser->isSysop()){
418 if( $n = $wgTitle->isDeleted() ) {
419 $content_actions['delete'] = array(
420 'class' => false,
421 'text' => wfMsg( "undelete_short", $n ),
422 'href' => $this->makeSpecialUrl('Undelete/'.$this->thispage)
428 if ( $wgUser->getID() != 0 and $action != 'edit' and $action != 'submit' ) {
429 if( !$wgTitle->userIsWatching()) {
430 $content_actions['watch'] = array('class' => ($action == 'watch' or $action == 'unwatch') ? 'selected' : false,
431 'text' => wfMsg('watch'),
432 'href' => $this->makeUrl($this->thispage, 'action=watch'));
433 } else {
434 $content_actions['unwatch'] = array('class' => ($action == 'unwatch' or $action == 'watch') ? 'selected' : false,
435 'text' => wfMsg('unwatch'),
436 'href' => $this->makeUrl($this->thispage, 'action=unwatch'));
440 # Show validate tab
441 if ( $wgUseValidation && $wgTitle->getArticleId() && $wgTitle->getNamespace() == 0 ) {
442 global $wgArticle ;
443 $article_time = "&timestamp=" . $wgArticle->mTimestamp ;
444 $content_actions['validate'] = array('class' => ($action == 'validate') ? 'selected' : false ,
445 'text' => wfMsg('val_tab'),
446 'href' => $this->makeUrl($this->thispage, "action=validate{$article_time}"));
449 } else {
450 /* show special page tab */
452 $content_actions['article'] = array('class' => 'selected',
453 'text' => wfMsg('specialpage'),
454 'href' => false);
457 return $content_actions;
460 # build array of common navigation links
461 function buildNavUrls () {
462 global $wgTitle, $wgUser, $wgRequest;
463 global $wgSiteSupportPage;
465 $action = $wgRequest->getText( 'action' );
466 $oldid = $wgRequest->getVal( 'oldid' );
467 $diff = $wgRequest->getVal( 'diff' );
468 // XXX: remove htmlspecialchars when tal:attributes works with i18n:attributes
469 $nav_urls = array();
470 $nav_urls['mainpage'] = array('href' => htmlspecialchars( $this->makeI18nUrl('mainpage')));
471 $nav_urls['randompage'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Randompage')));
472 $nav_urls['recentchanges'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchanges')));
473 $nav_urls['whatlinkshere'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Whatlinkshere', 'target='.urlencode( $this->thispage ))));
474 $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('currentevents'))) : false;
475 $nav_urls['portal'] = (wfMsg('portal') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('portal-url'))) : false;
476 $nav_urls['recentchangeslinked'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchangeslinked', 'target='.urlencode( $this->thispage ))));
477 $nav_urls['bugreports'] = array('href' => htmlspecialchars( $this->makeI18nUrl('bugreportspage')));
478 // $nav_urls['sitesupport'] = array('href' => htmlspecialchars( $this->makeI18nUrl('sitesupportpage')));
479 $nav_urls['sitesupport'] = array('href' => htmlspecialchars( $wgSiteSupportPage));
480 $nav_urls['help'] = array('href' => htmlspecialchars( $this->makeI18nUrl('helppage')));
481 $nav_urls['upload'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Upload')));
482 $nav_urls['specialpages'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Specialpages')));
484 if( $wgTitle->getNamespace() == NS_USER || $wgTitle->getNamespace() == NS_USER_TALK ) {
485 $id = User::idFromName($wgTitle->getText());
486 $ip = User::isIP($wgTitle->getText());
487 } else {
488 $id = 0;
489 $ip = false;
492 if($id || $ip) { # both anons and non-anons have contri list
493 $nav_urls['contributions'] = array(
494 'href' => htmlspecialchars( $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() ) )
497 if ( 0 != $wgUser->getID() ) { # show only to signed in users
498 if($id) { # can only email non-anons
499 $nav_urls['emailuser'] = array(
500 'href' => htmlspecialchars( $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() ) )
506 return $nav_urls;
509 function getNameSpaceKey () {
510 global $wgTitle;
511 switch ($wgTitle->getNamespace()) {
512 case NS_MAIN:
513 case NS_TALK:
514 return 'nstab-main';
515 case NS_USER:
516 case NS_USER_TALK:
517 return 'nstab-user';
518 case NS_MEDIA:
519 return 'nstab-media';
520 case NS_SPECIAL:
521 return 'nstab-special';
522 case NS_WP:
523 case NS_WP_TALK:
524 return 'nstab-wp';
525 case NS_IMAGE:
526 case NS_IMAGE_TALK:
527 return 'nstab-image';
528 case NS_MEDIAWIKI:
529 case NS_MEDIAWIKI_TALK:
530 return 'nstab-mediawiki';
531 case NS_TEMPLATE:
532 case NS_TEMPLATE_TALK:
533 return 'nstab-template';
534 case NS_HELP:
535 case NS_HELP_TALK:
536 return 'nstab-help';
537 case NS_CATEGORY:
538 case NS_CATEGORY_TALK:
539 return 'nstab-category';
540 default:
541 return 'nstab-main';
544 /* private */ function setupUserCssJs () {
545 global $wgRequest, $wgTitle;
546 $action = $wgRequest->getText('action');
547 # generated css
548 $this->usercss = '@import "'.$this->makeUrl('-','action=raw&gen=css').'";'."\n";
550 if( $this->loggedin ) {
551 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
552 # generated css
553 $this->usercss = '@import "'.$this->makeUrl('-','action=raw&smaxage=0&maxage=0&gen=css').'";'."\n";
554 // css preview
555 $this->usercss .= $wgRequest->getText('wpTextbox1');
556 } else {
557 # generated css
558 $this->usercss .= '@import "'.$this->makeUrl('-','action=raw&smaxage=0&gen=css').'";'."\n";
559 # import user stylesheet
560 $this->usercss .= '@import "'.
561 $this->makeUrl($this->userpage.'/'.$this->skinname.'.css', 'action=raw&ctype=text/css').'";'."\n";
563 if($wgTitle->isJsSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
564 # XXX: additional security check/prompt?
565 $this->userjsprev = $wgRequest->getText('wpTextbox1');
566 } else {
567 $this->userjs = $this->makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype=text/javascript&dontcountme=s');
571 # returns css with user-specific options
572 function getUserStylesheet() {
573 global $wgUser, $wgRequest, $wgTitle, $wgLang, $wgSquidMaxage, $wgStylePath;
574 $action = $wgRequest->getText('action');
575 $maxage = $wgRequest->getText('maxage');
576 $s = "/* generated user stylesheet */\n";
577 if($wgLang->isRTL()) $s .= '@import "'.$wgStylePath.'/'.$this->skinname.'/rtl.css";'."\n";
578 $s .= '@import "'.
579 $this->makeNSUrl(ucfirst($this->skinname).'.css', 'action=raw&ctype=text/css&smaxage='.$wgSquidMaxage, NS_MEDIAWIKI)."\";\n";
580 if($wgUser->getID() != 0) {
581 if ( 1 == $wgUser->getOption( "underline" ) ) {
582 $s .= "a { text-decoration: underline; }\n";
583 } else {
584 $s .= "a { text-decoration: none; }\n";
587 if ( 1 != $wgUser->getOption( "highlightbroken" ) ) {
588 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
590 if ( 1 == $wgUser->getOption( "justify" ) ) {
591 $s .= "#bodyContent { text-align: justify; }\n";
593 return $s;
595 function getUserJs() {
596 global $wgUser, $wgStylePath;
597 $s = "/* generated javascript */";
598 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
599 $s .= '/* MediaWiki:'.ucfirst($this->skinname)." */\n";
600 $s .= wfMsg(ucfirst($this->skinname).'.js');
601 return $s;
606 class SkinDaVinci extends SkinPHPTal {
607 function initPage( &$out ) {
608 SkinPHPTal::initPage( $out );
609 $this->skinname = "davinci";
613 class SkinMono extends SkinPHPTal {
614 function initPage( &$out ) {
615 SkinPHPTal::initPage( $out );
616 $this->skinname = "mono";
620 class SkinMonoBook extends SkinPHPTal {
621 function initPage( &$out ) {
622 SkinPHPTal::initPage( $out );
623 $this->skinname = "monobook";
627 class SkinMySkin extends SkinPHPTal {
628 function initPage( &$out ) {
629 SkinPHPTal::initPage( $out );
630 $this->skinname = "myskin";