Ejemplo n.º 1
0
 protected function formatCommentData($line, $time, $mode)
 {
     switch ($mode) {
         case 'insertComments':
             $comment_data = array('uid' => 1, 'nickname' => trim($line[1]), 'email' => '', 'subject' => trim($line[2]), 'photo_paths' => 's:0:\\"\\";', 'comment' => trim($line[3]), 'status' => 1, 'from' => 1, 'timestamp' => $time, 'directory_tid' => 0, 'tag_tid' => 0);
             return array('code' => 200, 'data' => $comment_data);
             break;
         case 'insertCommentsWithTid':
             $tid = $line[1];
             $term = new Term();
             $result = $term->setConnection($this->connection)->getTermInfo(array('tid' => $tid));
             if (empty($result)) {
                 $res['code'] = 500;
                 $res['message'] = 'can not find tid';
                 return $res;
             }
             if ($result->vid == 1) {
                 $comment_data = array('directory_tid' => 0, 'tag_tid' => $tid);
             } elseif ($result->vid == 3) {
                 $comment_data = array('directory_tid' => $tid, 'tag_tid' => 0);
             } else {
                 $res['code'] = 500;
                 $res['message'] = 'vid type is not right';
                 return $res;
             }
             // insert comment
             $comment_data = array_merge($comment_data, array('uid' => 1, 'nickname' => trim($line[2]), 'email' => '', 'subject' => trim($line[3]), 'photo_paths' => 's:0:\\"\\";', 'comment' => trim($line[4]), 'status' => 1, 'from' => 1, 'timestamp' => $time));
             return array('code' => 200, 'data' => $comment_data);
             break;
     }
     return array('code' => 400, 'message' => 'arguments error');
 }
Ejemplo n.º 2
0
 public function getTermInfo($condition)
 {
     $term = new Term();
     $term->setConnection($this->connection);
     $result = self::formatCondition($term->newQuery(), $condition)->get();
     return $result;
 }