/** * @inheritdoc */ public function getModel($id = 0) { $model = parent::getModel($id); if (!$id || !isset($model->params['images'])) { $params = is_array($model->params) ? $model->params : []; $params['images'] = ['images' => [], 'config' => Gallery::getDefaultOptions()]; $model->params = $params; } return $model; }
/** * Creates and edits a page. * * @param int optional id of a page to edit. If id is not provided * a new page is created. * @return string */ public function actionEdit($id = 0) { $model = new Page(); if ($id) { $model = Page::find()->where(['id' => $id])->with(['author', 'editor'])->one(); } else { $model->images['config'] = Gallery::getDefaultOptions(); } $request = Yii::$app->getRequest(); if ($model->load($request->post()) && $model->save()) { Yii::$app->getSession()->setFlash('success', Yii::t('cms', 'Page saved')); if (Yii::$app->toolbar->stayAfterSave()) { return $this->redirect(['edit', 'id' => $model->id]); } else { return $this->redirect(['index']); } } $categories = Yii::$app->big->categoryManager->getDropDownList('pages'); $templates = Yii::$app->big->templateManager->getDropDownList(Yii::t('cms', '- Use default template -')); return $this->render('edit', ['model' => $model, 'templates' => $templates, 'categories' => $categories]); }
</span> </div> </div> '])->label(Yii::t('cms', 'Link')); ?> </div> </div> </div> </div> <div class="panel panel-default"> <div class="panel-body"> <div class="row"> <div class="col-md-4"> <?php echo $form->field($model, 'images[config][type]')->dropDownList(Gallery::getGalleryTypes())->label(Yii::t('cms', 'Gallery type')); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'images[config][enableJs]')->dropDownList([1 => Yii::t('cms', 'Yes'), 0 => Yii::t('cms', 'No')])->label(Yii::t('cms', 'Enable javascript')); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'images[config][enableCss]')->dropDownList([1 => Yii::t('cms', 'Yes'), 0 => Yii::t('cms', 'No')])->label(Yii::t('cms', 'Enable CSS')); ?> </div> </div> </div> </div>
if (!empty($model->meta_keywords)) { $this->registerMetaTag(['name' => 'keywords', 'content' => $model->meta_keywords]); } // setup page $params = $model->params; $showPageInformation = isset($params['show_dates']) && $params['show_dates'] || isset($params['show_editor_author']) && $params['show_editor_author']; $images = $model->images; $options = []; if (isset($images['config'])) { $options = $images['config']; unset($images['config']); } ?> <?php echo Gallery::widget(['images' => $images, 'options' => $options]); ?> <div class="row"> <div class="col-md-12"> <div id="content-wrap"> <?php if ($model->params['show_title']) { ?> <h1><?php echo Html::encode($model->title); ?> </h1> <?php } ?>