Difference between revisions of "Extension:Wikiskin.php"
(try defining new skin class inside wfSetupWikiSkin) |
m |
||
Line 24: | Line 24: | ||
function wfWikiSkinMagicWordID(&$magicWords) { | function wfWikiSkinMagicWordID(&$magicWords) { | ||
global $wgWikiSkinMagic; | global $wgWikiSkinMagic; | ||
− | foreach($wgWikiSkinMagic as $magic) $magicWords[] = constant("MAG_$magic"); | + | foreach($wgWikiSkinMagic as $magic) {$magicWords[] = constant("MAG_$magic"); echo $magic;} |
return true; | return true; | ||
} | } | ||
Line 63: | Line 63: | ||
function wfSetupWikiSkin() { | function wfSetupWikiSkin() { | ||
− | # Create skin class based on monobook which parses the skin article and embeds the content | + | # Create skin class based on monobook which parses the skin article and embeds the content |
− | class SkinWikiSkin extends SkinTemplate { | + | 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() { | |
− | class WikiSkinTemplate extends QuickTemplate { | ||
− | |||
− | + | # Build the HTML, HEAD and BODY elements and send to output | |
− | + | wfSuppressWarnings(); | |
+ | |||
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>"> | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>"> | ||
Line 122: | Line 123: | ||
<a name="top" id="top"></a> | <a name="top" id="top"></a> | ||
<?php | <?php | ||
+ | |||
# Build list of special fields and their content | # Build list of special fields and their content | ||
$replace = array( | $replace = array( | ||
Line 181: | Line 183: | ||
</body></html> | </body></html> | ||
<?php | <?php | ||
− | |||
− | } | + | wfRestoreWarnings(); |
+ | |||
+ | } | ||
− | + | } # end of class definition | |
− | # Make the new skin current | + | # Make the new skin current |
− | global $wgUser; | + | global $wgUser; |
− | $wgUser->setOption('skin','WikiSkin'); | + | $wgUser->setOption('skin','WikiSkin'); |
− | $wgUser->mSkin =& new SkinWikiSkin; | + | $wgUser->mSkin =& new SkinWikiSkin; |
− | } # end of setup function | + | } # end of setup function |
?> | ?> |
Revision as of 23:09, 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
$wgWikiSkin = isset($_REQUEST['skin']) ? $_REQUEST['skin'] : 'WikiSkin';
$wgWikiSkinMagic = array('CURRENTUSER','LOGO','TEXT','SEARCH','PERSONAL','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"); echo $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;
# These ones are all replaced by a token to be filled by skin when rendering page case MAG_LOGO: case MAG_TEXT: case MAG_SEARCH: case MAG_PERSONAL: 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; }
- Define new skin class, create an instance and make it current
function wfSetupWikiSkin() {
# 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() {
# Build the HTML, HEAD and BODY elements and send to output 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') ?>
'.$this->msg('tagline').'
- ';
foreach ($this->data['content_actions'] as $key => $tab) $replace['ACTIONS'] .=
'
- '.htmlspecialchars($tab['text']).' '; $replace['ACTIONS'] .= '
- ';
foreach ($this->data['personal_urls'] as $key => $item) $replace['PERSONAL'] .=
'
- '.htmlspecialchars($item['text']).' '; $replace['PERSONAL'] .= '
html('reporttime') ?> <?php
wfRestoreWarnings();
}
} # end of class definition
# Make the new skin current global $wgUser; $wgUser->setOption('skin','WikiSkin'); $wgUser->mSkin =& new SkinWikiSkin;
} # end of setup function
?>