Index: trunk/extensions/CSS/CSS.php |
— | — | @@ -7,13 +7,13 @@ |
8 | 8 | * @file |
9 | 9 | * @ingroup Extensions |
10 | 10 | * @author Aran Dunkley [http://www.organicdesign.co.nz/nad User:Nad] |
11 | | - * @copyright © 2007 Aran Dunkley |
| 11 | + * @copyright © 2007 Aran Dunkley |
12 | 12 | * @licence GNU General Public Licence 2.0 or later |
13 | 13 | */ |
14 | 14 | |
15 | | -if (!defined('MEDIAWIKI')) die('Not an entry point.'); |
| 15 | +if ( !defined( 'MEDIAWIKI') ) die('Not an entry point.' ); |
16 | 16 | |
17 | | -define('CSS_VERSION', '1.0.6, 2008-10-27'); |
| 17 | +define( 'CSS_VERSION', '1.0.7, 2010-10-20' ); |
18 | 18 | |
19 | 19 | $wgCSSMagic = "css"; |
20 | 20 | $wgExtensionFunctions[] = 'wfSetupCSS'; |
— | — | @@ -35,17 +35,17 @@ |
36 | 36 | |
37 | 37 | function __construct() { |
38 | 38 | global $wgParser, $wgCSSMagic; |
39 | | - $wgParser->setFunctionHook($wgCSSMagic, array($this, 'magicCss')); |
| 39 | + $wgParser->setFunctionHook( $wgCSSMagic, array( $this, 'magicCss' ) ); |
40 | 40 | } |
41 | 41 | |
42 | | - function magicCss(&$parser, $css) { |
| 42 | + function magicCss( &$parser, $css ) { |
43 | 43 | global $wgOut, $wgRequest; |
44 | 44 | $parser->mOutput->mCacheTime = -1; |
45 | 45 | $url = false; |
46 | | - if (ereg('\\{', $css)) { |
| 46 | + if( preg_match( '|\\{|', $css ) ) { |
47 | 47 | |
48 | 48 | # Inline CSS |
49 | | - $css = htmlspecialchars(trim(Sanitizer::checkCss($css))); |
| 49 | + $css = htmlspecialchars( trim( Sanitizer::checkCss( $css ) ) ); |
50 | 50 | $parser->mOutput->addHeadItem( <<<EOT |
51 | 51 | <style type="text/css"> |
52 | 52 | /*<![CDATA[*/ |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | </style> |
56 | 56 | EOT |
57 | 57 | ); |
58 | | - } elseif ($css{0} == '/') { |
| 58 | + } elseif ( $css{0} == '/' ) { |
59 | 59 | |
60 | 60 | # File |
61 | 61 | $url = $css; |
— | — | @@ -62,18 +62,17 @@ |
63 | 63 | } else { |
64 | 64 | |
65 | 65 | # Article? |
66 | | - $title = Title::newFromText($css); |
67 | | - if (is_object($title)) { |
68 | | - $url = $title->getLocalURL('action=raw&ctype=text/css'); |
69 | | - $url = str_replace("&", "&", $url); |
| 66 | + $title = Title::newFromText( $css ); |
| 67 | + if( is_object( $title ) ) { |
| 68 | + $url = $title->getLocalURL( 'action=raw&ctype=text/css' ); |
| 69 | + $url = str_replace( "&", "&", $url ); |
70 | 70 | } |
71 | 71 | } |
72 | | - if ($url) $wgOut->addScript("<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); |
| 72 | + |
| 73 | + if( $url ) $wgOut->addScript( "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />" ); |
73 | 74 | return ''; |
74 | 75 | } |
75 | 76 | |
76 | | - # Needed in some versions to prevent Special:Version from breaking |
77 | | - function __toString() { return 'CSS'; } |
78 | 77 | } |
79 | 78 | |
80 | 79 | /** |
— | — | @@ -84,11 +83,8 @@ |
85 | 84 | $wgCSS = new CSS(); |
86 | 85 | } |
87 | 86 | |
88 | | -/** |
89 | | - * Needed in MediaWiki >1.8.0 for magic word hooks to work properly |
90 | | - */ |
91 | | -function wfCSSLanguageGetMagic(&$magicWords, $langCode = 0) { |
| 87 | +function wfCSSLanguageGetMagic( &$magicWords, $langCode = 0 ) { |
92 | 88 | global $wgCSSMagic; |
93 | | - $magicWords[$wgCSSMagic] = array($langCode, $wgCSSMagic); |
| 89 | + $magicWords[$wgCSSMagic] = array( $langCode, $wgCSSMagic ); |
94 | 90 | return true; |
95 | 91 | } |