]>
src.bluestatic.org Git - bugdar.git/blob - lang_registry_replacer.php
74ca060f8110b65febea3d533b88bde03195e87c
3 // replaces lang::r() with lang::p() calls
7 require_once('./global.php');
9 function fetch_listing($path, $basepath = '', $unset = 1)
18 if (substr($path, (strlen($path) - 1), 1) != '/')
23 if ($handle = opendir($path))
25 while (($file = readdir($handle)) !== false)
27 if (substr($file, 0, 1) != '.' AND $file != 'CVS')
29 if (is_dir($path . $file))
31 $filelist["$basepath"][] = "$file/";
32 fetch_listing("$path$file", "$basepath$file/", 0);
36 $filelist["$basepath"][] = $file;
45 function fetch_flat_listing($filelist)
47 foreach ($filelist AS $basepath => $files)
49 foreach ($files AS $file)
51 if (preg_match('#\.php$#', $file))
53 $flatlist[] = "./$basepath$file";
60 // ###################################################################
61 // ###################################################################
63 $listing = fetch_flat_listing(fetch_listing(getcwd()));
65 $phrases = $db->query("SELECT * FROM phrase WHERE md5");
66 while ($phrase = $db->fetch_array($phrases))
68 $replace["$phrase[md5]"] = $phrase['varname'];
71 foreach ($listing AS $filename)
73 $file = file_get_contents($filename);
75 preg_match_all("#lang::r\('(.*?)'\)#", $file, $matches);
76 foreach ($matches[0] AS $matchid => $match)
78 $mdstring = md5($matches[1]["$matchid"]);
79 if ($replace["$mdstring"])
81 $file = str_replace($match, 'lang::p(\'' . $replace["$mdstring"] . '\')', $file);
85 if ($h = fopen($filename, 'w'))