82 lines
1.8 KiB
PHP
82 lines
1.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
class IdiomaController extends Controller
|
||
|
|
{
|
||
|
|
public function actionCreate()
|
||
|
|
{
|
||
|
|
$model=new Idioma;
|
||
|
|
|
||
|
|
// Uncomment the following line if AJAX validation is needed
|
||
|
|
// $this->performAjaxValidation($model);
|
||
|
|
|
||
|
|
if(isset($_POST['Idioma']))
|
||
|
|
{
|
||
|
|
$model->attributes=$_POST['Idioma'];
|
||
|
|
if($model->save())
|
||
|
|
$this->redirect(array('index','id'=>$model->id));
|
||
|
|
}
|
||
|
|
|
||
|
|
$this->render('create',array(
|
||
|
|
'model'=>$model,
|
||
|
|
));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function actionDelete($id)
|
||
|
|
{
|
||
|
|
if(Yii::app()->request->isPostRequest)
|
||
|
|
{
|
||
|
|
// we only allow deletion via POST request
|
||
|
|
$this->loadModel($id)->delete();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
public function actionIndex()
|
||
|
|
{
|
||
|
|
$model=new Idioma('search');
|
||
|
|
$model->unsetAttributes(); // clear any default values
|
||
|
|
|
||
|
|
if(isset($_GET['Idioma']))
|
||
|
|
$model->attributes=$_GET['Idioma'];
|
||
|
|
|
||
|
|
$this->render('index',array(
|
||
|
|
'model'=>$model,
|
||
|
|
));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function actionUpdate($id)
|
||
|
|
{
|
||
|
|
$model=$this->loadModel($id);
|
||
|
|
|
||
|
|
// Uncomment the following line if AJAX validation is needed
|
||
|
|
// $this->performAjaxValidation($model);
|
||
|
|
|
||
|
|
if(isset($_POST['Idioma']))
|
||
|
|
{
|
||
|
|
$model->attributes=$_POST['Idioma'];
|
||
|
|
if($model->save())
|
||
|
|
$this->redirect(array('index','id'=>$model->id));
|
||
|
|
}
|
||
|
|
|
||
|
|
$this->render('update',array(
|
||
|
|
'model'=>$model,
|
||
|
|
));
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Returns the data model based on the primary key given in the GET variable.
|
||
|
|
* If the data model is not found, an HTTP exception will be raised.
|
||
|
|
* @param integer the ID of the model to be loaded
|
||
|
|
*/
|
||
|
|
public function loadModel($id)
|
||
|
|
{
|
||
|
|
$model=Idioma::model()->findByPk($id);
|
||
|
|
if($model===null)
|
||
|
|
throw new CHttpException(404,'The requested page does not exist.');
|
||
|
|
return $model;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|