r51488 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51487‎ | r51488 | r51489 >
Date:03:49, 5 June 2009
Author:laner
Status:deferred
Tags:
Comment:
* Changed the default renderer to generic
* Added a configuration option $wgPlottersRendererFiles, which can be used to configure new javascript libraries without modifying the code; use like this:
$wgPlottersRendererFiles = array( "mycustomrenderer" => array( "/mycustren/RenderCanvas.js", "/mycustren/RenderGraph.js", "..." ) );
Modified paths:
  • /trunk/extensions/Plotters/Plotters.php (modified) (history)
  • /trunk/extensions/Plotters/PlottersClass.php (modified) (history)
  • /trunk/extensions/Plotters/PlottersParser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Plotters/Plotters.php
@@ -52,6 +52,9 @@
5353 // sane defaults. always initialize to avoid register_globals vulnerabilities
5454 $wgPlottersExtensionPath = $wgScriptPath . '/extensions/Plotters';
5555 $wgPlottersJavascriptPath = $wgScriptPath . '/extensions/Plotters';
 56+$wgPlottersRendererFiles = array( "plotkit" => array( "/mochikit/MochiKit.js", "/plotkit/Base.js", "/plotkit/Layout.js",
 57+ "/plotkit/Canvas.js", "/plotkit/SweetCanvas.js" )
 58+ );
5659
5760 function wfPlottersArticleSaveComplete( &$article, &$wgUser, &$text ) {
5861 // update cache if MediaWiki:Plotters-definition was edited
Index: trunk/extensions/Plotters/PlottersClass.php
@@ -210,6 +210,7 @@
211211 static function setPlottersHeaders( &$outputPage, $renderer ) {
212212 global $wgPlottersJavascriptPath;
213213 global $wgPlottersExtensionPath;
 214+ global $wgPlottersRendererFiles;
214215
215216 $javascriptpath = $wgPlottersJavascriptPath;
216217
@@ -217,15 +218,10 @@
218219 $outputPage->addScript( '<script src="' . $wgPlottersExtensionPath . '/libs/fixencoding.js" type="text/javascript"></script>' );
219220 $outputPage->addScript( '<script src="' . $wgPlottersExtensionPath . '/libs/excanvas.js" type="text/javascript"></script>' );
220221
221 - if ( $renderer == "plotkit" ) {
222 - // Add mochikit (required by PlotKit)
223 - $outputPage->addScript( '<script src="' . $javascriptpath . '/mochikit/MochiKit.js" type="text/javascript"></script>' );
224 -
225 - // Add PlotKit javascript
226 - $outputPage->addScript( '<script src="' . $javascriptpath . '/plotkit/Base.js" type="text/javascript"></script>' );
227 - $outputPage->addScript( '<script src="' . $javascriptpath . '/plotkit/Layout.js" type="text/javascript"></script>' );
228 - $outputPage->addScript( '<script src="' . $javascriptpath . '/plotkit/Canvas.js" type="text/javascript"></script>' );
229 - $outputPage->addScript( '<script src="' . $javascriptpath . '/plotkit/SweetCanvas.js" type="text/javascript"></script>' );
 222+ if ( isset( $wgPlottersRendererFiles[$renderer] ) ) {
 223+ foreach ( $wgPlottersRendererFiles[$renderer] as $jsfile ) {
 224+ $outputPage->addScript( '<script src="' . $javascriptpath . $jsfile . '" type="text/javascript"></script>' );
 225+ }
230226 }
231227
232228 return true;
Index: trunk/extensions/Plotters/PlottersParser.php
@@ -34,7 +34,7 @@
3535
3636 function parseArguments( $argv ) {
3737 // Parse arguments, set defaults, and do sanity checks
38 - $this->argumentArray = array ( "renderer" => "plotkit", "preprocessors" => array(), "preprocessorarguments" => array(),
 38+ $this->argumentArray = array ( "renderer" => "generic", "preprocessors" => array(), "preprocessorarguments" => array(),
3939 "script" => "", "scriptarguments" => array(), "datasep" => ",", "width" => "300", "height" => "300", "labels" => array(),
4040 "name" => "plot", "tableclass" => "wikitable" );
4141 if ( isset( $argv["renderer"] ) ) {

Status & tagging log