/[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.4 by joko, Thu Dec 19 06:18:40 2002 UTC revision 1.6 by joko, Sun Feb 9 17:33:54 2003 UTC
# Line 3  Line 3 
3  //    $Id$  //    $Id$
4  //    ------------------------------------------------------------------  //    ------------------------------------------------------------------
5  //    $Log$  //    $Log$
6    //    Revision 1.6  2003/02/09 17:33:54  joko
7    //    + minor update related to new log level constants
8    //
9    //    Revision 1.5  2002/12/19 10:30:06  joko
10    //    + argument 'newMode' for function getlt and function _getldsvar: let _getldsvar evaluate variable to still provide old behaviour/functionality
11    //
12  //    Revision 1.4  2002/12/19 06:18:40  joko  //    Revision 1.4  2002/12/19 06:18:40  joko
13  //    + '$this->site' gets used here now  //    + '$this->site' gets used here now
14  //  //
# Line 56  class LocaleText { Line 62  class LocaleText {
62    // ----------------------------------------------------    // ----------------------------------------------------
63    function LocaleText() {    function LocaleText() {
64    
     /*  
     // was:  
     global $cfg, $slt;  
     session_register_safe('slt');  
     $this->langs_avail = $cfg[GLBL_LANGSAVAIL];  
     $this->load();  
     */  
       
65      // look at the bottom of this file!!!      // look at the bottom of this file!!!
66      //$smarty->register_block("translate", "do_translation");      //$smarty->register_block("translate", "do_translation");
67      //$this->site->smarty->register_block("translate", "_do_translation");      //$this->site->smarty->register_block("translate", "_do_translation");
# Line 74  class LocaleText { Line 72  class LocaleText {
72    }    }
73    
74    function start() {    function start() {
75      global $cfg, $slt;      global $app, $slt;
76      session_register_safe('slt');      session_register_safe('slt');
77      $this->langs_avail = $cfg[GLBL_LANGSAVAIL];      $this->langs_avail = $app->getConfig("languages.available");
78      $this->load();      $this->load();
79    }    }
80    
# Line 110  class LocaleText { Line 108  class LocaleText {
108        return $langs_avail[0];        return $langs_avail[0];
109      }      }
110    }    }
111      
112      // TODO: refactor this to Data::Deep  
113    function _dbkey2ldskey($dbkey) {    function _dbkey2ldskey($dbkey) {
114      // TODO: log this      // TODO: log this
115      //dprint("dbkey: $dbkey");      //dprint("dbkey: $dbkey");
# Line 124  class LocaleText { Line 123  class LocaleText {
123      }      }
124    }    }
125        
126    function _getldsvar($ldskey, $tpl=array()) {    // TODO: refactor this to Data::Deep  
127      function _getldsvar($ldskey, $tpl=array(), $newMode = 0) {
128            
129  //print "ldskey: $ldskey<br>";  //print "ldskey: $ldskey<br>";
130    
# Line 135  class LocaleText { Line 135  class LocaleText {
135      // interpolate variable-name      // interpolate variable-name
136      $var_value = eval($eval_string);      $var_value = eval($eval_string);
137      // interpolate variable-value to do some template-vars      // interpolate variable-value to do some template-vars
138      //$var_value = eval("return \"$var_value\";");      if (!$newMode) {
139          $var_value = eval("return \"$var_value\";");
140        }
141    
142      // V1 - result interpolation using eval      // V1 - result interpolation using eval
143      // print $eval_string."<br>";      // print $eval_string."<br>";
# Line 148  class LocaleText { Line 150  class LocaleText {
150      return $var_value;      return $var_value;
151    }    }
152        
153      // TODO: refactor this to Data::Deep  
154    function _setldsvar($ldskey, $val) {    function _setldsvar($ldskey, $val) {
155      $var_name = '$this->lds' . $ldskey;      $var_name = '$this->lds' . $ldskey;
156      $value_new = addslashes($val);      $value_new = addslashes($val);
# Line 159  class LocaleText { Line 162  class LocaleText {
162        
163    function _loadStructure_FromDb() {    function _loadStructure_FromDb() {
164      //global $site;      //global $site;
165      $this->site->log( get_class($this) . "->_loadStructure_FromDb loading language information", LOG_DEBUG);      $this->site->log( get_class($this) . "->_loadStructure_FromDb loading language information", PEAR_LOG_DEBUG);
166      //print "- loading structure from db ($this->langkey)<br>";      //print "- loading structure from db ($this->langkey)<br>";
167      //connectdb();      //connectdb();
168      $sql = "SELECT * FROM td_res_langtext WHERE countrykey='" . $this->langkey . "'";      $sql = "SELECT * FROM td_res_langtext WHERE countrykey='" . $this->langkey . "'";
# Line 171  class LocaleText { Line 174  class LocaleText {
174            $this->_loadStructure_FromDb_add($row["tkey"], $row["tval"]);            $this->_loadStructure_FromDb_add($row["tkey"], $row["tval"]);
175        }        }
176      }      }
177      $this->site->log( get_class($this) . "->_loadStructure_FromDb ready", LOG_DEBUG);      $this->site->log( get_class($this) . "->_loadStructure_FromDb ready", PEAR_LOG_DEBUG);
178    }    }
179        
180    function _loadStructure_FromDb_add($dbkey, $val) {    function _loadStructure_FromDb_add($dbkey, $val) {
# Line 219  class LocaleText { Line 222  class LocaleText {
222      return $this->lds;      return $this->lds;
223    }    }
224        
225    function getlt($key, $tpl=array()) {    function getlt($key, $tpl=array(), $newMode = 0) {
226      //dprint("getlt: $key");      //dprint("getlt: $key");
227      if ($ldskey = $this->_dbkey2ldskey($key)) {      if ($ldskey = $this->_dbkey2ldskey($key)) {
228        return $this->_getldsvar($ldskey, $tpl);        return $this->_getldsvar($ldskey, $tpl, $newMode);
229      }      }
230    }    }
231    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.6

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