public function index() { $put = I('s'); if (trim($put) == '') { $this->error('搜索内容不能为空!'); die; } $where['biaoti'] = $put; $where['content'] = $put; $where['_logic'] = 'OR'; $map['_complex'] = $where; $map['islock'] = 0; //复合查询 $count = M('article')->where($map)->count(); import('ORG.Util.Page'); $page = new page($count, 10); $page->setConfig('theme', '<ul class="pages">%first%%upPage%%linkPage%%downPage%%end%</ul>'); $show = $page->show(); //返回分页信息 $article = M('article')->where($map)->limit($page->firstRow . ',' . $page->listRows)->select(); foreach ($article as $key => $value2) { $article[$key]["imgs"] = imgs($article[$key]["imgs"]); } $this->assign('put', $put); $this->assign('show', $show); //分页信息 $this->assign('count', $count); //数据总数 $this->assign('list', $article); //数据集 $sidebar1 = M('article')->where('type=0')->order('approval desc')->limit('10')->select(); //赞多到少 $this->assign('approval', $sidebar1); $this->display('search'); }
public function index() { $objAsk = M('ask'); $objUser = M('user'); $word = deep_htmlspecialchars($_GET["word"]); $this->assign('searchWord', $word); if ($word == '') { redirect($_SERVER['HTTP_REFERER']); } //如果没有输入关键字 就重定向到上一页面 import('ORG.Util.Page'); //导入分页类 $count = $objAsk->where('INSTR(ask_name, "' . $word . '")>0')->count(); //统计总数 $this->assign('countSearch', $count); $page = new page($count, 10); $page->setConfig('theme', '%upPage% %first% %prePage% %linkPage% %downPage%'); $resultList = $objAsk->where('INSTR(ask_name, "' . $word . '")>0')->order('add_time desc')->limit($page->firstRow . ',' . $page->listRows)->select(); foreach ($resultList as $k1 => $v1) { $resultList[$k1]['username'] = $objUser->where('id=' . $v1['uid'])->getField('username'); } $resultList = deep_htmlspecialchars_decode($resultList); $show = $page->show(); $this->assign('resultList', $resultList); $this->assign('page', $show); $this->display(); }
public function review() { $uid = intval($_GET['uid']); if ($uid == '') { parent::error404(); } //分配根据GET传过来的uid用户的信息 $objUser = M('user'); $userMessage = $objUser->where('id=' . $uid)->field('id,username,face,introduce,point,exp')->find(); $userMessage = deep_htmlspecialchars_decode($userMessage); if ($userMessage == '') { parent::error404(); } $this->assign('userMessage', $userMessage); //分配该用户的评论 $objComment = M('comment'); import('ORG.Util.Page'); //导入分页类 $count = $objComment->where(array('comment_uid' => $uid))->count(); $page = new page($count, 20); $page->setConfig('theme', '%upPage% %first% %prePage% %linkPage% %downPage%'); $commentList = $objComment->where(array('comment_uid' => $uid))->field('aid,time,comment')->order('time desc')->limit($page->firstRow . ',' . $page->listRows)->select(); foreach ($commentList as $k1 => $v1) { $commentList[$k1]['url'] = '__APP__/List/detail/id/' . $v1['aid'] . '.html'; } $commentList = deep_htmlspecialchars_decode($commentList); $show = $page->show(); $this->assign('page', $show); $this->assign('commentList', $commentList); //分配Pagetitle $this->pageTitle = $userMessage['username'] . '的个人主页_支招网'; $this->display(); }
public function index() { $put = I('s'); if (trim($put) == '') { $this->error('搜索内容不能为空!'); die; } $where['title'] = $put; $where['content'] = $put; $count = M('Article')->where($where)->count(); import('ORG.Util.Page'); $page = new page($count, 10); $page->setConfig('theme', '<ul class="pagination"><li>%upPage%</li><li>%downPage%</li><li>%prePage%</li><li>%linkPage%</li><li>%nextPage%</li><li>%end%</li></ul>'); $show = $page->show(); //返回分页信息 $article = M('article')->where($where)->limit($page->firstRow . ',' . $page->listRows)->select(); $this->assign('put', $put); $this->assign('show', $show); //分页信息 $this->assign('count', $count); //数据总数 $this->assign('list', $article); //数据集 //侧栏的数据分配 $sidebar1 = M('Article')->where("ispush=1 and islock=0")->order('approval desc')->limit('5')->select(); $sidebar2 = M('Article')->where("ispush=1 and islock=0")->order('opposition desc')->limit('5')->select(); $sidebar3 = M('Article')->where("ispush=1 and islock=0")->order('rand()')->limit('5')->select(); //赞多到少 $this->assign('sidebar1', $sidebar1); //赞少到多 $this->assign('sidebar2', $sidebar2); //随机5篇 $this->assign('sidebar3', $sidebar3); $this->display('search'); }
public function index() { $sortId = intval($_GET['sid']); if ($sortId == '') { parent::error404(); } $sort = intval($_GET['sort']); if ($sort == '') { parent::error404(); } $objAsk = D('AskView'); $where = array('sort_id' => $sortId); if ($sort == 1) { $order = 'add_time desc'; } elseif ($sort == 2) { $order = 'reward desc,add_time desc'; } elseif ($sort == 3) { $order = 'comment_num desc,add_time desc'; } import('ORG.Util.Page'); //导入分页类 $count = $objAsk->where($where)->count(); //统计总数 $page = new page($count, 12); $page->setConfig('theme', '%upPage% %first% %prePage% %linkPage% %downPage%'); $askList = $objAsk->where($where)->field('id,ask_name,add_time,comment_num,reward,solve,username,sort_name')->order($order)->limit($page->firstRow . ',' . $page->listRows)->select(); $askList = deep_htmlspecialchars_decode($askList); $show = $page->show(); $this->assign('askList', $askList); $this->assign('page', $show); //分配pageTitle if ($sortId == 1) { $pageTitle = '生活_支招网'; } else { if ($sortId == 2) { $pageTitle = '情感_支招网'; } else { if ($sortId == 3) { $pageTitle = '健康_支招网'; } else { if ($sortId == 4) { $pageTitle = '职场_支招网'; } else { if ($sortId == 5) { $pageTitle = '公益_支招网'; } } } } } $this->assign('pageTitle', $pageTitle); //获取列表广告 $this->listBanner = $this->getListBanner(); $this->display(); }
public function stuList() { import("ORG.Util.Page"); //导入分页类 $p = new Page($count, 2); $Stu = D('Stu'); $count = $Stu->count(); $listRows = 5; $p = new page($count, $listRows); $list = $Stu->findAll('category_id desc,postdate desc', $p->firstRow . ',' . $p->listRows); $p->setConfig('header', '篇记录'); $p->setConfig('prev', "上一页"); $p->setConfig('next', '下一页'); $p->setConfig('first', '<<'); $p->setConfig('last', '>>'); $page = $p->show(); $this->assign('jz_res', $jz_res); $this->assign("page", $page); $this->display(); }
public function index() { import('ORG.Util.Page'); // 导入分页类 $aCounty = (int) getRequest('county'); $aWhere = $this->model->getConditionArray(); $aTown = $this->model->getTownName($aCounty); //查询4家公司信息(瀑布流分页) $count = D('Company')->where($aWhere)->count(); $Page = new page($count, 2); $Page->setConfig('theme', " %upPage% %downPage% %first% %prePage% %linkPage% %nextPage% %end%"); $show = $Page->show(); //$aCompany = D('Company')->where($aWhere)->order('ord DESC')->limit($Page->firstRow.','.$Page->listRows)->select(); if ($_GET['caseord']) { unset($_GET['caseord']); $aCompany = D('Company')->where($aWhere)->order('reserve_count DESC,ord DESC')->limit($Page->firstRow . ',' . $Page->listRows)->select(); } else { $aCompany = D('Company')->where($aWhere)->order('ord DESC')->limit($Page->firstRow . ',' . $Page->listRows)->select(); } //每家公司查询5条记录 foreach ($aCompany as $key => $aValue) { $case = $this->model->getTop($aValue['id'], 5); $aCompany[$key]['case'] = $case; } //dump($aCompany);die; $comtype = getRequest('comtype'); $aDistrict = D("District")->getFieldById(9); unset($_GET['_URL_']); $Acondition = $_GET; $Bcondition = $_GET; $Ccondition = $_GET; unset($Acondition['comtype']); unset($Acondition['p']); $comtypeurl = U("", $Acondition); unset($Bcondition['county']); unset($Bcondition['p']); $countyurl = U("", $Bcondition); unset($Ccondition['town']); unset($Ccondition['p']); $townurl = U("", $Ccondition); $this->assign('page', $show); $this->assign('comtypeurl', $comtypeurl); $this->assign('countyurl', $countyurl); $this->assign('townurl', $townurl); $this->assign('town', $aTown); $this->assign('comtype', $comtype); $this->assign('district', $aDistrict); $this->assign('company', $aCompany); $this->assign('county', $aCounty); $this->display(); }
public function index() { import("ORG.Util.Page"); $now = date("Y-m-d"); $db = new WorldsModel(); $count['total'] = $db->count(); //总条数 $count['new'] = $db->where("substring(time,1,10)='{$now}'")->count(); //今日更新条数 $page = new page($count['total'], 10); $page->setConfig('header', '条微博'); $world = $db->relation(true)->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select(); $this->assign('count', $count); $this->assign('world', $world); $this->assign('page_nav', $page->show()); $this->display(); //dump($); }
public function audit() { import('ORG.Util.Page'); // 导入分页类 $count = D('Construction')->where(array('is_approve' => 3))->order('ord')->count(); $Page = new page($count, 3); $Page->setConfig('theme', " %upPage% %downPage% %first% %prePage% %linkPage% %nextPage% %end%"); $show = $Page->show(); $aConstruction = $this->model->where(array('is_approve' => 3))->order('ord')->limit($Page->firstRow . ',' . $Page->listRows)->select(); //$aConstruction = $this->model->join('tb_case on tb_construction.id=tb_case.consid' )->where(array('tb_construction.is_approve'=>3,'tb_case.is_approve'=>3,'tb_construction.status'=>0,'tb_case.status'=>0,'tb_construction.appid'=>1,'tb_case.appid'=>1))->order('tb_construction.ord')->limit($Page->firstRow.','.$Page->listRows)->field('tb_construction.id,tb_case.consid,tb_construction.name cname,tb_construction.focus cfocus,tb_case.focus focus,tb_case.name,tb_case.housetype')->select(); //echo $this->model->getLastSql();die; foreach ($aConstruction as $key => $val) { $aConstruction[$key]['case'] = D('Case')->where(array('is_approve' => 3, 'consid' => $val['id']))->limit(4)->select(); } //dump($aConstruction);die; $this->assign('cons', $aConstruction); $this->assign('page', $show); $this->display(); }
public function answer() { parent::isLogin(); //登录判断 $Model = M('comment'); import('ORG.Util.Page'); //导入分页类 $where = array('comment_uid' => $_SESSION['uid']); $count = $Model->where($where)->count(); $this->assign('articleAllNum', $count); $page = new page($count, 12); $page->setConfig('theme', '%upPage% %first% %prePage% %linkPage% %downPage%'); $articleList = $Model->where($where)->field('id,comment,aid,time')->order('time desc')->limit($page->firstRow . ',' . $page->listRows)->select(); $articleList = deep_htmlspecialchars_decode($articleList); $show = $page->show(); $this->assign('articleList', $articleList); $this->assign('page', $show); $this->answerNumAll = $this->getAnswerNum(); $this->adoptNumAll = $this->getAdoptNum(); $this->display(); }
public function index() { $article_id = I('articleid', '', 'intval'); //input id $this->assign('aid', $article_id); /* 左侧分类列表*/ $mlist = R('Index/menulist'); $this->assign('categoryq', $mlist); $article = M('Article')->where("article_id={$article_id}")->find(); if ($article == false) { //查询结果无 $this->redirect('/index'); } else { if ($article_id != cookie('lastaid')) { cookie('lastaid', $article_id); M('article')->execute("update __TABLE__ set llcs=llcs+1 where article_id={$article_id}"); } //cookie浏览次数防刷新 $article[imgs] = str_replace("s_", "b_", $article[imgs]); $this->assign('article', $article); $imgs = explode('|', $article[imgs]); $this->assign('allimg', $imgs); $fbr = M('member_user')->where("username='******'username'] . "'")->find(); $user = M('member_user')->where("user_id=" . cookie('userid') . "")->find(); $marticle = M('Article')->where("username='******'username'] . "' and article_id !={$article_id}")->order('rand()')->limit('6')->select(); $similer = M('Article')->where("class2=" . $article['class2'] . " and article_id !={$article_id}")->order('rand()')->limit('6')->select(); $c1 = M('class1')->where('id=' . $article['class1'] . '')->find(); $c2 = M('class2')->where('id=' . $article['class2'] . '')->find(); $this->assign('fbr', $fbr); $this->assign('user', $user); $this->assign('marticle', $marticle); $this->assign('similer', $similer); $this->assign('c1', $c1); $this->assign('c2', $c2); //判断当前ip是否点赞 $ip = get_client_ip(); $Uip = M('Zan_ip'); $result = $Uip->where("articleid={$article_id} and ip='{$ip}'"); $count = $result->count(); if ($count == 0) { $love = '未'; } else { $love = '已'; } $this->assign('love', $love); //导入评论 $reply = D('CommentView'); //实例化Comment视图模型 $count = $reply->where(array('article_id' => $article_id, 'pid' => 0))->limit($page->firstRow . ',' . $page->listRows)->count(); import('ORG.Util.Page'); //导入分页类 $page = new page($count, 8); //reply分页 $articleComments = $reply->where(array('article_id' => $article_id, 'pid' => 0))->limit($page->firstRow . ',' . $page->listRows)->select(); //将一级8条评论查询出来 $page->setConfig('theme', '<ul class="pages">%first%%upPage%%linkPage%%downPage%%end%</ul>'); $show = $page->show(); //返回分页信息 foreach ($articleComments as $comment) { $comments[$comment['id']] = $comment; //将查询出来的一级评论按id赋给comments数组 } $commentID = array_keys($comments); //取出一级评论的id,为下面查询对应的二级评论做准备 if (!empty($commentID)) { foreach ($commentID as $id) { $sqlArray[] = 'pid=' . $id; //生成查询二级评论所用条件数组 } $sql = implode(' OR ', $sqlArray); //将数组连接,生成对应的SQL条件语句 $articleComments = $reply->where($sql)->select(); //查询对应二级评论 foreach ($articleComments as $comment) { $comments[$comment['pid']]['comments'][] = $comment; //按树形排列评论 } } $this->assign('comments', $comments); $this->assign('show', $show); //分页信息 if ($article[type] == 0) { $this->display('article_article'); } else { if ($article[type] == 1) { $mnews = M('article')->where("article_id !={$article_id} and type=1")->order('article_id desc')->limit('10')->select(); $this->assign('mnews', $mnews); $this->display('article_news'); } } } }