/** * 文章列表 * @author Saki <*****@*****.**> * @date 2014-5-13上午10:30:51 * @version v1.0.0 */ public function listinfo() { $model = new \Admin\Model\ArticleListModel(); //计算分类总数 $sql = "select count(ctm) as count from (select date_format(ctm,'%Y-%m') as ctm from __PREFIX__article_list group by date_format(ctm,'%Y-%m')) a"; $count = $model->query($sql); //分页显示设置 $Page = new \Think\Page($count[0]['count'], 10); $Page->setConfig('prev', '上一页'); $Page->setConfig('next', '下一页'); $Page->setConfig('theme', '%FIRST% %LINK_PAGE% %END%'); $show = $Page->show(); //分页数据处理 $list = $model->getArticleList_Mon($Page); $this->assign('list', $list); $this->assign('page', $show); $this->display(); }
/** * @todo: 日历插件 * @author Saki <*****@*****.**> * @date 2014-12-17 上午11:21:33 * @version V1.0 */ public function calendar() { $str = ''; $Y = date('Y', time()); //当前年份 $m = date('m', time()); //当前月份 $w = date('w', time()); //当前星期几,0-6,0代表星期天 $d = date('d', time()); $beginDate = date('Y-m-01', strtotime(date("Y-m-d"))); //当前月的第一天 $beginTime = strtotime($beginDate); //当前月的第一天的时间戳 $w_first = date('w', $beginTime); //当前月第一天是星期几 $day_count = cal_days_in_month(CAL_GREGORIAN, $m, $Y); //当前月总共天数 //计算总行数等数值 $row_num = ($day_count + $w_first) % 7 == 0 ? floor(($day_count + $w_first) / 7) : floor(($day_count + $w_first) / 7 + 1); $data = array(); //每行的具体信息 for ($i = 1; $i <= $row_num; $i++) { if ($i == 1) { //第一行 $temp['type'] = 'top'; $temp['colspan'] = $w_first; //开头空格数 $temp['start'] = 1; $temp['end'] = 7 - $w_first + 1; $temp['day_num'] = 7 - $w_first; } elseif ($i == $row_num) { $temp['type'] = 'end'; $temp['colspan'] = 7 - ($day_count + $w_first) % 7; $temp['start'] = 7 * ($i - 1) + 1 - $w_first; $temp['end'] = $day_count + 1; $temp['day_num'] = ($day_count + $w_first) % 7; } else { $temp['type'] = 'center'; $temp['colspan'] = 0; $temp['start'] = 7 * ($i - 1) + 1 - $w_first; $temp['end'] = 7 * ($i - 1) + 1 - $w_first + 6 + 1; $temp['day_num'] = 7; } //加入到总数组中 array_push($data, $temp); } //当前月发表过文章的列表信息 $model = new \Admin\Model\ArticleListModel(); $sql = "select group_concat(date_format(ctm,'%d')) as ctm FROM __PREFIX__article_list where date_format(ctm,'%Y-%m')=date_format(now(),'%Y-%m') and status=1"; $has_ctm = $model->query($sql); $this->assign('calendar', $data); $this->assign('has_ctm', $has_ctm[0]['ctm']); $this->assign('d', $d); }