/** * tags数据列表 */ public function actionPost($name) { $tagName = CHtml::encode(strip_tags(urldecode($name))); $tagModel = new Post2tags(); $post2TagsCriteria = new CDbCriteria(); if ($tagName) { $post2TagsCriteria->addCondition("tag_name = :tagName"); $post2TagsCriteria->params[':tagName'] = $tagName; } $post2TagsCriteria->order = 't.id DESC'; $post2TagsCriteria->with = array('post'); $post2TagsCount = $tagModel->count($post2TagsCriteria); $post2TagsPages = new CPagination($post2TagsCount); $post2TagsPages->pageSize = 30; $pageParams = XUtils::buildCondition($_GET, array('name')); $post2TagsPages->params = is_array($pageParams) ? $pageParams : array(); $post2TagsCriteria->limit = $post2TagsPages->pageSize; $post2TagsCriteria->offset = $post2TagsPages->currentPage * $post2TagsPages->pageSize; $data['bagecmsDataList'] = $tagModel->findAll($post2TagsCriteria); $data['bagecmsPagebar'] = $post2TagsPages; $data['tagName'] = $tagName; $this->_seoTitle = 'Tag-' . $tagName; $this->render('post2tags', $data); }
/** * 内容连带tags删除 * * @param $ids * @param $model */ static function Xdelete($ids = '0') { $id = @explode(',', $ids); //删除关联 foreach ($id as $row) { Post2tags::model()->deleteAll('title_id=:title_id', array('title_id' => $row)); } }
/** * 批量操作 * */ public function actionBatch() { if (XUtils::method() == 'GET') { $command = trim($_GET['command']); $ids = intval($_GET['id']); } elseif (XUtils::method() == 'POST') { $command = trim($_POST['command']); $ids = $_POST['id']; is_array($ids) && ($ids = implode(',', $ids)); } else { XUtils::message('errorBack', '只支持POST,GET数据'); } empty($ids) && XUtils::message('error', '未选择记录'); switch ($command) { case 'delete': parent::_acl('post_delete'); Post2tags::xdelete($ids); $commentModel = new PostComment(); $commentModel->deleteAll('post_id IN(' . $ids . ')'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除内容,ID:' . $ids)); parent::_delete(new Post(), $ids, array('index'), array('attach_file', 'attach_thumb')); break; case 'commentDelete': parent::_acl('post_comment_delete'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除内容评论,ID:' . $ids)); parent::_delete(new PostComment(), $ids, array('comment')); break; case 'commentVerify': parent::_acl('post_comment_verify'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '审核评论,ID:' . $ids)); parent::_verify(new PostComment(), 'verify', $ids, array('comment')); break; case 'commentUnVerify': parent::_acl('post_comment_verify'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '取消评论审核,ID:' . $ids)); parent::_verify(new PostComment(), 'unVerify', $ids, array('comment')); break; case 'verify': parent::_acl('post_verify'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '批量审核内容,ID:' . $ids)); parent::_verify(new Post(), 'verify', $ids, array('index')); break; case 'unVerify': parent::_acl('post_verify'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '批量取消内容审核,ID:' . $ids)); parent::_verify(new Post(), 'unVerify', $ids, array('index')); break; case 'commend': parent::_acl('post_commend'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '批量推荐内容,ID:' . $ids)); parent::_commend(new Post(), 'commend', $ids, array('index')); break; case 'unCommend': parent::_acl('post_commend'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '批量取消内容推荐,ID:' . $ids)); parent::_commend(new Post(), 'unCommend', $ids, array('index')); break; case 'specialDelete': parent::_acl('post_special_delete'); AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除内容,ID:' . $ids)); parent::_delete(new Special(), $ids, array('special'), array('attach_file', 'attach_thumb')); break; default: throw new CHttpException(404, '错误的操作类型:' . $command); break; } }