r50619 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50618‎ | r50619 | r50620 >
Date:04:07, 15 May 2009
Author:laner
Status:deferred
Tags:
Comment:
Added support for generic canvas drawing via the generic renderer
Modified paths:
  • /trunk/extensions/Plotters/Plotters.i18n.php (modified) (history)
  • /trunk/extensions/Plotters/Plotters.php (modified) (history)
  • /trunk/extensions/Plotters/PlottersClass.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Plotters/Plotters.i18n.php
@@ -26,6 +26,7 @@
2727 'plotters-missing-script' => 'No script was defined.',
2828 'plotters-excessively-long-scriptname' => 'The script name is too long. Please define a script that is less than 255 characters.',
2929 'plotters-no-data' => 'No data was provided.',
 30+ 'plotters-invalid-renderer' => 'An invalid renderer was selected.',
3031 'plotters-errors' => '<b>Plotters error(s):</b>',
3132 );
3233
Index: trunk/extensions/Plotters/Plotters.php
@@ -222,7 +222,13 @@
223223 function PlotterParserOutput( &$outputPage, &$parserOutput ) {
224224 if ( !empty( $parserOutput->mPlotterTag ) ) {
225225 // 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+ }
227233
228234 // Output user defined javascript
229235 $plotters = wfLoadPlotters();
Index: trunk/extensions/Plotters/PlottersClass.php
@@ -39,6 +39,11 @@
4040
4141 $errors = '';
4242
 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+
4348 // Check for a script
4449 if ( $this->argumentArray["script"] == "" ) {
4550 $errors .= wfMsg( "plotters-missing-script" ) . "<br />";
@@ -69,6 +74,10 @@
7075 // Add tags to parser
7176 $this->parser->mOutput->mPlotterTag = true;
7277
 78+ // Add renderer specific tag
 79+ $renderer = "mplotter-" . $this->argumentArray["renderer"];
 80+ $this->parser->mOutput->$renderer = true;
 81+
7382 foreach ( $this->argumentArray["preprocessors"] as $preprocessor ) {
7483 $preprocessor = "mplotter-" . $preprocessor;
7584 $this->parser->mOutput->$preprocessor = true;
@@ -142,24 +151,26 @@
143152 return $output;
144153 }
145154
146 - static function setPlotterHeaders( &$outputPage ) {
 155+ static function setPlotterHeaders( &$outputPage, $renderer ) {
147156 global $wgPlotterJavascriptPath;
148157 global $wgPlotterExtensionPath;
149158
150159 $extensionpath = $wgPlotterJavascriptPath;
151160
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 -
161161 // Add javascript to fix encoding
162162 $outputPage->addScript( '<script src="' . $wgPlotterExtensionPath . '/libs/fixencoding.js" type="text/javascript"></script>' );
163163
 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+
164175 return true;
165176 }
166177

Status & tagging log