Difference between revisions of "Extension:Wikiskin.php"
m |
m |
||
Line 8: | Line 8: | ||
$wgWikiSkinArticle = isset($_REQUEST['skin']) ? $_REQUEST['skin'] : 'WikiSkin'; | $wgWikiSkinArticle = isset($_REQUEST['skin']) ? $_REQUEST['skin'] : 'WikiSkin'; | ||
− | $wgWikiSkinMagic = array(' | + | $wgWikiSkinMagic = array('SITELOGO','TEXT','SEARCH','PERSONAL','ACTIONS','SITENOTICE','SUBTITLE','INFO','CATLINKS','FOOTER'); |
$wgExtensionFunctions[] = 'wfSetupWikiSkin'; | $wgExtensionFunctions[] = 'wfSetupWikiSkin'; | ||
Line 45: | Line 45: | ||
# These ones are all replaced by a token to be filled by skin when rendering page | # These ones are all replaced by a token to be filled by skin when rendering page | ||
− | case | + | case MAG_SITELOGO: |
case MAG_TEXT: | case MAG_TEXT: | ||
case MAG_SEARCH: | case MAG_SEARCH: | ||
Line 124: | Line 124: | ||
<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 137: | Line 137: | ||
.'<input type="submit" name="fulltext" class="searchButton" value="'.$this->msg('search').'" /></div></form>' | .'<input type="submit" name="fulltext" class="searchButton" value="'.$this->msg('search').'" /></div></form>' | ||
.'</div></div>', | .'</div></div>', | ||
− | ' | + | 'SITELOGO' => '<div class="portlet" id="p-logo"><a style="background-image: url('.$this->text('logopath').');" ' |
.'href="'.htmlspecialchars($this->data['nav_urls']['mainpage']['href']).'" ' | .'href="'.htmlspecialchars($this->data['nav_urls']['mainpage']['href']).'" ' | ||
.'title="'.$this->msg('mainpage').'"></a></div>' | .'title="'.$this->msg('mainpage').'"></a></div>' | ||
Line 151: | Line 151: | ||
'CATLINKS' => $this->html('catlinks') ? '<div id="catlinks">'.$this->html('catlinks').'</div>' : '' | 'CATLINKS' => $this->html('catlinks') ? '<div id="catlinks">'.$this->html('catlinks').'</div>' : '' | ||
); | ); | ||
− | + | ||
# Actions | # Actions | ||
$replace['ACTIONS'] = '<ul>'; | $replace['ACTIONS'] = '<ul>'; |
Revision as of 06:45, 6 April 2007
<?
- Extension:WikiSkin
- - 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-06)
- - 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
$wgWikiSkinArticle = isset($_REQUEST['skin']) ? $_REQUEST['skin'] : 'WikiSkin'; $wgWikiSkinMagic = array('SITELOGO','TEXT','SEARCH','PERSONAL','ACTIONS','SITENOTICE','SUBTITLE','INFO','CATLINKS','FOOTER');
$wgExtensionFunctions[] = 'wfSetupWikiSkin'; $wgHooks['MagicWordMagicWords'][] = 'wfWikiSkinMagicWord'; $wgHooks['MagicWordwgVariableIDs'][] = 'wfWikiSkinVariableID'; $wgHooks['LanguageGetMagic'][] = 'wfWikiSkinLangMagic'; $wgHooks['ParserGetVariableValueSwitch'][] = 'wfWikiSkinGetVariable';
function wfWikiSkinMagicWord(&$magicWords) { global $wgWikiSkinMagic; foreach($wgWikiSkinMagic as $var) $magicWords[] = "MAG_$var"; return true; }
function wfWikiSkinVariableID(&$variables) { global $wgWikiSkinMagic; foreach($wgWikiSkinMagic as $var) $variables[] = constant("MAG_$var"); return true; }
function wfWikiSkinLangMagic(&$langMagic, $langCode = 0) { global $wgWikiSkinMagic; foreach($wgWikiSkinMagic as $var) { $magic = "MAG_$var"; $langMagic[defined($magic) ? constant($magic) : $magic] = array(0,$var); } return true; }
function wfWikiSkinGetVariable(&$this,&$cache,&$index,&$ret) { 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_SITELOGO: 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 = constant($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
?>