Esempio n. 1
0
 /**
  * Creates a new Page model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  * @throws \yii\base\InvalidParamException
  */
 public function actionCreate()
 {
     $model = new Page();
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 2
0
 /**
  * Creates a new Page model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Page();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index', 'project_id' => Yii::$app->request->get('project_id')]);
     } else {
         $model->project_id = Yii::$app->request->get('project_id');
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 3
0
 /**
  * Creates a new Page model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Page();
     $pageList = Page::find()->select(['id', 'header', 'pid'])->asArray()->all();
     $pageList = Tree::header($pageList);
     $pageList = ArrayHelper::map($pageList, 'id', 'header');
     $paramsPageList = ['prompt' => 'Эта страница будет родительская', 'encode' => false, 'size' => 20];
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'pageList' => $pageList, 'paramsPageList' => $paramsPageList]);
     }
 }
Esempio n. 4
0
 public function actionCreate($catid = 0)
 {
     $model = new Page();
     $model->category_id = $catid;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         $locals = [];
         $locals['model'] = $model;
         $locals['catid'] = $catid;
         $locals['categories'] = PageCategory::getAllCategories();
         $locals['tpls'] = CommonUtility::getFrontViews('page', 'detail_');
         return $this->render('create', $locals);
     }
 }
Esempio n. 5
0
 public function actionUpdate($id)
 {
     if ($id) {
         $model = Page::findOne($id);
         if (!$model) {
             throw new NotFoundHttpException();
         }
     } else {
         $model = new Page();
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->addFlash('success', 'Страница сохранена');
         return $this->redirect(['index']);
     }
     return $this->render('update', ['model' => $model]);
 }
Esempio n. 6
0
 /**
  * Creates a new Content model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Page();
     $model->allowComment = true;
     $model->allowFeed = true;
     $model->allowPing = true;
     if (Yii::$app->request->isPost) {
         if ($model->load(Yii::$app->request->post())) {
             $model->inputAttachments = Yii::$app->request->post('inputAttachments', []);
             if ($model->save()) {
                 return $this->redirect(['index']);
             }
         }
     }
     return $this->render('create', ['model' => $model]);
 }
 /**
  * Creates a new PageData model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new PageData();
     $page = new Page();
     $model->setScenario('create');
     if (Yii::$app->request->isPost) {
         $page->load(Yii::$app->request->post());
         $model->load(Yii::$app->request->post());
         if ($page->validate()) {
             $model->id_page = $page->id;
             if ($page->save() && $model->save()) {
                 return $this->redirect(['index']);
             }
         }
     }
     return $this->render('create', ['page' => $page, 'model' => $model]);
 }
Esempio n. 8
0
 /**
  * Creates a new Page model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Page();
     $model->created_by = Yii::$app->user->id;
     $task = Yii::$app->request->post('task', 'save');
     if ($model->load(Yii::$app->request->post())) {
         //$model = $this->uploadFoto($model);
         if ($model->uploadFoto() === false) {
             Yii::$app->session->setFlash('error', 'Ошибка загрузки фото');
         }
         $model->save();
         Yii::$app->session->setFlash('success', 'Saved');
         if ($task == 'apply') {
             return $this->redirect(['update', 'id' => $model->id]);
         } else {
             return $this->redirect(['index']);
         }
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }