Esempio n. 1
0
 /**
  * Creates a new Block model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($source_id = -1, $lang_id = -1)
 {
     if ($lang_id == -1) {
         $lang_id = Language::getDefaultID();
     }
     $model = new Block();
     $model->source_id = $source_id;
     $model->lang_id = $lang_id;
     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 item
  * @return mixed
  */
 public function actionCreateItem($menu_id, $source_id = -1, $lang_id = -1)
 {
     if ($lang_id == -1) {
         $lang_id = Language::getDefaultID();
     }
     $menu = $this->findModel($menu_id);
     $items = $menu->items;
     $model = new MenuItem();
     $model->menu_id = $menu_id;
     $model->source_id = $source_id;
     $model->lang_id = $lang_id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['items', 'id' => $menu->id]);
     } else {
         return $this->render('create_item', ['items' => $items, 'menu' => $menu, 'model' => $model]);
     }
 }
Esempio n. 3
0
 /**
  * Finds source node
  * @return $this|array|null|\yii\db\ActiveRecord
  */
 public function getSource()
 {
     if ($this->source_id == -1) {
         return $this;
     }
     return $this->find()->where(['id' => $this->getSourceID(), 'lang_id' => Language::getDefaultID()])->one();
 }