diff options
Diffstat (limited to 'it_text.class')
-rw-r--r-- | it_text.class | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/it_text.class b/it_text.class index 5b43ea6..554fcda 100644 --- a/it_text.class +++ b/it_text.class @@ -273,9 +273,18 @@ function dump_php() $this->statictext = array_merge(array('_' => $this->statictext['_']), $this->statictext); $oldmask = umask(002); - if ((count($this->p['phpfiles']) == 1) && ($f = it::fopen($this->p['phpfiles'][0], 'w'))) + $filename = $this->p['phpfiles'][0]; + $oldsyntax = file_exists($filename) && trim(it::exec('grep -q \'array(\' {filename} && echo array', ['filename' => $filename])); + if ((count($this->p['phpfiles']) == 1) && ($f = it::fopen($filename, 'w'))) { - $result = (fputs($f, '<?php return ' . strtr(var_export($this->statictext, true), array("=> \n array (" => "=> array(", "array (\n '_'" => "array(\n'_'", "\n ),\n " => "\n),\n", "\n ),\n" => "\n),\n", "\r" => "")) . ";\n?>\n") !== false); + $dump = '<?php return ' . strtr(var_export($this->statictext, true), array("=> \n array (" => "=> array(", "array (\n '_'" => "array(\n'_'", "\n ),\n " => "\n),\n", "\n ),\n" => "\n),\n", "\r" => "")) . ";\n?>\n"; + if (!$oldsyntax) + { + it::file_put_contents($tmpfile = tempnam('/tmp/', 'texts_'), $dump); + $dump = it::exec('/www/server/bin/convertsyntax.php -a {tmpfile}', ['tmpfile' => $tmpfile]); + unlink($tmpfile); + } + $result = (fputs($f, $dump) !== false); fclose($f); } |