/[cvs]/nfo/php/libs/org.netfrag.flib/Application/l10n/LocaleText.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.flib/Application/l10n/LocaleText.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by jonen, Wed Dec 4 07:40:05 2002 UTC revision 1.5 by joko, Thu Dec 19 10:30:06 2002 UTC
# Line 3  Line 3 
3  //    $Id$  //    $Id$
4  //    ------------------------------------------------------------------  //    ------------------------------------------------------------------
5  //    $Log$  //    $Log$
6    //    Revision 1.5  2002/12/19 10:30:06  joko
7    //    + argument 'newMode' for function getlt and function _getldsvar: let _getldsvar evaluate variable to still provide old behaviour/functionality
8    //
9    //    Revision 1.4  2002/12/19 06:18:40  joko
10    //    + '$this->site' gets used here now
11    //
12  //    Revision 1.3  2002/12/04 07:40:05  jonen  //    Revision 1.3  2002/12/04 07:40:05  jonen
13  //    + comment out dprint  //    + comment out dprint
14  //  //
# Line 52  class LocaleText { Line 58  class LocaleText {
58        
59    // ----------------------------------------------------    // ----------------------------------------------------
60    function LocaleText() {    function LocaleText() {
61    
62        /*
63        // was:
64        global $cfg, $slt;
65        session_register_safe('slt');
66        $this->langs_avail = $cfg[GLBL_LANGSAVAIL];
67        $this->load();
68        */
69        
70        // look at the bottom of this file!!!
71        //$smarty->register_block("translate", "do_translation");
72        //$this->site->smarty->register_block("translate", "_do_translation");
73    
74        //global $site;
75        //$site->smarty->register_block("translate", "_do_translation");
76    
77      }
78    
79      function start() {
80      global $cfg, $slt;      global $cfg, $slt;
81      session_register_safe('slt');      session_register_safe('slt');
82      $this->langs_avail = $cfg[GLBL_LANGSAVAIL];      $this->langs_avail = $cfg[GLBL_LANGSAVAIL];
# Line 102  class LocaleText { Line 127  class LocaleText {
127      }      }
128    }    }
129        
130    function _getldsvar($ldskey, $tpl=array()) {    function _getldsvar($ldskey, $tpl=array(), $newMode = 0) {
131        
132    //print "ldskey: $ldskey<br>";
133    
134      $var_name = '$this->lds' . $ldskey;      $var_name = '$this->lds' . $ldskey;
135      $eval_string = "return $var_name;";      $eval_string = "return $var_name;";
136      //print $eval_string . "<br>";      //print $eval_string . "<br>";
137    
138      // interpolate variable-name      // interpolate variable-name
139      $var_value = eval($eval_string);      $var_value = eval($eval_string);
140      // interpolate variable-value to do some template-vars      // interpolate variable-value to do some template-vars
141      $var_value = eval("return \"$var_value\";");      if (!$newMode) {
142          $var_value = eval("return \"$var_value\";");
143        }
144    
145        // V1 - result interpolation using eval
146      // print $eval_string."<br>";      // print $eval_string."<br>";
147      //$var_value = $$var_name;      //$var_value = $$var_name;
148    
149        // V2 - result interpolation using smarty
150        //print Dumper($tpl);
151        //$this->site->loadTemplate();
152    
153      return $var_value;      return $var_value;
154    }    }
155        
# Line 125  class LocaleText { Line 163  class LocaleText {
163    }    }
164        
165    function _loadStructure_FromDb() {    function _loadStructure_FromDb() {
166      global $site;      //global $site;
167      $site->log( get_class($this) . "->_loadStructure_FromDb loading language information", LOG_DEBUG);      $this->site->log( get_class($this) . "->_loadStructure_FromDb loading language information", LOG_DEBUG);
168      //print "- loading structure from db ($this->langkey)<br>";      //print "- loading structure from db ($this->langkey)<br>";
169      //connectdb();      //connectdb();
170      $sql = "SELECT * FROM td_res_langtext WHERE countrykey='" . $this->langkey . "'";      $sql = "SELECT * FROM td_res_langtext WHERE countrykey='" . $this->langkey . "'";
171      if ($result = $site->db->query($sql)) {      if ($result = $this->site->db->query($sql)) {
172        //while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {        //while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
173        while ( $result->fetchInto($row) ) {        while ( $result->fetchInto($row) ) {
174           //print $row[tval]."<br>";           //print $row[tval]."<br>";
# Line 138  class LocaleText { Line 176  class LocaleText {
176            $this->_loadStructure_FromDb_add($row["tkey"], $row["tval"]);            $this->_loadStructure_FromDb_add($row["tkey"], $row["tval"]);
177        }        }
178      }      }
179      $site->log( get_class($this) . "->_loadStructure_FromDb ready", LOG_DEBUG);      $this->site->log( get_class($this) . "->_loadStructure_FromDb ready", LOG_DEBUG);
180    }    }
181        
182    function _loadStructure_FromDb_add($dbkey, $val) {    function _loadStructure_FromDb_add($dbkey, $val) {
# Line 186  class LocaleText { Line 224  class LocaleText {
224      return $this->lds;      return $this->lds;
225    }    }
226        
227    function getlt($key, $tpl=array()) {    function getlt($key, $tpl=array(), $newMode = 0) {
228      //dprint("getlt: $key");      //dprint("getlt: $key");
229      if ($ldskey = $this->_dbkey2ldskey($key)) {      if ($ldskey = $this->_dbkey2ldskey($key)) {
230        return $this->_getldsvar($ldskey, $tpl);        return $this->_getldsvar($ldskey, $tpl, $newMode);
231      }      }
232    }    }
233    
234  }  }
235    
236    
237    
238    /*
239    Example 13-17. register_block
240    taken from: http://smarty.php.net/manual/en/api.register.block.html
241    will be triggered by this template-code:
242      {* template *}
243      {translate lang="br"}
244         Hello, world!
245      {/translate}
246    */
247    
248      /* PHP */
249      //global $smarty;
250      //$smarty->register_block("translate", "do_translation");
251    
252    /*  
253      function _do_translation ($params, $content, &$smarty) {
254          print "do_translation<br>";
255          print "params: " . Dumper($params) . "<br>";
256          print "content: $content<br>";
257          if ($content) {
258              //$lang = $params['lang'];
259              // do some translation with $content
260              //echo $translation;
261              return getlt($content);
262          }
263      }
264    */
265      
266  ?>  ?>

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.5

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed