本文整理匯總了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');
//.........這裏部分代碼省略.........