Beispiel #1
0
 function rss()
 {
     if (!empty($_GET['id'])) {
         $uid = (int) $_GET['id'];
         $user = App\Func::getUser($uid);
         $_mblog = createModel('MicroBlog');
         $_blog = createModel('UserLogs');
         $gets['uid'] = $uid;
         $gets['select'] = 'id,content,addtime';
         $gets['limit'] = 10;
         $mblogs = $_mblog->gets($gets);
         foreach ($mblogs as &$v) {
             $v['title'] = strip_tags(App\Func::mblog_link($v['id'], $v['content'], 30, true));
             $v['content'] = nl2br($v['content']);
             $v['url'] = WEBROOT . '/mblog/detail/' . $v['id'];
         }
         $gets['uid'] = $uid;
         $gets['select'] = 'id,title,content,addtime';
         $gets['limit'] = 10;
         $gets['dir'] = 0;
         $blogs = $_blog->gets($gets);
         $list = array_merge($mblogs, $blogs);
         usort($list, 'Func::time_sort');
         foreach ($list as &$v) {
             $v['addtime'] = date('r', strtotime($v['addtime']));
             if (empty($v['url'])) {
                 $v['url'] = WEBROOT . '/blog/detail/' . $v['id'];
             }
         }
         $this->swoole->tpl->ref('user', $user);
         $this->swoole->tpl->ref('list', $list);
         $this->swoole->tpl->display('blog_rss.xml');
     }
 }
Beispiel #2
0
 function detail()
 {
     if (!isset($_GET['id'])) {
         exit;
     }
     $id = (int) $_GET['id'];
     $model = model('MicroBlog');
     $_u = model('UserInfo');
     $_c = model('UserComment');
     $comments = $_c->getByAid('mblog', $id);
     $mblog = $model->get($id)->get();
     $this->userinfo($mblog['uid']);
     $mblog['addtime'] = date('n月j日 H:i', strtotime($mblog['addtime']));
     $this->swoole->tpl->assign('mblog', $mblog);
     $title = strip_tags(App\Func::mblog_link(0, $mblog['content'], 32, true));
     $this->swoole->tpl->assign('title', $title);
     $this->swoole->tpl->assign('comments', $comments);
     $this->swoole->tpl->display();
 }
Beispiel #3
0
 /**
  * 获取微博客内容列表
  * @param $pagesize
  * @return unknown_type
  */
 protected function getMblogs($pagesize = 10, $uid = 0)
 {
     $_mblog = createModel('MicroBlog');
     $_user = createModel('UserInfo');
     $_photo = createModel('UserPhoto');
     $_link = createModel('UserLink');
     $gets1['select'] = $_mblog->table . '.id as id,uid,pic_id,url_id,sex,substring(content,1,170) as content,nickname,avatar,UNIX_TIMESTAMP(addtime) as addtime,reply_count';
     $gets1['order'] = $_mblog->table . '.id desc';
     if (!empty($uid)) {
         $gets1['uid'] = $uid;
     }
     $gets1['leftjoin'] = array($_user->table, $_user->table . '.id=' . $_mblog->table . '.uid');
     $gets1['page'] = empty($_GET['page']) ? 1 : (int) $_GET['page'];
     $gets1['pagesize'] = $pagesize;
     $pager = '';
     $mblogs_atta = array();
     $mblogs = $_mblog->gets($gets1, $pager);
     $pager->span_open = array();
     $pager = array('total' => $pager->total, 'render' => $pager->render());
     foreach ($mblogs as &$m) {
         $m['content'] = Func::mblog_link($m['id'], $m['content']);
         $m['addtime'] = date('n月j日 H:i', $m['addtime']);
         if (!empty($m['url_id'])) {
             $mblogs_atta['url'][] = $m['url_id'];
         }
         if (!empty($m['pic_id'])) {
             $mblogs_atta['pic'][] = $m['pic_id'];
         }
     }
     if (!empty($mblogs_atta['pic'])) {
         $pics = $_photo->getMap(array('select' => 'id,imagep,picture', 'in' => array('id', implode(',', $mblogs_atta['pic']))));
         $this->swoole->tpl->assign('pics', $pics);
     }
     if (!empty($mblogs_atta['url'])) {
         $urls = $_link->getMap(array('select' => 'id,title,url', 'in' => array('id', implode(',', $mblogs_atta['url']))));
         $this->swoole->tpl->assign('urls', $urls);
     }
     $this->swoole->tpl->assign('mblogs', $mblogs);
     $this->swoole->tpl->assign('pager', $pager);
 }