public function actionView() { $id = zmf::val('id', 2); if (!$id) { throw new CHttpException(404, 'The requested page does not exist.'); } $info = $this->loadModel($id); $pageSize = 30; $comments = Comments::getCommentsByPage($id, 'posts', 1, $pageSize); $tags = Tags::getByIds($info['tagids']); $relatePosts = Posts::getRelations($id, 5); if (!zmf::actionLimit('visit-Posts', $id, 5, 60)) { Posts::updateCount($id, 'Posts', 1, 'hits'); } $size = '600'; if ($this->isMobile) { $size = '640'; } $info['content'] = zmf::text(array(), $info['content'], true, $size); $data = array('info' => $info, 'comments' => $comments, 'tags' => $tags, 'relatePosts' => $relatePosts, 'loadMore' => count($comments) == $pageSize ? 1 : 0); $this->favorited = Favorites::checkFavored($id, 'post'); $this->pageTitle = $info['title']; $this->selectNav = 'posts'; $this->render('view', $data); }
public function actionIndex() { $tagid = zmf::val('tagid', 2); $tagInfo = array(); $default = true; if ($tagid) { $tagInfo = Tags::getByIds($tagid); if ($tagInfo) { $default = false; $tagInfo = $tagInfo[0]; $sql = "SELECT p.id,p.uid,p.title,p.faceimg,p.content,p.tagids,p.comments,p.favorite FROM {{posts}} p,{{tag_relation}} tr WHERE tr.tagid='{$tagid}' AND tr.classify='posts' AND tr.logid=p.id AND p.`status`=" . Posts::STATUS_PASSED . " ORDER BY p.cTime DESC"; } } if ($default) { $sql = 'SELECT id,uid,title,faceimg,content,tagids,comments,favorite FROM {{posts}} WHERE `status`=1 ORDER BY cTime DESC'; } Posts::getAll(array('sql' => $sql), $pages, $posts); $size = '640'; if ($this->isMobile) { $size = '240'; } foreach ($posts as $k => $val) { if ($val['tagids'] != '') { $_tags = Tags::getByIds($val['tagids']); $posts[$k]['tagids'] = $_tags; } $posts[$k]['faceimg'] = Attachments::faceImg($val, $size); } $this->pageTitle = '文章 - ' . zmf::config('sitename'); $this->selectNav = 'posts'; $data = array('posts' => $posts, 'tagInfo' => $tagInfo, 'pages' => $pages); $this->render('/index/index', $data); }
public function actionIndex() { $type = zmf::val('type', 1); if (!$type || $type == 'staycheck') { $status = Posts::STATUS_STAYCHECK; } else { $status = Posts::STATUS_PASSED; } $sql = "SELECT c.id,c.uid,c.content,c.cTime,p.title,c.logid,c.status FROM {{comments}} c,{{posts}} p WHERE c.status={$status} AND c.logid=p.id ORDER BY c.cTime DESC"; Posts::getAll(array('sql' => $sql), $pager, $items); if (!empty($items)) { $uids = array_filter(array_keys(CHtml::listData($items, 'uid', ''))); $uidsStr = join(',', $uids); if ($uidsStr != '') { $usernames = Yii::app()->db->createCommand("SELECT id,truename FROM {{users}} WHERE id IN({$uidsStr})")->queryAll(); if (!empty($usernames)) { foreach ($items as $k => $val) { foreach ($usernames as $val2) { if ($val['uid'] > 0 && $val['uid'] == $val2['id']) { $items[$k]['loginUsername'] = $val2['truename']; } } } } } } $this->render('index', array('pages' => $pager, 'posts' => $items)); }
/** * Lists all models. */ public function actionIndex() { $criteria = new CDbCriteria(); $uid = zmf::val('uid', 2); if ($uid) { $criteria->addCondition("uid='{$uid}'"); } $criteria->order = '`status` ASC,cTime DESC'; $count = Feedback::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 30; $pager->applyLimit($criteria); $posts = Feedback::model()->findAll($criteria); $this->render('index', array('pages' => $pager, 'posts' => $posts)); }
public function actionIndex() { $uid = zmf::val('uid', 2); $username = zmf::val('username', 1); $start = zmf::val('start', 1); $end = zmf::val('end', 1); $orderBy = zmf::val('orderBy', 1); $criteria = new CDbCriteria(); $criteria->addInCondition('status', array(Posts::STATUS_NOTPASSED, Posts::STATUS_PASSED)); if ($username) { $uinfo = Users::model()->find("username LIKE '%{$username}%'"); if ($uinfo) { $uid = $uinfo['id']; } } if ($uid) { $criteria->addCondition("uid='{$uid}'"); } if ($start) { $start = strtotime($start, $now); $criteria->addCondition("cTime>='{$start}'"); } if ($end) { $end = strtotime($end, $now); $criteria->addCondition("cTime<='{$end}'"); } if ($orderBy == 'hits') { $criteria->order = 'hits DESC'; } elseif ($orderBy == 'favors') { $criteria->order = 'favors DESC'; } elseif ($orderBy == 'imgs') { $criteria->order = 'imgs DESC'; } elseif ($orderBy == 'videos') { $criteria->order = 'videos DESC'; } else { $criteria->order = 'cTime DESC'; } $count = Posts::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 30; $pager->applyLimit($criteria); $posts = Posts::model()->findAll($criteria); $this->render('index', array('pages' => $pager, 'posts' => $posts)); }
public function actionInfo() { $code = zmf::val('code', 1); $_title = SiteInfo::exTypes($code); if (!$_title) { throw new CHttpException(404, '您所查看的页面不存在'); } $info = SiteInfo::model()->find('code=:code', array(':code' => $code)); if (!$info) { throw new CHttpException(404, '您所查看的页面不存在'); } $allInfos = SiteInfo::model()->findAll(array('select' => 'code,title', 'condition' => 'code!=:code AND status=' . Posts::STATUS_PASSED, 'params' => array(':code' => $code))); //更新访问统计 Posts::updateCount($info['id'], 'SiteInfo'); $data = array('info' => $info, 'code' => $code, 'allInfos' => $allInfos); $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename'); $this->selectNav = 'about'; $this->render('about', $data); }
public function actionFavorite() { $data = zmf::val('data', 1); $type = zmf::val('type', 1); $ckinfo = Posts::favorite($data, $type, 'web'); $this->jsonOutPut($ckinfo['state'], $ckinfo['msg']); }