4efb322be219492382d4ded85b9db9dc16f10f9b
[Pman.Core] / DataObjects / Core_templatestr.php
1 <?php
2 /**
3  * Table Definition for core_templatestr
4  *
5  *
6  * The idea here is that it contains all the strings in the templates with a language '' (empty)
7  * , it then generates a matching set of strings
8  * 
9  */
10 class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
11
12 class Pman_Core_DataObjects_Core_templatestr extends DB_DataObject 
13 {
14     ###START_AUTOCODE
15     /* the code below is auto generated do not remove the above tag */
16
17     public $__table = 'core_templatestr';         // table name
18     public $id;                              // int(11)  not_null primary_key auto_increment
19     public $template_id;                           // string(64)  not_null
20     public $txt;                    // datetime(19)  multiple_key binary
21     public $updated;                        // blob(65535)  blob
22     public $src_id;                          // int(11)  not_null
23     public $lang;    // text  NOT NULL;
24     public $mdsum;    // text  NOT NULL;
25     public $active;
26     public $on_table;
27     public $on_id;
28     public $on_col;
29  
30     /* the code above is auto generated do not remove the tag below */
31     ###END_AUTOCODE
32     
33     function beforeInsert($q,$roo)
34     {
35         if(!empty($q['_rescan'])){
36             $this->syncLang($q['_rescan']);
37             $roo->jok('OK');
38         }
39     }
40     
41     
42     function applyFilters($q, $au, $roo)
43     {
44         if (!empty($q['_tree'])) {
45             $this->applyFiltersTree($q,$roo);
46         }
47         
48         if(!empty($q['on_table']) && (empty($q['template_id']) || !is_numeric($q['template_id']))){
49             $this->template_id = 0;
50              $this->whereAdd("  join_src_id_id.txt != ''");
51         }
52         if (!empty($q['_search_txt'])) {
53             $str = $this->escape($q['_search_txt']);
54             $this->whereAdd("core_templatestr.txt like '%{$str}%' OR join_src_id_id.txt like '%{$str}%'");
55             
56         }
57     }
58     function translateTableCol($obj, $col, $lang)
59     {
60         $cts = DB_DataObject::factory('core_templatestr');
61         $cts->lang = $lang;
62         $cts->on_table = $obj->tableName();
63         $cts->on_id = $obj->pid();
64         $cc = clone($cts);
65         if(!$cts->find(true)){
66             return $obj->$col;
67         }
68         
69         
70         if(empty($cts->txt)){
71             return $obj->$col;
72         }
73             
74         return $cts->txt;
75     }
76     /**
77      *
78      * insert the origanal table text
79      * 
80      * @param type $roo
81      * @param type $obj
82      * @param type $chg
83      * @return type 
84      */
85     function onTableChange($roo, $obj, $chg)
86     {
87         
88         $ff = HTML_FlexyFramework::get()->Pman_Core;
89             
90         if(empty($ff['DataObjects_Core_templatestr']['tables'])){
91             return;
92         }
93         $tn = $obj->tableName();
94         if(empty($ff['DataObjects_Core_templatestr']['tables'][$tn])){
95             return;
96         }
97         $cols = $ff['DataObjects_Core_templatestr']['tables'][$tn];
98         
99         $deactive = array();
100
101
102         foreach($cols as $c) {
103             $x = $this->factory($this->tableName());
104             $x->on_id = $obj->pid();
105             $x->on_table = $tn;
106             $x->on_col = $c;
107             $x->lang = ''; /// eg. base language..
108             $up = $x->find(true);
109             if ($up && $x->txt == $obj->$c) {
110
111                 // deactivate empty words
112                 if(empty($obj->$c)) {
113                     $deactive[] = $x->id;
114                 }
115                 else {
116                     $active[] = $x->id;
117                 }
118                 continue;
119             }
120
121             // skip empty words
122             if(empty($obj->$c)) {
123                 continue;
124             }
125             $x->active = 1;
126             $x->src_id = 0;
127             $x->txt = $obj->$c;
128             $x->mdsum = md5($obj->$c);
129             $x->template_id = 0;
130             $x->updated = date('Y-m-d H:i:s', strtotime("NOW"));
131             $up ? $x->update() : $x->insert();
132         }
133
134         if(count($deactive)) {
135             $t = DB_DataObject::factory($this->tableName());
136             // deactivate the parent data
137             $t->query("UPDATE core_templatestr
138                       SET active = 0 WHERE id in (" . implode(',' ,$deactive) . ")
139                      ");
140
141             // deactivate the child data
142             $t->query("UPDATE  core_templatestr 
143             SET active = 0
144             WHERE
145                 src_id IN (". implode(',' ,$deactive) . ")
146                 AND
147                 lang != ''
148              ");
149         }
150
151         if(count($active)) {
152             $t = DB_DataObject::factory($this->tableName());
153             $t->query("UPDATE core_templatestr
154                 SET active = 1 WHERE id in (" . implode(',' ,$active) . ")
155             ");
156
157             $t->query("UPDATE  core_templatestr 
158             SET active = 1
159               WHERE
160                  src_id IN (". implode(',' ,$active) . ")
161                 AND
162                 lang != ''
163             ");
164         }
165         
166         
167     }
168     
169     
170     function applyFiltersTree($q,$roo)
171     {
172         if (empty($q['node'])) {
173             $roo->jerr("invalid node");
174         }
175         switch(true) {
176             
177             case ($q['node'] == 'transtree'):
178             case ($q['node'] == 'langlist'):
179                // DB_DataObject::debugLevel(1);
180                 $x = DB_Dataobject::Factory($this->tableName());
181                 $x->selectAdd();
182                 $x->selectAdd('distinct(lang) as lang');
183                 
184                 $x->selectAdd("i18n_translate('l', lang, 'en') as lang_name");
185                 $x->whereAdd("lang != ''");
186                 $ret= array();
187                 foreach( $x->fetchAll() as $l) {
188                     $ret[] = array(
189                         'text'=>$l->lang_name,
190                         'id' => $q['node'] == 'langlist' ? $l->lang : 'lang:'.$l->lang ,
191                         'language' => true
192                     );
193                 }
194                 if (empty($ret)) {
195                     $ret[] = array(
196                         'text'=>'English',
197                         'id' => 'lang:en',
198                         'language' => true
199                     );
200                 }
201                 $roo->jdata($ret);
202             
203             case  preg_match('/^lang:/', $q['node']):
204                 
205                 $lang = preg_replace('/^lang:/', '', $q['node']);
206                 $ret= array();  
207                 $x = DB_DataObject::factory('core_templatestr');
208                 $x->autoJoin();
209                 $x->selectAdd();
210                 $x->selectAdd('distinct(view_name) as view_name');
211                 $x->lang = $lang;
212                 $x->whereAdd('join_template_id_id.is_deleted = 0');
213                 $x->orderBy('view_name DESC');
214                 $x->find();
215                 while($x->fetch()) {
216                     $ret[] = array( 
217                         'text'=> $x->view_name,
218                         'id' => 'view:'. $lang .':'.  $x->view_name,
219                         'leaf' => false
220                     );
221                 }
222
223                 $ff = HTML_FlexyFramework::get()->Pman_Core;
224
225                 if(!empty($ff['DataObjects_Core_templatestr']['tables'])){
226                     foreach($ff['DataObjects_Core_templatestr']['tables'] as $table=>$v){
227                         $ret[] = array(
228                             'text'=> $table,
229                             'on_table' => $table,
230                             'id' => 'table:'. $lang .':'. $table,
231                             'leaf' => true
232                         );
233                     }
234                 }
235                 
236                  
237                 $roo->jdata($ret);
238                 
239                 break;
240                 
241                 
242             case  preg_match('/^view:/', $q['node']):
243                 
244                
245                 $bits= explode(":",preg_replace('/^view:/', '', $q['node']));
246                 
247                 $x = DB_DataObject::factory($this->tableName());
248                 $x->autoJoin();
249                 $x->selectAdd();
250                 $x->selectAdd('distinct(core_templatestr.template_id) as template_id');
251                 $x->whereAdd("join_template_id_id.view_name = '{$x->escape($bits[1])}'");
252                 $x->whereAdd('join_template_id_id.is_deleted = 0');
253                 $x->lang = $bits[0];
254                 $ids = $x->fetchAll('template_id');
255                 
256                 $ret= array();
257                 //add the table type lists
258                 /*
259                 $ff = HTML_FlexyFramework::get()->Pman_Core;
260                 
261                 
262 //                $x->orderBy('template ASC');
263 //                $x->whereAdd("lang != ''");
264                 */
265                 //below are old code
266                 $xx = DB_Dataobject::Factory('core_template');
267                 $xx->whereAddIn('id', $ids, 'int');
268                 $xx->selectAdd();
269                 $xx->selectAdd("
270                                
271                     id, concat(  template) as template_name
272                 ");
273                 $xx->orderBy('template_name ASC');
274                 
275                 foreach( $xx->fetchAll('id', 'template_name') as $l =>$n) {
276                     $ret[] = array(
277                         'text'=> $n,
278                         'id' => $l,
279                         'leaf' => true
280                     );
281                 }
282                 
283                 $roo->jdata($ret);
284                  break;
285         }
286                 
287         
288         
289     }
290     
291     
292     /**
293      *
294      * 
295      * @param object $tmpl core_template data object
296      * @param array $words array of words 
297      */ 
298     function syncTemplateWords($tmpl, $keyvalue = false)
299     {
300         
301         $words = $tmpl->words;
302         // mapping for template : 
303         //tablename => $n (templatename) 
304         //tableid => $k (key value)
305         //colname => $n (templatename) 
306         // mdsum => md5(sum)
307         //
308         //print_r($words);exit;
309         // grab original
310         $tt = DB_DataObject::factory($this->tableName());
311  
312         $t = clone($tt);
313         $t->template_id = $tmpl->id;
314         $t->whereAdd("lang = ''");
315         
316         
317         // we have a situation where old md sums where created..
318         
319         
320         
321         $cur = $t->fetchAll('mdsum', 'id'); 
322         
323         
324         
325         
326         
327         
328         
329         // now loop through current..
330         $cwords = array();// not in used??
331         $active = array();
332 //        echo "sync Template Words... \n";
333 //        print_r($words);
334         
335         foreach($words as $k=>$v) {
336             
337             
338             $v = trim($v);
339
340             // skip empty words
341             if(empty($v)) {
342                 continue;
343             }
344             
345             $md = $keyvalue ? $k : md5($v);
346             
347             // check to see if there are more that one versions of that md5
348             
349             
350             if (!isset($cur[$md])) {
351                 // create a record for it..
352                 $t = DB_DataObject::factory($this->tableName());
353                 $t->setFrom(array(
354                     'txt' => $v,
355                     'lang' => '',// by default should a english 
356                     'updated' => date('Y-m-d H:i:s', strtotime("YESTERDAY")),
357                     'template_id'=>$tmpl->id,
358                     'mdsum' => $md,
359                     'src_id' => 0,
360                     'active' => 1,
361                 ));
362                 $active[] =  $t->insert();
363                 continue;
364             }  
365             $cur[$md] = $this->checkDupes($tmpl->id, '',  $cur[$md] , $md);
366             
367             $active[] = $cur[$md];
368             
369             // we have it already? - 
370             $t = DB_DataObject::factory($this->tableName());
371             $t->query("UPDATE {$this->tableName()}
372                         SET active= 1
373                         WHERE
374                         id = ".$cur[$md]);
375             unset($cur[$md]);
376             
377         }
378         // delete unused.
379         
380         
381         
382
383         $deactive = array();
384         if (count(array_values($cur))) {// de-active unused
385
386             $t = DB_DataObject::factory($this->tableName());
387 //            echo "de-active current?? \n";
388 //            print_r($cur);
389 //            echo "\n";
390             $deactive = array_values($cur);
391             $t->query("UPDATE core_templatestr
392                       SET active = 0 WHERE id in (" . implode(',' ,$deactive) . ")
393                      ");
394         }
395         
396         // delete all the items that are not relivant.
397         // clear orphaned chidren - it just blanks out the src id, so they can be used as suggestions..?
398         // this does not help - as it just puts random strings in there.. - with no reference to the original text..
399         $t = DB_DataObject::factory($this->tableName());
400     
401         // this will active the child data
402         if (empty($active)) {// set the active array to empty
403             $active = array(-1);
404         }
405         $t->query("UPDATE  core_templatestr 
406                 SET active = 1
407                   WHERE
408                      src_id IN (". implode(',' ,$active) . ")
409                     AND
410                     template_id = {$tmpl->id}
411         ");
412         //deactive the child data
413         if (empty($deactive)) {
414             $deactive = array(-1);
415         }
416         $t->query("UPDATE  core_templatestr 
417                 SET active = 0
418                   WHERE
419                     src_id IN (". implode(',' ,$deactive) . ")
420                     AND
421                     template_id = {$tmpl->id}
422                     AND
423                     lang != ''
424         ");
425     }
426     
427     function checkDupes($tid, $lang, $id, $mdsum) {
428         
429         $t = DB_DataObject::factory($this->tableName());
430         $t->template_id = $tid;
431         $t->mdsum = $mdsum;
432         $t->whereAdd("lang = '{$lang}'");
433         if ($t->count() == 1) {
434             return $id; // only got one ... no issues..
435         }
436         
437         //echo "GOT DUPES : $id, $lang, $id , $mdsum\n";
438         
439         //DB_DataObject::debugLevel(1);
440         // find out if any of them have got translations.
441         $ids = $t->fetchAll('id');
442         
443         
444         $t = DB_DataObject::factory($this->tableName());
445         $t->whereAddIn('src_id', $ids, 'int');
446         $t->whereAdd("txt != ''");
447         $t->orderBy('updated DESC');
448         if ($t->count()) {
449             $t->limit(1);
450             // do any translations exist?
451             $t->find(true);
452             $id = $t->src_id;
453         }
454         
455         
456         // delete all the others...
457         $t = DB_DataObject::factory($this->tableName());
458         $t->whereAddIn('src_id', $ids, 'int');
459         $t->whereAdd("src_id != $id");
460         $t->find();
461         while($t->fetch()) {
462             $tt = clone($t);
463             $tt->mdsum = $t->mdsum . '-bad-'. $t->id;
464             $tt->update($t);
465         }
466         $t = DB_DataObject::factory($this->tableName());
467         $t->whereAddIn('id', $ids, 'int');
468         $t->whereAdd("id != $id");
469         $t->find();
470         while($t->fetch()) {
471             $tt = clone($t);
472             $tt->mdsum = $t->mdsum . '-bad-'. $t->id;
473             $tt->update($t);
474         }
475         // this is done by calling code 
476         //$t = DB_DataObject::factory($this->tableName());
477         //$t->query("update core_templatestr set active= 1 where src_id = $id");
478         
479         
480         
481        //exit;
482         return $id;
483     
484                
485          
486     }
487     
488     function syncLang($lang)
489     {
490         // bugs with our old code...
491 //        die('in?');
492         $tn = $this->tableName();
493         $t = DB_DataObject::factory($tn);
494         $t->query("DELETE FROM {$tn} WHERE lang !='' AND src_id = 0 AND on_table  = ''");
495         
496         // find all the id's from lang that have not been generated..
497         
498         
499         static $id_tmp = false;
500         
501         if ($id_tmp == false) {
502             //find the origanal 
503             $t = DB_DataObject::factory($tn);
504             $t->whereAdd("lang = ''");
505             $t->active = 1;
506             
507             //old code, this did not support the on_table
508     //        $id_tmp = $t->fetchAll('id','template_id');
509     //        $ids = array_keys($id_tmp);
510             $id_tmp = array();
511             //new code for support the sync tables 
512             foreach($t->fetchAll() as $ori){
513                 $id_tmp[$ori->id] = $ori;
514             }
515         }
516         $ids = array_keys($id_tmp);
517         
518         // matching by language:
519         $t = DB_DataObject::factory($tn);
520         $t->whereAddIn('src_id', $ids , 'int');
521         $t->lang = $lang;
522         //$t->active = 1;
523         $got = $t->fetchAll('src_id');
524         $missing = array_diff($ids, $got);
525         
526         if (empty($missing)) {
527             return;
528         }
529         $t = DB_DataObject::factory($tn);
530         $q = "CREATE TEMPORARY TABLE core_templatestr_insert SELECT
531             id as src_id,
532             '' as txt,
533             '$lang' as lang,
534             NOW() as updated,
535             template_id,
536             on_table,
537             on_id,
538             on_col,
539             1 as active
540             FROM core_templatestr
541             WHERE
542             id IN (". implode(',', $missing) . ")
543         ";
544         //echo $q; exit;
545         DB_DataObject::factory($tn)->query($q);
546         $q = "INSERT INTO $tn (src_id, txt, lang, updated, template_id, on_table,on_id, on_col, active) SELECT * FROM core_templatestr_insert";
547         DB_DataObject::factory($tn)->query($q);
548         $q = "DROP TEMPORARY TABLE core_templatestr_insert";
549         DB_DataObject::factory($tn)->query($q);
550             
551       
552         
553     }
554     
555     // called from flexy to translate a string.
556     
557     
558     function translateFlexyString($flexy, $string)
559     {
560          $debug = false;;
561         //if (!empty($_REQUEST['_debug'])) { $debug= true; }
562         
563         // using $flexy->currentTemplate -> find the template we are looking at..
564         // then find the string for $flexy->options['locale']
565         //DB_DataObject::debugLevel(1);
566         if ($debug) { var_dump($string); }
567         
568         static $cache = array(); // cache of templates..
569         
570         $ff = HTML_FlexyFramework::get();
571         $view_name = isset($ff->Pman_Core['view_name']) ? $ff->Pman_Core['view_name'] : false;
572         if (empty($view_name)) {
573             $pg = HTML_FlexyFramework::get()->page;
574             if (isset($pg->templateViewName)) {
575                 $view_name = $pg->templateViewName;
576             }
577             
578         }
579         
580         
581         
582         if ($debug) { var_dump(array('view_name'=> $view_name)); }
583         
584         $tempdir = '';
585         foreach($flexy->options['templateDir'] as $td) {
586             if (substr($flexy->currentTemplate, 0, strlen($td)) == $td) {
587                 $tempdir = $td;
588                 break;
589             }
590         }
591         
592         
593         $tmpname = substr($flexy->currentTemplate, strlen($td) +1);
594         
595          
596         if (isset($cache[$tmpname]) && $cache[$tmpname] === false) {
597             if ($debug) { echo "from cache no match - $string\n"; }
598             return $string;
599         }
600         
601         if (!isset($cache[$tmpname])) {
602                 
603             
604             
605             $tmpl = DB_DataObject::factory('core_template');
606             if ($view_name !== false) {
607                 $tmpl->view_name = $view_name;
608             }
609             if(!$tmpl->get('template', $tmpname)){
610                 // strip of site prefix if set...
611                  
612                 $tmpl = DB_DataObject::factory('core_template');
613                 if(!$tmpl->get('template', $tmpname)){
614                     //var_dump("no template? {$tmpname} or {$relpath}" );
615                     $cache[$tmpname] = false;
616                     if ($debug) { echo "no template found - no match - $string\n"; }
617                     return $string;
618                 }
619             }
620             $cache[$tmpname] = $tmpl;
621         } else {
622             $tmpl = $cache[$tmpname] ;
623         }
624         
625         
626     
627         //get original template id
628         /*
629         $orig = DB_DataObject::factory($this->tableName());
630         $orig->lang = '';
631         $orig->template_id = $tmpl->id;
632         $orig->active = 1;
633         
634         $cache[$tmpname]->words = 
635         
636         if(!$orig->get( 'mdsum' , md5(trim($string)))){
637              //var_dump('no text? '. $string);
638             if ($debug) { echo "no original string found tplid: {$tmpl->id}\n"; }
639             return false;
640         }
641         */
642         
643         if (empty($cache[$tmpname]->translations)) {
644         
645             //find out the text by language
646             //DB_DataObject::DebugLevel(1);
647             $x = DB_DataObject::factory($this->tableName());
648             $x->lang = $flexy->options['locale'];
649             $x->template_id = $tmpl->id;
650             $x->autoJoin();
651             $cache[$tmpname]->translations = $x->fetchAll('src_id_mdsum', 'txt');
652             if (empty($cache[$tmpname]->translations)) {
653                 $cache[$tmpname]->translations = true;
654             }
655             //var_Dump($cache[$tmpname]->translations);
656         }
657         
658         
659         if ($cache[$tmpname]->translations === true) {
660             return $string;
661         }
662         //var_dump("Checking: " . md5(trim($string)));
663         
664         if (!empty($cache[$tmpname]->translations [md5(trim($string))])){
665            // var_dump("RETURNING: ". $cache[$tmpname]->translations [md5(trim($string))]);
666             return $cache[$tmpname]->translations [md5(trim($string))];
667         }
668         return $string;
669         
670     }
671     
672     
673     function translateChanged($flexy)
674     {
675         
676         $date = $this->lastUpdated($flexy);
677         if ($date === false) {
678             return false;
679         }
680         $utime = file_exists($flexy->compiledTemplate) ?  filemtime( $flexy->compiledTemplate) : 0;
681         return strtotime($date) >  $utime;
682     }
683     
684     // determine if a complied template need recompling
685     
686     function lastUpdated($flexy)
687     {
688         //return true;
689         // var_dump('check changed?');
690         //DB_DataObject::debugLevel(1);
691         //var_Dump(array($flexy->options['templateDir'][0], $flexy->currentTemplate));
692         
693         //var_dump($flexy->compiledTemplate);
694         $utime = file_exists($flexy->compiledTemplate) ?  filemtime( $flexy->compiledTemplate) : 0;
695         
696        
697         static $cache = array(); // cache of templates..
698         
699         $ff = HTML_FlexyFramework::get();
700         $view_name = isset($ff->Pman_Core['view_name']) ? $ff->Pman_Core['view_name'] : false;
701         
702         // find which of the template directories was actually used for the template.
703         
704         $tempdir = '';
705         foreach($flexy->options['templateDir'] as $td) {
706             if (substr($flexy->currentTemplate, 0, strlen($td)) == $td) {
707                 $tempdir = $td;
708                 break;
709             }
710         }
711         
712         
713         $tmpname = substr($flexy->currentTemplate, strlen($td) +1);
714         
715         // we do not have any record of this template..
716         if (isset($cache[$tmpname]) && $cache[$tmpname] === false) {
717             return false;
718         }
719         
720         if (!isset($cache[$tmpname])) {
721                 
722             
723             
724             $tmpl = DB_DataObject::factory('core_template');
725             if ($view_name !== false) {
726                 $tmpl->view_name = $view_name;
727             }
728             if(!$tmpl->get('template', $tmpname)){
729                 // strip of site prefix if set...
730                  
731                 $tmpl = DB_DataObject::factory('core_template');
732                 if(!$tmpl->get('template', $tmpname)){
733                     //var_dump("no template? {$tmpname} or {$relpath}" );
734                     $cache[$tmpname] = false;
735                     return false;
736                 }
737             }
738             $cache[$tmpname] = $tmpl;
739         } else {
740             $tmpl = $cache[$tmpname] ;
741         }
742           
743          
744         
745         $x = DB_DataObject::factory($this->tableName());
746         $x->lang = $flexy->options['locale'];
747         $x->active = 1;
748         $x->template_id = $tmpl->id;
749         //$x->whereAdd("updated > '". date('Y-m-d H:i:s', $utime)."'");
750         if ($x->count() < 1) {
751             return false; // we don't have any record of it.
752         }
753         $x->selectAdd();
754         $x->selectAdd('max(updated) as max_updated');
755         $x->find(true);
756         return $x->max_updated;
757         
758         
759     }
760     
761     function toRooArray($req) {
762         $ret = $this->toArray();
763
764         if (empty($req['csvCols'])) {
765             return $ret;
766         }
767
768         // for download
769
770         // translations for table columns
771         if(!empty($ret['on_table']) && !empty($ret['on_id']) && !empty($ret['on_col'])) {
772             $ret['template_id_view_name'] = 'database';
773             $ret['template_id_template'] = $ret['on_table'] . ':' . $ret['on_col'];
774         }
775
776         return $ret;
777     }
778
779     function postListFilter($ar, $au, $req)
780     {
781         if (empty($req['csvCols'])) {
782             return $ar;
783         }
784
785         // for download
786
787         $ret = array();
788
789         foreach($ar as $v) {
790             if(empty($v['on_table']) || empty($v['on_id']) || empty($v['on_col'])) {
791                 $ret[] = $v;
792                 continue;
793             }
794
795             // translations for table columns
796             // avoid duplicate (same src_id_mdsum, same on_table, same on_col, but different on_id)
797
798             $key = $v['on_table'] . ':' . $v['on_col'] . ':' . $v['src_id_mdsum'];
799
800             if(!empty($ret[$key])) {
801                 continue;
802             }
803
804             $ret[$key] = $v;
805         }
806
807         $ret = array_values($ret);
808         
809         return $ret;
810
811     }
812 }