Index: Admin/Container/xml.php =================================================================== RCS file: /repository/pear/Translation2/Admin/Container/xml.php,v retrieving revision 1.9 diff -u -u -r1.9 xml.php --- Admin/Container/xml.php 17 Feb 2005 13:23:51 -0000 1.9 +++ Admin/Container/xml.php 17 Feb 2005 17:08:51 -0000 @@ -268,8 +268,8 @@ if (PEAR::isError($e = $this->_saveData())) { return $e; } - // refresh memory cache - return $this->_loadFile(); + + return true; } // }}} @@ -284,8 +284,14 @@ */ function _saveData() { - $this->_convertEncodings('to_xml'); - $this->_convertLangEncodings('to_xml'); + if ($this->options['save_on_shutdown']) { + $data =& $this->_data; + } else { + $data = $this->_data; + } + + $this->_convertEncodings('to_xml', $data); + $this->_convertLangEncodings('to_xml', $data); // Serializing @@ -294,7 +300,7 @@ "\n" . " \n"; - foreach ($this->_data['languages'] as $lang => $spec) { + foreach ($data['languages'] as $lang => $spec) { extract ($spec); $xml .= " \n" . " " . @@ -316,7 +322,7 @@ $xml .= " \n" . " \n"; - foreach ($this->_data['pages'] as $page => $strings) { + foreach ($data['pages'] as $page => $strings) { $xml .= " \n"; foreach ($strings as $str_id => $translations) { @@ -334,6 +340,8 @@ $xml .= " \n" . "\n"; + unset ($data); + // Saving if (!$f = fopen ($this->_filename, 'w')) { @@ -355,4 +363,4 @@ // }}} } -?> \ No newline at end of file +?> Index: Container/xml.php =================================================================== RCS file: /repository/pear/Translation2/Container/xml.php,v retrieving revision 1.6 diff -u -u -r1.6 xml.php --- Container/xml.php 10 Feb 2005 08:09:42 -0000 1.6 +++ Container/xml.php 17 Feb 2005 17:08:51 -0000 @@ -173,12 +173,12 @@ } // convert lang metadata from UTF-8 - if (PEAR::isError($e = $this->_convertLangEncodings('from_xml'))) { + if (PEAR::isError($e = $this->_convertLangEncodings('from_xml', $this->_data))) { return $e; } // convert encodings of the translated strings from xml (somehow heavy) - return $this->_convertEncodings('from_xml'); + return $this->_convertEncodings('from_xml', $this->_data); } // }}} @@ -188,9 +188,10 @@ * Convert strings to/from XML unique charset (UTF-8) * * @param string ['from_xml' | 'to_xml'] + * @param array $data Data buffer to operate on * @return boolean|PEAR_Error */ - function _convertEncodings($direction) + function _convertEncodings($direction, &$data) { if ($direction == 'from_xml') { $source_encoding = 'UTF-8'; @@ -198,15 +199,15 @@ $target_encoding = 'UTF-8'; } - foreach ($this->_data['pages'] as $page_id => $page_content) { + foreach ($data['pages'] as $page_id => $page_content) { foreach ($page_content as $str_id => $translations) { foreach ($translations as $lang => $str) { if ($direction == 'from_xml') { $target_encoding = - strtoupper($this->_data['languages'][$lang]['encoding']); + strtoupper($data['languages'][$lang]['encoding']); } else { $source_encoding = - strtoupper($this->_data['languages'][$lang]['encoding']); + strtoupper($data['languages'][$lang]['encoding']); } if ($target_encoding != $source_encoding) { $res = iconv ($source_encoding, $target_encoding, $str); @@ -220,7 +221,7 @@ PEAR_ERROR_RETURN, E_USER_WARNING); } - $this->_data['pages'][$page_id][$str_id][$lang] = $res; + $data['pages'][$page_id][$str_id][$lang] = $res; } } } @@ -235,9 +236,10 @@ * Convert lang data to/from XML unique charset (UTF-8) * * @param string $direction ['from_xml' | 'to_xml'] + * @param array $data Data buffer to operate on * @return boolean|PEAR_Error */ - function _convertLangEncodings($direction) + function _convertLangEncodings($direction, &$data) { static $fields = array('name', 'meta', 'error_text'); @@ -246,8 +248,8 @@ } else { $target_encoding = 'UTF-8'; } - - foreach ($this->_data['languages'] as $lang_id => $lang) { + + foreach ($data['languages'] as $lang_id => $lang) { if ($direction == 'from_xml') { $target_encoding = strtoupper($lang['encoding']); } else { @@ -267,7 +269,7 @@ PEAR_ERROR_RETURN, E_USER_WARNING); } - $this->_data['languages'][$lang_id][$field] = $res; + $data['languages'][$lang_id][$field] = $res; } } } @@ -446,4 +448,4 @@ // }}} } -?> \ No newline at end of file +?>