コード例 #1
0
ファイル: Member.php プロジェクト: block8/octo
 public function getLoginForm($returnUrl = null)
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction('/member/login');
     $form->disableValidation();
     if (!is_null($returnUrl)) {
         $rtn = new Hidden();
         $rtn->setName('rtn');
         $rtn->setValue($returnUrl);
         $form->addField($rtn);
     }
     $form->addField(Email::create('email', 'Email Address', true));
     $form->addField(Password::create('password', 'Password', true));
     $submit = new Submit();
     $submit->setClass('button pull-right');
     $submit->setValue('Login');
     $form->addField($submit);
     return $form;
 }
コード例 #2
0
ファイル: SessionController.php プロジェクト: ntoniazzi/PHPCI
 /**
  * Handles user login (form and processing)
  */
 public function login()
 {
     $isLoginFailure = false;
     if ($this->request->getMethod() == 'POST') {
         $token = $this->getParam('token');
         if (!isset($token, $_SESSION['login_token']) || $token !== $_SESSION['login_token']) {
             $isLoginFailure = true;
         } else {
             unset($_SESSION['login_token']);
             $user = $this->userStore->getByEmail($this->getParam('email'));
             if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
                 session_regenerate_id(true);
                 $_SESSION['phpci_user_id'] = $user->getId();
                 $response = new b8\Http\Response\RedirectResponse();
                 $response->setHeader('Location', $this->getLoginRedirect());
                 return $response;
             } else {
                 $isLoginFailure = true;
             }
         }
     }
     $form = new b8\Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'session/login');
     $email = new b8\Form\Element\Email('email');
     $email->setLabel(Lang::get('email_address'));
     $email->setRequired(true);
     $email->setContainerClass('form-group');
     $email->setClass('form-control');
     $form->addField($email);
     $pwd = new b8\Form\Element\Password('password');
     $pwd->setLabel(Lang::get('password'));
     $pwd->setRequired(true);
     $pwd->setContainerClass('form-group');
     $pwd->setClass('form-control');
     $form->addField($pwd);
     $pwd = new b8\Form\Element\Submit();
     $pwd->setValue(Lang::get('log_in'));
     $pwd->setClass('btn-success');
     $form->addField($pwd);
     $tokenValue = $this->generateToken();
     $_SESSION['login_token'] = $tokenValue;
     $token = new b8\Form\Element\Hidden('token');
     $token->setValue($tokenValue);
     $form->addField($token);
     $this->view->form = $form->render();
     $this->view->failed = $isLoginFailure;
     return $this->view->render();
 }
コード例 #3
0
ファイル: SessionController.php プロジェクト: kukupigs/PHPCI
 /**
  * Handles user login (form and processing)
  */
 public function login()
 {
     $isLoginFailure = false;
     if ($this->request->getMethod() == 'POST') {
         $user = $this->userStore->getByEmail($this->getParam('email'));
         if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
             $_SESSION['user_id'] = $user->getId();
             header('Location: ' . $this->getLoginRedirect());
             die;
         } else {
             $isLoginFailure = true;
         }
     }
     $form = new b8\Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'session/login');
     $email = new b8\Form\Element\Email('email');
     $email->setLabel('Email Address');
     $email->setRequired(true);
     $email->setContainerClass('form-group');
     $email->setClass('form-control');
     $form->addField($email);
     $pwd = new b8\Form\Element\Password('password');
     $pwd->setLabel('Password');
     $pwd->setRequired(true);
     $pwd->setContainerClass('form-group');
     $pwd->setClass('form-control');
     $form->addField($pwd);
     $pwd = new b8\Form\Element\Submit();
     $pwd->setValue('Log in »');
     $pwd->setClass('btn-success');
     $form->addField($pwd);
     $this->view->form = $form->render();
     $this->view->failed = $isLoginFailure;
     return $this->view->render();
 }
コード例 #4
0
 protected function contactForm()
 {
     $form = new \Octo\Admin\Form();
     $form->addField(Form\Element\Text::create('first_name', 'First Name', true));
     $form->addField(Form\Element\Text::create('last_name', 'Last Name', true));
     $form->addField(Form\Element\Email::create('email', 'Email Address', true));
     $form->addField(Form\Element\Text::create('phone', 'Phone Number'));
     $form->addField(Form\Element\Text::create('company', 'Company'));
     $form->addField(Form\Element\Submit::create('submit', 'Save')->setValue('Save Contact'));
     return $form;
 }
