コード例 #1
0
 public function up()
 {
     $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
     $this->createTable('{{%prefiltered_pages}}', ['id' => Schema::TYPE_PK, 'slug' => Schema::TYPE_STRING, 'active' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'last_category_id' => 'INT UNSIGNED NOT NULL DEFAULT 0', 'params' => 'TEXT', 'title' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'announce' => 'TEXT', 'content' => 'TEXT', 'h1' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'meta_description' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'breadcrumbs_label' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'view_id' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0'], $tableOptions);
     $prefiltered_pages_item = new BackendMenu();
     $prefiltered_pages_item->attributes = ['parent_id' => BackendMenu::find()->where(['name' => 'Shop'])->one()->id, 'name' => 'Prefiltered pages', 'route' => 'backend/prefiltered-pages/index', 'icon' => 'filter', 'sort_order' => '7', 'added_by_ext' => 'core', 'rbac_check' => 'shop manage', 'css_class' => '', 'translation_category' => 'app'];
     $prefiltered_pages_item->save();
 }
コード例 #2
0
 public function up()
 {
     $parent = BackendMenu::findOne(['parent_id' => 1, 'name' => 'Reviews']);
     if (!is_null($parent)) {
         $prods = new BackendMenu();
         $prods->attributes = ['parent_id' => $parent->id, 'name' => 'Product reviews', 'route' => 'backend/review/products', 'icon' => 'comments', 'sort_order' => '0', 'added_by_ext' => 'core', 'rbac_check' => 'review manage', 'css_class' => '', 'translation_category' => 'app'];
         $prods->save();
         $pages = new BackendMenu();
         $pages->attributes = ['parent_id' => $parent->id, 'name' => 'Page reviews', 'route' => 'backend/review/pages', 'icon' => 'comments-o', 'sort_order' => '1', 'added_by_ext' => 'core', 'rbac_check' => 'review manage', 'css_class' => '', 'translation_category' => 'app'];
         $pages->save();
         $parent->route = '';
         $parent->save(true, ['route']);
     }
 }
コード例 #3
0
 public function actionEdit($parent_id = null, $id = null)
 {
     if (null === $parent_id) {
         throw new NotFoundHttpException();
     }
     /** @var null|BackendMenu|HasProperties $model */
     $model = null;
     if (null !== $id) {
         $model = BackendMenu::findById($id);
     } else {
         if (null !== ($parent = BackendMenu::findById($parent_id))) {
             $model = new BackendMenu();
             $model->loadDefaultValues();
             $model->parent_id = $parent_id;
         } else {
             $model = new BackendMenu();
             $model->loadDefaultValues();
             $model->parent_id = 0;
         }
     }
     if (null === $model) {
         throw new ServerErrorHttpException();
     }
     $post = \Yii::$app->request->post();
     if ($model->load($post) && $model->validate()) {
         if ($model->save()) {
             Yii::$app->session->setFlash('success', Yii::t('app', 'Record has been saved'));
             $returnUrl = Yii::$app->request->get('returnUrl', ['/backend/backend-menu/index']);
             switch (Yii::$app->request->post('action', 'save')) {
                 case 'next':
                     return $this->redirect(['/backend/backend-menu/edit', 'returnUrl' => $returnUrl]);
                 case 'back':
                     return $this->redirect($returnUrl);
                 default:
                     return $this->redirect(Url::toRoute(['/backend/backend-menu/edit', 'id' => $model->id, 'returnUrl' => $returnUrl, 'parent_id' => $model->parent_id]));
             }
         } else {
             throw new ServerErrorHttpException();
         }
     }
     return $this->render('form', ['model' => $model]);
 }
コード例 #4
0
 public function up()
 {
     $currencies_page_item = new BackendMenu();
     $currencies_page_item->attributes = ['parent_id' => 1, 'name' => 'Content Blocks', 'route' => 'core/backend-chunk/index', 'icon' => 'file-code-o', 'sort_order' => 7, 'added_by_ext' => 'core', 'rbac_check' => 'content manage', 'css_class' => '', 'translation_category' => 'app'];
     $currencies_page_item->save();
 }
コード例 #5
0
 public function up()
 {
     $currencies_page_item = new BackendMenu();
     $currencies_page_item->attributes = ['parent_id' => BackendMenu::find()->where(['name' => 'Shop'])->one()->id, 'name' => 'Currencies', 'route' => 'backend/currencies/index', 'icon' => 'dollar', 'sort_order' => '8', 'added_by_ext' => 'core', 'rbac_check' => 'shop manage', 'css_class' => '', 'translation_category' => 'app'];
     $currencies_page_item->save();
 }