r75065 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75064‎ | r75065 | r75066 >
Date:04:19, 20 October 2010
Author:nad
Status:ok (Comments)
Tags:
Comment:
ereg deprecated, use preg_match
Modified paths:
  • /trunk/extensions/CSS/CSS.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CSS/CSS.php
@@ -7,13 +7,13 @@
88 * @file
99 * @ingroup Extensions
1010 * @author Aran Dunkley [http://www.organicdesign.co.nz/nad User:Nad]
11 - * @copyright © 2007 Aran Dunkley
 11+ * @copyright © 2007 Aran Dunkley
1212 * @licence GNU General Public Licence 2.0 or later
1313 */
1414
15 -if (!defined('MEDIAWIKI')) die('Not an entry point.');
 15+if ( !defined( 'MEDIAWIKI') ) die('Not an entry point.' );
1616
17 -define('CSS_VERSION', '1.0.6, 2008-10-27');
 17+define( 'CSS_VERSION', '1.0.7, 2010-10-20' );
1818
1919 $wgCSSMagic = "css";
2020 $wgExtensionFunctions[] = 'wfSetupCSS';
@@ -35,17 +35,17 @@
3636
3737 function __construct() {
3838 global $wgParser, $wgCSSMagic;
39 - $wgParser->setFunctionHook($wgCSSMagic, array($this, 'magicCss'));
 39+ $wgParser->setFunctionHook( $wgCSSMagic, array( $this, 'magicCss' ) );
4040 }
4141
42 - function magicCss(&$parser, $css) {
 42+ function magicCss( &$parser, $css ) {
4343 global $wgOut, $wgRequest;
4444 $parser->mOutput->mCacheTime = -1;
4545 $url = false;
46 - if (ereg('\\{', $css)) {
 46+ if( preg_match( '|\\{|', $css ) ) {
4747
4848 # Inline CSS
49 - $css = htmlspecialchars(trim(Sanitizer::checkCss($css)));
 49+ $css = htmlspecialchars( trim( Sanitizer::checkCss( $css ) ) );
5050 $parser->mOutput->addHeadItem( <<<EOT
5151 <style type="text/css">
5252 /*<![CDATA[*/
@@ -54,7 +54,7 @@
5555 </style>
5656 EOT
5757 );
58 - } elseif ($css{0} == '/') {
 58+ } elseif ( $css{0} == '/' ) {
5959
6060 # File
6161 $url = $css;
@@ -62,18 +62,17 @@
6363 } else {
6464
6565 # Article?
66 - $title = Title::newFromText($css);
67 - if (is_object($title)) {
68 - $url = $title->getLocalURL('action=raw&ctype=text/css');
69 - $url = str_replace("&", "&amp;", $url);
 66+ $title = Title::newFromText( $css );
 67+ if( is_object( $title ) ) {
 68+ $url = $title->getLocalURL( 'action=raw&ctype=text/css' );
 69+ $url = str_replace( "&", "&amp;", $url );
7070 }
7171 }
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\" />" );
7374 return '';
7475 }
7576
76 - # Needed in some versions to prevent Special:Version from breaking
77 - function __toString() { return 'CSS'; }
7877 }
7978
8079 /**
@@ -84,11 +83,8 @@
8584 $wgCSS = new CSS();
8685 }
8786
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 ) {
9288 global $wgCSSMagic;
93 - $magicWords[$wgCSSMagic] = array($langCode, $wgCSSMagic);
 89+ $magicWords[$wgCSSMagic] = array( $langCode, $wgCSSMagic );
9490 return true;
9591 }

Comments

#Comment by Hashar (talk | contribs)   06:10, 20 October 2010

removed a garbage character in r75067 :p

Status & tagging log