@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @copyright (c) 2007-2014 G. Giunta |
6 | 6 | */ |
7 | 7 | |
8 | -if ($_SERVER['argc'] < 4) |
|
8 | +if ($_SERVER['argc']<4) |
|
9 | 9 | die("Usage: php convert.php docbook.xml \path\\to\stylesheet.xsl output-dir|output_file\n"); |
10 | 10 | else |
11 | 11 | echo "Starting xsl conversion process...\n"; |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | |
27 | 27 | // Configure the transformer |
28 | 28 | $proc = new XSLTProcessor; |
29 | -if (version_compare(PHP_VERSION,'5.4',"<")) |
|
29 | +if (version_compare(PHP_VERSION, '5.4', "<")) |
|
30 | 30 | { |
31 | - if(defined('XSL_SECPREF_WRITE_FILE')) |
|
31 | + if (defined('XSL_SECPREF_WRITE_FILE')) |
|
32 | 32 | ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); |
33 | 33 | } |
34 | 34 | else |
35 | 35 | { |
36 | - if(is_callable(array($proc, 'setSecurityPreferences'))) |
|
36 | + if (is_callable(array($proc, 'setSecurityPreferences'))) |
|
37 | 37 | { |
38 | 38 | $proc->setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); |
39 | 39 | } |
@@ -5,18 +5,21 @@ discard block |
||
5 | 5 | * @copyright (c) 2007-2014 G. Giunta |
6 | 6 | */ |
7 | 7 | |
8 | -if ($_SERVER['argc'] < 4) |
|
8 | +if ($_SERVER['argc'] < 4) { |
|
9 | 9 | die("Usage: php convert.php docbook.xml \path\\to\stylesheet.xsl output-dir|output_file\n"); |
10 | -else |
|
10 | +} else { |
|
11 | 11 | echo "Starting xsl conversion process...\n"; |
12 | +} |
|
12 | 13 | |
13 | 14 | $doc = $_SERVER['argv'][1]; |
14 | 15 | $xss = $_SERVER['argv'][2]; |
15 | 16 | |
16 | -if (!file_exists($doc)) |
|
17 | +if (!file_exists($doc)) { |
|
17 | 18 | die("KO: file $doc cannot be found\n"); |
18 | -if (!file_exists($xss)) |
|
19 | +} |
|
20 | +if (!file_exists($xss)) { |
|
19 | 21 | die("KO: file $xss cannot be found\n"); |
22 | +} |
|
20 | 23 | |
21 | 24 | // Load the XML source |
22 | 25 | $xml = new DOMDocument; |
@@ -28,16 +31,15 @@ discard block |
||
28 | 31 | $proc = new XSLTProcessor; |
29 | 32 | if (version_compare(PHP_VERSION,'5.4',"<")) |
30 | 33 | { |
31 | - if(defined('XSL_SECPREF_WRITE_FILE')) |
|
32 | - ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); |
|
33 | -} |
|
34 | -else |
|
34 | + if(defined('XSL_SECPREF_WRITE_FILE')) { |
|
35 | + ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); |
|
36 | + } |
|
37 | + } else |
|
35 | 38 | { |
36 | 39 | if(is_callable(array($proc, 'setSecurityPreferences'))) |
37 | 40 | { |
38 | 41 | $proc->setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); |
39 | - } |
|
40 | - else |
|
42 | + } else |
|
41 | 43 | { |
42 | 44 | $proc->setSecurityPrefs(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); |
43 | 45 | } |
@@ -48,18 +50,19 @@ discard block |
||
48 | 50 | //{ |
49 | 51 | if (is_dir($_SERVER['argv'][3])) |
50 | 52 | { |
51 | - if (!$proc->setParameter('', 'base.dir', realpath($_SERVER['argv'][3]))) |
|
52 | - echo "setting param base.dir KO\n"; |
|
53 | - } |
|
54 | - else |
|
53 | + if (!$proc->setParameter('', 'base.dir', realpath($_SERVER['argv'][3]))) { |
|
54 | + echo "setting param base.dir KO\n"; |
|
55 | + } |
|
56 | + } else |
|
55 | 57 | { |
56 | 58 | //echo "{$_SERVER['argv'][3]} is not a dir\n"; |
57 | 59 | } |
58 | 60 | //} |
59 | 61 | |
60 | 62 | $out = $proc->transformToXML($xml); |
61 | -if (!is_dir($_SERVER['argv'][3])) |
|
63 | +if (!is_dir($_SERVER['argv'][3])) { |
|
62 | 64 | file_put_contents($_SERVER['argv'][3], $out); |
65 | +} |
|
63 | 66 | |
64 | 67 | echo "OK\n"; |
65 | 68 | ?> |
66 | 69 | \ No newline at end of file |