Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites
View Statistics - Next Notice - Previous NoticeDirectory filter : [ all ] / postnuke_official / html / includes [ view in CVS ]
Date | Directory [filter] | File(s) [view] | Author [filter] |
08 Aug 2002 19:26:04 | postnuke_official/html/includes | pnML.php,1.5,1.6 | Paul Rosania |
fixed bug that was preventing var binding in pnMLByKey() |
Update of /home/cvsroot/postnuke_official/html/includes In directory ns7.hostnuke.net:/tmp/cvs-serv13421 Modified Files: pnML.php Log Message: fixed bug that was preventing var binding in pnMLByKey() Index: pnML.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/includes/pnML.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pnML.php 3 Aug 2002 23:06:14 -0000 1.5 --- pnML.php 8 Aug 2002 19:26:02 -0000 1.6 *************** *** 1,446 **** ! <?php ! // File: $Id$ ! // ---------------------------------------------------------------------- ! // PostNuke Content Management System ! // Copyright (C) 2001 by the PostNuke Development Team. ! // http://www.postnuke.com/ ! // ---------------------------------------------------------------------- ! // LICENSE ! // ! // This program is free software; you can redistribute it and/or ! // modify it under the terms of the GNU General Public License (GPL) ! // as published by the Free Software Foundation; either version 2 ! // of the License, or (at your option) any later version. ! // ! // This program is distributed in the hope that it will be useful, ! // but WITHOUT ANY WARRANTY; without even the implied warranty of ! // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! // GNU General Public License for more details. ! // ! // To read the license please visit http://www.gnu.org/copyleft/gpl.html ! // ---------------------------------------------------------------------- ! // Original Author of file: Marco Canini ! // Purpose of file: Multi Language System ! // ---------------------------------------------------------------------- ! ! // TODO <marco> see how utf-8 works for xml backend ! ! /** ! * Initialise the Multi Language System ! * @returns bool ! * @return true on success ! */ ! function pnMLInit() ! { ! global $pnML_backend, $pnML_listeners; ! ! // TODO <marco> choose a name for a config var here to create right backend ! ! $pnML_backend = new pnML_XMLTranslationsBackend(); ! //$pnML_backend = new pnML_PHPTranslationsBackend(); ! $pnML_listeners = array(); ! ! // Load core translations ! pnML_Load('base', 'base', 'index'); ! ! return true; ! } ! ! /** ! * Translate a string ! * @returns string ! * @return the translated string, or the original string if no translation is available ! */ ! function pnML($string) ! { ! global $pnML_backend, $pnML_listeners; ! ! $trans = $pnML_backend->translate($string); ! if (!isset($trans) || $trans == '') { ! foreach($pnML_listeners as $listener) { ! $res = pnModAPIFunc($listener, 'user', 'missing_translation_string', ! array('string' => $string)); ! if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) { ! // Since pnMLByKey doesn't raise exceptions, here we ! // ignore possible exceptions that should not be thrown ! pnExceptionFree(); ! } ! } ! $trans = $string; ! } ! if (func_num_args() > 1) { ! $args = func_get_args(); ! unset($args[0]); // Unset $string argument ! if (is_array($args[1])) $args = $args[1]; // Only the second argument is considered if it's an array ! $trans = pnML_bind_variables($trans, $args); ! } ! ! return $trans; ! } ! ! /** ! * Return the translation associated to passed key ! * @returns string ! * @return the translation string, or the key if no translation is available ! */ ! function pnMLByKey($key) ! { ! global $pnML_backend, $pnML_listeners; ! ! $trans = $pnML_backend->translateByKey($key); ! if (!isset($trans) || $trans == '') { ! foreach($pnML_listeners as $listener) { ! $res = pnModAPIFunc($listener, 'user', 'missing_translation_key', ! array('key' => $key)); ! if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) { ! // Since pnMLByKey doesn't raise exceptions, here we ! // ignore possible exceptions that should not be thrown ! pnExceptionFree(); ! } ! } ! $trans = $key; ! } else { ! if (func_num_args() > 1) { ! $args = func_get_args(); ! unset($args[0]); // Unset $string argument ! $trans = pnML_bind_variables($trans, $args); ! } ! } ! ! return $trans; ! } ! ! function pnMLRegisterListener($modname) ! { ! global $pnML_listeners; ! $res = pnModAPILoad($modname, 'user'); ! if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) return; ! ! $pnML_listeners[] = $modname; ! ! return true; ! } ! ! function pnMLGetDynamic($refid, $table_name, $fields) ! { ! $table_name .= '_mldata'; ! $fields = implode(',', $fields); ! ! $query = "SELECT $fields FROM $table_name WHERE pn_refid = $refid"; ! $dbresult = $dbconn->Execute($query); ! ! if($dbconn->ErrorNo() != 0) { ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR', ! new SystemException(__FILE__."(".__LINE__."): Database error while querying: $query")); ! return; ! } ! ! return $dbresult; ! } ! ! function pnML_bind_variables($string, $args) ! { ! $i = 1; ! foreach($args as $var) { ! $search = "#($i)"; ! $string = str_replace($search, $var, $string); ! $i++; ! } ! return $string; ! } ! ! function pnML_load($modname, $moddir, $type) ! { ! global $pnML_backend, $pnML_listeners; ! static $pnML_loadedCommons = array(); ! ! if (!isset($pnML_loadedCommons[$modname])) { ! $pnML_loadedCommons[$modname] = true; ! $res = pnML_load($modname, $moddir, 'common'); ! if (!isset($res)) { ! return; // throw back ! } ! } ! ! //$locale = pnUserGetLocale(); ! $locale = 'en'; ! //$locale = 'it'; ! ! $ctx = array('modname' => $modname, ! 'moddir' => $moddir, ! 'type' => $type, ! 'locale' => $locale); ! ! $res = $pnML_backend->load($ctx); ! if (!isset($res)) { ! return; // throw back ! } ! if ($res == false) { ! foreach($pnML_listeners as $listener) { ! $res = pnModAPIFunc($listener, 'user', 'missing_translation_context', ! array('translation_ctx' => $ctx)); ! if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) { ! // Here we ignore possible exceptions that should not be thrown ! pnExceptionFree(); ! } ! } ! } ! ! return true; ! } ! ! ! /* ! class pnML_TranslationsBackend ! { ! function translateByKey($key) ! { ! } ! function translate($string) ! { ! } ! function load($translation_ctx) ! { ! } ! } ! */ ! ! class pnML_XMLTranslationsBackend ! { ! var $curEntry; ! var $curData; ! ! var $parser; ! ! var $trans = array(); // where translations are kept ! var $transEntries = array(); // mapping for string-based translations ! var $transKeyEntries = array(); // mapping for key-based translations ! ! var $transInd = 0; ! var $transKeyInd = 0; ! ! function translate($string) ! { ! if (!isset($this->transEntries[$string])) { ! return; ! } ! $ind = $this->transEntries[$string]; ! return $this->trans[$ind]['translation']; ! } ! ! function translateByKey($key) ! { ! if (!isset($this->transKeyEntries[$key])) { ! return; ! } ! $ind = $this->transKeyEntries[$key]; ! return $this->trans[$ind]['translation']; ! } ! ! function load($translation_ctx) ! { ! /*$D = new pnDebug(); ! $D->msg('pnML_XMLTranslationsBackend::load');*/ ! ! list($ostype, $oslocale) = pnVarPrepForOS($translation_ctx['type'], ! $translation_ctx['locale']); ! ! $filename = "modules/$translation_ctx[moddir]/pnlang/xml/$oslocale/pn$ostype.xml"; ! if (!file_exists($filename)) { ! return false; ! } ! /*$D->v($filename,"filename"); ! ! list($t1) = explode(" ", microtime());*/ ! ! $this->curData = ''; ! ! $this->parser = xml_parser_create(); ! xml_set_object($this->parser, $this); ! xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); ! xml_set_element_handler($this->parser, "beginElement", "endElement"); ! xml_set_character_data_handler($this->parser, "characterData"); ! ! if (!($fp = fopen($filename, 'r'))) { ! return; ! } ! ! while ($data = fread($fp, 4096)) { ! if (!xml_parse($this->parser, $data, feof($fp))) { ! // NOTE: <marco> Of course don't use pnML here! ! $errstr = xml_error_string(xml_get_error_code($this->parser)); ! $line = xml_get_current_line_number($this->parser); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'TRANSLATION_EXCEPTION', ! new SystemException("XML parser error in $filename: $errstr at line $line.")); ! return; ! } ! } ! ! xml_parser_free($this->parser); ! /* ! list($t2) = explode(" ", microtime()); ! $time = (float) $t2 - (float) $t1; ! $D->v($time,"load time"); ! ! $D->v($this->transEntries, "transEntries"); ! $D->v($this->transKeyEntries, "transKeyEntries"); ! $D->v($this->trans, "trans");*/ ! ! return true; ! } ! ! function entry($string) ! { ! if (!isset($this->transEntries[$string])) { ! return; ! } ! $ind = $this->transEntries[$string]; ! return $this->trans[$ind]; ! } ! ! function entryByKey($key) ! { ! if (!isset($this->transKeyEntries[$key])) { ! return; ! } ! $ind = $this->transKeyEntries[$key]; ! return $this->trans[$ind]; ! } ! ! function transient_id($string) ! { ! if (!isset($this->transEntries[$string])) { ! return; ! } ! return $this->transEntries[$string]; ! } ! ! function lookup($transient_id) ! { ! if (!isset($this->trans[(int) $transient_id])) { ! return; ! } ! return $this->trans[(int) $transient_id]; ! } ! ! function enumTranslations($reset = false) { ! if ($reset == true) { ! $this->transInd = 0; ! } ! $count = count($this->trans); ! if ($this->transInd == $count) { ! return false; ! } ! while ($this->transInd < $count) { ! if (isset($this->trans[$this->transInd]['string'])) { ! $res = array($this->trans[$this->transInd]['string'], $this->trans[$this->transInd]['translation']); ! $this->transInd++; ! return $res; ! } ! $this->transInd++; ! } ! return false; ! } ! ! function enumKeyTranslations($reset = false) { ! if ($reset == true) { ! $this->transKeyInd = 0; ! } ! $count = count($this->trans); ! if ($this->transKeyInd == $count) { ! return false; ! } ! while ($this->transKeyInd < $count) { ! if (isset($this->trans[$this->transKeyInd]['key'])) { ! $res = array($this->trans[$this->transKeyInd]['key'], $this->trans[$this->transKeyInd]['translation']); ! $this->transKeyInd++; ! return $res; ! } ! $this->transKeyInd++; ! } ! return false; ! } ! ! function beginElement($parser, $tag, $attribs) ! { ! if (strpos($tag, ':') !== false) { ! list($ns, $tag) = explode(':', $tag); ! } ! if ($tag == 'entry' || $tag == 'keyEntry') { ! $this->curEntry = array(); ! $this->curEntry['references'] = array(); ! } elseif ($tag == 'reference') { ! $reference['file'] = $attribs['file']; ! $reference['line'] = $attribs['line']; ! $this->curEntry['references'][] = $reference; ! } ! /*elseif ($tag == 'original') { ! $this->curEntry['original'] = array(); ! $this->curEntry['original']['file'] = $attribs['file']; ! $this->curEntry['original']['xpath'] = $attribs['xpath']; ! }*/ ! } ! ! function endElement($parser, $tag) ! { ! if (strpos($tag, ':') !== false) { ! list($ns, $tag) = explode(':', $tag); ! } ! if ($tag == 'entry') { ! $string = $this->curEntry['string']; ! $this->trans[] = $this->curEntry; ! $this->transEntries[$string] = count($this->trans) -1; ! } elseif ($tag == 'keyEntry') { ! $key = $this->curEntry['key']; ! $this->trans[] = $this->curEntry; ! $this->transKeyEntries[$key] = count($this->trans) -1; ! } elseif ($tag == 'string') { ! $this->curEntry['string'] = utf8_decode(trim($this->curData)); ! } elseif ($tag == 'key') { ! $this->curEntry['key'] = trim($this->curData); ! } elseif ($tag == 'translation') { ! $this->curEntry['translation'] = utf8_decode(trim($this->curData)); ! } ! $this->curData = ''; ! } ! ! function characterData($parser, $data) ! { ! // FIXME <marco> consider to replace \n,\r with '' ! $this->curData .= $data; ! } ! ! } ! ! class pnML_PHPTranslationsBackend ! { ! function translate($string) ! { ! global $pnML_PHPBackend_entries; ! return @$pnML_PHPBackend_entries[$string]; ! } ! ! function translateByKey($key) ! { ! global $pnML_PHPBackend_keyEntries; ! return @$pnML_PHPBackend_keyEntries[$key]; ! } ! ! function load($translation_ctx) ! { ! list($ostype, $oslocale) = pnVarPrepForOS($translation_ctx['type'], ! $translation_ctx['locale']); ! ! $filename = "modules/$translation_ctx[moddir]/pnlang/php/$oslocale/pn$ostype.php"; ! if (!file_exists($filename)) { ! return false; ! } ! ! include $filename; ! ! return true; ! } ! ! } ! ! ?> --- 1,447 ---- ! <?php ! // File: $Id$ ! // ---------------------------------------------------------------------- ! // PostNuke Content Management System ! // Copyright (C) 2001 by the PostNuke Development Team. ! // http://www.postnuke.com/ ! // ---------------------------------------------------------------------- ! // LICENSE ! // ! // This program is free software; you can redistribute it and/or ! // modify it under the terms of the GNU General Public License (GPL) ! // as published by the Free Software Foundation; either version 2 ! // of the License, or (at your option) any later version. ! // ! // This program is distributed in the hope that it will be useful, ! // but WITHOUT ANY WARRANTY; without even the implied warranty of ! // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! // GNU General Public License for more details. ! // ! // To read the license please visit http://www.gnu.org/copyleft/gpl.html ! // ---------------------------------------------------------------------- ! // Original Author of file: Marco Canini ! // Purpose of file: Multi Language System ! // ---------------------------------------------------------------------- ! ! // TODO <marco> see how utf-8 works for xml backend ! ! /** ! * Initialise the Multi Language System ! * @returns bool ! * @return true on success ! */ ! function pnMLInit() ! { ! global $pnML_backend, $pnML_listeners; ! ! // TODO <marco> choose a name for a config var here to create right backend ! ! $pnML_backend = new pnML_XMLTranslationsBackend(); ! //$pnML_backend = new pnML_PHPTranslationsBackend(); ! $pnML_listeners = array(); ! ! // Load core translations ! pnML_Load('base', 'base', 'index'); ! ! return true; ! } ! ! /** ! * Translate a string ! * @returns string ! * @return the translated string, or the original string if no translation is available ! */ ! function pnML($string) ! { ! global $pnML_backend, $pnML_listeners; ! ! $trans = $pnML_backend->translate($string); ! if (!isset($trans) || $trans == '') { ! foreach($pnML_listeners as $listener) { ! $res = pnModAPIFunc($listener, 'user', 'missing_translation_string', ! array('string' => $string)); ! if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) { ! // Since pnMLByKey doesn't raise exceptions, here we ! // ignore possible exceptions that should not be thrown ! pnExceptionFree(); ! } ! } ! $trans = $string; ! } ! if (func_num_args() > 1) { ! $args = func_get_args(); ! unset($args[0]); // Unset $string argument ! if (is_array($args[1])) $args = $args[1]; // Only the second argument is considered if it's an array ! $trans = pnML_bind_variables($trans, $args); ! } ! ! return $trans; ! } ! ! /** ! * Return the translation associated to passed key ! * @returns string ! * @return the translation string, or the key if no translation is available ! */ ! function pnMLByKey($key) ! { ! global $pnML_backend, $pnML_listeners; ! ! $trans = $pnML_backend->translateByKey($key); ! if (!isset($trans) || $trans == '') { ! foreach($pnML_listeners as $listener) { ! $res = pnModAPIFunc($listener, 'user', 'missing_translation_key', ! array('key' => $key)); ! if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) { ! // Since pnMLByKey doesn't raise exceptions, here we ! // ignore possible exceptions that should not be thrown ! pnExceptionFree(); ! } ! } ! $trans = $key; ! } ! ! if (func_num_args() > 1) { ! $args = func_get_args(); ! unset($args[0]); // Unset $string argument ! if (is_array($args[1])) $args = $args[1]; // Only the second argument is considered if it's an array ! $trans = pnML_bind_variables($trans, $args); ! } ! ! return $trans; ! } ! ! function pnMLRegisterListener($modname) ! { ! global $pnML_listeners; ! $res = pnModAPILoad($modname, 'user'); ! if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) return; ! ! $pnML_listeners[] = $modname; ! ! return true; ! } ! ! function pnMLGetDynamic($refid, $table_name, $fields) ! { ! $table_name .= '_mldata'; ! $fields = implode(',', $fields); ! ! $query = "SELECT $fields FROM $table_name WHERE pn_refid = $refid"; ! $dbresult = $dbconn->Execute($query); ! ! if($dbconn->ErrorNo() != 0) { ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR', ! new SystemException(__FILE__."(".__LINE__."): Database error while querying: $query")); ! return; ! } ! ! return $dbresult; ! } ! ! function pnML_bind_variables($string, $args) ! { ! $i = 1; ! foreach($args as $var) { ! $search = "#($i)"; ! $string = str_replace($search, $var, $string); ! $i++; ! } ! return $string; ! } ! ! function pnML_load($modname, $moddir, $type) ! { ! global $pnML_backend, $pnML_listeners; ! static $pnML_loadedCommons = array(); ! ! if (!isset($pnML_loadedCommons[$modname])) { ! $pnML_loadedCommons[$modname] = true; ! $res = pnML_load($modname, $moddir, 'common'); ! if (!isset($res)) { ! return; // throw back ! } ! } ! ! //$locale = pnUserGetLocale(); ! $locale = 'en'; ! //$locale = 'it'; ! ! $ctx = array('modname' => $modname, ! 'moddir' => $moddir, ! 'type' => $type, ! 'locale' => $locale); ! ! $res = $pnML_backend->load($ctx); ! if (!isset($res)) { ! return; // throw back ! } ! if ($res == false) { ! foreach($pnML_listeners as $listener) { ! $res = pnModAPIFunc($listener, 'user', 'missing_translation_context', ! array('translation_ctx' => $ctx)); ! if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) { ! // Here we ignore possible exceptions that should not be thrown ! pnExceptionFree(); ! } ! } ! } ! ! return true; ! } ! ! ! /* ! class pnML_TranslationsBackend ! { ! function translateByKey($key) ! { ! } ! function translate($string) ! { ! } ! function load($translation_ctx) ! { ! } ! } ! */ ! ! class pnML_XMLTranslationsBackend ! { ! var $curEntry; ! var $curData; ! ! var $parser; ! ! var $trans = array(); // where translations are kept ! var $transEntries = array(); // mapping for string-based translations ! var $transKeyEntries = array(); // mapping for key-based translations ! ! var $transInd = 0; ! var $transKeyInd = 0; ! ! function translate($string) ! { ! if (!isset($this->transEntries[$string])) { ! return; ! } ! $ind = $this->transEntries[$string]; ! return $this->trans[$ind]['translation']; ! } ! ! function translateByKey($key) ! { ! if (!isset($this->transKeyEntries[$key])) { ! return; ! } ! $ind = $this->transKeyEntries[$key]; ! return $this->trans[$ind]['translation']; ! } ! ! function load($translation_ctx) ! { ! /*$D = new pnDebug(); ! $D->msg('pnML_XMLTranslationsBackend::load');*/ ! ! list($ostype, $oslocale) = pnVarPrepForOS($translation_ctx['type'], ! $translation_ctx['locale']); ! ! $filename = "modules/$translation_ctx[moddir]/pnlang/xml/$oslocale/pn$ostype.xml"; ! if (!file_exists($filename)) { ! return false; ! } ! /*$D->v($filename,"filename"); ! ! list($t1) = explode(" ", microtime());*/ ! ! $this->curData = ''; ! ! $this->parser = xml_parser_create(); ! xml_set_object($this->parser, $this); ! xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); ! xml_set_element_handler($this->parser, "beginElement", "endElement"); ! xml_set_character_data_handler($this->parser, "characterData"); ! ! if (!($fp = fopen($filename, 'r'))) { ! return; ! } ! ! while ($data = fread($fp, 4096)) { ! if (!xml_parse($this->parser, $data, feof($fp))) { ! // NOTE: <marco> Of course don't use pnML here! ! $errstr = xml_error_string(xml_get_error_code($this->parser)); ! $line = xml_get_current_line_number($this->parser); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'TRANSLATION_EXCEPTION', ! new SystemException("XML parser error in $filename: $errstr at line $line.")); ! return; ! } ! } ! ! xml_parser_free($this->parser); ! /* ! list($t2) = explode(" ", microtime()); ! $time = (float) $t2 - (float) $t1; ! $D->v($time,"load time"); ! ! $D->v($this->transEntries, "transEntries"); ! $D->v($this->transKeyEntries, "transKeyEntries"); ! $D->v($this->trans, "trans");*/ ! ! return true; ! } ! ! function entry($string) ! { ! if (!isset($this->transEntries[$string])) { ! return; ! } ! $ind = $this->transEntries[$string]; ! return $this->trans[$ind]; ! } ! ! function entryByKey($key) ! { ! if (!isset($this->transKeyEntries[$key])) { ! return; ! } ! $ind = $this->transKeyEntries[$key]; ! return $this->trans[$ind]; ! } ! ! function transient_id($string) ! { ! if (!isset($this->transEntries[$string])) { ! return; ! } ! return $this->transEntries[$string]; ! } ! ! function lookup($transient_id) ! { ! if (!isset($this->trans[(int) $transient_id])) { ! return; ! } ! return $this->trans[(int) $transient_id]; ! } ! ! function enumTranslations($reset = false) { ! if ($reset == true) { ! $this->transInd = 0; ! } ! $count = count($this->trans); ! if ($this->transInd == $count) { ! return false; ! } ! while ($this->transInd < $count) { ! if (isset($this->trans[$this->transInd]['string'])) { ! $res = array($this->trans[$this->transInd]['string'], $this->trans[$this->transInd]['translation']); ! $this->transInd++; ! return $res; ! } ! $this->transInd++; ! } ! return false; ! } ! ! function enumKeyTranslations($reset = false) { ! if ($reset == true) { ! $this->transKeyInd = 0; ! } ! $count = count($this->trans); ! if ($this->transKeyInd == $count) { ! return false; ! } ! while ($this->transKeyInd < $count) { ! if (isset($this->trans[$this->transKeyInd]['key'])) { ! $res = array($this->trans[$this->transKeyInd]['key'], $this->trans[$this->transKeyInd]['translation']); ! $this->transKeyInd++; ! return $res; ! } ! $this->transKeyInd++; ! } ! return false; ! } ! ! function beginElement($parser, $tag, $attribs) ! { ! if (strpos($tag, ':') !== false) { ! list($ns, $tag) = explode(':', $tag); ! } ! if ($tag == 'entry' || $tag == 'keyEntry') { ! $this->curEntry = array(); ! $this->curEntry['references'] = array(); ! } elseif ($tag == 'reference') { ! $reference['file'] = $attribs['file']; ! $reference['line'] = $attribs['line']; ! $this->curEntry['references'][] = $reference; ! } ! /*elseif ($tag == 'original') { ! $this->curEntry['original'] = array(); ! $this->curEntry['original']['file'] = $attribs['file']; ! $this->curEntry['original']['xpath'] = $attribs['xpath']; ! }*/ ! } ! ! function endElement($parser, $tag) ! { ! if (strpos($tag, ':') !== false) { ! list($ns, $tag) = explode(':', $tag); ! } ! if ($tag == 'entry') { ! $string = $this->curEntry['string']; ! $this->trans[] = $this->curEntry; ! $this->transEntries[$string] = count($this->trans) -1; ! } elseif ($tag == 'keyEntry') { ! $key = $this->curEntry['key']; ! $this->trans[] = $this->curEntry; ! $this->transKeyEntries[$key] = count($this->trans) -1; ! } elseif ($tag == 'string') { ! $this->curEntry['string'] = utf8_decode(trim($this->curData)); ! } elseif ($tag == 'key') { ! $this->curEntry['key'] = trim($this->curData); ! } elseif ($tag == 'translation') { ! $this->curEntry['translation'] = utf8_decode(trim($this->curData)); ! } ! $this->curData = ''; ! } ! ! function characterData($parser, $data) ! { ! // FIXME <marco> consider to replace \n,\r with '' ! $this->curData .= $data; ! } ! ! } ! ! class pnML_PHPTranslationsBackend ! { ! function translate($string) ! { ! global $pnML_PHPBackend_entries; ! return @$pnML_PHPBackend_entries[$string]; ! } ! ! function translateByKey($key) ! { ! global $pnML_PHPBackend_keyEntries; ! return @$pnML_PHPBackend_keyEntries[$key]; ! } ! ! function load($translation_ctx) ! { ! list($ostype, $oslocale) = pnVarPrepForOS($translation_ctx['type'], ! $translation_ctx['locale']); ! ! $filename = "modules/$translation_ctx[moddir]/pnlang/php/$oslocale/pn$ostype.php"; ! if (!file_exists($filename)) { ! return false; ! } ! ! include $filename; ! ! return true; ! } ! ! } ! ! ?>
View Statistics - Next Notice - Previous Notice
Visit Developer Site - Browse CVS Repository |
Syndicate via backend.rss (max. once per hour please) | Powered by CVSNotice 0.1.3 |