Esempio n. 1
0
 public function getAllTranslations()
 {
     $this->initConnection();
     $result = array();
     $node = array();
     $language_ids = array();
     $node['id'] = $this->slide_id;
     $node['language'] = $this->getLanguage();
     if (!isset($node['language']['id'])) {
         $node['language']['id'] == 'xh';
         $node['language']['name'] == 'undefined';
     }
     $result = $this->getTranslatedTo(true);
     foreach ($result as $lang) {
         $language_ids[] = $lang['language']['id'];
     }
     if (!in_array($node['language']['id'], $language_ids)) {
         $language_ids[] = $node['language']['id'];
         $result[] = $node;
     }
     $visited = array();
     foreach ($result as $node) {
         $visited[] = $node['id'];
     }
     $parent = $this->translated_from;
     while ($parent) {
         $parent_slide = new Slide();
         $parent_slide->slide_id = $parent;
         $parent_slide->language = $parent_slide->getLanguage();
         $parent_slide->translated_from = $parent_slide->getTranslatedFrom();
         if (!in_array($parent_slide->language['id'], $language_ids)) {
             $parent_arr = array();
             $parent_arr['id'] = $parent;
             $parent_arr['language'] = $parent_slide->language;
             $result[] = $parent_arr;
             $language_ids[] = $parent_arr['language']['id'];
         }
         foreach ($parent_slide->getTranslatedTo(true) as $node) {
             if (!in_array($node['id'], $visited) && !in_array($node['language']['id'], $language_ids)) {
                 $visited[] = $node['id'];
                 $result[] = $node;
                 $language_ids[] = $node['language']['id'];
             }
         }
         $parent = $parent_slide->translated_from;
     }
     return $result;
 }