From 8340e4da0e77b22e88aabee7f5500cc34cd16477 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 25 Aug 2005 04:14:08 +0000 Subject: [PATCH] r379: Adding language registry replacer --- docs/lang_registry_replacer.php | 92 +++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 docs/lang_registry_replacer.php diff --git a/docs/lang_registry_replacer.php b/docs/lang_registry_replacer.php new file mode 100755 index 0000000..74ca060 --- /dev/null +++ b/docs/lang_registry_replacer.php @@ -0,0 +1,92 @@ + $files) + { + foreach ($files AS $file) + { + if (preg_match('#\.php$#', $file)) + { + $flatlist[] = "./$basepath$file"; + } + } + } + return $flatlist; +} + +// ################################################################### +// ################################################################### + +$listing = fetch_flat_listing(fetch_listing(getcwd())); + +$phrases = $db->query("SELECT * FROM phrase WHERE md5"); +while ($phrase = $db->fetch_array($phrases)) +{ + $replace["$phrase[md5]"] = $phrase['varname']; +} + +foreach ($listing AS $filename) +{ + $file = file_get_contents($filename); + + preg_match_all("#lang::r\('(.*?)'\)#", $file, $matches); + foreach ($matches[0] AS $matchid => $match) + { + $mdstring = md5($matches[1]["$matchid"]); + if ($replace["$mdstring"]) + { + $file = str_replace($match, 'lang::p(\'' . $replace["$mdstring"] . '\')', $file); + } + } + + if ($h = fopen($filename, 'w')) + { + fwrite($h, $file); + } + fclose($h); +} + +?> \ No newline at end of file -- 2.43.5