视频丢了一段,在postController里面那段。有源代码吗?丢了就出错了
视频丢了一段,在postController里面那段。有源代码吗?丢了就出错了
视频丢了一段,在postController里面那段。有源代码吗?丢了就出错了
2016-12-17
<?php
namespace frontend\controllers;
use frontend\controllers\base\BaseController;
use frontend\models\PostForm;
use common\models\Cats;
use Yii;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use common\models\PostExtends;
class PostController extends BaseController
{
/**
* 首页
*/
public function actionIndex(){
return $this->render('index');
}
/**
* 控制登录权限
* @see \yii\base\Component::behaviors()
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['index', 'create', 'upload', 'ueditor'],
'rules' => [
[
'actions' => ['index'],
'allow' => true,
],
[
'actions' => ['create', 'upload', 'ueditor'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'*' => ['post','get'],
],
],
];
}
/**
* 创建文章
*/
public function actionCreate()
{
$model = new PostForm();
//定义场景
$model->setScenario(PostForm::SCENARIOS_CREATE);
if($model->load(Yii::$app->request->post())&&$model->validate()){
if(!$model->create()){
Yii::$app->session->setFlash('warning',$model->_lastError);
}else{
return $this->redirect(['post/view', 'id'=>$model->id]);
}
}
//获取所有分类
$cats = Cats::getAllCats();
return $this->render('create',['model' => $model,'cat'=>$cats]);
}
public function actionView($id)
{
$model = new PostForm();
$data = $model->getViewById($id);
$model = new PostExtends();
$model->upCounters(['post_id'=>$id],'browser',1);
return $this->render('view',['data'=>$data]);
}
/**
* 插件调用
* @see \yii\base\Controller::actions()
*/
public function actions()
{
return [
'upload'=>[
'class' => 'common\widgets\file_upload\UploadAction', //这里扩展地址别写错
'config' => [
'imagePathFormat' => "/image/{yyyy}{mm}{dd}/{time}{rand:6}",
]
],
'ueditor'=>[
'class' => 'common\widgets\ueditor\UeditorAction',
'config'=>[
//上传图片配置
'imageUrlPrefix' => "", /* 图片访问路径前缀 */
'imagePathFormat' => "/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
]
],
];
}
}
?>
举报