>From 707e8dd0495cdc82da62e31eaf2f5f147e0f34bb Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Fri, 31 Jul 2009 20:12:03 +0200 Subject: [PATCH] Move a function to lib_res for re-use --- transl/php/lib_res.php | 25 +++++++++++++++++++++++++ transl/php/resource.php | 26 -------------------------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/transl/php/lib_res.php b/transl/php/lib_res.php index a7af016..21ba98d 100644 --- a/transl/php/lib_res.php +++ b/transl/php/lib_res.php @@ -253,6 +253,31 @@ function diff_sequences(&$res1, $count1, &$res2, $count2, $compare_method) return array_reverse($out); } +function load_resource(&$resources, $type, $id, $langid, &$res) +{ + $file_type = $type & 0xff; /* wrc adds 0x100 for *EX resource*/ + $resdata = $resources->loadResource($file_type, $id, get_lang_binid($langid)); + if (!$resdata) + die("Resource not found in *.res file\n"); + switch ($type) + { + case 4: /* RT_MENU */ + $res = new MenuResource($resdata[0], $resdata[1]); + return TRUE; + case 5: /* RT_DIALOG */ + case 261: /* res_dialogex */ + $res = new DialogResource($resdata[0], $resdata[1]); + return TRUE; + case 6: /* RT_STRING*/ + $res = new StringTable($resdata[0], $resdata[1], $id); + return TRUE; + case 11: /* RT_MESSAGETABLE */ + $res = new MessageTable($resdata[0], $resdata[1], $id); + return TRUE; + default: + die("Unhandled resource type $type"); + } +} class ResFile { diff --git a/transl/php/resource.php b/transl/php/resource.php index 4f51879..db9e3ac 100644 --- a/transl/php/resource.php +++ b/transl/php/resource.php @@ -25,32 +25,6 @@ $compare = isset($_REQUEST['compare']); loadResource($file_type, $id, get_lang_binid($langid)); - if (!$resdata) - die("Resource not found in *.res file\n"); - switch ($type) - { - case 4: /* RT_MENU */ - $res = new MenuResource($resdata[0], $resdata[1]); - return TRUE; - case 5: /* RT_DIALOG */ - case 261: /* res_dialogex */ - $res = new DialogResource($resdata[0], $resdata[1]); - return TRUE; - case 6: /* RT_STRING*/ - $res = new StringTable($resdata[0], $resdata[1], $id); - return TRUE; - case 11: /* RT_MESSAGETABLE */ - $res = new MessageTable($resdata[0], $resdata[1], $id); - return TRUE; - default: - die("Unhandled resource type $type"); - } -} - $resources = new ResFile(get_res_path($resfile)); $res_lang = update_lang_from_resfile($lang, $resfile); -- 1.6.0.6