Anomalie #1498 » 01-inkscape2rsvg.diff
include/config.php | ||
---|---|---|
113 | 113 |
); |
114 | 114 | |
115 | 115 |
// Command used to convert SVG files into images, optional unless you |
116 |
// want to use this feature. Be sure to have at least inkscape v0.44
|
|
117 |
define ( INKSCAPE_COMMAND, '/usr/bin/inkscape' );
|
|
116 |
// want to use this feature. |
|
117 |
define ( SVGCONVERT_COMMAND, '/usr/bin/rsvg' );
|
|
118 | 118 | |
119 | 119 | |
120 | 120 |
/* |
include/config.php.template | ||
---|---|---|
79 | 79 | |
80 | 80 |
// Command used to convert SVG files into images, optional unless you |
81 | 81 |
// want to use this feature. |
82 |
define ( INKSCAPE_COMMAND, '{$inkscape_path}' );
|
|
82 |
define ( SVGCONVERT_COMMAND, '{$rsvg_path}' );
|
|
83 | 83 | |
84 | 84 |
// Uncomment if you need LDAP |
85 | 85 |
// define ( LDAP_HOST, 'localhost' ); |
include/inst.php | ||
---|---|---|
180 | 180 | |
181 | 181 | |
182 | 182 | |
183 |
function inst_test_inkscape ()
|
|
183 |
function inst_test_rsvg ()
|
|
184 | 184 |
{ |
185 | 185 |
global $_SESSION; |
186 |
if ( ! $_SESSION [ 'inkscape_path' ] )
|
|
187 |
exec ( 'inkscape --version 2>&1', $output, $retval );
|
|
186 |
if ( ! $_SESSION [ 'rsvg_path' ] )
|
|
187 |
exec ( 'rsvg --version 2>&1', $output, $retval );
|
|
188 | 188 |
else |
189 |
exec ( $_SESSION [ 'inkscape_path' ] . '/inkscape --version 2>&1',
|
|
189 |
exec ( $_SESSION [ 'rsvg_path' ] . '/rsvg --version 2>&1',
|
|
190 | 190 |
$output, $retval ); |
191 | 191 | |
192 |
preg_match ( '/inkscape ([0-9]*)\.([0-9]*)/i', $output [ 0 ], $matches ); |
|
193 | ||
194 |
return ( $matches [ 1 ] > 0 || $matches [ 2 ] >= 44 ); |
|
192 |
return ( $retval == 0); |
|
195 | 193 |
} |
196 | 194 | |
197 | 195 | |
198 | 196 | |
199 |
function inst_configure_inkscape ( )
|
|
197 |
function inst_configure_rsvg ( )
|
|
200 | 198 |
{ |
201 |
exec ( 'inkscape --version 2>&1', $output, $retval ); |
|
202 |
preg_match ( '/inkscape ([0-9\.]*)/i', $output [ 0 ], $matches ); |
|
203 |
|
|
204 |
if ( $matches [ 1 ] ) |
|
205 |
$data [ 'inkscape_version' ] = $matches [ 1 ]; |
|
199 |
exec ( 'rsvg --version 2>&1', $output, $retval ); |
|
200 | ||
201 |
if ( $retval == 0 ) |
|
202 |
$data [ 'rsvg_version' ] = $output; |
|
206 | 203 |
else |
207 |
$data [ 'inkscape_version' ] = '<b>none!</b>';
|
|
204 |
$data [ 'rsvg_version' ] = '<b>none!</b>';
|
|
208 | 205 | |
209 | 206 |
$data [ 'path' ] = $_ENV [ 'PATH' ]; |
210 | 207 |
|
211 |
my_smarty ( "installer/configure-inkscape.tpl", $data ); |
|
208 |
// FIXME: seems no more available |
|
209 |
// my_smarty ( "installer/configure-inkscape.tpl", $data ); |
|
212 | 210 |
} |
213 | 211 | |
214 | 212 | |
215 | 213 | |
216 |
function inst_do_configure_inkscape ( $args )
|
|
214 |
function inst_do_configure_rsvg ( $args )
|
|
217 | 215 |
{ |
218 | 216 |
global $_SESSION; |
219 |
$_SESSION [ 'inkscape_path' ] = $args [ 'inkscape_path' ];
|
|
220 |
if ( inst_test_inkscape ( ) )
|
|
217 |
$_SESSION [ 'rsvg_path' ] = $args [ 'rsvg_path' ];
|
|
218 |
if ( inst_test_rsvg ( ) )
|
|
221 | 219 |
{ |
222 | 220 |
header ("Location: installer.php"); |
223 | 221 |
exit; |
224 | 222 |
} |
225 | 223 |
else |
226 | 224 |
{ |
227 |
inst_croak ( "Unable to find inkscape in " . $args [ 'inkscape_path' ] );
|
|
225 |
inst_croak ( "Unable to find rsvg in " . $args [ 'rsvg_path' ] );
|
|
228 | 226 |
} |
229 | 227 |
} |
230 | 228 | |
... | ... | |
402 | 400 |
$base_url = 'http://' . $_SERVER [ 'HTTP_HOST' ] . $_SERVER [ 'SCRIPT_NAME' ]; |
403 | 401 |
$base_url = preg_replace ( '/[^\/]*.php/', '', $base_url ); |
404 | 402 | |
405 |
if ( $_SESSION [ 'inkscape_path' ] )
|
|
406 |
$inkscape = $_SESSION [ 'inkscape_path' ] . '/inkscape';
|
|
403 |
if ( $_SESSION [ 'rsvg_path' ] )
|
|
404 |
$rsvg = $_SESSION [ 'rsvg_path' ] . '/rsvg';
|
|
407 | 405 |
else |
408 |
$inkscape = 'inkscape';
|
|
406 |
$rsvg = 'rsvg';
|
|
409 | 407 | |
410 | 408 |
$data = Array ( 'db_host' => $_SESSION [ 'db_host' ], |
411 | 409 |
'db_name' => $_SESSION [ 'db_name' ], |
... | ... | |
414 | 412 |
'base_dir' => $base_dir, |
415 | 413 |
'base_url' => $base_url, |
416 | 414 |
'smarty_path' => $_SESSION [ 'smarty_path' ], |
417 |
'inkscape_path' => $inkscape,
|
|
415 |
'rsvg_path' => $rsvg,
|
|
418 | 416 |
'mail_bot' => $_SESSION [ 'mail_bot' ] ); |
419 | 417 | |
420 | 418 |
// Generate config file |
include/svg.php | ||
---|---|---|
148 | 148 | |
149 | 149 |
if ( $format == 'pdf' ) |
150 | 150 |
{ |
151 |
system ( INKSCAPE_COMMAND . " -z --export-pdf=/tmp/$id.pdf --export-width=640 /tmp/$id.svg 2>/dev/null > /dev/null" );
|
|
151 |
system ( SVGCONVERT_COMMAND . " --width 640 -f pdf /tmp/$id.svg /tmp/$id.pdf 2>/dev/null> /dev/null" );
|
|
152 | 152 |
header ( "Content-type: application/pdf\n\n" ); |
153 | 153 |
print file_get_contents ( "/tmp/$id.pdf" ); |
154 | 154 |
@unlink ( "/tmp/$id.pdf" ); |
... | ... | |
157 | 157 |
} |
158 | 158 |
else if ( $format != 'svg' ) |
159 | 159 |
{ |
160 |
system ( INKSCAPE_COMMAND . " -z --export-png=/tmp/$id.png --export-width=640 /tmp/$id.svg 2>/tmp/plop > /tmp/plop2");
|
|
160 |
system ( SVGCONVERT_COMMAND . " --width 640 -f png /tmp/$id.svg /tmp/$id.png 2>/dev/null> /dev/null" );
|
|
161 | 161 |
header ( "Content-type: image/png\n\n" ); |
162 | 162 |
print file_get_contents ( "/tmp/$id.png" ); |
163 | 163 |
@unlink ( "/tmp/$id.png" ); |
installer.php | ||
---|---|---|
74 | 74 |
{ |
75 | 75 |
my_smarty ( "installer/create-admin.tpl", Array ( 'title' => 'Configure administrator' ) ); |
76 | 76 |
} |
77 |
else if ( $action == 'configure_inkscape' )
|
|
77 |
else if ( $action == 'configure_rsvg' )
|
|
78 | 78 |
{ |
79 |
inst_configure_inkscape ();
|
|
79 |
inst_configure_rsvg ();
|
|
80 | 80 |
} |
81 |
else if ( $action == 'do_configure_inkscape' )
|
|
81 |
else if ( $action == 'do_configure_rsvg' )
|
|
82 | 82 |
{ |
83 |
inst_do_configure_inkscape ( $_GET );
|
|
83 |
inst_do_configure_rsvg ( $_GET );
|
|
84 | 84 |
} |
85 | 85 |
else if ( $action == 'create_admin' ) |
86 | 86 |
{ |
... | ... | |
152 | 152 |
'nok_string' => '<li><a href="?action=configure_admin"><div class="error">Administrator not created.</div></a></li>', |
153 | 153 |
'test_func' => 'inst_test_admin' ), |
154 | 154 | |
155 |
Array ( 'ok_string' => '<li><div class="notice">Inkscape detected (for map generation).</div></li>',
|
|
156 |
'nok_string' => '<li><a href="?action=configure_inkscape"><div class="warning">Inkscape not detected (maps will not be generated correctly).</div></a></li>',
|
|
157 |
'test_func' => 'inst_test_inkscape',
|
|
155 |
Array ( 'ok_string' => '<li><div class="notice">Rsvg detected (for map generation).</div></li>',
|
|
156 |
'nok_string' => '<li><a href="?action=configure_rsvg"><div class="warning">Rsvg not detected (maps will not be generated correctly).</div></a></li>',
|
|
157 |
'test_func' => 'inst_test_rsvg',
|
|
158 | 158 |
'not_mandatory' => 1 ), |
159 | 159 | |
160 | 160 |
Array ( 'ok_string' => '<li><div class="notice">Configuration file created</div></li>', |