https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111864

Revision: 111864
Author:   amire80
Date:     2012-02-19 14:09:29 +0000 (Sun, 19 Feb 2012)
Log Message:
-----------
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
    trunk/extensions/timeline/Timeline.php

Modified: trunk/extensions/timeline/EasyTimeline.pl
===================================================================
--- trunk/extensions/timeline/EasyTimeline.pl   2012-02-19 13:16:26 UTC (rev 
111863)
+++ trunk/extensions/timeline/EasyTimeline.pl   2012-02-19 14:09:29 UTC (rev 
111864)
@@ -83,6 +83,9 @@
 
 # Global variables.
 # Many of these should be refactored.
+
+# Whether to generate only an SVG file and have it converted to PNG later.
+# To enable it in the MediaWiki extension, use <timeline method="svg2png">
 my $SVG_ONLY = 0;
 
 my @PlotLines;

Modified: trunk/extensions/timeline/Timeline.php
===================================================================
--- trunk/extensions/timeline/Timeline.php      2012-02-19 13:16:26 UTC (rev 
111863)
+++ trunk/extensions/timeline/Timeline.php      2012-02-19 14:09:29 UTC (rev 
111864)
@@ -38,9 +38,6 @@
 
        // The name of the FileBackend to use for timeline (see $wgFileBackends)
        public $fileBackend = '';
-
-       // Whether to generate only an SVG file using ploticus
-       public $svgOnly = false;
 }
 $wgTimelineSettings = new TimelineSettings;
 $wgTimelineSettings->ploticusCommand = "/usr/bin/ploticus";
@@ -63,10 +60,12 @@
  * @param $timelinesrc string
  * @return string
  */
-function wfRenderTimeline( $timelinesrc ) {
+function wfRenderTimeline( $timelinesrc, array $args ) {
        global $wgUploadDirectory, $wgUploadPath, $wgArticlePath, 
$wgTmpDirectory, $wgRenderHashAppend;
        global $wgTimelineSettings;
 
+       $svg2png = ( $args['method'] == 'svg2png' );
+
        // Get the backend to store plot data and pngs
        if ( $wgTimelineSettings->fileBackend != '' ) {
                $backend = FileBackendGroup::singleton()->get( 
$wgTimelineSettings->fileBackend );
@@ -79,8 +78,10 @@
                ) );
        }
 
-       // Get a hash of the plot data
-       $hash = md5( $timelinesrc );
+       // Get a hash of the plot data.
+       // $args must be checked, because the same source text may be used with
+       // with different args.
+       $hash = md5( $timelinesrc . join( $args ) );
        if ( $wgRenderHashAppend != '' ) {
                $hash = md5( $hash . $wgRenderHashAppend );
        }
@@ -110,7 +111,7 @@
                        // Get command for ploticus to read the user input and 
output an error, 
                        // map, and rendering (png or gif) file under the same 
dir as the temp file.
                        $cmdline = wfEscapeShellArg( 
$wgTimelineSettings->perlCommand, $wgTimelineSettings->timelineFile ) .
-                       ($wgTimelineSettings->svgOnly ? " -s " : "") .
+                       ($svg2png ? " -s " : "") .
                        " -i " . wfEscapeShellArg( $tmpPath ) . " -m -P " . 
wfEscapeShellArg( $wgTimelineSettings->ploticusCommand ) .
                        " -T " . wfEscapeShellArg( $wgTmpDirectory ) . " -A " . 
wfEscapeShellArg( $wgArticlePath ) .
                        " -f " . wfEscapeShellArg( 
$wgTimelineSettings->fontFile );
@@ -120,8 +121,8 @@
                        $retVal = null;
                        $ret = wfShellExec( $cmdline, $retVal );
 
-                       // If running in svgOnly mode, create the PNG file from 
the SVG
-                       if ( $wgTimelineSettings->svgOnly ) {
+                       // If running in svg2png mode, create the PNG file from 
the SVG
+                       if ( $svg2png ) {
                                // Read the default timeline image size from 
the DVG file
                                $svgFilename = "{$tmpPath}.svg";
                                wfSuppressWarnings();


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to