Difference between revisions of "Extension:CSS"

From Organic Design wiki
m (sortkey)
(doh - just has to ensure that parser-cache doesn't apply!)
Line 6: Line 6:
 
if (!defined('MEDIAWIKI')) die('Not an entry point.');
 
if (!defined('MEDIAWIKI')) die('Not an entry point.');
 
   
 
   
define('CSS_VERSION','1.0.0, 2007-06-15');
+
define('CSS_VERSION','1.0.1, 2007-08-25');
 
   
 
   
 
$wgCSSMagic                    = "css";
 
$wgCSSMagic                    = "css";
Line 31: Line 31:
 
function magicCss(&$parser,$css) {
 
function magicCss(&$parser,$css) {
 
global $wgOut;
 
global $wgOut;
 +
$parser->mOutput->mCacheTime = -1;
 
$url = Title::newFromText($css)->getLocalURL('action=raw&ctype=text/css');
 
$url = Title::newFromText($css)->getLocalURL('action=raw&ctype=text/css');
 
$wgOut->addScript("<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />");
 
$wgOut->addScript("<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />");

Revision as of 23:55, 24 August 2007

<?php

  1. Extension:CSS
Info.svg These are the MediaWiki extensions we're using and/or developing. Please refer to the information on the mediawiki.org wiki for installation and usage details. Extensions here which have no corresponding mediawiki article are either not ready for use or have been superseded. You can also browse our extension code in our local Subversion repository or our GitHub mirror.

Template:Php

  1. - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
  2. - Author: User:NadCategory:Extensions created with Template:Extension

if (!defined('MEDIAWIKI')) die('Not an entry point.');

define('CSS_VERSION','1.0.1, 2007-08-25');

$wgCSSMagic = "css"; $wgExtensionFunctions[] = 'wfSetupCSS'; $wgHooks['LanguageGetMagic'][] = 'wfCSSLanguageGetMagic';

$wgExtensionCredits['parserhook'][] = array( 'name' => 'CSS', 'author' => 'User:Nad', 'description' => 'A parser-function for adding CSS\'s to articles', 'url' => 'http://www.mediawiki.org/wiki/Extension:CSS', 'version' => CSS_VERSION );

class CSS {

# Constructor function CSS() { global $wgParser,$wgCSSMagic; $wgParser->setFunctionHook($wgCSSMagic,array($this,'magicCss')); }

# Expand the css-magic function magicCss(&$parser,$css) { global $wgOut; $parser->mOutput->mCacheTime = -1; $url = Title::newFromText($css)->getLocalURL('action=raw&ctype=text/css'); $wgOut->addScript("<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); return ; }

# Needed in some versions to prevent Special:Version from breaking function __toString() { return 'CSS'; }

	}

  1. Called from $wgExtensionFunctions array when initialising extensions

function wfSetupCSS() { global $wgCSS; $wgCSS = new CSS(); }

  1. Needed in MediaWiki >1.8.0 for magic word hooks to work properly

function wfCSSLanguageGetMagic(&$magicWords,$langCode = 0) { global $wgCSSMagic; $magicWords[$wgCSSMagic] = array(0,$wgCSSMagic); return true; } ?>