Difference between revisions of "Extension:Wikiskin.php"

From Organic Design wiki
m (go away hiddeous ugly url!)
(add html, head and body tags from monobook.php)
Line 86: Line 86:
 
class WikiSkinTemplate extends QuickTemplate {
 
class WikiSkinTemplate extends QuickTemplate {
 
function execute() {
 
function execute() {
 +
wfSuppressWarnings();
 +
?><!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') ?>">
 +
<head>
 +
<meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
 +
<?php $this->html('headlinks') ?>
 +
<title><?php $this->text('pagetitle') ?></title>
 +
<style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/main.css?7"; /*]]>*/</style>
 +
<link rel="stylesheet" type="text/css" <?php if(empty($this->data['printable']) ) { ?>media="print"<?php } ?> href="<?php $this->text('stylepath') ?>/common/commonPrint.css" />
 +
<!--[if lt IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE50Fixes.css";</style><![endif]-->
 +
<!--[if IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE55Fixes.css";</style><![endif]-->
 +
<!--[if IE 6]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE60Fixes.css";</style><![endif]-->
 +
<!--[if IE 7]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE70Fixes.css?1";</style><![endif]-->
 +
<!--[if lt IE 7]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js"></script>
 +
<meta http-equiv="imagetoolbar" content="no" /><![endif]-->
 +
<script type="<?php $this->text('jsmimetype') ?>">var skin = '<?php $this->text('skinname')?>';var stylepath = '<?php $this->text('stylepath')?>';</script>
 +
<script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js"><!-- wikibits js --></script>
 +
<?php if($this->data['jsvarurl'  ]) { ?>
 +
<script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('jsvarurl'  ) ?>"><!-- site js --></script>
 +
<?php } ?>
 +
<?php if($this->data['pagecss'  ]) { ?>
 +
<style type="text/css"><?php $this->html('pagecss'  ) ?></style>
 +
<?php }
 +
if($this->data['usercss'  ]) { ?>
 +
<style type="text/css"><?php $this->html('usercss'  ) ?></style>
 +
<?php }
 +
if($this->data['userjs'    ]) { ?>
 +
<script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('userjs' ) ?>"></script>
 +
<?php }
 +
if($this->data['userjsprev']) { ?>
 +
<script type="<?php $this->text('jsmimetype') ?>"><?php $this->html('userjsprev') ?></script>
 +
<?php }
 +
if($this->data['trackbackhtml']) print $this->data['trackbackhtml']; ?>
 +
<!-- Head Scripts -->
 +
<?php $this->html('headscripts') ?>
 +
</head>
 +
<body <?php if($this->data['body_ondblclick']) { ?>ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
 +
<?php if($this->data['body_onload'    ]) { ?>onload="<?php    $this->text('body_onload')    ?>"<?php } ?>
 +
class="<?php $this->text('nsclass') ?> <?php $this->text('dir') ?>">
 +
 +
 +
<?php $this->html('reporttime') ?>
 +
</body></html>
 +
<?php
 +
wfRestoreWarnings();
 +
  
 
}
 
}

Revision as of 03:02, 5 April 2007

<?

  1. Extension:Livelets
  2. - Uses a wikitext article for the skin instead of a PHP file. Special items like search box and login link use magic words
  3. - Version 0.1 (2007-04-05)
  4. - See http://www.mediawiki.org/wiki/Extension:WikiSkin for installation and usage details
  5. - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
  6. - Author: http://www.organicdesign.co.nz/nad

$wgWikiSkinMagic = array('CURRENTUSER','LOGO','SEARCH','ACTIONS','SITENOTICE','SUBTITLE','UNDELETE','NEWTALK','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) { switch ($index) {

case MAG_CURRENTUSER: $ret = $GLOBALS['wgUser']->mName; break;

case MAG_LOGO: $ret = $GLOBALS['wgLogo']; break;

case MAG_SEARCH: break;

case MAG_ACTIONS: break;

case MAG_SITENOTICE: break;

case MAG_SUBTITLE: break;

case MAG_UNDELETE: break;

case MAG_NEWTALK: break;

case MAG_CATLINKS: break;

case MAG_FOOTER: break; } return true; }

  1. 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') ?> <?php $this->text('pagetitle') ?> data['printable']) ) { ?>media="print" href="text('stylepath') ?>/common/commonPrint.css" /> data['jsvarurl' ]) { ?> data['pagecss' ]) { ?> data['usercss' ]) { ?> data['userjs' ]) { ?> data['userjsprev']) { ?> data['trackbackhtml']) print $this->data['trackbackhtml']; ?> html('headscripts') ?> data['body_ondblclick']) { ?>ondblclick="text('body_ondblclick') ?>" data['body_onload' ]) { ?>onload="text('body_onload') ?>" class="text('nsclass') ?> text('dir') ?>"> html('reporttime') ?> <?php wfRestoreWarnings();


}

}

  1. Make the new skin current

function wfSetupWikiSkin() { global $wgUser; $wgUser->setOption('skin','WikiSkin'); $wgUser->mSkin =& new SkinWikiSkin; }

?>