Index: trunk/extensions/timeline/EasyTimeline.pl |
— | — | @@ -83,6 +83,9 @@ |
84 | 84 | |
85 | 85 | # Global variables. |
86 | 86 | # Many of these should be refactored. |
| 87 | + |
| 88 | +# Whether to generate only an SVG file and have it converted to PNG later. |
| 89 | +# To enable it in the MediaWiki extension, use <timeline method="svg2png"> |
87 | 90 | my $SVG_ONLY = 0; |
88 | 91 | |
89 | 92 | my @PlotLines; |
Index: trunk/extensions/timeline/Timeline.php |
— | — | @@ -38,9 +38,6 @@ |
39 | 39 | |
40 | 40 | // The name of the FileBackend to use for timeline (see $wgFileBackends) |
41 | 41 | public $fileBackend = ''; |
42 | | - |
43 | | - // Whether to generate only an SVG file using ploticus |
44 | | - public $svgOnly = false; |
45 | 42 | } |
46 | 43 | $wgTimelineSettings = new TimelineSettings; |
47 | 44 | $wgTimelineSettings->ploticusCommand = "/usr/bin/ploticus"; |
— | — | @@ -63,10 +60,12 @@ |
64 | 61 | * @param $timelinesrc string |
65 | 62 | * @return string |
66 | 63 | */ |
67 | | -function wfRenderTimeline( $timelinesrc ) { |
| 64 | +function wfRenderTimeline( $timelinesrc, array $args ) { |
68 | 65 | global $wgUploadDirectory, $wgUploadPath, $wgArticlePath, $wgTmpDirectory, $wgRenderHashAppend; |
69 | 66 | global $wgTimelineSettings; |
70 | 67 | |
| 68 | + $svg2png = ( $args['method'] == 'svg2png' ); |
| 69 | + |
71 | 70 | // Get the backend to store plot data and pngs |
72 | 71 | if ( $wgTimelineSettings->fileBackend != '' ) { |
73 | 72 | $backend = FileBackendGroup::singleton()->get( $wgTimelineSettings->fileBackend ); |
— | — | @@ -79,8 +78,10 @@ |
80 | 79 | ) ); |
81 | 80 | } |
82 | 81 | |
83 | | - // Get a hash of the plot data |
84 | | - $hash = md5( $timelinesrc ); |
| 82 | + // Get a hash of the plot data. |
| 83 | + // $args must be checked, because the same source text may be used with |
| 84 | + // with different args. |
| 85 | + $hash = md5( $timelinesrc . join( $args ) ); |
85 | 86 | if ( $wgRenderHashAppend != '' ) { |
86 | 87 | $hash = md5( $hash . $wgRenderHashAppend ); |
87 | 88 | } |
— | — | @@ -110,7 +111,7 @@ |
111 | 112 | // Get command for ploticus to read the user input and output an error, |
112 | 113 | // map, and rendering (png or gif) file under the same dir as the temp file. |
113 | 114 | $cmdline = wfEscapeShellArg( $wgTimelineSettings->perlCommand, $wgTimelineSettings->timelineFile ) . |
114 | | - ($wgTimelineSettings->svgOnly ? " -s " : "") . |
| 115 | + ($svg2png ? " -s " : "") . |
115 | 116 | " -i " . wfEscapeShellArg( $tmpPath ) . " -m -P " . wfEscapeShellArg( $wgTimelineSettings->ploticusCommand ) . |
116 | 117 | " -T " . wfEscapeShellArg( $wgTmpDirectory ) . " -A " . wfEscapeShellArg( $wgArticlePath ) . |
117 | 118 | " -f " . wfEscapeShellArg( $wgTimelineSettings->fontFile ); |
— | — | @@ -120,8 +121,8 @@ |
121 | 122 | $retVal = null; |
122 | 123 | $ret = wfShellExec( $cmdline, $retVal ); |
123 | 124 | |
124 | | - // If running in svgOnly mode, create the PNG file from the SVG |
125 | | - if ( $wgTimelineSettings->svgOnly ) { |
| 125 | + // If running in svg2png mode, create the PNG file from the SVG |
| 126 | + if ( $svg2png ) { |
126 | 127 | // Read the default timeline image size from the DVG file |
127 | 128 | $svgFilename = "{$tmpPath}.svg"; |
128 | 129 | wfSuppressWarnings(); |