From 05d87bd756ab1cf392d50d3969c2c5586b643eb6 Mon Sep 17 00:00:00 2001 From: Christian Helbling Date: Tue, 25 Sep 2018 17:26:43 +0200 Subject: save texts.php in new array syntax if it is already converted to the new syntax --- it_text.class | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'it_text.class') 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, 'statictext, true), array("=> \n array (" => "=> array(", "array (\n '_'" => "array(\n'_'", "\n ),\n " => "\n),\n", "\n ),\n" => "\n),\n", "\r" => "")) . ";\n?>\n") !== false); + $dump = '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); } -- cgit v1.2.3