Example #1
0
 /**
  * Returns the Form object for the login form
  * 
  * @access protected
  * @param \Zepi\Turbo\Framework $framework
  * @param \Zepi\Turbo\Request\RequestAbstract $request
  * @param \Zepi\Turbo\Response\Response $response
  * @return \Zepi\Web\UserInterface\Form\Form
  */
 protected function createForm(Framework $framework, RequestAbstract $request, Response $response)
 {
     // Create the form
     $form = new Form('request-new-password', $request->getFullRoute(), 'post');
     // Add the user data group
     $errorBox = new ErrorBox('request-errors', 1);
     $form->addPart($errorBox);
     // Add the user data group
     $group = new Group('user-data', $this->translate('Please insert your username and submit the form.', '\\Zepi\\Web\\AccessControl'), array(new Text('username', $this->translate('Username', '\\Zepi\\Web\\AccessControl'), true)), 10);
     $form->addPart($group);
     // Add the submit button
     $buttonGroup = new ButtonGroup('buttons', array(new Submit('submit', $this->translate('Request new password', '\\Zepi\\Web\\AccessControl'))), 100);
     $form->addPart($buttonGroup);
     return $form;
 }
Example #2
0
 /**
  * Returns the Form object for the login form
  * 
  * @access protected
  * @param \Zepi\Turbo\Framework $framework
  * @param \Zepi\Turbo\Request\WebRequest $request
  * @param \Zepi\Turbo\Response\Response $response
  * @return \Zepi\Web\UserInterface\Form\Form
  */
 protected function createForm(Framework $framework, WebRequest $request, Response $response)
 {
     // Create the form
     $form = new Form('login', $request->getFullRoute('login'), 'post');
     // Add the user data group
     $errorBox = new ErrorBox('login-errors', 1);
     $form->addPart($errorBox);
     $origin = '';
     if ($request->hasParam('_origin')) {
         $origin = $request->getParam('_origin');
     }
     $helpText = '';
     if ($this->getSetting('accesscontrol.allowRenewPassword')) {
         $helpText = $this->translate('Lost your password? <a href="%link%">Renew it here.</a>', '\\Zepi\\Web\\AccessControl', array('link' => $request->getFullRoute('request-new-password')));
     }
     // Add the user data group
     $group = new Group('user-data', $this->translate('User data', '\\Zepi\\Web\\AccessControl'), array(new Text('username', $this->translate('Username', '\\Zepi\\Web\\AccessControl'), true), new Password('password', $this->translate('Password', '\\Zepi\\Web\\AccessControl'), true, '', $helpText), new Hidden('origin', $origin)), 10);
     $form->addPart($group);
     // Add the submit button
     $buttonGroup = new ButtonGroup('buttons', array(new Submit('submit', $this->translate('Login', '\\Zepi\\Web\\AccessControl'))), 100);
     $form->addPart($buttonGroup);
     return $form;
 }
 /**
  * Returns the Form object for the change password form
  * 
  * @access protected
  * @param \Zepi\Turbo\Framework $framework
  * @param \Zepi\Turbo\Request\WebRequest $request
  * @param \Zepi\Turbo\Response\Response $response
  * @return \Zepi\Web\UserInterface\Form\Form
  */
 protected function createForm(Framework $framework, WebRequest $request, Response $response)
 {
     // Create the form
     $form = new Form('change-password', $request->getFullRoute('profile/change-password'), 'post');
     // Add the user data group
     $errorBox = new ErrorBox('login-errors', 1);
     $form->addPart($errorBox);
     // Add the user data group
     $group = new Group('change-password', $this->translate('Please insert your old and your new password', '\\Zepi\\Web\\AccessControl'), array(new Password('old-password', $this->translate('Old password', '\\Zepi\\Web\\AccessControl'), true), new Password('new-password', $this->translate('New password', '\\Zepi\\Web\\AccessControl'), true), new Password('new-password-confirmed', $this->translate('Confirm new password', '\\Zepi\\Web\\AccessControl'), true)));
     $form->addPart($group);
     // Add the submit button
     $buttonGroup = new ButtonGroup('buttons', array(new Submit('submit', $this->translate('Change password', '\\Zepi\\Web\\AccessControl'))), 100);
     $form->addPart($buttonGroup);
     return $form;
 }
Example #4
0
 /**
  * Extracts all values from the given form and returns
  * an array with the field path and the field value.
  * 
  * @param \Zepi\Web\UserInterface\Form\Form $form
  * @return array
  */
 protected function extractFormValues(Form $form)
 {
     $values = array();
     foreach ($form->getChildrenByType('\\Zepi\\Web\\UserInterface\\Form\\Field\\FieldAbstract', true) as $field) {
         if ($field->getValue() === null) {
             continue;
         }
         $values[$field->getPath($form)] = $field->getValue();
     }
     return $values;
 }
Example #5
0
 /**
  * Updates the error box with the form data, result or error objects
  * 
  * @param \Zepi\Web\UserInterface\Form\Form $form
  * @param boolean|string $result
  * @param array $errors
  */
 public function updateErrorBox($form, $result, $errors)
 {
     if ($form->isSubmitted() && $result !== true || count($errors) > 0) {
         if (is_string($result)) {
             $this->addError(new Error(Error::GENERAL_ERROR, $result));
         } else {
             if (count($errors) > 0) {
                 foreach ($errors as $error) {
                     $this->addError($error);
                 }
             } else {
                 $this->addError(new Error(Error::UNKNOWN_ERROR, ''));
             }
         }
     }
 }
Example #6
0
 /**
  * Returns the Form object for the login form
  * 
  * @access protected
  * @param \Zepi\Turbo\Framework $framework
  * @param \Zepi\Turbo\Request\RequestAbstract $request
  * @param \Zepi\Turbo\Response\Response $response
  * @return \Zepi\Web\UserInterface\Form\Form
  */
 protected function createForm(Framework $framework, RequestAbstract $request, Response $response)
 {
     // Create the form
     $form = new Form('register', $request->getFullRoute(), 'post');
     // Add the user data group
     $errorBox = new ErrorBox('register-errors', 1);
     $form->addPart($errorBox);
     // Add the user data group
     $group = new Group('user-data', $this->translate('Please fill out the fields below and accept our terms of service.', '\\Zepi\\Web\\AccessControl'), array(new Text('username', $this->translate('Username', '\\Zepi\\Web\\AccessControl'), true), new Text('email', $this->translate('Email address', '\\Zepi\\Web\\AccessControl'), true), new Password('password', $this->translate('Password', '\\Zepi\\Web\\AccessControl'), true), new Checkbox('tos-accepted', $this->translate('Do you accept our <a href="%link%" target="_blank">terms of service</a>?', '\\Zepi\\Web\\AccessControl', array('link' => $request->getFullRoute('tos'))), true)), 10);
     $form->addPart($group);
     // Add the submit button
     $buttonGroup = new ButtonGroup('buttons', array(new Submit('submit', $this->translate('Register', '\\Zepi\\Web\\AccessControl'))), 100);
     $form->addPart($buttonGroup);
     return $form;
 }