Index: trunk/extensions/Plotters/PlottersParser.php |
— | — | @@ -35,7 +35,8 @@ |
36 | 36 | function parseArguments( $argv ) { |
37 | 37 | // Parse arguments, set defaults, and do sanity checks |
38 | 38 | $this->argumentArray = array ( "renderer" => "plotkit", "preprocessors" => array(), "preprocessorarguments" => array(), |
39 | | - "script" => "", "scriptarguments" => array(), "datasep" => ",", "width" => "300", "height" => "300", "labels" => array() ); |
| 39 | + "script" => "", "scriptarguments" => array(), "datasep" => ",", "width" => "300", "height" => "300", "labels" => array(), |
| 40 | + "helpers" => array() ); |
40 | 41 | if ( isset( $argv["renderer"] ) ) { |
41 | 42 | //TODO: limit this to supported renderers |
42 | 43 | $this->argumentArray["renderer"] = preg_replace( '/[^A-Z0-9]/i', '', $argv["renderer"] ); |
— | — | @@ -106,6 +107,13 @@ |
107 | 108 | $this->argumentArray["labels"][] = $label; |
108 | 109 | } |
109 | 110 | } |
| 111 | + if ( isset( $argv["helpers"] ) ) { |
| 112 | + // Sanitize scripts - alphanumerics only |
| 113 | + $this->argumentArray["helpers"] = explode( ',', $argv["helpers"] ); |
| 114 | + foreach ( $this->argumentArray["helpers"] as &$helper ) { |
| 115 | + $helper = preg_replace( '/[^A-Z0-9]/i', '', $helper ); |
| 116 | + } |
| 117 | + } |
110 | 118 | } |
111 | 119 | |
112 | 120 | function parseData( $input, $parser ) { |
Index: trunk/extensions/Plotters/Plotters.i18n.php |
— | — | @@ -24,7 +24,10 @@ |
25 | 25 | This overview provides easy access to the system message pages that define each plotter's description and code.", |
26 | 26 | 'plotters-uses' => 'Uses', |
27 | 27 | 'plotters-missing-script' => 'No script was defined.', |
| 28 | + 'plotters-missing-arguments' => 'No arguments specified.', |
28 | 29 | 'plotters-excessively-long-scriptname' => 'The script name is too long. Please define a script that is less than 255 characters.', |
| 30 | + 'plotters-excessively-long-preprocessorname' => 'The preprocessor name is too long. Please define a preprocessor that is less than 255 characters.', |
| 31 | + 'plotters-excessively-long-helpername' => 'The helper name is too long. Please define a helper that is less than 255 characters.', |
29 | 32 | 'plotters-no-data' => 'No data was provided.', |
30 | 33 | 'plotters-invalid-renderer' => 'An invalid renderer was selected.', |
31 | 34 | 'plotters-errors' => '<b>Plotters error(s):</b>', |
Index: trunk/extensions/Plotters/Plotters.php |
— | — | @@ -169,7 +169,8 @@ |
170 | 170 | function initPlottersPF( &$parser ) { |
171 | 171 | $numargs = func_num_args(); |
172 | 172 | if ( $numargs < 2 ) { |
173 | | - $input = "#Plotters: no arguments specified"; |
| 173 | + wfLoadExtensionMessages( 'Plotters' ); |
| 174 | + $input = wfMsg( "plotters-errors" ) . " " . wfMsg( "plotters-missing-arguments" ); |
174 | 175 | return str_replace( '§', '<', '§pre>§nowiki>' . $input . '§/nowiki>§/pre>' ); |
175 | 176 | } |
176 | 177 | |
Index: trunk/extensions/Plotters/PlottersClass.php |
— | — | @@ -51,6 +51,17 @@ |
52 | 52 | // Check to ensure scriptname is < 255 characters |
53 | 53 | $errors .= wfMsg( "plotters-excessively-long-scriptname" ) . "<br />"; |
54 | 54 | } |
| 55 | + // Check preprocessors and helpers |
| 56 | + foreach ( $this->argumentArray["preprocessors"] as $preprocessor ) { |
| 57 | + if ( strlen( $preprocessor ) > 255 ) { |
| 58 | + $errors .= wfMsg( "plotters-excessively-long-preprocessorname" ) . "<br />"; |
| 59 | + } |
| 60 | + } |
| 61 | + foreach ( $this->argumentArray["helpers"] as $helper ) { |
| 62 | + if ( strlen( $helper ) > 255 ) { |
| 63 | + $errors .= wfMsg( "plotters-excessively-long-helpername" ) . "<br />"; |
| 64 | + } |
| 65 | + } |
55 | 66 | // Check for data |
56 | 67 | if ( count( $this->dataArray ) == 0 ) { |
57 | 68 | $errors .= wfMsg( "plotters-no-data" ) . "<br />"; |
— | — | @@ -78,10 +89,15 @@ |
79 | 90 | $renderer = "mplotter-" . $this->argumentArray["renderer"]; |
80 | 91 | $this->parser->mOutput->$renderer = true; |
81 | 92 | |
| 93 | + // Add preprocessor and helper tags |
82 | 94 | foreach ( $this->argumentArray["preprocessors"] as $preprocessor ) { |
83 | 95 | $preprocessor = "mplotter-" . $preprocessor; |
84 | 96 | $this->parser->mOutput->$preprocessor = true; |
85 | 97 | } |
| 98 | + foreach ( $this->argumentArray["helpers"] as $helper ) { |
| 99 | + $helper = "mplotter-" . $helper; |
| 100 | + $this->parser->mOutput->$helper = true; |
| 101 | + } |
86 | 102 | |
87 | 103 | $script = "mplotter-" . $this->argumentArray["script"]; |
88 | 104 | $this->parser->mOutput->$script = true; |