コード例 #5
0
ファイル: FormTest.php プロジェクト: dw250100785/b8framework
 public function testElements()
 {
     $e = new Form\Element\Button();
     $this->assertTrue($e->validate());
     $this->assertTrue(strpos($e->render(), 'button') !== false);
     $e = new Form\Element\Checkbox();
     $e->setCheckedValue('ten');
     $this->assertTrue($e->getCheckedValue() == 'ten');
     $this->assertTrue(strpos($e->render(), 'checkbox') !== false);
     $this->assertTrue(strpos($e->render(), 'checked') === false);
     $e->setValue(true);
     $this->assertTrue(strpos($e->render(), 'checked') !== false);
     $e->setValue('ten');
     $this->assertTrue(strpos($e->render(), 'checked') !== false);
     $e->setValue('fail');
     $this->assertTrue(strpos($e->render(), 'checked') === false);
     $e = new Form\Element\CheckboxGroup();
     $this->assertTrue(strpos($e->render(), 'group') !== false);
     $e = new Form\ControlGroup();
     $this->assertTrue(strpos($e->render(), 'group') !== false);
     $e = new Form\Element\Email();
     $this->assertTrue(strpos($e->render(), 'email') !== false);
     $e = new Form\Element\Select();
     $e->setOptions(array('key' => 'Val'));
     $html = $e->render();
     $this->assertTrue(strpos($html, 'select') !== false);
     $this->assertTrue(strpos($html, 'option') !== false);
     $this->assertTrue(strpos($html, 'key') !== false);
     $this->assertTrue(strpos($html, 'Val') !== false);
     $e = new Form\Element\Submit();
     $this->assertTrue($e->validate());
     $this->assertTrue(strpos($e->render(), 'submit') !== false);
     $e = new Form\Element\Text();
     $e->setValue('test');
     $this->assertTrue(strpos($e->render(), 'test') !== false);
     $e = new Form\Element\TextArea();
     $e->setRows(10);
     $this->assertTrue(strpos($e->render(), '10') !== false);
     $e = new Form\Element\Url();
     $this->assertTrue(strpos($e->render(), 'url') !== false);
 }
コード例 #6
0
ファイル: MemberController.php プロジェクト: block8/octo
 protected function forgotPasswordForm()
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction('/member/forgot-password');
     $form->disableValidation();
     $form->addField(Email::create('email', 'Email Address', true));
     $submit = new Submit();
     $submit->setClass('button pull-right');
     $submit->setValue('Submit');
     $form->addField($submit);
     return $form;
 }
コード例 #7
0
ファイル: UserController.php プロジェクト: dw250100785/Octo
 public function profile()
 {
     if ($this->getRequest()->getMethod() == 'POST') {
         $this->currentUser->setEmail($this->getParam('email'));
         $this->currentUser->setName($this->getParam('name'));
         $password = $this->getParam('password', '');
         if (!empty($password)) {
             $this->currentUser->setHash(password_hash($password, PASSWORD_DEFAULT));
         }
         $this->currentUser = $this->userStore->save($this->currentUser);
         $this->successMessage('Profile updated successfully!');
     }
     $this->setTitle($this->currentUser->getName(), 'Edit Profile');
     $form = new \Octo\Admin\Form();
     $form->setMethod('POST');
     $name = Form\Element\Text::create('name', 'Name', true);
     $name->setValue($this->currentUser->getName());
     $email = Form\Element\Email::create('email', 'Email Address', true);
     $email->setValue($this->currentUser->getEmail());
     $password = Form\Element\Password::create('password', 'Password (enter a new password to change)', false);
     $submit = new Form\Element\Submit();
     $submit->setValue('Update Profile');
     $submit->setClass('btn btn-success');
     $form->addField($name);
     $form->addField($email);
     $form->addField($password);
     $form->addField($submit);
     $this->view->form = $form;
 }
