OutputTranslations.php
[Pman.Cms] / OutputTranslations.php
1 <?php
2
3 require_once 'Pman.php'; /// needed as we might not be included from pman..
4
5 class Pman_Cms_OutputTranslations extends Pman
6 {
7     var $lang = 'en';
8     
9     function get($lang)
10     {
11         if(!empty($lang)){
12             $this->lang = $lang;
13         }
14         
15         $ret = array();
16         $template = DB_DataObject::factory('cms_template');
17
18         foreach ($template->fetchAll() as $tmpl){
19             $base = DB_DataObject::factory('cms_templatestr');
20             $base->setFrom(array(
21                 'template_id' => $template->id,
22                 'lang' => '',
23                 'active' => 1
24             ));
25             $base = $base->fetchAll('id');
26             
27             $translation = DB_DataObject::factory('cms_templatestr');
28             $translation->autoJoin();
29             $translation->setFrom(array(
30                 'template_id' => $template->id,
31                 'lang' => $this->lang,
32                 'active' => 1
33             ));
34             $translation->whereAddIn('cms_templatestr.src_id', $base, 'int');
35             
36             foreach ($translation->fetchAll() as $t){
37                 if(!isset($ret[$tmpl->template])){
38                     $ret[$tmpl->template] = array();
39                 }
40                 
41                 $ret[$tmpl->template][$t->src_id_mdsum] = (empty($t->txt)) ? $t->src_id_txt : $t->txt;
42             }
43         }
44         print_R($ret);exit;
45         return $ret;
46     }
47     
48 }