Exemplo n.º 1
0
 protected function setTitle($title)
 {
     if (is_array($title)) {
         $title = implode(' | ', $title);
     }
     $title .= ' | ' . SettingsData::get('name');
     $this->set('title_for_layout', $title);
 }
Exemplo n.º 2
0
 public function settings($tab)
 {
     $settings = null;
     try {
         $settings = Settings::getAll($tab);
     } catch (\Exception $e) {
         $settings = Settings::getAll('general');
     }
     /* @var $form \Cake\Form\Form */
     $form = $settings->form;
     /* @var $validator \Cake\Validation\Validator */
     $validator = $settings->validator;
     $data = [];
     /* @var $v \ThreeCMS\Core\Settings\Setting */
     foreach ($settings->settings as $v) {
         $data[$v->getKey()] = SettingsData::get($v->getKey());
     }
     if ($this->request->is(['post', 'put'])) {
         $form->validator($validator);
         $form->validate($this->request->data);
         if (!$form->errors()) {
             try {
                 foreach ($this->request->data as $k => $v) {
                     if ($data[$k] != $v) {
                         SettingsData::set($k, $v);
                     }
                 }
             } catch (\Exception $e) {
                 $this->Flash->error(__('Veuillez réessayer.'));
             }
             $this->Flash->success(__('Paramètres enregistrés avec succès !'));
         } else {
             $this->Flash->error(__('Veuillez vérifier les données saisies !'));
         }
     } else {
         $this->request->data = $data;
     }
     $this->set(compact('settings', 'form'));
     $this->setTitle(__('Paramètres'));
 }
Exemplo n.º 3
0
 public function getSetting($key)
 {
     return SettingsData::get($key);
 }