Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function before()
 {
     parent::before();
     if (isset($this->request->cookies['data-table-per-page'])) {
         $this->object->rowsPerPage = intval($this->request->cookies['data-table-per-page']);
     }
     if (isset($this->request->cookies['data-table-density'])) {
         $this->object->density = $this->request->cookies['data-table-density'];
     } else {
         $this->object->density = 'medium';
     }
     $tableSettings = new Form('tableSettings');
     $tableSettings->addField('perPage', DataType::integer(DataType::UNSIGNED));
     $tableSettings->__set('perPage', $this->object->rowsPerPage);
     $tableSettings->addField('density', DataType::enum(array('low', 'medium', 'high')));
     $tableSettings->__set('density', $this->object->density);
     $this->viewData['tableSettings'] = $tableSettings;
 }
Esempio n. 2
0
 /**
  * Set up maintenance user and install lock.
  * @param string $data POST data if any.
  * @return \Jivoo\Routing\Response|string Response.
  */
 public function configure($data = null)
 {
     $this->viewData['title'] = tr('Configure maintenance user');
     $form = new Form('user');
     $form->addField('username', DataType::string(), tr('Username'));
     $form->addField('password', DataType::string(), tr('Password'));
     $form->addField('confirmPassword', DataType::string(), tr('Confirm password'));
     $form->username = '******';
     if (isset($data)) {
         $form->addData($data['user']);
         if ($form->isValid()) {
             if ($form->password !== $form->confirmPassword) {
                 $form->addError('password', tr('The two passwords are not identical.'));
             } else {
                 $auth = $this->m->Setup->getAuth();
                 $password = $auth->passwordHasher->hash($form->password);
                 $this->m->Setup->lock($form->username, $password);
                 return $this->next();
             }
         }
     }
     $this->viewData['user'] = $form;
     return $this->render();
 }