DataObjects/I18n.php
[Pman.Core] / DataObjects / I18n.php
1 <?php
2 /**
3  * Table Definition for i18n
4  *
5  * This is heavily related to the Pman_I18n implementation..
6  *
7  * It should eventually replace most of that..
8  * 
9  */
10 require_once 'DB/DataObject.php';
11
12 class Pman_Core_DataObjects_I18n extends DB_DataObject 
13 {
14     ###START_AUTOCODE
15     /* the code below is auto generated do not remove the above tag */
16
17     public $__table = 'i18n';                            // table name
18     public $id;                              // int(11)  not_null primary_key auto_increment
19     public $ltype;                           // string(1)  not_null multiple_key
20     public $lkey;                            // string(8)  not_null
21     public $inlang;                          // string(8)  not_null
22     public $lval;                            // string(64)  not_null
23
24     
25     /* the code above is auto generated do not remove the tag below */
26     ###END_AUTOCODE
27     
28     static $cfg; // the default configuration.
29     
30     function applyFilters($q, $au)
31     {
32         
33         //DB_DataObject::debugLevel(1);
34         if (!empty($q['query']['_with_en'])) {
35             $this->selectAdd("
36                 i18n_translate(ltype, lkey, 'en') as lval_en
37                 
38             ");
39         }
40     }
41     
42     function loadDefault()
43     {
44         /// 
45         
46         
47         
48     }
49     function buildDB($ltype= false, $inlang= false )
50     {
51         if ($ltype === false) {
52             die("OOPS NO LTYPE");
53         }
54         if ($inlang == '**') {
55             return; // dont bother building generic..
56         }
57         
58         
59         if ($inlang === false) {
60             foreach( $this->cfg['t'] as $l) {
61                 $this->buildDB($ltype, $l);
62             }
63             return;
64         }
65         
66         $list =  $this->getDefaultCfg($ltype);
67         
68         DB_DataObject::debugLevel(1);
69         
70         foreach($list as $lkey) {
71             $x = DB_DataObject::factory('i18n');
72             $x->ltype = $ltype;
73             $x->lkey = $lkey;
74             $x->inlang= $inlang;
75             if ($x->find(true)) {
76                 $xx= clone($x);
77                 $x->lval = $this->translate($inlang, $ltype, $lkey);
78                 $x->update($xx);
79                 continue;
80             }
81             $x->lval = $this->translate($inlang, $ltype, $lkey);
82             $x->insert();
83             
84         }
85         
86         
87         
88         
89     }
90     
91     
92 }