本文整理汇总了PHP中Posts::handleContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::handleContent方法的具体用法?PHP Posts::handleContent怎么用?PHP Posts::handleContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Posts
的用法示例。
在下文中一共展示了Posts::handleContent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
public function actionCreate($id = '')
{
if (!$this->uid) {
$this->redirect(array('site/login'));
}
if ($id) {
$model = $this->loadModel($id);
} else {
$model = new SiteInfo();
}
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['SiteInfo'])) {
$filter = Posts::handleContent($_POST['SiteInfo']['content']);
$_POST['SiteInfo']['content'] = $filter['content'];
if (!empty($filter['attachids'])) {
$attkeys = array_filter(array_unique($filter['attachids']));
if (!empty($attkeys)) {
$_POST['SiteInfo']['faceimg'] = $attkeys[0];
//默认将文章中的第一张图作为封面图
}
}
$model->attributes = $_POST['SiteInfo'];
if ($model->save()) {
//将上传的图片置为通过
Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'siteinfo'));
if (!empty($attkeys)) {
$attstr = join(',', $attkeys);
if ($attstr != '') {
Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
}
}
$this->redirect(array('siteinfo/view', 'code' => $model->code));
}
}
$this->render('/site/createSiteInfo', array('model' => $model));
}
示例2: actionCreate
public function actionCreate()
{
$model = new Naodong();
if (isset($_POST['Naodong'])) {
Yii::app()->session['checkHasBadword'] = 'no';
$filter = Posts::handleContent($_POST['Naodong']['content']);
$_POST['Naodong']['content'] = $filter['content'];
if (!empty($filter['attachids'])) {
$attkeys = array_filter(array_unique($filter['attachids']));
if (!empty($attkeys)) {
$_POST['Naodong']['attachid'] = $attkeys[0];
//默认将文章中的第一张图作为封面图
}
}
if (Yii::app()->session['checkHasBadword'] == 'yes') {
$_POST['Naodong']['status'] = Posts::STATUS_STAYCHECK;
}
$model->attributes = $_POST['Naodong'];
if ($model->save()) {
//将上传的图片置为通过
Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'post'));
if (!empty($attkeys)) {
$attstr = join(',', $attkeys);
if ($attstr != '') {
Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
}
}
//更新用户作品数
Posts::updateCount($this->uid, 'Users', 1, 'posts');
Yii::app()->user->setFlash('publishSuccess', '您的作品已发表,欢迎继续添加!');
$this->redirect(array('create'));
}
}
$this->pageTitle = '脑洞患者交流会 - ' . zmf::config('sitename');
$this->render('/index/create', array('model' => $model));
}
示例3: actionAddcomment
public function actionAddcomment()
{
if (!Yii::app()->request->isAjaxRequest) {
$this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
}
if (Yii::app()->user->isGuest) {
$this->jsonOutPut(2, Yii::t('default', 'loginfirst'));
} else {
$uid = zmf::uid();
}
// $checkInfo = UserPower::check('addComment', true);
// if (!$checkInfo['status']) {
// $this->jsonOutPut(0, $checkInfo['msg']);
// }
$keyid = zmf::filterInput($_POST['k']);
$to = zmf::filterInput($_POST['to']);
$type = zmf::filterInput($_POST['t'], 't', 1);
$content = zmf::filterInput($_POST['c'], 't', 1);
if (!isset($type) or !in_array($type, array('naodong'))) {
$this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
}
if (!isset($keyid) or !is_numeric($keyid)) {
$this->jsonOutPut(0, Yii::t('default', 'pagenotexists') . '--1');
}
if (!$content) {
$this->jsonOutPut(0, '评论不能为空哦~');
}
$status = Posts::STATUS_PASSED;
//判断是否应被禁止
// $forbidInfo = Posts::isForbidden($content, 'comment');
// if ($forbidInfo['status'] != Posts::STATUS_PASSED) {
// //todo,增加用户非法操作次数
// $status = Posts::STATUS_STAYCHECK;
// }
//处理文本
$filter = Posts::handleContent($content);
$content = $filter['content'];
if (Yii::app()->session['checkHasBadword'] == 'yes') {
$status = Posts::STATUS_STAYCHECK;
}
$model = new Comments();
$ainfo = Posts::getSimpleInfo(array('keyid' => $keyid, 'origin' => strtolower($type)));
if (!$ainfo) {
$this->jsonOutPut(0, Yii::t('default', 'contentnotexists') . '--' . $type);
}
$toNotice = true;
if ($ainfo['uid'] == $uid) {
$toNotice = false;
}
$touid = $ainfo['uid'];
if ($to) {
$comInfo = Posts::getSimpleInfo(array('keyid' => $to, 'origin' => 'comments'));
if (!$comInfo || $comInfo['status'] != Posts::STATUS_PASSED) {
$to = '';
} elseif ($comInfo['uid'] == $uid) {
$toNotice = false;
} else {
$touid = $comInfo['uid'];
$toNotice = true;
}
}
$intoData = array('logid' => $keyid, 'uid' => $uid, 'content' => $content, 'cTime' => zmf::now(), 'classify' => $type, 'platform' => $this->platform, 'tocommentid' => $to, 'status' => $status);
unset(Yii::app()->session['checkHasBadword']);
$model->attributes = $intoData;
if ($model->validate()) {
if ($model->save()) {
if ($type == 'naodong') {
Posts::updateCount($keyid, 'Naodong', 1, 'comments');
$_url = CHtml::link('查看详情', array('index/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
$_content = '您的作品有了新的评论,' . $_url;
}
if ($to && $_url) {
$_content = '您的评论有了新的回复,' . $_url;
}
if ($toNotice) {
$_noticedata = array('uid' => $touid, 'authorid' => $uid, 'content' => $_content, 'new' => 1, 'type' => 'comment', 'cTime' => zmf::now(), 'from_id' => $keyid, 'from_num' => 1);
Notification::add($_noticedata);
}
$html = $this->renderPartial('//comments/_comment', array('data' => $model), true);
$this->jsonOutPut(1, $html);
} else {
$this->jsonOutPut(0, '新增评论失败');
}
} else {
$this->jsonOutPut(0, '新增评论失败');
}
}
示例4: actionAddComment
public function actionAddComment()
{
$keyid = zmf::val('k', 2);
$to = zmf::val('to', 2);
$type = zmf::val('t', 1);
$content = zmf::val('c', 1);
$email = zmf::val('email', 1);
$username = zmf::val('username', 1);
if (!isset($type) or !in_array($type, array('posts'))) {
$this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
}
if (!isset($keyid) or !is_numeric($keyid)) {
$this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
}
if (!$content) {
$this->jsonOutPut(0, '评论不能为空哦~');
}
if ($this->uid) {
$status = Posts::STATUS_PASSED;
$uid = $this->uid;
} else {
if (!$username) {
$this->jsonOutPut(0, '请填写称呼');
}
zmf::setCookie('noLoginUsername', $username, 2592000);
if ($email != '') {
$validator = new CEmailValidator();
if (!$validator->validateValue($email)) {
$this->jsonOutPut(0, '请填写正确的邮箱地址');
}
zmf::setCookie('noLoginEmail', $email, 2592000);
}
$status = Posts::STATUS_STAYCHECK;
$uid = 0;
if (zmf::actionLimit($type, $keyid, 5, 86400, true)) {
$this->jsonOutPut(0, '操作太频繁,请稍后再试');
}
}
$postInfo = Posts::model()->findByPk($keyid);
if (!$postInfo || $postInfo['status'] != Posts::STATUS_PASSED) {
$this->jsonOutPut(0, '您所评论的内容不存在');
}
//处理文本
$filter = Posts::handleContent($content);
$content = $filter['content'];
$model = new Comments();
$toNotice = true;
$touid = $postInfo['uid'];
if ($to) {
$comInfo = Comments::model()->findByPk($to);
if (!$comInfo || $comInfo['status'] != Posts::STATUS_PASSED) {
$to = '';
} elseif ($comInfo['uid'] == $uid) {
$toNotice = false;
} else {
$touid = $comInfo['uid'] > 0 ? $comInfo['uid'] : '';
$toNotice = true;
}
}
$intoData = array('logid' => $keyid, 'uid' => $uid, 'content' => $content, 'cTime' => zmf::now(), 'classify' => $type, 'platform' => '', 'tocommentid' => $to, 'status' => $status, 'username' => $username, 'email' => $email);
unset(Yii::app()->session['checkHasBadword']);
$model->attributes = $intoData;
if ($model->validate()) {
if ($model->save()) {
if ($type == 'posts') {
$_url = CHtml::link('查看详情', array('posts/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
if ($status == Posts::STATUS_PASSED) {
Posts::updateCommentsNum($keyid);
}
$_content = '您的文章有了新的评论,' . $_url;
}
if ($to && $_url) {
$_content = '您的评论有了新的回复,' . $_url;
}
if ($toNotice) {
$_noticedata = array('uid' => $touid, 'authorid' => $uid, 'content' => $_content, 'new' => 1, 'type' => 'comment', 'cTime' => zmf::now(), 'from_id' => $model->id, 'from_num' => 1);
Notification::add($_noticedata);
}
if ($uid) {
$intoData['loginUsername'] = $this->userInfo['truename'];
}
$html = $this->renderPartial('/posts/_comment', array('data' => $intoData, 'postInfo' => $postInfo), true);
$this->jsonOutPut(1, $html);
} else {
$this->jsonOutPut(0, '新增评论失败');
}
} else {
$this->jsonOutPut(0, '新增评论失败');
}
}
示例5: actionCreate
public function actionCreate($id = '')
{
$this->layout = 'common';
$id = zmf::myint($id);
if (!$this->uid) {
$this->redirect(array('site/login'));
}
if ($id) {
$model = $this->loadModel($id);
$isNew = false;
} else {
$model = new Posts();
$isNew = true;
}
if (isset($_POST['ajax']) && $_POST['ajax'] === 'posts-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['Posts'])) {
//处理文本
$filter = Posts::handleContent($_POST['Posts']['content']);
$_POST['Posts']['content'] = $filter['content'];
if (!empty($filter['attachids'])) {
$attkeys = array_filter(array_unique($filter['attachids']));
if (!empty($attkeys)) {
$_POST['Posts']['faceimg'] = $attkeys[0];
//默认将文章中的第一张图作为封面图
}
} else {
$_POST['Posts']['faceimg'] = '';
//否则将封面图置为空(有可能编辑后没有图片了)
}
if (!$_POST['Posts']['mapZoom']) {
//没有缩放级别则认为用户只是点开看了一下
$_POST['Posts']['lat'] = $_POST['Posts']['long'] = '';
}
$tagids = array_unique(array_filter($_POST['tags']));
$model->attributes = $_POST['Posts'];
if ($model->save()) {
//将上传的图片置为通过
Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'posts'));
if (!empty($attkeys)) {
$attstr = join(',', $attkeys);
if ($attstr != '') {
Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
}
}
//处理标签
$intoTags = array();
if (!empty($tagids)) {
foreach ($tagids as $tagid) {
$_info = Tags::addRelation($tagid, $model->id, 'posts');
if ($_info) {
$intoTags[] = $tagid;
}
}
}
if (!$isNew || !empty($intoTags)) {
Posts::model()->updateByPk($model->id, array('tagids' => join(',', $intoTags)));
}
if ($model->status == Posts::STATUS_NOTPASSED) {
$this->redirect(array('posts/index'));
} else {
$this->redirect(array('/posts/view', 'id' => $model->id));
}
}
}
$tags = Tags::getClassifyTags('posts');
$postTags = array();
if (!$isNew) {
$postTags = Tags::getByIds($model->tagids);
}
$this->pageTitle = '与世界分享你的旅行见闻 - ' . zmf::config('sitename');
$this->render('create', array('model' => $model, 'tags' => $tags, 'postTags' => $postTags));
}
示例6: actionCreate
/**
* 已取消其他文章类型,默认为游记
* @param type $classify,分类
*/
public function actionCreate($id = '')
{
$id = zmf::filterInput($id);
if (!zmf::uid()) {
$this->redirect(array('site/login'));
}
if ($id) {
$model = $this->loadModel($id);
if ($model->uid != zmf::uid()) {
if (!Users::checkPower('editpost', false, true)) {
throw new CHttpException(403, '不被允许的操作.');
}
}
} else {
$model = new Posts();
$model->classify = Posts::CLASSIFY_WEDDING;
//文章分类
}
if (isset($_POST['ajax']) && $_POST['ajax'] === 'posts-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['Posts'])) {
//判断是否应被禁止
//todo,应排除编辑
// $forbidInfo = Posts::isForbidden($_POST['Posts']['content'], 'post');
// if ($forbidInfo['status'] != Posts::STATUS_PASSED) {
// //todo,增加用户非法操作次数
// $_POST['Posts']['status'] = Posts::STATUS_STAYCHECK;
// }
//处理文本
$filter = Posts::handleContent($_POST['Posts']['content']);
$_POST['Posts']['content'] = $filter['content'];
foreach ($_POST['Posts'] as $k => $val) {
$_POST['Posts'][$k] = zmf::filterInput($val, 't');
}
if (Yii::app()->session['checkHasBadword'] == 'yes') {
$_POST['Posts']['status'] = Posts::STATUS_STAYCHECK;
}
if (!$model->isNewRecord) {
$_POST['Posts']['updateTime'] = zmf::now();
$isNew = false;
} else {
$isNew = true;
}
unset(Yii::app()->session['checkHasBadword']);
if (!empty($filter['attachids'])) {
$attkeys = array_filter(array_unique($filter['attachids']));
if (!empty($attkeys)) {
$_POST['Posts']['faceimg'] = $attkeys[0];
//默认将文章中的第一张图作为封面图
}
} else {
$_POST['Posts']['faceimg'] = '';
//否则将封面图置为空(有可能编辑后没有图片了)
}
//相关标签
$tags = $_POST['tagnames'];
$tags = !empty($tags) ? array_unique(array_filter($tags)) : array();
$model->attributes = $_POST['Posts'];
if ($model->save()) {
//将上传的图片置为通过
Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'posts'));
if (!empty($attkeys)) {
$attstr = join(',', $attkeys);
if ($attstr != '') {
Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
}
}
//相关标签
$tagids = array();
if (!empty($tags)) {
foreach ($tags as $str) {
$_tmp = explode('-', $str);
if ($_tmp[1] > 0) {
//添加对应关系
if (Tags::addRelation($_tmp[1], $model->id, 'posts')) {
$tagids[] = $_tmp[1];
}
} else {
//查找是否有对应话题
$_tagid = Tags::findAndAdd($_tmp[0], 'posts', $model->id);
if ($_tagid) {
$tagids[] = $_tagid;
}
}
}
$tagids = !empty($tagids) ? array_unique(array_filter($tagids)) : array();
$tagStr = join(',', $tagids);
if ($tagStr != '') {
Posts::model()->updateByPk($model->id, array('tagids' => $tagStr));
}
}
$this->redirect(array('view', 'id' => $model->id));
}
}
//.........这里部分代码省略.........
示例7: actionComment
/**
* 写评论
*/
public function actionComment()
{
if (!Yii::app()->request->isAjaxRequest) {
$this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
}
if (Yii::app()->user->isGuest) {
$this->jsonOutPut(2, Yii::t('default', 'loginfirst'));
} else {
$uid = zmf::uid();
}
$checkInfo = UserPower::check('addComment', true);
if (!$checkInfo['status']) {
$this->jsonOutPut(0, $checkInfo['msg']);
}
$keyid = zmf::filterInput($_POST['k']);
$to = zmf::filterInput($_POST['to']);
$type = zmf::filterInput($_POST['t'], 't', 1);
$content = zmf::filterInput($_POST['c'], 't', 1);
if (!isset($type) or !in_array($type, array('attachments', 'posts', 'poipost', 'poitips', 'question', 'answer', 'yueban', 'goods'))) {
$this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
}
if (!isset($keyid) or !is_numeric($keyid)) {
$this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
}
if (!$content) {
$this->jsonOutPut(0, '评论不能为空哦~');
}
$status = Posts::STATUS_PASSED;
//判断是否应被禁止
// $forbidInfo = Posts::isForbidden($content, 'comment');
// if ($forbidInfo['status'] != Posts::STATUS_PASSED) {
// //todo,增加用户非法操作次数
// $status = Posts::STATUS_STAYCHECK;
// }
//处理文本
$filter = Posts::handleContent($content);
$content = $filter['content'];
if (Yii::app()->session['checkHasBadword'] == 'yes') {
$status = Posts::STATUS_STAYCHECK;
}
$model = new Comments();
$ainfo = Posts::getSimpleInfo(array('keyid' => $keyid, 'origin' => strtolower($type)));
if (!$ainfo) {
$this->jsonOutPut(0, Yii::t('default', 'contentnotexists'));
}
$toNotice = true;
if ($ainfo['uid'] == $uid) {
$toNotice = false;
}
//当为商品评论且不是回复某人时,不提醒发布商品的人
if ($type == 'goods' && !$to) {
$toNotice = false;
}
$touid = $ainfo['uid'];
if ($to) {
$comInfo = Posts::getSimpleInfo(array('keyid' => $to, 'origin' => 'comments'));
if (!$comInfo || $comInfo['status'] != Posts::STATUS_PASSED) {
$to = '';
} elseif ($comInfo['uid'] == $uid) {
$toNotice = false;
} else {
$touid = $comInfo['uid'];
$toNotice = true;
}
}
$intoData = array('logid' => $keyid, 'uid' => $uid, 'content' => $content, 'cTime' => zmf::now(), 'classify' => $type, 'platform' => $this->platform, 'tocommentid' => $to, 'status' => $status);
unset(Yii::app()->session['checkHasBadword']);
$model->attributes = $intoData;
if ($model->validate()) {
if ($model->save()) {
if ($type == 'answer') {
Answer::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
$_url = CHtml::link('查看详情', array('question/answer', 'id' => $keyid, '#' => 'pid-' . $model->id));
$_content = '您的回答有了新的评论,' . $_url;
} elseif ($type == 'poitips') {
PoiTips::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
$_url = CHtml::link('查看详情', array('question/answer', 'id' => $keyid, '#' => 'pid-' . $model->id));
$_content = '您的短评有了新的评论,' . $_url;
} elseif ($type == 'poipost') {
$_url = CHtml::link('查看详情', array('poipost/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
PoiPost::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
$_content = '您的点评有了新的评论,' . $_url;
} elseif ($type == 'question') {
$_url = CHtml::link('查看详情', array('question/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
Question::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
$_content = '您的提问有了新的评论,' . $_url;
} elseif ($type == 'posts') {
$_url = CHtml::link('查看详情', array('posts/index', 'id' => $keyid, '#' => 'pid-' . $model->id));
Posts::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
$_content = '您的文章有了新的评论,' . $_url;
} elseif ($type == 'attachments') {
$_url = CHtml::link('查看详情', array('attachments/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
Attachments::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
$_content = '您的图片有了新的评论,' . $_url;
} elseif ($type == 'yueban') {
$_url = CHtml::link('查看详情', array('yueban/index', 'areaid' => $ainfo['toAreaid'], 'year' => zmf::time($ainfo['startTime'], 'Y'), 'month' => zmf::time($ainfo['startTime'], 'm'), 'day' => zmf::time($ainfo['startTime'], 'd')));
Posts::updateCount($keyid, 'UserYueban', 1, 'comments');
//.........这里部分代码省略.........