r50630 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50629‎ | r50630 | r50631 >
Date:16:02, 15 May 2009
Author:laner
Status:deferred
Tags:
Comment:
Changed class names, function names, etc. to reflect the changes to the extension name make earlier.
Modified paths:
  • /trunk/extensions/Plotters/Plotters.php (modified) (history)
  • /trunk/extensions/Plotters/PlottersClass.php (modified) (history)
  • /trunk/extensions/Plotters/PlottersParser.php (modified) (history)
  • /trunk/extensions/Plotters/README (modified) (history)

Diff [purge]

Index: trunk/extensions/Plotters/PlottersParser.php
@@ -1,7 +1,7 @@
22 <?php
33
44 /**
5 - * Plotter parser. Parses arguments and data for the Plotters extension.
 5+ * Plotters parser. Parses arguments and data for the Plotters extension.
66 *
77 * @addtogroup Extensions
88 * @author Ryan Lane, rlane32+mwext@gmail.com
@@ -14,12 +14,12 @@
1515 die( 1 );
1616 }
1717
18 -class PlotterParser {
 18+class PlottersParser {
1919
2020 var $argumentArray;
2121 var $dataArray;
2222
23 - function PlotterParser( $input, $argv, &$parser ) {
 23+ function PlottersParser( $input, $argv, &$parser ) {
2424 $this->parseArguments( $argv );
2525 $this->parseData( $input, $parser );
2626 }
@@ -82,7 +82,7 @@
8383 $argument = htmlentities( $argument, ENT_QUOTES );
8484 $this->argumentArray["scriptarguments"][] = $argument;
8585 }
86 - Plotter::debug( 'plot script argument values: ', $this->argumentArray["scriptarguments"] );
 86+ Plotters::debug( 'plot script argument values: ', $this->argumentArray["scriptarguments"] );
8787 }
8888 if ( isset( $argv["datasep"] ) ) {
8989 $this->argumentArray["datasep"] = $argv["datasep"];
@@ -111,7 +111,7 @@
112112 function parseData( $input, $parser ) {
113113 $this->dataArray = array();
114114
115 - Plotter::debug( 'plot script input: ', $this->argumentArray["scriptarguments"] );
 115+ Plotters::debug( 'plot script input: ', $this->argumentArray["scriptarguments"] );
116116 if ( trim( $input ) == '' ) {
117117 return;
118118 }
@@ -130,7 +130,7 @@
131131 $value = htmlentities( $value, ENT_QUOTES );
132132 }
133133 $this->dataArray[] = $values;
134 - Plotter::debug( 'plot data values: ', $values );
 134+ Plotters::debug( 'plot data values: ', $values );
135135 }
136136 }
137137 }
Index: trunk/extensions/Plotters/Plotters.php
@@ -34,24 +34,24 @@
3535 'url' => 'http://www.mediawiki.org/wiki/Extension:Plotters',
3636 );
3737
38 -$wgExtensionFunctions[] = "efPlotter";
 38+$wgExtensionFunctions[] = "efPlotters";
3939
40 -$wgHooks['OutputPageParserOutput'][] = 'PlotterParserOutput';
41 -$wgHooks['LanguageGetMagic'][] = 'PlotterLanguageGetMagic';
 40+$wgHooks['OutputPageParserOutput'][] = 'PlottersParserOutput';
 41+$wgHooks['LanguageGetMagic'][] = 'PlottersLanguageGetMagic';
4242 $wgHooks['ArticleSaveComplete'][] = 'wfPlottersArticleSaveComplete';
4343
4444 $dir = dirname( __FILE__ ) . '/';
4545 $wgExtensionMessagesFiles['Plotters'] = $dir . 'Plotters.i18n.php';
4646 $wgExtensionAliasesFiles['Plotters'] = $dir . 'Plotters.alias.php';
47 -$wgAutoloadClasses['Plotter'] = $dir . 'PlottersClass.php';
48 -$wgAutoloadClasses['PlotterParser'] = $dir . 'PlottersParser.php';
 47+$wgAutoloadClasses['Plotters'] = $dir . 'PlottersClass.php';
 48+$wgAutoloadClasses['PlottersParser'] = $dir . 'PlottersParser.php';
4949 $wgAutoloadClasses['SpecialPlotters'] = $dir . 'SpecialPlotters.php';
5050 $wgSpecialPages['Plotters'] = 'SpecialPlotters';
5151 $wgSpecialPageGroups['Plotters'] = 'wiki';
5252
5353 // sane defaults. always initialize to avoid register_globals vulnerabilities
54 -$wgPlotterExtensionPath = $wgScriptPath . '/extensions/Plotters';
55 -$wgPlotterJavascriptPath = $wgScriptPath . '/extensions/Plotters';
 54+$wgPlottersExtensionPath = $wgScriptPath . '/extensions/Plotters';
 55+$wgPlottersJavascriptPath = $wgScriptPath . '/extensions/Plotters';
5656
5757 function wfPlottersArticleSaveComplete( &$article, &$wgUser, &$text ) {
5858 // update cache if MediaWiki:Plotters-definition was edited
@@ -159,19 +159,17 @@
160160 }
161161 }
162162
163 -function efPlotter() {
 163+function efPlotters() {
164164 global $wgParser;
165165
166 - $wgParser->setHook( 'plot', 'initPlotter' );
167 - $wgParser->setFunctionHook( 'plot', 'initPlotterPF' );
 166+ $wgParser->setHook( 'plot', 'initPlotters' );
 167+ $wgParser->setFunctionHook( 'plot', 'initPlottersPF' );
168168 }
169169
170 -function initPlotterPF( &$parser ) {
171 - global $wgPlotterDelimiter;
172 -
 170+function initPlottersPF( &$parser ) {
173171 $numargs = func_num_args();
174172 if ( $numargs < 2 ) {
175 - $input = "#Plotter: no arguments specified";
 173+ $input = "#Plotters: no arguments specified";
176174 return str_replace( '§', '<', '§pre>§nowiki>' . $input . '§/nowiki>§/pre>' );
177175 }
178176
@@ -186,7 +184,7 @@
187185 if ( count( $aParam ) < 2 ) {
188186 continue;
189187 }
190 - Plotter::debug( 'plot tag parameter: ', $aParam );
 188+ Plotters::debug( 'plot tag parameter: ', $aParam );
191189 if ( $aParam[0] == "data" ) {
192190 $input = $aParam[1];
193191 continue;
@@ -199,13 +197,13 @@
200198 }
201199 }
202200
203 - $output = initPlotter( $input, $argv, $parser );
 201+ $output = initPlotters( $input, $argv, $parser );
204202 return array( $output, 'noparse' => true, 'isHTML' => true );
205203 }
206204
207 -function initPlotter( $input, $argv, &$parser ) {
208 - $pParser = new PlotterParser( $input, $argv, $parser );
209 - $pPlotter = new Plotter( $pParser, $parser );
 205+function initPlotters( $input, $argv, &$parser ) {
 206+ $pParser = new PlottersParser( $input, $argv, $parser );
 207+ $pPlotter = new Plotters( $pParser, $parser );
210208
211209 $pPlotter->checkForErrors();
212210 if ( $pPlotter->hasErrors() ) {
@@ -219,15 +217,15 @@
220218 * Hook callback that injects messages and things into the <head> tag
221219 * Does nothing if $parserOutput->mPlotterTag is not set
222220 */
223 -function PlotterParserOutput( &$outputPage, &$parserOutput ) {
224 - if ( !empty( $parserOutput->mPlotterTag ) ) {
 221+function PlottersParserOutput( &$outputPage, &$parserOutput ) {
 222+ if ( !empty( $parserOutput->mPlottersTag ) ) {
225223 // Output required javascript
226224 $genericname = "mplotter-generic";
227225 $plotkitname = "mplotter-plotkit";
228226 if ( !empty( $parserOutput->$genericname ) ) {
229 - Plotter::setPlotterHeaders( $outputPage, 'generic' );
 227+ Plotters::setPlottersHeaders( $outputPage, 'generic' );
230228 } else if ( !empty( $parserOutput->$plotkitname ) ) {
231 - Plotter::setPlotterHeaders( $outputPage, 'plotkit' );
 229+ Plotters::setPlottersHeaders( $outputPage, 'plotkit' );
232230 }
233231
234232 // Output user defined javascript
@@ -251,7 +249,7 @@
252250 * We ignore langCode - parser function names can be translated but
253251 * we are not using this feature
254252 */
255 -function PlotterLanguageGetMagic( &$magicWords, $langCode ) {
 253+function PlottersLanguageGetMagic( &$magicWords, $langCode ) {
256254 $magicWords['plot'] = array( 0, 'plot' );
257255 return true;
258256 }
Index: trunk/extensions/Plotters/PlottersClass.php
@@ -9,14 +9,14 @@
1010 * @license GNU General Public Licence 2.0 or later
1111 */
1212
13 -class Plotter {
 13+class Plotters {
1414
1515 var $parser;
1616 var $set;
1717 var $argumentArray, $dataArray;
1818 var $errors;
1919
20 - function Plotter( $pParser, &$parser ) {
 20+ function Plotters( $pParser, &$parser ) {
2121 $this->parser = $parser;
2222 $this->argumentArray = $pParser->getArguments();
2323 $this->dataArray = $pParser->getData();
@@ -72,7 +72,7 @@
7373 $output .= $this->renderJavascript();
7474
7575 // Add tags to parser
76 - $this->parser->mOutput->mPlotterTag = true;
 76+ $this->parser->mOutput->mPlottersTag = true;
7777
7878 // Add renderer specific tag
7979 $renderer = "mplotter-" . $this->argumentArray["renderer"];
@@ -151,14 +151,14 @@
152152 return $output;
153153 }
154154
155 - static function setPlotterHeaders( &$outputPage, $renderer ) {
156 - global $wgPlotterJavascriptPath;
157 - global $wgPlotterExtensionPath;
 155+ static function setPlottersHeaders( &$outputPage, $renderer ) {
 156+ global $wgPlottersJavascriptPath;
 157+ global $wgPlottersExtensionPath;
158158
159 - $extensionpath = $wgPlotterJavascriptPath;
 159+ $extensionpath = $wgPlottersJavascriptPath;
160160
161161 // Add javascript to fix encoding
162 - $outputPage->addScript( '<script src="' . $wgPlotterExtensionPath . '/libs/fixencoding.js" type="text/javascript"></script>' );
 162+ $outputPage->addScript( '<script src="' . $wgPlottersExtensionPath . '/libs/fixencoding.js" type="text/javascript"></script>' );
163163
164164 if ( $renderer == "plotkit" ) {
165165 // Add mochikit (required by PlotKit)
@@ -175,15 +175,15 @@
176176 }
177177
178178 static function debug( $debugText, $debugArr = null ) {
179 - global $wgPlotterDebug;
 179+ global $wgPlottersDebug;
180180
181181 if ( isset( $debugArr ) ) {
182 - if ( $wgPlotterDebug > 0 ) {
 182+ if ( $wgPlottersDebug > 0 ) {
183183 $text = $debugText . " " . implode( "::", $debugArr );
184184 wfDebugLog( 'plot', $text, false );
185185 }
186186 } else {
187 - if ( $wgPlotterDebug > 0 ) {
 187+ if ( $wgPlottersDebug > 0 ) {
188188 wfDebugLog( 'plot', $debugText, false );
189189 }
190190 }
Index: trunk/extensions/Plotters/README
@@ -25,7 +25,7 @@
2626 |data=1,2
2727 2,4}}
2828
29 -Currently, only PlotKit is supported; but other javascript plotting libraries
 29+Currently, only PlotKit, and generic canvas drawing is supported; but other javascript plotting libraries
3030 will be supported in the future.
3131
3232 This code is very alpha quality right now; many features may not work.

Status & tagging log