コード例 #8
0
 /**
  * Get the email settings form.
  * @param array $values
  * @return Form
  */
 protected function getEmailForm($values = array())
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'settings/email');
     $form->addField(new Form\Element\Csrf('csrf'));
     $field = new Form\Element\Text('smtp_address');
     $field->setRequired(false);
     $field->setLabel(Lang::get('smtp_server'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $field->setValue('localhost');
     $form->addField($field);
     $field = new Form\Element\Text('smtp_port');
     $field->setRequired(false);
     $field->setPattern('[0-9]+');
     $field->setLabel(Lang::get('smtp_port'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $field->setValue(25);
     $form->addField($field);
     $field = new Form\Element\Text('smtp_username');
     $field->setRequired(false);
     $field->setLabel(Lang::get('smtp_username'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Password('smtp_password');
     $field->setRequired(false);
     $field->setLabel(Lang::get('smtp_password'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Email('from_address');
     $field->setRequired(false);
     $field->setLabel(Lang::get('from_email_address'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Email('default_mailto_address');
     $field->setRequired(false);
     $field->setLabel(Lang::get('default_notification_address'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Select('smtp_encryption');
     $field->setOptions(array('' => Lang::get('none'), 'tls' => Lang::get('tls'), 'ssl' => Lang::get('ssl')));
     $field->setRequired(false);
     $field->setLabel(Lang::get('use_smtp_encryption'));
     $field->setContainerClass('form-group');
     $field->setValue(1);
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue(Lang::get('save'));
     $field->setClass('btn btn-success pull-right');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }
コード例 #9
0
ファイル: UserController.php プロジェクト: mrudtf/PHPCI
 /**
  * Create user add / edit form.
  */
 protected function userForm($values, $type = 'add')
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'user/' . $type);
     $form->addField(new Form\Element\Csrf('csrf'));
     $field = new Form\Element\Email('email');
     $field->setRequired(true);
     $field->setLabel(Lang::get('email_address'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Text('name');
     $field->setRequired(true);
     $field->setLabel(Lang::get('name'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Password('password');
     if ($type == 'add') {
         $field->setRequired(true);
         $field->setLabel(Lang::get('password'));
     } else {
         $field->setRequired(false);
         $field->setLabel(Lang::get('password_change'));
     }
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Checkbox('is_admin');
     $field->setRequired(false);
     $field->setCheckedValue(1);
     $field->setLabel(Lang::get('is_user_admin'));
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue(Lang::get('save_user'));
     $field->setClass('btn-success');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }
コード例 #10
0
ファイル: UserController.php プロジェクト: kukupigs/PHPCI
 /**
  * Create user add / edit form.
  */
 protected function userForm($values, $type = 'add')
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'user/' . $type);
     $form->addField(new Form\Element\Csrf('csrf'));
     $field = new Form\Element\Email('email');
     $field->setRequired(true);
     $field->setLabel('Email Address');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Text('name');
     $field->setRequired(true);
     $field->setLabel('Name');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Password('password');
     if ($type == 'add') {
         $field->setRequired(true);
         $field->setLabel('Password');
     } else {
         $field->setRequired(false);
         $field->setLabel('Password (leave blank to keep current password)');
     }
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Checkbox('is_admin');
     $field->setRequired(false);
     $field->setCheckedValue(1);
     $field->setLabel('Is this user an administrator?');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue('Save User');
     $field->setClass('btn-success');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }
コード例 #11
0
ファイル: SettingsController.php プロジェクト: bztrn/PHPCI
 protected function getEmailForm($values = array())
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'settings/email');
     $form->addField(new Form\Element\Csrf('csrf'));
     $field = new Form\Element\Text('smtp_address');
     $field->setRequired(false);
     $field->setLabel('SMTP Server');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $field->setValue('localhost');
     $form->addField($field);
     $field = new Form\Element\Text('smtp_port');
     $field->setRequired(false);
     $field->setPattern('[0-9]+');
     $field->setLabel('SMTP Port');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $field->setValue(25);
     $form->addField($field);
     $field = new Form\Element\Text('smtp_username');
     $field->setRequired(false);
     $field->setLabel('SMTP Username');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Text('smtp_password');
     $field->setRequired(false);
     $field->setLabel('SMTP Password');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Email('from_address');
     $field->setRequired(false);
     $field->setLabel('From Email Address');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Email('default_mailto_address');
     $field->setRequired(false);
     $field->setLabel('Default Notification Address');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Checkbox('smtp_encryption');
     $field->setCheckedValue(1);
     $field->setRequired(false);
     $field->setLabel('Use SMTP encryption?');
     $field->setContainerClass('form-group');
     $field->setValue(1);
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue('Save »');
     $field->setClass('btn btn-success pull-right');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }