yiiapi/demos/blog/protected/controllers/CommentController.php
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
class CommentController extends Controller
{
public $layout='column2';
/**
* @var CActiveRecord the currently loaded data model instance.
*/
private $_model;
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow authenticated users to access all actions
'users'=>array('@'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
*/
public function actionUpdate()
{
$model=$this->loadModel();
if(isset($_POST['ajax']) && $_POST['ajax']==='comment-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
if(isset($_POST['Comment']))
{
$model->attributes=$_POST['Comment'];
if($model->save())
$this->redirect(array('index'));
}
$this->render('update',array(
'model'=>$model,
));
后面还有 70 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
