Index: trunk/extensions/Plotters/Plotters.i18n.php |
— | — | @@ -26,6 +26,7 @@ |
27 | 27 | 'plotters-missing-script' => 'No script was defined.', |
28 | 28 | 'plotters-excessively-long-scriptname' => 'The script name is too long. Please define a script that is less than 255 characters.', |
29 | 29 | 'plotters-no-data' => 'No data was provided.', |
| 30 | + 'plotters-invalid-renderer' => 'An invalid renderer was selected.', |
30 | 31 | 'plotters-errors' => '<b>Plotters error(s):</b>', |
31 | 32 | ); |
32 | 33 | |
Index: trunk/extensions/Plotters/Plotters.php |
— | — | @@ -222,7 +222,13 @@ |
223 | 223 | function PlotterParserOutput( &$outputPage, &$parserOutput ) { |
224 | 224 | if ( !empty( $parserOutput->mPlotterTag ) ) { |
225 | 225 | // Output required javascript |
226 | | - Plotter::setPlotterHeaders( $outputPage ); |
| 226 | + $genericname = "mplotter-generic"; |
| 227 | + $plotkitname = "mplotter-plotkit"; |
| 228 | + if ( !empty( $parserOutput->$genericname ) ) { |
| 229 | + Plotter::setPlotterHeaders( $outputPage, 'generic' ); |
| 230 | + } else if ( !empty( $parserOutput->$plotkitname ) ) { |
| 231 | + Plotter::setPlotterHeaders( $outputPage, 'plotkit' ); |
| 232 | + } |
227 | 233 | |
228 | 234 | // Output user defined javascript |
229 | 235 | $plotters = wfLoadPlotters(); |
Index: trunk/extensions/Plotters/PlottersClass.php |
— | — | @@ -39,6 +39,11 @@ |
40 | 40 | |
41 | 41 | $errors = ''; |
42 | 42 | |
| 43 | + // Check for a valid renderer |
| 44 | + if ( $this->argumentArray["renderer"] != "generic" && $this->argumentArray["renderer"] != "plotkit" ) { |
| 45 | + $errors .= wfMsg( "plotters-invalid-renderer" ) . "<br />"; |
| 46 | + } |
| 47 | + |
43 | 48 | // Check for a script |
44 | 49 | if ( $this->argumentArray["script"] == "" ) { |
45 | 50 | $errors .= wfMsg( "plotters-missing-script" ) . "<br />"; |
— | — | @@ -69,6 +74,10 @@ |
70 | 75 | // Add tags to parser |
71 | 76 | $this->parser->mOutput->mPlotterTag = true; |
72 | 77 | |
| 78 | + // Add renderer specific tag |
| 79 | + $renderer = "mplotter-" . $this->argumentArray["renderer"]; |
| 80 | + $this->parser->mOutput->$renderer = true; |
| 81 | + |
73 | 82 | foreach ( $this->argumentArray["preprocessors"] as $preprocessor ) { |
74 | 83 | $preprocessor = "mplotter-" . $preprocessor; |
75 | 84 | $this->parser->mOutput->$preprocessor = true; |
— | — | @@ -142,24 +151,26 @@ |
143 | 152 | return $output; |
144 | 153 | } |
145 | 154 | |
146 | | - static function setPlotterHeaders( &$outputPage ) { |
| 155 | + static function setPlotterHeaders( &$outputPage, $renderer ) { |
147 | 156 | global $wgPlotterJavascriptPath; |
148 | 157 | global $wgPlotterExtensionPath; |
149 | 158 | |
150 | 159 | $extensionpath = $wgPlotterJavascriptPath; |
151 | 160 | |
152 | | - // Add mochikit (required by PlotKit) |
153 | | - $outputPage->addScript( '<script src="' . $extensionpath . '/mochikit/MochiKit.js" type="text/javascript"></script>' ); |
154 | | - |
155 | | - // Add PlotKit javascript |
156 | | - $outputPage->addScript( '<script src="' . $extensionpath . '/plotkit/Base.js" type="text/javascript"></script>' ); |
157 | | - $outputPage->addScript( '<script src="' . $extensionpath . '/plotkit/Layout.js" type="text/javascript"></script>' ); |
158 | | - $outputPage->addScript( '<script src="' . $extensionpath . '/plotkit/Canvas.js" type="text/javascript"></script>' ); |
159 | | - $outputPage->addScript( '<script src="' . $extensionpath . '/plotkit/SweetCanvas.js" type="text/javascript"></script>' ); |
160 | | - |
161 | 161 | // Add javascript to fix encoding |
162 | 162 | $outputPage->addScript( '<script src="' . $wgPlotterExtensionPath . '/libs/fixencoding.js" type="text/javascript"></script>' ); |
163 | 163 | |
| 164 | + if ( $renderer == "plotkit" ) { |
| 165 | + // Add mochikit (required by PlotKit) |
| 166 | + $outputPage->addScript( '<script src="' . $extensionpath . '/mochikit/MochiKit.js" type="text/javascript"></script>' ); |
| 167 | + |
| 168 | + // Add PlotKit javascript |
| 169 | + $outputPage->addScript( '<script src="' . $extensionpath . '/plotkit/Base.js" type="text/javascript"></script>' ); |
| 170 | + $outputPage->addScript( '<script src="' . $extensionpath . '/plotkit/Layout.js" type="text/javascript"></script>' ); |
| 171 | + $outputPage->addScript( '<script src="' . $extensionpath . '/plotkit/Canvas.js" type="text/javascript"></script>' ); |
| 172 | + $outputPage->addScript( '<script src="' . $extensionpath . '/plotkit/SweetCanvas.js" type="text/javascript"></script>' ); |
| 173 | + } |
| 174 | + |
164 | 175 | return true; |
165 | 176 | } |
166 | 177 | |