Exemplo n.º 1
0
 public function actionCreate()
 {
     $model = new CGroup();
     $description = new CGroupDescription();
     $this->performAjaxValidation(array($model, $description), 'cgroup-form');
     if (isset($_POST['CGroupDescription'])) {
         //$model->setAttributes($_POST[$this->modelName]);
         $description->setAttributes($_POST[$this->modelName . 'Description']);
         $suc = Yii::t('info', 'CGroup was successfully created');
         $err = Yii::t('info', 'Could not update CGroup');
         $description->c_group_id = 0;
         $description->locale_code = Yii::app()->getLanguage();
         if ($model->validate() && $description->validate()) {
             if ($model->save()) {
                 $description->c_group_id = $model->id;
                 $description->save();
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, $suc);
                 if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                     $this->renderPartial('_view', array('model' => $model, 'description' => $description), false, true);
                     Yii::app()->end();
                 } else {
                     $this->redirect(array('view', 'id' => $model->id));
                 }
             } else {
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, $err);
             }
         } else {
             $description->validate();
         }
         UtilityHelper::sendToLog($model->getErrors());
         UtilityHelper::sendToLog($description->getErrors());
     }
     if (Yii::app()->getRequest()->getIsAjaxRequest()) {
         $this->renderPartial('_form', array('model' => $model, 'description' => $description), false, true);
         Yii::app()->end();
     }
     $this->render('create', array('model' => $model, 'description' => $description));
 }
Exemplo n.º 2
0
 public function actionCreate()
 {
     $model = new Theme();
     $suc = Yii::t('info', 'The record was successfully created');
     $err = Yii::t('info', 'The record could not be created');
     $zip = new XUploadForm();
     $userZips = array();
     if (!isset($_POST[$this->modelName])) {
         Yii::app()->user->setState('images', NULL);
     }
     if (isset($_POST['Theme'])) {
         $model->attributes = $_POST['Theme'];
         $userZips = Yii::app()->user->getState('images');
         if ($model->validate()) {
             //$path = Yii::app()->runtimePath.'/dir/'.$model->zip;
             //$img->saveAs('dir/'.$model->name);
             $model->save();
             $path = $userZips[0]["path"];
             $this->unzipTheme($path, $model->name, UtilityHelper::yiiparam('frontPath') . "/www/themes");
             Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, $suc);
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 $this->renderPartial('_view', array('model' => $model), false, true);
                 Yii::app()->end();
             } else {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         } else {
             Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, $err);
         }
         UtilityHelper::sendToLog($userZips);
     }
     if (Yii::app()->getRequest()->getIsAjaxRequest()) {
         $this->renderPartial('_form', array('model' => $model, 'zip' => $zip, 'userZips' => $userZips), false, true);
         Yii::app()->end();
     }
     $this->render('create', array('model' => $model, 'zip' => $zip, 'userZips' => $userZips));
 }