public function manageAction($id = false)
 {
     $this->permission('manage');
     $this->language->load("settings");
     $model = new \modules\settings\models\Settings();
     $model->language_id = $this->language->getDefaultLanguage();
     if ($id) {
         $model->key = $id;
         if (!$model->get()) {
             Brightery::error404();
         }
     } else {
     }
     if (REQUEST_METHOD == 'POST') {
         $model->attributes = ['value' => $this->input->post('value'), 'default_value' => $this->input->post('default_value'), 'required' => $this->input->post('required')];
     }
     if ($model->save()) {
         Uri_helper::redirect("management/settings");
     }
     return $this->render('settings/manage', ['item' => $id ? $model->get() : null]);
 }
Exemplo n.º 2
0
 public function indexAction()
 {
     $this->permission('index');
     $model = new \modules\settings\models\Settings();
     $model->_order_by = false;
     if (REQUEST_METHOD == 'POST') {
         foreach ($_POST as $key => $value) {
             $model->key = $key;
             $model->set('value', $value);
             $model->save();
         }
     }
     $model->reset();
     $items = $model->get();
     foreach ($items as $item) {
         $arr[$item->key] = $item->value;
     }
     return $this->render('settings/index', ['item' => $arr, 'timezones' => array_combine(\DateTimeZone::listIdentifiers(), \DateTimeZone::listIdentifiers()), 'management_styles' => $model->getAvailableStyles('management'), 'frontend_styles' => $model->getAvailableStyles('frontend'), 'frontend_layouts' => $model->getAvailableLayouts('frontend', $this->config->get('frontend_style')), 'management_layouts' => $model->getAvailableLayouts('management', $this->config->get('management_style'))]);
 }