r111864 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111863‎ | r111864 | r111865 >
Date:14:09, 19 February 2012
Author:amire80
Status:ok (Comments)
Tags:
Comment:
Replaced the svgOnly setting with a method parameter to the <timeline> tag, so that both the old and the new image creation methods would be available. Ping r111776 and r111760.
Modified paths:
  • /trunk/extensions/timeline/EasyTimeline.pl (modified) (history)
  • /trunk/extensions/timeline/Timeline.php (modified) (history)

Diff [purge]

Index: trunk/extensions/timeline/EasyTimeline.pl
@@ -83,6 +83,9 @@
8484
8585 # Global variables.
8686 # 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">
8790 my $SVG_ONLY = 0;
8891
8992 my @PlotLines;
Index: trunk/extensions/timeline/Timeline.php
@@ -38,9 +38,6 @@
3939
4040 // The name of the FileBackend to use for timeline (see $wgFileBackends)
4141 public $fileBackend = '';
42 -
43 - // Whether to generate only an SVG file using ploticus
44 - public $svgOnly = false;
4542 }
4643 $wgTimelineSettings = new TimelineSettings;
4744 $wgTimelineSettings->ploticusCommand = "/usr/bin/ploticus";
@@ -63,10 +60,12 @@
6461 * @param $timelinesrc string
6562 * @return string
6663 */
67 -function wfRenderTimeline( $timelinesrc ) {
 64+function wfRenderTimeline( $timelinesrc, array $args ) {
6865 global $wgUploadDirectory, $wgUploadPath, $wgArticlePath, $wgTmpDirectory, $wgRenderHashAppend;
6966 global $wgTimelineSettings;
7067
 68+ $svg2png = ( $args['method'] == 'svg2png' );
 69+
7170 // Get the backend to store plot data and pngs
7271 if ( $wgTimelineSettings->fileBackend != '' ) {
7372 $backend = FileBackendGroup::singleton()->get( $wgTimelineSettings->fileBackend );
@@ -79,8 +78,10 @@
8079 ) );
8180 }
8281
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 ) );
8586 if ( $wgRenderHashAppend != '' ) {
8687 $hash = md5( $hash . $wgRenderHashAppend );
8788 }
@@ -110,7 +111,7 @@
111112 // Get command for ploticus to read the user input and output an error,
112113 // map, and rendering (png or gif) file under the same dir as the temp file.
113114 $cmdline = wfEscapeShellArg( $wgTimelineSettings->perlCommand, $wgTimelineSettings->timelineFile ) .
114 - ($wgTimelineSettings->svgOnly ? " -s " : "") .
 115+ ($svg2png ? " -s " : "") .
115116 " -i " . wfEscapeShellArg( $tmpPath ) . " -m -P " . wfEscapeShellArg( $wgTimelineSettings->ploticusCommand ) .
116117 " -T " . wfEscapeShellArg( $wgTmpDirectory ) . " -A " . wfEscapeShellArg( $wgArticlePath ) .
117118 " -f " . wfEscapeShellArg( $wgTimelineSettings->fontFile );
@@ -120,8 +121,8 @@
121122 $retVal = null;
122123 $ret = wfShellExec( $cmdline, $retVal );
123124
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 ) {
126127 // Read the default timeline image size from the DVG file
127128 $svgFilename = "{$tmpPath}.svg";
128129 wfSuppressWarnings();

Follow-up revisions

RevisionCommit summaryAuthorDate
r111876Checking for empty method....amire8018:42, 19 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111760Added the svgOnly setting. If it's enabled, the PNG will be created by MediaW...amire8016:12, 17 February 2012
r111776Removed "use warnings" and "use Data::Dumper" - needed only for debugging....amire8019:12, 17 February 2012

Comments

#Comment by Nikerabbit (talk | contribs)   13:18, 20 February 2012

Instead of join() maybe you could use implode directly()

Status & tagging log