[PATCH] Translation2::get[Raw]Page()
| From: | Michael Henry | Date: | Mon, 06 Nov 2006 20:46:44 +0000 |
| Subject: | [PATCH] Translation2::get[Raw]Page() | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-44857@lists.php.net to get a copy of this message | ||
Hi all,
Regarding my post yesterday on the indices of the array returned by the getPage() and getRawPage() methods, I've modified the dataobjectsimple container to index the array by stringID of type string.
Please find the patch below.
Regards,
Michael
? Translation2.diff
Index: Container/dataobjectsimple.php
===================================================================
RCS file: /repository/pear/Translation2/Container/dataobjectsimple.php,v
retrieving revision 1.13
diff -u -r1.13 dataobjectsimple.php
--- Container/dataobjectsimple.php 6 Jul 2006 09:21:09 -0000 1.13 +++ Container/dataobjectsimple.php 6 Nov 2006 20:31:07 -0000@@ -149,14 +149,33 @@
if (PEAR::isError($langID)) {
return $langID;
}
+
+ // First get the array of string IDs
$do = DB_DataObject::factory($this->options['table']);
- $do->lang = $langID;
+ $do->lang = '-';
$do->page = $pageID;
+ $do->find();
+
+ $stringIDs = array();
+ while ($do->fetch()) {
+ $stringIDs[$do->string_id] = $do->translation;
+ }
+
+ // Now get the array of strings + $do = DB_DataObject::factory($this->options['table']); + $do->page = $pageID; + $do->lang = $langID;
$do->find();
- $strings = array();
+ $translations = array();
while ($do->fetch()) {
- $strings[$do->string_id] = $do->translation;
+ $translations[$do->string_id] = $do->translation;
+ }
+
+ // Construct an associative array of stringIDs and translations
+ $strings = array();
+ foreach ($translations as $key => $value) {
+ $strings[$stringIDs[$key]] = $value;
}
return $strings;@@ -227,4 +246,4 @@
// }}}} -?> \ No newline at end of file +?>