diff options
author | Christian Helbling | 2018-09-25 17:26:43 +0200 |
---|---|---|
committer | Christian Helbling | 2018-09-25 17:28:53 +0200 |
commit | 05d87bd756ab1cf392d50d3969c2c5586b643eb6 (patch) | |
tree | bcdc87048c775ff138b802840290e44e09d90c71 /it_text.class | |
parent | 808df7b23e2bbcd782f61f4e50f10a2fea5ef06e (diff) | |
download | itools-05d87bd756ab1cf392d50d3969c2c5586b643eb6.tar.gz itools-05d87bd756ab1cf392d50d3969c2c5586b643eb6.tar.bz2 itools-05d87bd756ab1cf392d50d3969c2c5586b643eb6.zip |
save texts.php in new array syntax if it is already converted to the new syntax
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); } |