Exemplo n.º 1
0
 /**
  * 加载更多热门微博
  */
 public function addMoreHotWeibo()
 {
     $aPage = I('post.page', 1, 'op_t');
     $aCount = I('post.count', 10, 'op_t');
     $hot_left = modC('HOT_LEFT', 3);
     $time_left = get_some_day($hot_left);
     $time_left = get_some_day($hot_left);
     $param['create_time'] = array('gt', $time_left);
     $param['status'] = 1;
     $param['is_top'] = 0;
     $weibo = D('Weibo')->where(array('status' => 1, $param))->page($aPage, $aCount)->order('comment_count desc')->select();
     $support['appname'] = 'Weibo';
     //查找是否点赞
     $support['table'] = 'weibo';
     $support['uid'] = is_login();
     $is_zan = D('Support')->where($support)->select();
     $is_zan = array_column($is_zan, 'row');
     foreach ($weibo as &$v) {
         $v['user'] = query_user(array('nickname', 'avatar64', 'uid'), $v['uid']);
         $v['rand_title'] = mob_get_head_title($v['uid']);
         $v['support'] = D('Support')->where(array('appname' => 'Weibo', 'table' => 'weibo', 'row' => $v['id']))->count();
         if ($v['type'] === "repost") {
             $v['content'] = A('Mob/WeiboType')->fetchRepost($v);
         } else {
             if ($v['type'] === "xiami" || $v['type'] == "video") {
                 $v['content'] = Hook::exec('Addons\\Insert' . ucfirst($v['type']) . '\\Insert' . ucfirst($v['type']) . 'Addon', 'fetch' . ucfirst($v['type']), $v);
             } else {
                 $v['content'] = parse_weibo_mobile_content($v['content']);
             }
         }
         if (empty($v['from'])) {
             $v['from'] = "网站端";
         }
         $v['data'] = unserialize($v['data']);
         //字符串转换成数组,获取微博源ID
         if ($v['data']['sourceId']) {
             //判断是否是源微博
             $v['sourceId'] = $v['data']['sourceId'];
             $v['is_sourceId'] = '1';
         } else {
             $v['sourceId'] = $v['id'];
             $v['is_sourceId'] = '0';
         }
         $v['sourceId_user'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->find();
         //源微博用户名
         $v['sourceId_user'] = $v['sourceId_user']['uid'];
         $v['sourceId_user'] = query_user(array('nickname', 'uid'), $v['sourceId_user']);
         $v['sourceId_content'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('content')->find();
         //源微博内容
         if (!is_null($v['sourceId_content'])) {
             $v['sourceId_content'] = parse_weibo_mobile_content($v['sourceId_content']['content']);
             //把表情显示出来。
         }
         $v['sourceId_repost_count'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('repost_count')->find();
         //源微博转发数
         $v['sourceId_from'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('from')->find();
         //源微博来源
         if (empty($v['sourceId_from']['from'])) {
             $v['sourceId_from'] = "网站端";
         } else {
             $v['sourceId_from'] = "手机网页版";
         }
         $v['sourceId_img'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('data')->find();
         //为了获取源微图片
         $v['sourceId_img'] = unserialize($v['sourceId_img']['data']);
         $v['sourceId_img'] = explode(',', $v['sourceId_img']['attach_ids']);
         //把attach_ids里的图片ID转出来
         foreach ($v['sourceId_img'] as &$b) {
             $v['sourceId_img_path'][] = getThumbImageById($b, 100, 100);
             //获得缩略图
             //获得原图
             $bi = M('Picture')->where(array('status' => 1))->getById($b);
             if (!is_bool(strpos($bi['path'], 'http://'))) {
                 $v['sourceId_img_big'][] = $bi['path'];
             } else {
                 $v['sourceId_img_big'][] = getRootUrl() . substr($bi['path'], 1);
             }
         }
         $v['cover_url'] = explode(',', $v['data']['attach_ids']);
         //把attach_ids里的图片ID转出来
         foreach ($v['cover_url'] as &$a) {
             $v['img_path'][] = getThumbImageById($a, 100, 100);
             //获得原图
             $bi = M('Picture')->where(array('status' => 1))->getById($b);
             if (!is_bool(strpos($bi['path'], 'http://'))) {
                 $v['sourceId_img_big'][] = $bi['path'];
             } else {
                 $v['sourceId_img_big'][] = getRootUrl() . substr($bi['path'], 1);
             }
         }
         if (in_array($v['id'], $is_zan)) {
             //判断是否已经点赞
             $v['is_support'] = '1';
         } else {
             $v['is_support'] = '0';
         }
         if (empty($v['data']['attach_ids'])) {
             //判断是否是图片
             $v['is_img'] = '0';
         } else {
             $v['is_img'] = '1';
         }
         if (empty($v['sourceId_img']['0'])) {
             $v['sourceId_is_img'] = '0';
         } else {
             $v['sourceId_is_img'] = '1';
         }
     }
     if ($weibo) {
         $data['html'] = "";
         foreach ($weibo as $val) {
             $this->assign("vl", $val);
             $data['html'] .= $this->fetch("_weibolist");
             $data['status'] = 1;
         }
     } else {
         $data['stutus'] = 0;
     }
     $this->ajaxReturn($data);
 }
Exemplo n.º 2
0
 public function addmoreWeibo()
 {
     $aPage = I('post.page', 1, 'op_t');
     $aCount = I('post.count', 10, 'op_t');
     $uid = I('post.uid', '', 'op_t');
     $weibo = D('Weibo')->where(array('status' => 1, 'uid' => $uid))->order('create_time desc')->page($aPage, $aCount)->select();
     //我关注的人的微博
     $support['appname'] = 'Weibo';
     //查找是否点赞
     $support['table'] = 'weibo';
     $support['uid'] = is_login();
     $is_zan = D('Support')->where($support)->select();
     $is_zan = array_column($is_zan, 'row');
     foreach ($weibo as &$v) {
         $v['user'] = query_user(array('nickname', 'avatar64', 'space_mob_url'), $v['uid']);
         $v['rand_title'] = mob_get_head_title($v['uid']);
         $v['support'] = D('Support')->where(array('appname' => 'Weibo', 'table' => 'weibo', 'row' => $v['id']))->count();
         $v['content'] = parse_weibo_mobile_content($v['content']);
         if (empty($v['from'])) {
             $v['from'] = "网站端";
         }
         $v['data'] = unserialize($v['data']);
         //字符串转换成数组,获取微博源ID
         if ($v['data']['sourceId']) {
             //判断是否是源微博
             $v['sourceId'] = $v['data']['sourceId'];
             $v['is_sourceId'] = '1';
         } else {
             $v['sourceId'] = $v['id'];
             $v['is_sourceId'] = '0';
         }
         $v['sourceId_user'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->find();
         //源微博用户名
         $v['sourceId_user'] = $v['sourceId_user']['uid'];
         $v['sourceId_user'] = query_user(array('nickname', 'space_mob_url'), $v['sourceId_user']);
         $v['sourceId_content'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('content')->find();
         //源微博内容
         $v['sourceId_content'] = parse_weibo_mobile_content($v['sourceId_content']['content']);
         //把表情显示出来。
         $v['sourceId_repost_count'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('repost_count')->find();
         //源微博转发数
         $v['sourceId_from'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('from')->find();
         //源微博来源
         if (empty($v['sourceId_from']['from'])) {
             $v['sourceId_from'] = "网站端";
         } else {
             $v['sourceId_from'] = "手机网页版";
         }
         $v['sourceId_img'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('data')->find();
         //为了获取源微图片
         $v['sourceId_img'] = unserialize($v['sourceId_img']['data']);
         $v['sourceId_img'] = explode(',', $v['sourceId_img']['attach_ids']);
         //把attach_ids里的图片ID转出来
         foreach ($v['sourceId_img'] as &$b) {
             $v['sourceId_img_path'][] = getThumbImageById($b, 100, 100);
             //获得缩略图
             //获得原图
             $bi = M('Picture')->where(array('status' => 1))->getById($b);
             if (!is_bool(strpos($bi['path'], 'http://'))) {
                 $v['sourceId_img_big'][] = $bi['path'];
             } else {
                 $v['sourceId_img_big'][] = getRootUrl() . substr($bi['path'], 1);
             }
         }
         $v['cover_url'] = explode(',', $v['data']['attach_ids']);
         //把attach_ids里的图片ID转出来
         foreach ($v['cover_url'] as &$a) {
             $v['img_path'][] = getThumbImageById($a, 100, 100);
             //获得原图
             $bi = M('Picture')->where(array('status' => 1))->getById($b);
             if (!is_bool(strpos($bi['path'], 'http://'))) {
                 $v['sourceId_img_big'][] = $bi['path'];
             } else {
                 $v['sourceId_img_big'][] = getRootUrl() . substr($bi['path'], 1);
             }
         }
         if (in_array($v['id'], $is_zan)) {
             //判断是否已经点赞
             $v['is_support'] = '1';
         } else {
             $v['is_support'] = '0';
         }
         if (empty($v['data']['attach_ids'])) {
             //判断是否是图片
             $v['is_img'] = '0';
         } else {
             $v['is_img'] = '1';
         }
         if (empty($v['sourceId_img']['0'])) {
             $v['sourceId_is_img'] = '0';
         } else {
             $v['sourceId_is_img'] = '1';
         }
     }
     if ($weibo) {
         $data['html'] = "";
         foreach ($weibo as $val) {
             $this->assign("vo", $val);
             $data['html'] .= $this->fetch("_myweibo");
             $data['status'] = 1;
         }
     } else {
         $data['stutus'] = 0;
     }
     $this->ajaxReturn($data);
 }