Index: trunk/extensions/Plotters/PlottersParser.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Plotter parser. Parses arguments and data for the Plotters extension. |
| 5 | + * Plotters parser. Parses arguments and data for the Plotters extension. |
6 | 6 | * |
7 | 7 | * @addtogroup Extensions |
8 | 8 | * @author Ryan Lane, rlane32+mwext@gmail.com |
— | — | @@ -14,12 +14,12 @@ |
15 | 15 | die( 1 ); |
16 | 16 | } |
17 | 17 | |
18 | | -class PlotterParser { |
| 18 | +class PlottersParser { |
19 | 19 | |
20 | 20 | var $argumentArray; |
21 | 21 | var $dataArray; |
22 | 22 | |
23 | | - function PlotterParser( $input, $argv, &$parser ) { |
| 23 | + function PlottersParser( $input, $argv, &$parser ) { |
24 | 24 | $this->parseArguments( $argv ); |
25 | 25 | $this->parseData( $input, $parser ); |
26 | 26 | } |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | $argument = htmlentities( $argument, ENT_QUOTES ); |
84 | 84 | $this->argumentArray["scriptarguments"][] = $argument; |
85 | 85 | } |
86 | | - Plotter::debug( 'plot script argument values: ', $this->argumentArray["scriptarguments"] ); |
| 86 | + Plotters::debug( 'plot script argument values: ', $this->argumentArray["scriptarguments"] ); |
87 | 87 | } |
88 | 88 | if ( isset( $argv["datasep"] ) ) { |
89 | 89 | $this->argumentArray["datasep"] = $argv["datasep"]; |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | function parseData( $input, $parser ) { |
113 | 113 | $this->dataArray = array(); |
114 | 114 | |
115 | | - Plotter::debug( 'plot script input: ', $this->argumentArray["scriptarguments"] ); |
| 115 | + Plotters::debug( 'plot script input: ', $this->argumentArray["scriptarguments"] ); |
116 | 116 | if ( trim( $input ) == '' ) { |
117 | 117 | return; |
118 | 118 | } |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | $value = htmlentities( $value, ENT_QUOTES ); |
132 | 132 | } |
133 | 133 | $this->dataArray[] = $values; |
134 | | - Plotter::debug( 'plot data values: ', $values ); |
| 134 | + Plotters::debug( 'plot data values: ', $values ); |
135 | 135 | } |
136 | 136 | } |
137 | 137 | } |
Index: trunk/extensions/Plotters/Plotters.php |
— | — | @@ -34,24 +34,24 @@ |
35 | 35 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Plotters', |
36 | 36 | ); |
37 | 37 | |
38 | | -$wgExtensionFunctions[] = "efPlotter"; |
| 38 | +$wgExtensionFunctions[] = "efPlotters"; |
39 | 39 | |
40 | | -$wgHooks['OutputPageParserOutput'][] = 'PlotterParserOutput'; |
41 | | -$wgHooks['LanguageGetMagic'][] = 'PlotterLanguageGetMagic'; |
| 40 | +$wgHooks['OutputPageParserOutput'][] = 'PlottersParserOutput'; |
| 41 | +$wgHooks['LanguageGetMagic'][] = 'PlottersLanguageGetMagic'; |
42 | 42 | $wgHooks['ArticleSaveComplete'][] = 'wfPlottersArticleSaveComplete'; |
43 | 43 | |
44 | 44 | $dir = dirname( __FILE__ ) . '/'; |
45 | 45 | $wgExtensionMessagesFiles['Plotters'] = $dir . 'Plotters.i18n.php'; |
46 | 46 | $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'; |
49 | 49 | $wgAutoloadClasses['SpecialPlotters'] = $dir . 'SpecialPlotters.php'; |
50 | 50 | $wgSpecialPages['Plotters'] = 'SpecialPlotters'; |
51 | 51 | $wgSpecialPageGroups['Plotters'] = 'wiki'; |
52 | 52 | |
53 | 53 | // 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'; |
56 | 56 | |
57 | 57 | function wfPlottersArticleSaveComplete( &$article, &$wgUser, &$text ) { |
58 | 58 | // update cache if MediaWiki:Plotters-definition was edited |
— | — | @@ -159,19 +159,17 @@ |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | | -function efPlotter() { |
| 163 | +function efPlotters() { |
164 | 164 | global $wgParser; |
165 | 165 | |
166 | | - $wgParser->setHook( 'plot', 'initPlotter' ); |
167 | | - $wgParser->setFunctionHook( 'plot', 'initPlotterPF' ); |
| 166 | + $wgParser->setHook( 'plot', 'initPlotters' ); |
| 167 | + $wgParser->setFunctionHook( 'plot', 'initPlottersPF' ); |
168 | 168 | } |
169 | 169 | |
170 | | -function initPlotterPF( &$parser ) { |
171 | | - global $wgPlotterDelimiter; |
172 | | - |
| 170 | +function initPlottersPF( &$parser ) { |
173 | 171 | $numargs = func_num_args(); |
174 | 172 | if ( $numargs < 2 ) { |
175 | | - $input = "#Plotter: no arguments specified"; |
| 173 | + $input = "#Plotters: no arguments specified"; |
176 | 174 | return str_replace( '§', '<', '§pre>§nowiki>' . $input . '§/nowiki>§/pre>' ); |
177 | 175 | } |
178 | 176 | |
— | — | @@ -186,7 +184,7 @@ |
187 | 185 | if ( count( $aParam ) < 2 ) { |
188 | 186 | continue; |
189 | 187 | } |
190 | | - Plotter::debug( 'plot tag parameter: ', $aParam ); |
| 188 | + Plotters::debug( 'plot tag parameter: ', $aParam ); |
191 | 189 | if ( $aParam[0] == "data" ) { |
192 | 190 | $input = $aParam[1]; |
193 | 191 | continue; |
— | — | @@ -199,13 +197,13 @@ |
200 | 198 | } |
201 | 199 | } |
202 | 200 | |
203 | | - $output = initPlotter( $input, $argv, $parser ); |
| 201 | + $output = initPlotters( $input, $argv, $parser ); |
204 | 202 | return array( $output, 'noparse' => true, 'isHTML' => true ); |
205 | 203 | } |
206 | 204 | |
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 ); |
210 | 208 | |
211 | 209 | $pPlotter->checkForErrors(); |
212 | 210 | if ( $pPlotter->hasErrors() ) { |
— | — | @@ -219,15 +217,15 @@ |
220 | 218 | * Hook callback that injects messages and things into the <head> tag |
221 | 219 | * Does nothing if $parserOutput->mPlotterTag is not set |
222 | 220 | */ |
223 | | -function PlotterParserOutput( &$outputPage, &$parserOutput ) { |
224 | | - if ( !empty( $parserOutput->mPlotterTag ) ) { |
| 221 | +function PlottersParserOutput( &$outputPage, &$parserOutput ) { |
| 222 | + if ( !empty( $parserOutput->mPlottersTag ) ) { |
225 | 223 | // Output required javascript |
226 | 224 | $genericname = "mplotter-generic"; |
227 | 225 | $plotkitname = "mplotter-plotkit"; |
228 | 226 | if ( !empty( $parserOutput->$genericname ) ) { |
229 | | - Plotter::setPlotterHeaders( $outputPage, 'generic' ); |
| 227 | + Plotters::setPlottersHeaders( $outputPage, 'generic' ); |
230 | 228 | } else if ( !empty( $parserOutput->$plotkitname ) ) { |
231 | | - Plotter::setPlotterHeaders( $outputPage, 'plotkit' ); |
| 229 | + Plotters::setPlottersHeaders( $outputPage, 'plotkit' ); |
232 | 230 | } |
233 | 231 | |
234 | 232 | // Output user defined javascript |
— | — | @@ -251,7 +249,7 @@ |
252 | 250 | * We ignore langCode - parser function names can be translated but |
253 | 251 | * we are not using this feature |
254 | 252 | */ |
255 | | -function PlotterLanguageGetMagic( &$magicWords, $langCode ) { |
| 253 | +function PlottersLanguageGetMagic( &$magicWords, $langCode ) { |
256 | 254 | $magicWords['plot'] = array( 0, 'plot' ); |
257 | 255 | return true; |
258 | 256 | } |
Index: trunk/extensions/Plotters/PlottersClass.php |
— | — | @@ -9,14 +9,14 @@ |
10 | 10 | * @license GNU General Public Licence 2.0 or later |
11 | 11 | */ |
12 | 12 | |
13 | | -class Plotter { |
| 13 | +class Plotters { |
14 | 14 | |
15 | 15 | var $parser; |
16 | 16 | var $set; |
17 | 17 | var $argumentArray, $dataArray; |
18 | 18 | var $errors; |
19 | 19 | |
20 | | - function Plotter( $pParser, &$parser ) { |
| 20 | + function Plotters( $pParser, &$parser ) { |
21 | 21 | $this->parser = $parser; |
22 | 22 | $this->argumentArray = $pParser->getArguments(); |
23 | 23 | $this->dataArray = $pParser->getData(); |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | $output .= $this->renderJavascript(); |
74 | 74 | |
75 | 75 | // Add tags to parser |
76 | | - $this->parser->mOutput->mPlotterTag = true; |
| 76 | + $this->parser->mOutput->mPlottersTag = true; |
77 | 77 | |
78 | 78 | // Add renderer specific tag |
79 | 79 | $renderer = "mplotter-" . $this->argumentArray["renderer"]; |
— | — | @@ -151,14 +151,14 @@ |
152 | 152 | return $output; |
153 | 153 | } |
154 | 154 | |
155 | | - static function setPlotterHeaders( &$outputPage, $renderer ) { |
156 | | - global $wgPlotterJavascriptPath; |
157 | | - global $wgPlotterExtensionPath; |
| 155 | + static function setPlottersHeaders( &$outputPage, $renderer ) { |
| 156 | + global $wgPlottersJavascriptPath; |
| 157 | + global $wgPlottersExtensionPath; |
158 | 158 | |
159 | | - $extensionpath = $wgPlotterJavascriptPath; |
| 159 | + $extensionpath = $wgPlottersJavascriptPath; |
160 | 160 | |
161 | 161 | // 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>' ); |
163 | 163 | |
164 | 164 | if ( $renderer == "plotkit" ) { |
165 | 165 | // Add mochikit (required by PlotKit) |
— | — | @@ -175,15 +175,15 @@ |
176 | 176 | } |
177 | 177 | |
178 | 178 | static function debug( $debugText, $debugArr = null ) { |
179 | | - global $wgPlotterDebug; |
| 179 | + global $wgPlottersDebug; |
180 | 180 | |
181 | 181 | if ( isset( $debugArr ) ) { |
182 | | - if ( $wgPlotterDebug > 0 ) { |
| 182 | + if ( $wgPlottersDebug > 0 ) { |
183 | 183 | $text = $debugText . " " . implode( "::", $debugArr ); |
184 | 184 | wfDebugLog( 'plot', $text, false ); |
185 | 185 | } |
186 | 186 | } else { |
187 | | - if ( $wgPlotterDebug > 0 ) { |
| 187 | + if ( $wgPlottersDebug > 0 ) { |
188 | 188 | wfDebugLog( 'plot', $debugText, false ); |
189 | 189 | } |
190 | 190 | } |
Index: trunk/extensions/Plotters/README |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | |data=1,2 |
27 | 27 | 2,4}} |
28 | 28 | |
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 |
30 | 30 | will be supported in the future. |
31 | 31 | |
32 | 32 | This code is very alpha quality right now; many features may not work. |