本文整理汇总了PHP中zmf::myint方法的典型用法代码示例。如果您正苦于以下问题:PHP zmf::myint方法的具体用法?PHP zmf::myint怎么用?PHP zmf::myint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zmf
的用法示例。
在下文中一共展示了zmf::myint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}