Пример #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;
 }
Пример #2
0
 public function getCreateSlide($user_id = false, $slide_id = false, $start, $end, $keywords = '')
 {
     if ($user_id != false || $slide_id != false) {
         $this->initConnection();
         $activities = array();
         $result = array();
         if ($user_id) {
             $user = new User();
             $user->id = $user_id;
             $user->getUsername();
             if (strlen($keywords)) {
                 $result = $this->dbQuery('SELECT * FROM slide_revision WHERE user_id=:user_id AND based_on IS NULL AND translated_from_revision IS NULL AND MATCH (slide_revision.content) AGAINST (\'' . $keywords . '*\' IN BOOLEAN MODE)', array('user_id' => $user_id));
             } else {
                 $result = $this->dbQuery('SELECT * FROM slide_revision WHERE user_id=:user_id AND based_on IS NULL AND translated_from_revision IS NULL AND timestamp >= "' . $start . '" AND timestamp < "' . $end . '"', array('user_id' => $user_id));
             }
             if (count($result)) {
                 foreach ($result as $row) {
                     $slide = new Slide();
                     $slide->id = $row['id'];
                     $slide->slide_id = $slide->getBasicId();
                     $slide->id = $slide->getLastRevisionID();
                     $slide->createFromIDLite($slide->id);
                     $slide->title = $slide->getTitle();
                     if ($slide->title == "") {
                         $slide->title = "Untitled";
                     }
                     $activity = new Activity($row['timestamp'], $user, 'created_slide', $slide);
                     $activities[] = $activity;
                 }
             }
         } else {
             $result = $this->dbQuery('SELECT * FROM slide_revision WHERE slide=:slide_id AND timestamp >= "' . $start . '" AND timestamp < "' . $end . '"', array('slide_id' => $slide_id));
             if (count($result)) {
                 foreach ($result as $row) {
                     $slide = new Slide();
                     $slide->createFromIDLite($row['id']);
                     $slide->title = $slide->getTitle();
                     if ($slide->title == "") {
                         $slide->title = "Untitled";
                     }
                     $user = new User();
                     $user->id = $row['user_id'];
                     $user->getUsername();
                     if ($row['translated_from_revision']) {
                         $based_on = new Slide();
                         $based_on->id = $row['translated_from_revision'];
                         $based_on->slide_id = $based_on->getBasicId();
                         $based_on->language = $based_on->getLanguage();
                         $activity = new Activity($row['timestamp'], $user, 'translated_slide_from', $slide, $based_on);
                     } else {
                         if (!$row['based_on']) {
                             $activity = new Activity($row['timestamp'], $user, 'created_slide', $slide);
                         } else {
                             $based_on = new Slide();
                             $based_on->id = $row['based_on'];
                             $based_on->slide_id = $based_on->getBasicId();
                             $based_on->translator_id = $based_on->getTranslatorId();
                             if ($based_on->translator_id == $row['translator_id']) {
                                 $activity = new Activity($row['timestamp'], $user, 'created_slide_revision', $slide);
                             } else {
                                 $activity = new Activity($row['timestamp'], $user, 'translated_slide_revision', $slide);
                             }
                         }
                     }
                     $activities[] = $activity;
                 }
             }
         }
         if (count($activities)) {
             foreach ($activities as $activity) {
                 $this->activities[] = $activity;
             }
         }
     }
 }