Difference between revisions of "Extension:CSS"

From Organic Design wiki
(Undo revision 77343 by Nad (Talk))
m (Nad moved page Extension:CSS.php to Extension:CSS)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<?php
+
{{svn|http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/CSS}}
# Extension:CSS{{Category:Extensions|CSS}}{{php}}
 
# - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
 
# - Author: [http://www.organicdesign.co.nz/nad User:Nad]{{Category: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'      => '[http://www.organicdesign.co.nz/nad 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'; }
 
}
 
 
# Called from $wgExtensionFunctions array when initialising extensions
 
function wfSetupCSS() {
 
global $wgCSS;
 
$wgCSS = new CSS();
 
}
 
 
# 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;
 
}
 
?>
 

Latest revision as of 09:52, 30 April 2015

Info.svg This code is in our Git repository here.

Note: If there is no information in this page about this code and it's a MediaWiki extension, there may be something at mediawiki.org.