Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

SkinPHPTal.php

Go to the documentation of this file.
00001 <?php 00002 # Generic PHPTal (http://phptal.sourceforge.net/) skin 00003 # Based on Brion's smarty skin 00004 # Copyright (C) Gabriel Wicke -- http://www.aulinx.de/ 00005 # 00006 # Todo: Needs some serious refactoring into functions that correspond 00007 # to the computations individual esi snippets need. Most importantly no body 00008 # parsing for most of those of course. 00009 # 00010 # Set this in LocalSettings to enable phptal: 00011 # set_include_path(get_include_path() . ":" . $IP.'/PHPTAL-NP-0.7.0/libs'); 00012 # $wgUsePHPTal = true; 00013 # 00014 # This program is free software; you can redistribute it and/or modify 00015 # it under the terms of the GNU General Public License as published by 00016 # the Free Software Foundation; either version 2 of the License, or 00017 # (at your option) any later version. 00018 # 00019 # This program is distributed in the hope that it will be useful, 00020 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 # GNU General Public License for more details. 00023 # 00024 # You should have received a copy of the GNU General Public License along 00025 # with this program; if not, write to the Free Software Foundation, Inc., 00026 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00027 # http://www.gnu.org/copyleft/gpl.html 00028 00029 require_once "GlobalFunctions.php"; 00030 global $IP; 00031 require_once $IP."/PHPTAL-NP-0.7.0/libs/PHPTAL.php"; 00032 00033 class MediaWiki_I18N extends PHPTAL_I18N 00034 { 00035 var $_context = array(); 00036 00037 function set($varName, $value) { 00038 $this->_context[$varName] = $value; 00039 } 00040 00041 function translate($value) { 00042 $value = wfMsg( $value ); 00043 // interpolate variables 00044 while (preg_match('/\$([0-9]*?)/sm', $value, $m)) { 00045 list($src, $var) = $m; 00046 $varValue = @$this->_context[$var]; 00047 $value = str_replace($src, $varValue, $value); 00048 } 00049 return $value; 00050 } 00051 } 00052 00053 class SkinPHPTal extends Skin { 00054 var $template; 00055 00056 function initPage( &$out ) { 00057 parent::initPage( $out ); 00058 $this->skinname = "davinci"; 00059 $this->template = "xhtml_slim"; 00060 } 00061 00062 function outputPage( &$out ) { 00063 global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgOut; 00064 global $wgScript, $wgStylePath, $wgLanguageCode, $wgUseNewInterlanguage; 00065 global $wgMimeType, $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest; 00066 global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgSiteNotice; 00067 00068 extract( $wgRequest->getValues( 'oldid', 'diff' ) ); 00069 00070 $this->initPage( $out ); 00071 $tpl = new PHPTAL($this->template . '.pt', 'templates'); 00072 00073 #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText 00074 $tpl->setTranslator(new MediaWiki_I18N()); 00075 #} 00076 00077 $this->thispage = $wgTitle->getPrefixedDbKey(); 00078 $this->thisurl = $wgTitle->getPrefixedURL(); 00079 $this->loggedin = $wgUser->getID() != 0; 00080 $this->iscontent = ($wgTitle->getNamespace() != Namespace::getSpecial() ); 00081 $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit')); 00082 $this->username = $wgUser->getName(); 00083 $this->userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName(); 00084 $this->userpageUrlDetails = $this->makeUrlDetails($this->userpage); 00085 00086 $this->usercss = $this->userjs = $this->userjsprev = false; 00087 $this->setupUserCssJs(); 00088 00089 $this->titletxt = $wgTitle->getPrefixedText(); 00090 00091 $tpl->set( "title", $wgOut->getPageTitle() ); 00092 $tpl->set( "pagetitle", $wgOut->getHTMLTitle() ); 00093 00094 $tpl->setRef( "thispage", $this->thispage ); 00095 $subpagestr = $this->subPageSubtitle(); 00096 $tpl->set( 00097 "subtitle", !empty($subpagestr)? 00098 '<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle(): 00099 $out->getSubtitle() 00100 ); 00101 $undelete = $this->getUndeleteLink(); 00102 $tpl->set( 00103 "undelete", !empty($undelete)? 00104 '<span class="subpages">'.$undelete.'</span>': 00105 '' 00106 ); 00107 00108 $tpl->set( 'catlinks', $this->getCategories()); 00109 if( $wgOut->isSyndicated() ) { 00110 $feeds = array(); 00111 foreach( $wgFeedClasses as $format => $class ) { 00112 $feeds[$format] = array( 00113 'text' => $format, 00114 'href' => $wgRequest->appendQuery( "feed=$format" ), 00115 'ttip' => wfMsg('tooltip-'.$format) 00116 ); 00117 } 00118 $tpl->setRef( 'feeds', $feeds ); 00119 } 00120 $tpl->setRef( 'mimetype', $wgMimeType ); 00121 $tpl->setRef( 'charset', $wgOutputEncoding ); 00122 $tpl->set( 'headlinks', $out->getHeadLinks() ); 00123 $tpl->setRef( 'skinname', $this->skinname ); 00124 $tpl->setRef( "loggedin", $this->loggedin ); 00125 $tpl->set('nsclass', 'ns-'.$wgTitle->getNamespace()); 00126 /* XXX currently unused, might get useful later 00127 $tpl->set( "editable", ($wgTitle->getNamespace() != NS_SPECIAL ) ); 00128 $tpl->set( "exists", $wgTitle->getArticleID() != 0 ); 00129 $tpl->set( "watch", $wgTitle->userIsWatching() ? "unwatch" : "watch" ); 00130 $tpl->set( "protect", count($wgTitle->getRestrictions()) ? "unprotect" : "protect" ); 00131 $tpl->set( "helppage", wfMsg('helppage')); 00132 $tpl->set( "sysop", $wgUser->isSysop() ); 00133 */ 00134 $tpl->set( "searchaction", $this->escapeSearchLink() ); 00135 $tpl->setRef( "stylepath", $wgStylePath ); 00136 $tpl->setRef( "logopath", $wgLogo ); 00137 $tpl->setRef( "lang", $wgLanguageCode ); 00138 $tpl->set( "dir", $wgLang->isRTL() ? "rtl" : "ltr" ); 00139 $tpl->set( "rtl", $wgLang->isRTL() ); 00140 $tpl->set( "langname", $wgLang->getLanguageName( $wgLanguageCode ) ); 00141 $tpl->setRef( "username", $this->username ); 00142 $tpl->setRef( "userpage", $this->userpage); 00143 $tpl->setRef( "userpageurl", $this->userpageUrlDetails['href']); 00144 $tpl->setRef( "usercss", $this->usercss); 00145 $tpl->setRef( "userjs", $this->userjs); 00146 $tpl->setRef( "userjsprev", $this->userjsprev); 00147 if($this->loggedin) { 00148 $tpl->set( "jsvarurl", $this->makeUrl('-','action=raw&gen=js&smaxage=0') ); 00149 } else { 00150 $tpl->set( "jsvarurl", $this->makeUrl('-','action=raw&gen=js') ); 00151 } 00152 if( $wgUser->getNewtalk() ) { 00153 $usertitle = Title::newFromText( $this->userpage ); 00154 $usertalktitle = $usertitle->getTalkPage(); 00155 if($usertalktitle->getPrefixedDbKey() != $this->thispage){ 00156 00157 $ntl = wfMsg( "newmessages", 00158 $this->makeKnownLink( 00159 $wgLang->getNsText( Namespace::getTalk( Namespace::getUser() ) ) 00160 . ":" . $this->username, 00161 wfMsg("newmessageslink") ) 00162 ); 00163 } 00164 } else { 00165 $ntl = ""; 00166 } 00167 00168 $tpl->setRef( "newtalk", $ntl ); 00169 $tpl->setRef( "skin", $this); 00170 $tpl->set( "logo", $this->logoText() ); 00171 if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and 0 != $wgArticle->getID() ) { 00172 if ( !$wgDisableCounters ) { 00173 $viewcount = $wgLang->formatNum( $wgArticle->getCount() ); 00174 if ( $viewcount ) { 00175 $tpl->set('viewcount', wfMsg( "viewcount", $viewcount )); 00176 } 00177 } 00178 $tpl->set('lastmod', $this->lastModified()); 00179 $tpl->set('copyright',$this->getCopyright()); 00180 } 00181 $tpl->set( "copyrightico", $this->getCopyrightIcon() ); 00182 $tpl->set( "poweredbyico", $this->getPoweredBy() ); 00183 $tpl->set( "disclaimer", $this->disclaimerLink() ); 00184 $tpl->set( "about", $this->aboutLink() ); 00185 00186 $tpl->setRef( "debug", $out->mDebugtext ); 00187 $tpl->set( "reporttime", $out->reportTime() ); 00188 $tpl->set( "sitenotice", $wgSiteNotice ); 00189 00190 $tpl->setRef( "bodytext", $out->mBodytext ); 00191 00192 $language_urls = array(); 00193 foreach( $wgOut->getLanguageLinks() as $l ) { 00194 $nt = Title::newFromText( $l ); 00195 $language_urls[] = array('href' => $nt->getFullURL(), 00196 'text' => ($wgLang->getLanguageName( $nt->getInterwiki()) != ''?$wgLang->getLanguageName( $nt->getInterwiki()) : $l), 00197 'class' => $wgLang->isRTL() ? 'rtl' : 'ltr'); 00198 } 00199 if(count($language_urls)) { 00200 $tpl->setRef( 'language_urls', $language_urls); 00201 } else { 00202 $tpl->set('language_urls', false); 00203 } 00204 $tpl->set('personal_urls', $this->buildPersonalUrls()); 00205 $content_actions = $this->buildContentActionUrls(); 00206 $tpl->setRef('content_actions', $content_actions); 00207 // XXX: attach this from javascript, same with section editing 00208 if($this->iseditable && $wgUser->getOption("editondblclick") ) 00209 { 00210 $tpl->set('body-ondblclick', 'document.location = "' .$content_actions['edit']['href'] .'";'); 00211 } else { 00212 $tpl->set('body-ondblclick', false); 00213 } 00214 $tpl->set( "nav_urls", $this->buildNavUrls() ); 00215 00216 // execute template 00217 $res = $tpl->execute(); 00218 // result may be an error 00219 if (PEAR::isError($res)) { 00220 echo $res->toString(), "\n"; 00221 } else { 00222 echo $res; 00223 } 00224 00225 } 00226 00227 # build array of urls for personal toolbar 00228 function buildPersonalUrls() { 00229 /* set up the default links for the personal toolbar */ 00230 global $wgShowIPinHeader; 00231 $personal_urls = array(); 00232 if ($this->loggedin) { 00233 $personal_urls['userpage'] = array( 00234 'text' => $this->username, 00235 'href' => &$this->userpageUrlDetails['href'], 00236 'class' => $this->userpageUrlDetails['exists']?false:'new' 00237 ); 00238 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage); 00239 $personal_urls['mytalk'] = array( 00240 'text' => wfMsg('mytalk'), 00241 'href' => &$usertalkUrlDetails['href'], 00242 'class' => $usertalkUrlDetails['exists']?false:'new' 00243 ); 00244 $personal_urls['preferences'] = array( 00245 'text' => wfMsg('preferences'), 00246 'href' => $this->makeSpecialUrl('Preferences') 00247 ); 00248 $personal_urls['watchlist'] = array( 00249 'text' => wfMsg('watchlist'), 00250 'href' => $this->makeSpecialUrl('Watchlist') 00251 ); 00252 $personal_urls['mycontris'] = array( 00253 'text' => wfMsg('mycontris'), 00254 'href' => $this->makeSpecialUrl('Contributions','target=' . urlencode( $this->username ) ) 00255 ); 00256 $personal_urls['logout'] = array( 00257 'text' => wfMsg('userlogout'), 00258 'href' => $this->makeSpecialUrl('Userlogout','returnto=' . $this->thisurl ) 00259 ); 00260 } else { 00261 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) { 00262 $personal_urls['anonuserpage'] = array( 00263 'text' => $this->username, 00264 'href' => &$this->userpageUrlDetails['href'], 00265 'class' => $this->userpageUrlDetails['exists']?false:'new' 00266 ); 00267 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage); 00268 $personal_urls['anontalk'] = array( 00269 'text' => wfMsg('anontalk'), 00270 'href' => &$usertalkUrlDetails['href'], 00271 'class' => $usertalkUrlDetails['exists']?false:'new' 00272 ); 00273 $personal_urls['anonlogin'] = array( 00274 'text' => wfMsg('userlogin'), 00275 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl ) 00276 ); 00277 } else { 00278 00279 $personal_urls['login'] = array( 00280 'text' => wfMsg('userlogin'), 00281 'href' => $this->makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl ) 00282 ); 00283 } 00284 } 00285 00286 return $personal_urls; 00287 } 00288 00289 # an array of edit links by default used for the tabs 00290 function buildContentActionUrls () { 00291 global $wgTitle, $wgUser, $wgRequest; 00292 $action = $wgRequest->getText( 'action' ); 00293 $section = $wgRequest->getText( 'section' ); 00294 $oldid = $wgRequest->getVal( 'oldid' ); 00295 $diff = $wgRequest->getVal( 'diff' ); 00296 $content_actions = array(); 00297 00298 if( $this->iscontent ) { 00299 00300 $nskey = $this->getNameSpaceKey(); 00301 $content_actions[$nskey] = array('class' => (!Namespace::isTalk( $wgTitle->getNamespace())) ? 'selected' : false, 00302 'text' => wfMsg($nskey), 00303 'href' => $this->makeArticleUrl($this->thispage)); 00304 00305 /* set up the classes for the talk link */ 00306 $talk_class = (Namespace::isTalk( $wgTitle->getNamespace()) ? 'selected' : false); 00307 $talktitle = Title::newFromText( $this->titletxt ); 00308 $talktitle = $talktitle->getTalkPage(); 00309 $this->checkTitle($talktitle, $this->titletxt); 00310 if($talktitle->getArticleId() != 0) { 00311 $content_actions['talk'] = array( 00312 'class' => $talk_class, 00313 'text' => wfMsg('talk'), 00314 'href' => $this->makeTalkUrl($this->titletxt) 00315 ); 00316 } else { 00317 $content_actions['talk'] = array( 00318 'class' => $talk_class?$talk_class.' new':'new', 00319 'text' => wfMsg('talk'), 00320 'href' => $this->makeTalkUrl($this->titletxt,'action=edit') 00321 ); 00322 } 00323 00324 if ( $wgTitle->userCanEdit() ) { 00325 $oid = ( $oldid && ! isset( $diff ) ) ? "&oldid={$oldid}" : false; 00326 $istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) ); 00327 $istalkclass = $istalk?' istalk':''; 00328 $content_actions['edit'] = array( 00329 'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ? 'selected' : '').$istalkclass, 00330 'text' => wfMsg('edit'), 00331 'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid) 00332 ); 00333 if ( $istalk ) { 00334 $content_actions['addsection'] = array( 00335 'class' => $section == 'new'?'selected':false, 00336 'text' => wfMsg('addsection'), 00337 'href' => $this->makeUrl($this->thispage, 'action=edit&section=new') 00338 ); 00339 } 00340 } else { 00341 $oid = ( $oldid && ! isset( $diff ) ) ? "&oldid={$oldid}" : ''; 00342 $content_actions['viewsource'] = array('class' => ($action == 'edit') ? 'selected' : false, 00343 'text' => wfMsg('viewsource'), 00344 'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid)); 00345 } 00346 00347 if ( $wgTitle->getArticleId() ) { 00348 00349 $content_actions['history'] = array('class' => ($action == 'history') ? 'selected' : false, 00350 'text' => wfMsg('history_short'), 00351 'href' => $this->makeUrl($this->thispage, 'action=history')); 00352 00353 # XXX: is there a rollback action anywhere or is it planned? 00354 # Don't recall where i got this from... 00355 /*if( $wgUser->getNewtalk() ) { 00356 $content_actions['rollback'] = array('class' => ($action == 'rollback') ? 'selected' : false, 00357 'text' => wfMsg('rollback_short'), 00358 'href' => $this->makeUrl($this->thispage, 'action=rollback'), 00359 'ttip' => wfMsg('tooltip-rollback'), 00360 'akey' => wfMsg('accesskey-rollback')); 00361 }*/ 00362 00363 if($wgUser->isSysop()){ 00364 if(!$wgTitle->isProtected()){ 00365 $content_actions['protect'] = array( 00366 'class' => ($action == 'protect') ? 'selected' : false, 00367 'text' => wfMsg('protect'), 00368 'href' => $this->makeUrl($this->thispage, 'action=protect') 00369 ); 00370 00371 } else { 00372 $content_actions['unprotect'] = array( 00373 'class' => ($action == 'unprotect') ? 'selected' : false, 00374 'text' => wfMsg('unprotect'), 00375 'href' => $this->makeUrl($this->thispage, 'action=unprotect') 00376 ); 00377 } 00378 $content_actions['delete'] = array( 00379 'class' => ($action == 'delete') ? 'selected' : false, 00380 'text' => wfMsg('delete'), 00381 'href' => $this->makeUrl($this->thispage, 'action=delete') 00382 ); 00383 } 00384 if ( $wgUser->getID() != 0 ) { 00385 if ( $wgTitle->userCanEdit()) { 00386 $content_actions['move'] = array('class' => ($wgTitle->getDbKey() == 'Movepage' and $wgTitle->getNamespace == Namespace::getSpecial()) ? 'selected' : false, 00387 'text' => wfMsg('move'), 00388 'href' => $this->makeSpecialUrl('Movepage', 'target='. urlencode( $this->thispage )) 00389 ); 00390 } else { 00391 $content_actions['move'] = array('class' => 'inactive', 00392 'text' => wfMsg('move'), 00393 'href' => false); 00394 00395 } 00396 } 00397 } else { 00398 //article doesn't exist or is deleted 00399 if($wgUser->isSysop()){ 00400 if( $n = $wgTitle->isDeleted() ) { 00401 $content_actions['delete'] = array( 00402 'class' => false, 00403 'text' => wfMsg( "undelete_short", $n ), 00404 'href' => $this->makeSpecialUrl('Undelete/'.$this->thispage) 00405 ); 00406 } 00407 } 00408 } 00409 00410 if ( $wgUser->getID() != 0 and $action != 'edit' and $action != 'submit' ) { 00411 if( !$wgTitle->userIsWatching()) { 00412 $content_actions['watch'] = array('class' => ($action == 'watch' or $action == 'unwatch') ? 'selected' : false, 00413 'text' => wfMsg('watch'), 00414 'href' => $this->makeUrl($this->thispage, 'action=watch')); 00415 } else { 00416 $content_actions['watch'] = array('class' => ($action == 'unwatch' or $action == 'watch') ? 'selected' : false, 00417 'text' => wfMsg('unwatch'), 00418 'href' => $this->makeUrl($this->thispage, 'action=unwatch')); 00419 } 00420 } 00421 } else { 00422 /* show special page tab */ 00423 00424 $content_actions['article'] = array('class' => 'selected', 00425 'text' => wfMsg('specialpage'), 00426 'href' => false); 00427 } 00428 00429 return $content_actions; 00430 } 00431 00432 # build array of common navigation links 00433 function buildNavUrls () { 00434 global $wgTitle, $wgUser, $wgRequest; 00435 global $wgSiteSupportPage; 00436 00437 $action = $wgRequest->getText( 'action' ); 00438 $oldid = $wgRequest->getVal( 'oldid' ); 00439 $diff = $wgRequest->getVal( 'diff' ); 00440 // XXX: remove htmlspecialchars when tal:attributes works with i18n:attributes 00441 $nav_urls = array(); 00442 $nav_urls['mainpage'] = array('href' => htmlspecialchars( $this->makeI18nUrl('mainpage'))); 00443 $nav_urls['randompage'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Randompage'))); 00444 $nav_urls['recentchanges'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchanges'))); 00445 $nav_urls['whatlinkshere'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Whatlinkshere', 'target='.urlencode( $this->thispage )))); 00446 $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('currentevents'))) : false; 00447 $nav_urls['portal'] = (wfMsg('portal') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('portal-url'))) : false; 00448 $nav_urls['recentchangeslinked'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchangeslinked', 'target='.urlencode( $this->thispage )))); 00449 $nav_urls['bugreports'] = array('href' => htmlspecialchars( $this->makeI18nUrl('bugreportspage'))); 00450 // $nav_urls['sitesupport'] = array('href' => htmlspecialchars( $this->makeI18nUrl('sitesupportpage'))); 00451 $nav_urls['sitesupport'] = array('href' => htmlspecialchars( $wgSiteSupportPage)); 00452 $nav_urls['help'] = array('href' => htmlspecialchars( $this->makeI18nUrl('helppage'))); 00453 $nav_urls['upload'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Upload'))); 00454 $nav_urls['specialpages'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Specialpages'))); 00455 00456 if( $wgTitle->getNamespace() == NS_USER || $wgTitle->getNamespace() == NS_USER_TALK ) { 00457 $id = User::idFromName($wgTitle->getText()); 00458 $ip = User::isIP($wgTitle->getText()); 00459 } else { 00460 $id = 0; 00461 $ip = false; 00462 } 00463 00464 if($id || $ip) { # both anons and non-anons have contri list 00465 $nav_urls['contributions'] = array( 00466 'href' => htmlspecialchars( $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() ) ) 00467 ); 00468 } 00469 if ( 0 != $wgUser->getID() ) { # show only to signed in users 00470 if($id) { # can only email non-anons 00471 $nav_urls['emailuser'] = array( 00472 'href' => htmlspecialchars( $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() ) ) 00473 ); 00474 } 00475 } 00476 00477 00478 return $nav_urls; 00479 } 00480 00481 function getNameSpaceKey () { 00482 global $wgTitle; 00483 switch ($wgTitle->getNamespace()) { 00484 case NS_MAIN: 00485 case NS_TALK: 00486 return 'nstab-main'; 00487 case NS_USER: 00488 case NS_USER_TALK: 00489 return 'nstab-user'; 00490 case NS_MEDIA: 00491 return 'nstab-media'; 00492 case NS_SPECIAL: 00493 return 'nstab-special'; 00494 case NS_WP: 00495 case NS_WP_TALK: 00496 return 'nstab-wp'; 00497 case NS_IMAGE: 00498 case NS_IMAGE_TALK: 00499 return 'nstab-image'; 00500 case NS_MEDIAWIKI: 00501 case NS_MEDIAWIKI_TALK: 00502 return 'nstab-mediawiki'; 00503 case NS_TEMPLATE: 00504 case NS_TEMPLATE_TALK: 00505 return 'nstab-template'; 00506 case NS_HELP: 00507 case NS_HELP_TALK: 00508 return 'nstab-help'; 00509 case NS_CATEGORY: 00510 case NS_CATEGORY_TALK: 00511 return 'nstab-category'; 00512 default: 00513 return 'nstab-main'; 00514 } 00515 } 00516 /* private */ function setupUserCssJs () { 00517 global $wgRequest, $wgTitle; 00518 $action = $wgRequest->getText('action'); 00519 # generated css 00520 $this->usercss = '@import "'.$this->makeUrl('-','action=raw&gen=css').'";'."\n"; 00521 00522 if( $this->loggedin ) { 00523 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) { 00524 # generated css 00525 $this->usercss = '@import "'.$this->makeUrl('-','action=raw&gen=css&smaxage=0&maxage=0').');'."\n"; 00526 // css preview 00527 $this->usercss .= $wgRequest->getText('wpTextbox1'); 00528 } else { 00529 # generated css 00530 $this->usercss .= '@import "'.$this->makeUrl('-','action=raw&gen=css&smaxage=0').'";'."\n"; 00531 # import user stylesheet 00532 $this->usercss .= '@import "'. 00533 $this->makeUrl($this->userpage.'/'.$this->skinname.'.css', 'action=raw&ctype=text/css').'";'."\n"; 00534 } 00535 if($wgTitle->isJsSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) { 00536 # XXX: additional security check/prompt? 00537 $this->userjsprev = $wgRequest->getText('wpTextbox1'); 00538 } else { 00539 $this->userjs = $this->makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype=text/javascript'); 00540 } 00541 } 00542 } 00543 # returns css with user-specific options 00544 function getUserStylesheet() { 00545 global $wgUser, $wgRequest, $wgTitle, $wgLang, $wgSquidMaxage, $wgStylePath; 00546 $action = $wgRequest->getText('action'); 00547 $maxage = $wgRequest->getText('maxage'); 00548 $s = "/* generated user stylesheet */\n"; 00549 if($wgLang->isRTL()) $s .= '@import "'.$wgStylePath.'/'.$this->skinname.'/rtl.css";'."\n"; 00550 $s .= '@import "'. 00551 $this->makeNSUrl(ucfirst($this->skinname).'.css', 'action=raw&ctype=text/css&smaxage='.$wgSquidMaxage, NS_MEDIAWIKI)."\";\n"; 00552 if($wgUser->getID() != 0) { 00553 if ( 1 == $wgUser->getOption( "underline" ) ) { 00554 $s .= "a { text-decoration: underline; }\n"; 00555 } else { 00556 $s .= "a { text-decoration: none; }\n"; 00557 } 00558 } 00559 if ( 1 != $wgUser->getOption( "highlightbroken" ) ) { 00560 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n"; 00561 } 00562 if ( 1 == $wgUser->getOption( "justify" ) ) { 00563 $s .= "#bodyContent { text-align: justify; }\n"; 00564 } 00565 return $s; 00566 } 00567 function getUserJs() { 00568 global $wgUser, $wgStylePath; 00569 $s = "/* generated javascript */"; 00570 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';"; 00571 $s .= '/* MediaWiki:'.ucfirst($this->skinname)." */\n"; 00572 $s .= wfMsg(ucfirst($this->skinname).'.js'); 00573 return $s; 00574 } 00575 00576 } 00577 00578 class SkinDaVinci extends SkinPHPTal { 00579 function initPage( &$out ) { 00580 SkinPHPTal::initPage( $out ); 00581 $this->skinname = "davinci"; 00582 } 00583 } 00584 00585 class SkinMono extends SkinPHPTal { 00586 function initPage( &$out ) { 00587 SkinPHPTal::initPage( $out ); 00588 $this->skinname = "mono"; 00589 } 00590 } 00591 00592 class SkinMonoBook extends SkinPHPTal { 00593 function initPage( &$out ) { 00594 SkinPHPTal::initPage( $out ); 00595 $this->skinname = "monobook"; 00596 } 00597 } 00598 00599 class SkinMySkin extends SkinPHPTal { 00600 function initPage( &$out ) { 00601 SkinPHPTal::initPage( $out ); 00602 $this->skinname = "myskin"; 00603 } 00604 } 00605 00606 ?>

Generated on Tue Jun 29 23:40:07 2004 for Mediawiki by doxygen 1.3.7