| @@ 9-35 (lines=27) @@ | ||
| 6 | use Extend\Core\Arch\AdminController; |
|
| 7 | use Apps\Model\Admin\Contenttag\FormSettings; |
|
| 8 | ||
| 9 | class Contenttag extends AdminController |
|
| 10 | { |
|
| 11 | const VERSION = 0.1; |
|
| 12 | ||
| 13 | public $type = 'widget'; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * Show and edit widget settings |
|
| 17 | * @return string |
|
| 18 | */ |
|
| 19 | public function actionIndex() |
|
| 20 | { |
|
| 21 | // initialize model and pass configs as arg |
|
| 22 | $model = new FormSettings($this->getConfigs()); |
|
| 23 | ||
| 24 | // check if form of depend model is submited |
|
| 25 | if ($model->send() && $model->validate()) { |
|
| 26 | $this->setConfigs($model->getAllProperties()); |
|
| 27 | App::$Session->getFlashBag()->add('success', __('Settings is successful updated')); |
|
| 28 | } |
|
| 29 | ||
| 30 | // render view output |
|
| 31 | return App::$View->render('index', [ |
|
| 32 | 'model' => $model |
|
| 33 | ]); |
|
| 34 | } |
|
| 35 | } |
|
| @@ 12-38 (lines=27) @@ | ||
| 9 | /** |
|
| 10 | * Admin controller of new content widget. |
|
| 11 | */ |
|
| 12 | class Newcontent extends AdminController |
|
| 13 | { |
|
| 14 | const VERSION = 0.1; |
|
| 15 | ||
| 16 | public $type = 'widget'; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * Show widget settings |
|
| 20 | * @return string |
|
| 21 | */ |
|
| 22 | public function actionIndex() |
|
| 23 | { |
|
| 24 | // init settings model |
|
| 25 | $model = new FormSettings($this->getConfigs()); |
|
| 26 | ||
| 27 | // check if request is submited |
|
| 28 | if ($model->send() && $model->validate()) { |
|
| 29 | $this->setConfigs($model->getResult()); |
|
| 30 | App::$Session->getFlashBag()->add('success', __('Settings is successful updated')); |
|
| 31 | } |
|
| 32 | ||
| 33 | // render viewer |
|
| 34 | return App::$View->render('index', [ |
|
| 35 | 'model' => $model->export() |
|
| 36 | ]); |
|
| 37 | } |
|
| 38 | } |
|