/** * 首页显示 * @author Saki <*****@*****.**> * @date 2014-5-13上午10:29:39 * @version v1.0.0 */ public function index() { $model = new \Admin\Model\ArticleListModel(); $count = $model->count(); //分页显示设置 $Page = new \Think\Page($count, 7); $Page->setConfig('prev', '上一页'); $Page->setConfig('next', '下一页'); $Page->setConfig('theme', '%FIRST% %LINK_PAGE% %END%'); $show = $Page->show(); //分页数据处理 $Parsedown = new \Org\Markdown\Parsedown(); $list = $model->relation(true)->where('status=1')->order('ctm desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); foreach ($list as $k => $article) { //内容的截取 $content = $article['content']; $new_content = strip_tags($Parsedown->text($content)); $list[$k]['content'] = mb_substr($new_content, 0, 300, 'utf-8') . '...'; //时间的处理 $list[$k]['ctm_M'] = date('M', strtotime($article['ctm'])); //月份简写 $ctm_F = date('F', strtotime($article['ctm'])); //月份全写 $len_M = strlen($list[$k]['ctm_M']); //缩写字符串的长度 $ctm_F = mb_substr($ctm_F, $len_M); //截取剩余字符串 $list[$k]['ctm_F'] = $ctm_F; //月份全写截取后的剩余字符串 $list[$k]['ctm_Y'] = date('Y', strtotime($article['ctm'])); //年份 $list[$k]['ctm_D'] = date('d', strtotime($article['ctm'])); //日期 } $this->assign('list', $list); $this->assign('page', $show); $this->display(); }
/** * @todo: 前台点击【文章标签】操作控制器 * @author Saki <*****@*****.**> * @date 2015-1-7 下午3:12:21 * @version V1.0 */ public function Tagslog() { $model = new \Admin\Model\ArticleListModel(); $type_model = D('Admin/ArticleType'); //查询条件判断 $map['admin_id'] = 1; if (isset($_GET['code'])) { $condition['id'] = $_GET['code']; $ishas_type = D('Admin/ArticleType')->where($condition)->limit(1)->find(); if ($ishas_type) { $map['type_id'] = $_GET['code']; } } $count = $model->where($map)->count(); //分页显示设置 $Page = new \Think\Page($count, 7); $Page->setConfig('prev', '上一页'); $Page->setConfig('next', '下一页'); $Page->setConfig('theme', '%FIRST% %LINK_PAGE% %END%'); $show = $Page->show(); //分页数据处理 $Parsedown = new \Org\Markdown\Parsedown(); $list = $model->relation(true)->where($map)->order('ctm desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); foreach ($list as $k => $article) { //内容的截取 $content = $article['content']; $new_content = strip_tags($Parsedown->text($content)); $list[$k]['content'] = mb_substr($new_content, 0, 200, 'utf-8') . '...'; //时间的处理 $list[$k]['ctm_M'] = date('M', strtotime($article['ctm'])); //月份简写 $ctm_F = date('F', strtotime($article['ctm'])); //月份全写 $len_M = strlen($list[$k]['ctm_M']); //缩写字符串的长度 $ctm_F = mb_substr($ctm_F, $len_M); //截取剩余字符串 $list[$k]['ctm_F'] = $ctm_F; //月份全写截取后的剩余字符串 $list[$k]['ctm_Y'] = date('Y', strtotime($article['ctm'])); //年份 $list[$k]['ctm_D'] = date('d', strtotime($article['ctm'])); //日期 } $this->assign('list', $list); $this->assign('page', $show); $this->display('tags'); }
/** * @todo: 获取文章的详情信息 * @param $id 文章ID * @author Saki <*****@*****.**> * @date 2014-12-26 上午11:40:34 * @version V1.0 */ public function getArticleInfo($id) { $model = D('Admin/ArticleList'); $condition['id'] = $id; $info = $model->relation(true)->where($condition)->find(); //markdown--文章内容解析 $Parsedown = new \Org\Markdown\Parsedown(); $Parsedown->setMarkupEscaped(true); $info['content'] = $Parsedown->text($info['content']); //文章时间解析 $info['ctm_M'] = date('M', strtotime($info['ctm'])); //月份简写 $ctm_F = date('F', strtotime($info['ctm'])); //月份全写 $len_M = strlen($info['ctm_M']); //缩写字符串的长度 $ctm_F = mb_substr($ctm_F, $len_M); //截取剩余字符串 $info['ctm_F'] = $ctm_F; //月份全写截取后的剩余字符串 $info['ctm_Y'] = date('Y', strtotime($info['ctm'])); //年份 $info['ctm_D'] = date('d', strtotime($info['ctm'])); //日期 return $info; }