public function indexAction() { $where = array(); $id = get("id", "int"); if (!empty($id)) { $where['id'] = $id; $this->getView()->assign(array('id' => $id)); } $where['status'] = \Admin\Article\Type\Status::STATUS_ENABLE; $count = db()->Table('twitter')->getAll($where)->count()->done(); $page = new \System\Library\Page($count); $page->listRows = 10; if ($page->isShow) { $showPage = $page->show(); } else { $showPage = ""; } $list = db()->Table('twitter')->getAll($where)->limit($page->firstRow, $page->listRows)->done(); $commentWhere['status'] = \Admin\Comment\Type\Status::STATUS_ENABLE; $commentWhere['type'] = \Admin\Comment\Type\Type::STATUS_TWIITER; $lists = array(); foreach ($list as $k => $v) { $commentWhere['data'] = $v['id']; $lists[$k] = $v; $lists[$k]['comment_count'] = count(db()->Table('comment')->getAll(array_merge($commentWhere, array('ref_id' => 0)))->done()); $lists[$k]['comment'] = $this->sortOut(db()->Table('comment')->getAll($commentWhere)->done()); } $this->getView()->assign(array('list' => $lists)); $this->getView()->display(); }
public function indexAction() { //获取相关用于检索的参数 //分类 $category = get("category", "txt") ? trim(get("category", "txt")) : ""; //归档 $archive = get("archive", "txt") ? trim(get("archive", "txt")) : ""; //标签 $tag = get("tag", "txt") ? trim(get("tag", "txt")) : ""; //获取文章列表 $where = $logList = array(); $where['status'] = \Admin\Article\Type\Status::STATUS_ENABLE; $where['member_id'] = 1; //检索 if (!empty($category)) { $where['category'] = $category; } if (!empty($archive)) { preg_match("/^(\\d{4})年(\\d{1,2})月\$/", $archive, $result); $where['time?>='] = "{$result['1']}-{$result['2']}-01 00:00:00"; $where['time?<'] = "{$result['1']}-" . ($result[2] + 1) . "-01 00:00:00"; } if (!empty($tag)) { $tagRow = db()->Table('article_tag')->getRow(array('tagname' => $tag))->done(); //getRow if ($tagRow) { $where['id'] = explode(",", $tagRow['gid']); } } $count = db()->Table('article')->getAll($where)->order("istop desc")->count()->done(); //getAll $page = new \System\Library\Page($count); if ($page->isShow) { $showPage = $page->show(); // 分页显示输出 } else { $showPage = ""; } // 进行分页数据查询 $all = db()->Table('article')->getAll($where)->limit($page->firstRow, $page->listRows)->order("istop desc")->done(); foreach ($all as $k => $v) { $logList[$k]['title'] = htmlspecialchars(trim($v['title'])); $logList[$k]['id'] = $v['id']; $logList[$k]['url'] = $this->getView()->log($v['id']); $cookiePassword = cookie('xtt_logpwd_' . $v['id']) ? addslashes(trim(cookie('xtt_logpwd_' . $v['id']))) : ''; $excerpt = empty($v['excerpt']) ? breakLog($v['content'], $v['id']) : $v['excerpt']; $excerpt = mb_substr(strip_tags($excerpt), 0, 60); $logList[$k]['excerpt'] = $v['excerpt'] = $excerpt; if (!empty($v['password']) && $cookiePassword != $v['password']) { $logList[$k]['excerpt'] = '<p>[该日志已设置加密,请点击标题输入密码访问]</p>'; } else { if (!empty($v['excerpt'])) { $logList[$k]['excerpt'] .= '<p class="readmore"><a href="' . $this->getView()->log($v['id']) . '">阅读全文>></a></p>'; } } $logList[$k]['thumbnail'] = $v['thumbnail']; $logList[$k]['time'] = $v['time']; $logList[$k]['author'] = member($v['member_id']); $model = new \Home\Model\homeModel(); $logList[$k]['category'] = $model->getArticleCategory($v['category']); $tag = new \Admin\Model\articleModel(); //获取该文章标签 $tags = $tag->getTags($v['id'], true); if ($tags) { $logList[$k]['tags'] = explode(",", $tags); } $logList[$k]['comment_num'] = $v['comment_num']; $logList[$k]['view_num'] = $v['view_num']; $logList[$k]['istop'] = $v['istop']; $logList[$k]['content'] = handleContent($v['content']); } $this->getView()->assign(array('articleAll' => $logList, 'show' => $showPage)); $this->getView()->display(); }