/** * 后台主页信息 */ public function actionSystemmain() { $SYS = array('PHP版本:' => $_SERVER['SERVER_SOFTWARE'], '当前系统类型:' => php_uname('s'), 'PHP运行方式:' => php_sapi_name(), '服务器域名:' => $_SERVER['SERVER_NAME'], '服务器端口:' => $_SERVER['SERVER_PORT'], '北京时间:' => date('Y年m月d日 H:i:s', time())); $count = array('会员总数:' => Account::model()->count('id!=:ID', array(':ID' => 0)), '文章总数:' => article::model()->count('id!=:ID', array(':ID' => 0)), '评论总数:' => Comments::model()->count('id!=:ID', array(':ID' => 0))); $Role = Role::model()->find('id=:ID', array(':ID' => Yii::app()->session['USER_ACCOUNT']['roleId'])); $basic = array('权限级别:' => $Role->name); $this->render('Systemmain', array('SYS' => $SYS, 'Info' => $count, 'basic' => $basic)); }
/** * 获取文章列表 */ public function actionDoclist() { $Rolelist = article::model(); $cri = new CDbCriteria(); $total = $Rolelist->count($cri); $pager = new CPagination($total); $pager->pageSize = 10; $pager->applyLimit($cri); $Infolist = $Rolelist->findAll($cri); $this->render('doc_list', array('taglist' => $Infolist, 'Pagers' => $pager)); }
/** * 查询出该标签下有多少篇文章 * @param int $tagId 需要查询的tag标签id */ public function actionTags($tagId = 0) { if (!isset($_GET['parent'])) { $_GET['parent'] = 100; $this->Menu = $this->Menulist('> 0', 100); } else { $this->Menu = $this->Menulist('> 0', $_GET['parent']); } $Md5cacheKey = md5('Category' . $tagId . $_GET['parent'] . $tagId); if (!empty($tagId)) { $Sql = "SELECT tagsAs.articleId FROM `" . $this->table('tagsasarticle') . "` AS tagsAs left join tags on tags.id=tagsAs.tagsId Where tags.name = '" . $tagId . "' Group by tagsAs.`articleId`"; if (!($cache = $this->cached($Md5cacheKey))) { $articleId = CActiveRecord::$db->createCommand($Sql)->queryAll(); $this->cached($Md5cacheKey, $articleId); } else { $articleId = $this->cached($Md5cacheKey); } $aid = array(); foreach ($articleId as $key => $value) { array_push($aid, $value['articleId']); } $cri = new CDbCriteria(); $cri->order = 'id desc'; $cri->addInCondition('id', $aid); $count = article::model()->count($cri); $pager = new CPagination($count); $pager->pageSize = 15; $pager->applyLimit($cri); $AllTag = article::model()->findAll($cri); $webdata = array('list' => $AllTag, 'Pages' => $pager); $this->render('list', $webdata); } }