本文整理汇总了PHP中Posts::checkInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::checkInfo方法的具体用法?PHP Posts::checkInfo怎么用?PHP Posts::checkInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Posts
的用法示例。
在下文中一共展示了Posts::checkInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionView
public function actionView($id)
{
$keyid = zmf::filterInput($id);
$checkInfo = Posts::checkInfo($info, $keyid, 'posts');
if (!$checkInfo['status']) {
$this->message(0, $checkInfo['msg']);
}
if ($info['redirect'] != '') {
$this->redirect(zmf::config('domain') . $info['redirect'], true, 301);
}
if ($info['classify'] == Posts::CLASSIFY_BLOG) {
$this->redirect(zmf::config('blog_domain') . '/post/' . $keyid . '.html', true, 301);
}
$groupInfo = array();
if ($info['groupid'] > 0) {
$groupInfo = WeddingGroup::getOne($info['groupid']);
if ($groupInfo['status'] != Posts::STATUS_PASSED) {
$this->message(0, '该团队已不存在');
}
$groupInfo['avatar'] = Users::getAvatar($groupInfo['avatar']);
}
$keyid = $info['id'];
$this->currentColid = $info['colid'];
$colinfo = Column::getSimpleInfo($info['colid']);
$breads[] = CHtml::link('作品', array('posts/index'));
if ($colinfo) {
$breads[] = CHtml::link($colinfo['title'], array('posts/index', 'colid' => $colinfo['id']));
}
//更新统计
Posts::updateCount($keyid, 'Posts');
//获取用户推荐文章
$sqlUser = "SELECT id,title,faceimg,uid,colid,cTime,updateTime FROM {{posts}} WHERE id!='{$id}' AND uid='{$info['uid']}' AND classify=" . Posts::CLASSIFY_WEDDING . " ORDER BY hits DESC LIMIT 5";
$userPosts = Yii::app()->db->createCommand($sqlUser)->queryAll();
//获取标签
$info['tagids'] = join(',', explode(',', $info['tagids']));
$relPosts = array();
if ($info['tagids'] != '') {
//获取与本文类似文章
//计算方法为与本文提到的标签相关文章出现次数最多的
$relPosts = Posts::getTopPostsByTags($id, $info['tagids']);
$_sql = "SELECT id,title FROM {{tags}} WHERE classify='posts' AND id IN({$info['tagids']})";
$info['tagids'] = Yii::app()->db->createCommand($_sql)->queryAll();
}
if (!empty($userPosts)) {
foreach ($userPosts as $k => $p) {
if ($p['faceimg'] > 0) {
$_attach = Attachments::getOne($p['faceimg']);
$_url = Attachments::getUrl($_attach);
$userPosts[$k]['faceimg'] = $_url;
} else {
$userPosts[$k]['faceimg'] = '';
}
}
}
if (!empty($relPosts)) {
foreach ($relPosts as $k => $p) {
if ($p['faceimg'] > 0) {
$_attach = Attachments::getOne($p['faceimg']);
$_url = Attachments::getUrl($_attach);
$relPosts[$k]['faceimg'] = $_url;
} else {
$relPosts[$k]['faceimg'] = '';
}
}
}
//判断是否已收藏和赞过
if (!Yii::app()->user->isGuest) {
if (Favorites::checkFavored($keyid, 'posts')) {
$this->favorited = true;
}
if (UserAction::checkAction($keyid, 'favorPost')) {
$this->favored = true;
}
}
$breads[] = $info['title'];
$data = array('colinfo' => $colinfo, 'data' => $info, 'breads' => $breads, 'userPosts' => $userPosts, 'relPosts' => $relPosts, 'groupInfo' => $groupInfo);
$this->pageTitle = (!empty($colinfo) ? "【{$colinfo['title']}】" : '') . $info['title'] . ' - ' . zmf::config('sitename');
$this->render('view', $data);
}
示例2: actionSetStatus
/**
* 将文章置为某种状态,如置顶
*/
public function actionSetStatus()
{
Users::checkPower('setstatus');
$keyid = zmf::filterInput($_POST['a']);
$classify = zmf::filterInput($_POST['b'], 't', 1);
$_status = zmf::filterInput($_POST['c'], 't', 1);
if (!$keyid) {
$this->jsonOutPut(0, '请选择对象');
}
if (!in_array($classify, array('posts', 'attachments', 'comments', 'travel'))) {
$this->jsonOutPut(0, '不允许的类型');
}
if (!in_array($_status, array('top', 'canceltop', 'del'))) {
$this->jsonOutPut(0, '不允许的类型');
}
if ($_status == 'top') {
if ($classify == 'travel') {
$attr = array('toped' => 1, 'lastTime' => zmf::now());
} elseif ($classify == 'posts') {
$attr = array('top' => 1, 'updateTime' => zmf::now());
} else {
$attr = array('top' => 1);
}
} else {
if ($_status == 'canceltop') {
if ($classify == 'travel') {
$attr = array('toped' => 0);
} else {
$attr = array('top' => 0);
}
} else {
if ($_status == 'del') {
$status = Posts::STATUS_DELED;
$attr = array('status' => Posts::STATUS_DELED);
}
}
}
$ucClassify = ucfirst($classify);
if (!class_exists($ucClassify)) {
$this->jsonOutPut(0, '不存在的类型');
}
$checkInfo = Posts::checkInfo($info, $keyid, $classify);
if (!$checkInfo['status']) {
$this->jsonOutPut(0, $checkInfo['msg']);
}
$model = new $ucClassify();
if ($model->updateByPk($keyid, $attr)) {
if ($info['uid'] != zmf::uid()) {
if ($_status == 'top' && $classify == 'posts') {
$_noticedata = array('uid' => $info['uid'], 'authorid' => zmf::uid(), 'content' => '您的文章已被置顶,' . CHtml::link('查看详情', array('posts/index', 'id' => $keyid)), 'new' => 1, 'type' => $_status . $ucClassify, 'cTime' => zmf::now(), 'from_id' => $keyid, 'from_num' => 1);
Notification::add($_noticedata);
}
}
//记录管理员的操作
$attr = array('logid' => $keyid, 'classify' => 'top', 'actype' => 'post', 'acvalue' => $_status . $ucClassify, 'desc' => '');
AdminAction::add($attr);
$this->jsonOutPut(1, '操作成功');
} else {
$this->jsonOutPut(0, '操作失败');
}
}