| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 | 
							- <?php
 
- namespace Community\Lib;
 
- use Dever;
 
- class Info
 
- {
 
-     private function table($type)
 
-     {
 
-         $table = Dever::db('community/info')->config['set']['table_name'][$type];
 
-         return $table;
 
-     }
 
-     public function getData($method = 'getAll', $uid, $cate_id = false, $type = false, $type_id = false, $total = false, $id = false)
 
-     {
 
-         # 获取分类下的帖子
 
-         $where['cate_id'] = $cate_id;
 
-         $where['type'] = $type;
 
-         $where['type_id'] = $type_id;
 
-         if ($id > 0) {
 
-             $where['noid'] = $id;
 
-         }
 
-         $data['info'] = Dever::db('community/info')->$method($where);
 
-         if ($total) {
 
-             if ($method == 'getAll') {
 
-                 $data['total'] = Dever::total();
 
-             } else {
 
-                 $data['total'] = Dever::db('community/info')->getTotal($where);
 
-             }
 
-         }
 
-         if ($data['info']) {
 
-             foreach ($data['info'] as $k => $v) {
 
-                 $data['info'][$k] = $this->one($uid, $v);
 
-             }
 
-         }
 
-         return $data;
 
-     }
 
-     public function content($content, $id)
 
-     {
 
-         $content = $this->getContent($content);
 
-         return '<span class=dever-emoji>'.$content.'</span>';
 
-     }
 
-     public function getContent($content)
 
-     {
 
-         if (strstr($content, '_b64')) {
 
-             $content = str_replace('_b64', '', $content);
 
-             $content = base64_decode($content);
 
-         }
 
-         return $content;
 
-     }
 
-     # 发表信息
 
-     public function submit($uid, $cate_id, $id, $type, $pic, $content, $to_id, $to_uid)
 
-     {
 
-         $where['uid'] = $uid;
 
-         $where['cate_id'] = $cate_id;
 
-         $where['type_id'] = $id;
 
-         $where['type'] = $type;
 
-         $where['content'] = $content;
 
-         $table = 'community/info';
 
-         //$info = Dever::db($table)->one($where);
 
-         $info = false;
 
-         if ($pic) {
 
-             $where['pic'] = $pic;
 
-         }
 
-         if ($to_id) {
 
-             $where['to_id'] = $to_id;
 
-         }
 
-         if ($to_uid) {
 
-             $where['to_uid'] = $to_uid;
 
-         }
 
-         $data_table = $this->table($type);
 
-         if (!$info) {
 
-             $data = Dever::db($data_table)->one($id);
 
-             if (isset($data['name']) && $data['name']) {
 
-                 $where['type_name'] = $data['name'];
 
-             }
 
-             
 
-             Dever::db($table)->insert($where);
 
-             Dever::score($uid, 'submit_community', '发表帖子');
 
-             # 更新评论数
 
-             /*
 
-             $where = array();
 
-             $where['type_id'] = $id;
 
-             $where['type'] = $type;
 
-             $where['state'] = 1;
 
-             $total = Dever::db($table)->total($where);
 
-             echo $data_table;die;
 
-             Dever::db($data_table)->update(array('where_id' => $id, 'num_comment' => $total));
 
-             */
 
-         }
 
-         return true;
 
-     }
 
-     private function one($uid, $info)
 
-     {
 
-         $info['pic'] = explode(',', $info['pic']);
 
-         $info['user'] = Dever::load('passport/api')->info($info['uid']);
 
-         $info['cdate_string'] = Dever::mdate($info['cdate'], 2);
 
-         # 点赞数
 
-         $info['num_up'] = $info['num_up'] + 0;
 
-         # 反对数
 
-         $info['num_oppose'] = $info['num_oppose'] + 0;
 
-         $info['is_up'] = $info['is_oppose'] = false;
 
-         if ($uid) {
 
-             # 是否点赞
 
-             $info['is_up'] = Dever::load('community/lib/up')->get($uid, $info['id'], 20);
 
-             # 是否反对
 
-             $info['is_oppose'] = Dever::load('community/lib/oppose')->get($uid, $info['id'], 20);
 
-         }
 
-         # 评论数
 
-         $info['num_comment'] = $info['num_comment'] + 0;
 
-         # 获取引用的数据
 
-         $info['to_user'] = array();
 
-         if ($info['to_uid']) {
 
-             $info['to_user'] = Dever::load('passport/api')->info($info['to_uid']);
 
-         }
 
-         # 获取热门的子信息
 
-         $info['child'] = array();
 
-         if ($info['type'] < 20) {
 
-             $child = $this->getData('getHot', $uid, $info['cate_id'], 20, $info['id'], true, 1);
 
-             if ($child && $child['info']) {
 
-                 $info['child'] = $child['info'];
 
-                 $info['child_total'] = $child['total'];
 
-             }
 
-         }
 
-         # 获取最新的服务器时间
 
-         $info['server_time'] = time();
 
-         return $info;
 
-     }
 
- }
 
 
  |