Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.Lang.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Generated Header (not documented yet)
8  *
9  * @author Anakeen
10  * @version $Id: Class.Lang.php,v 1.2 2003/08/18 15:46:42 eric Exp $
11  * @package FDL
12  * @subpackage CORE
13  */
14 /**
15  */
16 // ---------------------------------------------------------------
17 // $Id: Class.Lang.php,v 1.2 2003/08/18 15:46:42 eric Exp $
18 // $Source: /home/cvsroot/anakeen/freedom/core/Class/Layout/Class.Lang.php,v $
19 // ---------------------------------------------------------------
20 // $Log: Class.Lang.php,v $
21 // Revision 1.2 2003/08/18 15:46:42 eric
22 // phpdoc
23 //
24 // Revision 1.1 2002/01/08 12:41:34 eric
25 // first
26 //
27 // Revision 1.9 2001/10/17 09:08:49 eric
28 // mise en place de i18n via gettext
29 //
30 // Revision 1.8 2001/02/26 15:05:31 yannick
31 // Optimization : Add a buffer
32 //
33 // Revision 1.7 2000/11/02 19:04:51 marc
34 // Simplification, affichage des code si pas de message.
35 //
36 // Revision 1.6 2000/10/23 14:23:55 marc
37 // Another release
38 //
39 // Revision 1.5 2000/10/19 16:34:45 yannick
40 // Pour Marc
41 //
42 // Revision 1.4 2000/10/19 10:31:04 marc
43 // Langues: suppression ancien catalogue lors du reload de l'app
44 //
45 // Revision 1.3 2000/10/19 10:15:13 marc
46 // Finalisation de l'internationalisation
47 //
48 // Revision 1.2 2000/10/18 20:15:17 marc
49 // Internationalisation
50 //
51 // Revision 1.1 2000/10/18 19:55:08 marc
52 // Internationalisation
53 //
54 //
55 // ---------------------------------------------------------------
56 include_once ('Class.DbObj.php');
57 include_once ('Class.QueryDb.php');
58 include_once ('Class.Log.php');
59 
60 class Lang extends DbObj
61 {
62 
63  var $fmttxt = "NO TEXT DEFINED";
64  var $fields = array(
65  "idapp",
66  "lang",
67  "code",
68  "fmt"
69  );
70  var $id_fields = array(
71  "idapp",
72  "lang",
73  "code"
74  );
75  var $dbtable = "lang";
76 
77  var $sqlcreate = '
78 create table lang (idapp int not null,
79 lang varchar(10) not null,
80 code varchar(60) not null,
81 fmt varchar(200) not null );
82 create index lang_idx1 on lang(idapp, lang, code);
83 ';
84 
85  var $buffer = array();
86 
87  function Exist($idapp, $code, $lang)
88  {
89  $query = new QueryDb($this->dbaccess, "Lang");
90  $query->basic_elem->sup_where = array(
91  "idapp={$idapp}",
92  "lang='{$lang}'",
93  "code='{$code}'"
94  );
95  $query->Query();
96 
97  if ($query->nb == 0) return FALSE;
98  return TRUE;
99  }
100 
101  function SetEnv($id, $lang, $deflang)
102  {
103  $this->idapp = $id;
104  $this->lang = $lang;
105  $this->deflang = $lang;
106  $query = new QueryDb($this->dbaccess, "Lang");
107  $query->basic_elem->sup_where = array(
108  "idapp={$id}",
109  "lang='{$deflang}'"
110  );
111  $lista = $query->Query();
112  $query->basic_elem->sup_where = array(
113  "idapp={$id}",
114  "lang='{$lang}'"
115  );
116  $listb = $query->Query();
117  $list = array_merge($lista, $listb);
118  reset($list);
119  foreach ($list as $k => $v) {
120  $this->buffer[$v->code] = $v->fmt;
121  }
122  }
123 
124  function Store($idapp, $code, $lang, $fmt)
125  {
126  $this->idapp = $idapp;
127  $this->lang = $lang;
128  $this->code = $code;
129  $this->fmt = $fmt;
130  if ($this->exist($idapp, $code, $lang)) {
131  $this->Modify();
132  } else {
133  $this->Add();
134  }
135  }
136 
137  function Get($idapp, $lang, $code, $args = NULL)
138  {
139 
140  $query = new QueryDb($this->dbaccess, "Lang");
141  $query->basic_elem->sup_where = array(
142  "idapp={$idapp}",
143  "lang='{$lang}'",
144  "code='{$code}'"
145  );
146  $list = $query->Query();
147 
148  if ($query->nb <= 0) {
149  $this->fmttxt = "**{$code}**";
150  return FALSE;
151  }
152 
153  $uf = $list[0]->fmt;
154  if ($args == NULL) {
155  $this->fmttxt = $uf;
156  } else {
157  $nfmt = preg_replace("/%([0-9]+)%/", "{\$args[\\1]}", $uf);
158  eval("\$out = \"$nfmt\";");
159  $this->fmttxt = $out;
160  }
161  return TRUE;
162  }
163  function GetText($code, $args = NULL)
164  {
165  if (!isset($this->buffer[$code])) return FALSE;
166  $uf = $this->buffer[$code];
167  if ($args == NULL) {
168  $this->fmttxt = $uf;
169  } else {
170  $nfmt = preg_replace("/%([0-9]+)%/", "{\$args[\\1]}", $uf);
171  eval("\$out = \"$nfmt\";");
172  $this->fmttxt = $out;
173  }
174  return TRUE;
175  }
176 
177  function deletecatalog($idapp)
178  {
179  $query = new QueryDb($this->dbaccess, "Lang");
180  $query->basic_elem->sup_where = array(
181  "idapp={$idapp}"
182  );
183  $list = $query->Query();
184  if ($query->nb > 0) {
185  foreach ($list as $k => $v) $v->delete();
186  }
187  }
188 } // End Class
$sqlcreate
Definition: Class.Lang.php:77
if(substr($wsh, 0, 1)!= '/') $args
GetText($code, $args=NULL)
Definition: Class.Lang.php:163
Add($nopost=false, $nopre=false)
$lang
Definition: lang.php:18
Store($idapp, $code, $lang, $fmt)
Definition: Class.Lang.php:124
Get($idapp, $lang, $code, $args=NULL)
Definition: Class.Lang.php:137
$id_fields
Definition: Class.Lang.php:70
$dbtable
Definition: Class.Lang.php:75
if(($docid!==0)&&(!is_numeric($docid))) $query
SetEnv($id, $lang, $deflang)
Definition: Class.Lang.php:101
Exist($idapp, $code, $lang)
Definition: Class.Lang.php:87
deletecatalog($idapp)
Definition: Class.Lang.php:177
← centre documentaire © anakeen