Difference between revisions of "Extension:Wikiskin.php"
(add html, head and body tags from monobook.php) |
m |
||
Line 7: | Line 7: | ||
# - Author: http://www.organicdesign.co.nz/nad | # - Author: http://www.organicdesign.co.nz/nad | ||
− | $wgWikiSkinMagic = array('CURRENTUSER','LOGO','SEARCH','ACTIONS','SITENOTICE','SUBTITLE',' | + | $wgWikiSkinMagic = array('CURRENTUSER','LOGO','TEXT','SEARCH','ACTIONS','SITENOTICE','SUBTITLE','INFO','CATLINKS','FOOTER'); |
$wgExtensionFunctions[] = 'wfSetupWikiSkin'; | $wgExtensionFunctions[] = 'wfSetupWikiSkin'; | ||
Line 35: | Line 35: | ||
function wfGetWikiSkinMagicWord(&$this,&$cache,&$index,&$ret) { | function wfGetWikiSkinMagicWord(&$this,&$cache,&$index,&$ret) { | ||
+ | global $wgMagicWordsEn; | ||
switch ($index) { | switch ($index) { | ||
Line 45: | Line 46: | ||
break; | break; | ||
+ | # These ones are all replaced by a token to be filled by skin when rendering page | ||
+ | case MAG_TEXT: | ||
case MAG_SEARCH: | case MAG_SEARCH: | ||
− | |||
− | |||
case MAG_ACTIONS: | case MAG_ACTIONS: | ||
− | |||
− | |||
case MAG_SITENOTICE: | case MAG_SITENOTICE: | ||
− | |||
− | |||
case MAG_SUBTITLE: | case MAG_SUBTITLE: | ||
− | + | case MAG_INFO: | |
− | |||
− | case | ||
− | |||
− | |||
− | |||
− | |||
− | |||
case MAG_CATLINKS: | case MAG_CATLINKS: | ||
− | |||
− | |||
case MAG_FOOTER: | case MAG_FOOTER: | ||
+ | $magic = $wgMagicWordsEn[$index]; | ||
+ | $ret = "((((WikiSkin:$magic))))"; | ||
break; | break; | ||
} | } | ||
Line 126: | Line 116: | ||
class="<?php $this->text('nsclass') ?> <?php $this->text('dir') ?>"> | class="<?php $this->text('nsclass') ?> <?php $this->text('dir') ?>"> | ||
+ | $sitenotice = $this->data['sitenotice'] ? '<div id="siteNotice">'.$this->html('sitenotice').'</div>' : ''; | ||
+ | $subtitle = '<h3 id="siteSub">'.$this->msg('tagline').'</h3><div id="contentSub">'.$this->html('subtitle').'</div>'; | ||
+ | $info = ($this->data['undelete'] ? '<div id="contentSub2">'.$this->html('undelete').'</div>') | ||
+ | . ($this->data['newtalk'] ? '<div class="usermessage">'.$this->html('newtalk').'</div>') | ||
+ | . ($this->data['showjumplinks'] ? '<div id="jump-to-nav">'.$this->msg('jumpto') | ||
+ | .'<a href="#column-one">'.$this->msg('jumptonavigation').'</a>' | ||
+ | .', <a href="#searchInput">'.$this->msg('jumptosearch').'</a></div>'); | ||
+ | $text = $this->html('bodytext'); | ||
+ | $catlinks = $this->html('catlinks') ? '<div id="catlinks">'.$this->html('catlinks').'</div>' : ''; | ||
<?php $this->html('reporttime') ?> | <?php $this->html('reporttime') ?> |
Revision as of 03:31, 5 April 2007
<?
- Extension:Livelets
- - Uses a wikitext article for the skin instead of a PHP file. Special items like search box and login link use magic words
- - Version 0.1 (2007-04-05)
- - See http://www.mediawiki.org/wiki/Extension:WikiSkin for installation and usage details
- - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
- - Author: http://www.organicdesign.co.nz/nad
$wgWikiSkinMagic = array('CURRENTUSER','LOGO','TEXT','SEARCH','ACTIONS','SITENOTICE','SUBTITLE','INFO','CATLINKS','FOOTER');
$wgExtensionFunctions[] = 'wfSetupWikiSkin'; $wgHooks['MagicWordMagicWords'][] = 'wfWikiSkinMagicWord'; $wgHooks['MagicWordwgVariableIDs'][] = 'wfWikiSkinMagicWordID'; $wgHooks['LanguageGetMagic'][] = 'wfWikiSkinWordLang'; $wgHooks['ParserGetVariableValueSwitch'][] = 'wfGetWikiSkinMagicWord';
function wfWikiSkinMagicWord(&$magicWords) {
global $wgWikiSkinMagic;
foreach($wgWikiSkinMagic as $magic) $magicWords[] = "MAG_$magic";
return true;
}
function wfWikiSkinMagicWordID(&$magicWords) { global $wgWikiSkinMagic; foreach($wgWikiSkinMagic as $magic) $magicWords[] = constant("MAG_$magic"); return true; }
function wfWikiSkinWordLang(&$magicWords, $langCode = 0) { global $wgWikiSkinMagic; foreach($wgWikiSkinMagic as $magic) $magicWords[constant("MAG_$magic")] = array(0,$magic); return true; }
function wfGetWikiSkinMagicWord(&$this,&$cache,&$index,&$ret) { global $wgMagicWordsEn; switch ($index) {
case MAG_CURRENTUSER: $ret = $GLOBALS['wgUser']->mName; break;
case MAG_LOGO: $ret = $GLOBALS['wgLogo']; break;
# These ones are all replaced by a token to be filled by skin when rendering page case MAG_TEXT: case MAG_SEARCH: case MAG_ACTIONS: case MAG_SITENOTICE: case MAG_SUBTITLE: case MAG_INFO: case MAG_CATLINKS: case MAG_FOOTER: $magic = $wgMagicWordsEn[$index]; $ret = "((((WikiSkin:$magic))))"; break; } return true; }
- Create skin class based on monobook which parses the skin article and embeds the content
class SkinWikiSkin extends SkinTemplate {
function initPage(&$out) { SkinTemplate::initPage($out); $this->skinname = 'wikiskin'; $this->stylename = 'wikiskin'; $this->template = 'WikiSkinTemplate'; }
}
class WikiSkinTemplate extends QuickTemplate { function execute() { wfSuppressWarnings(); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> text('lang') ?>" lang="text('lang') ?>" dir="text('dir') ?>"> html('headlinks') ?>
' : ''; $subtitle = '
'.$this->msg('tagline').'
'; $info = ($this->data['undelete'] ? '
') . ($this->data['newtalk'] ? '
') . ($this->data['showjumplinks'] ? '
'); $text = $this->html('bodytext'); $catlinks = $this->html('catlinks') ? '
' : ''; html('reporttime') ?> <?php wfRestoreWarnings();
}
}
- Make the new skin current
function wfSetupWikiSkin() { global $wgUser; $wgUser->setOption('skin','WikiSkin'); $wgUser->mSkin =& new SkinWikiSkin; }
?>