Exemple #1
0
 public function addSubForm(Zend_Form $form, $name, $order = null)
 {
     $form->loadDefaultDecorators();
     $form->removeDecorator('Form');
     $form->addDecorator('Fieldset')->addDecorator('DtDdWrapper');
     $form->setElementsBelongTo($name);
     return parent::addSubForm($form, $name, $order);
 }
Exemple #2
0
 function indexAction()
 {
     $this->setupCache('default');
     $this->level = 500;
     $this->requirePriviledges();
     $this->toTpl('theInclude', 'profile');
     $data = $this->_request->getParams();
     $this->toTpl('module_title', $this->t('Profile of') . " " . $data['profile']);
     //check if the user is trying to view his profile
     $edit = false;
     if ($data['profile'] == 'me' || !$data['profile'] || $data['profile'] == 'index') {
         $profile = $_SESSION['user']['username'];
         $edit = true;
     } else {
         $profile = $data['profile'];
         $edit = false;
     }
     //try to get the user...
     $user = $this->getUserByName($profile);
     //now we need to get the data for this user
     $user['data'] = $this->getUserData($user['id']);
     //now if the user is viewing his profile, we need to create a nice form in order for him to edit the data
     if ($edit) {
         //get the fields
         $fields = $this->getUserProfileFields();
         $form = new Zend_Form();
         $form->setView($this->tpl);
         $form->setAttrib('class', 'form');
         $form->removeDecorator('dl');
         $form->setAction($this->config->host->folder . '/profiles/update')->setMethod('post');
         foreach ($fields as $k => $v) {
             switch ($v['field_type']) {
                 case "selectbox":
                     $values = explode(",", $v['default_value']);
                     break;
                 default:
                     $values = $v['default_value'];
                     break;
             }
             $form->addElement($this->getFormElement(array('name' => $v['name'], 'value' => $v['field_type'], 'title' => $this->t(ucfirst($v['name'])), 'use_pool' => 'valuesAsKeys', 'pool_type' => $values, 'novalue' => true), $user['data'][$v['name']]));
         }
         $form->addElement($this->getFormElement(array('name' => 'uid', 'value' => 'hidden'), $user['id']));
         $submit = new Zend_Form_Element_Submit('save');
         $submit->setLabel($this->t("Update"));
         $submit->setAttrib('class', "btn btn-primary");
         $form->addElement($submit);
         $form = $this->doQoolHook('pre_assign_user_profile_form', $form);
         $this->toTpl('formTitle', $this->t("Update your profile"));
         $this->toTpl('theForm', $form);
         $user = $this->doQoolHook('pre_assign_profiles_own_user_data', $user);
     } else {
         $user = $this->doQoolHook('pre_assign_profiles_user_data', $user);
     }
     $this->doQoolHook('pre_load_profiles_tpl');
     $this->toTpl('user', $user);
 }
Exemple #3
0
 /**
  * @group ZF-3069
  */
 public function testRemovingNamedDecoratorShouldWork()
 {
     $this->form->setDecorators(array('FormElements', array(array('div' => 'HtmlTag'), array('tag' => 'div')), array(array('fieldset' => 'HtmlTag'), array('tag' => 'fieldset'))));
     $decorators = $this->form->getDecorators();
     $this->assertTrue(array_key_exists('div', $decorators));
     $this->assertTrue(array_key_exists('fieldset', $decorators));
     $this->form->removeDecorator('div');
     $decorators = $this->form->getDecorators();
     $this->assertFalse(array_key_exists('div', $decorators));
     $this->assertTrue(array_key_exists('fieldset', $decorators));
 }
Exemple #4
0
 public static function build($formConfig)
 {
     $decorators = array();
     if ($formConfig->useInternalError) {
         $decorators[] = new Saf_Form_Zend_Helper_Error(array('class' => 'formErrors', 'id' => $newFormId . 'Errors', 'placement' => 'append', 'escape' => false));
     }
     $newForm = new Zend_Form();
     $newForm->setConfig($formConfig);
     $newForm->removeDecorator('HtmlTag');
     $newFormId = $newForm->getId();
     $formDecorator = $newForm->getDecorator('Form');
     $elementDecorator = $newForm->getDecorator('FormElements');
     $decorators[] = $elementDecorator;
     $decorators[] = $formDecorator;
     $newForm->setDecorators($decorators);
     foreach ($newForm->getElements() as $element) {
         self::fixElement($element);
     }
     return $newForm;
 }
Exemple #5
0
 public function buildLoginForm($redirect = false)
 {
     try {
         $form = new Zend_Form();
         $form->setView($this->tpl);
         $form->setAttrib('class', 'form-inline');
         $form->removeDecorator('dl');
         $form->setAction($this->config->host->folder . '/dologin')->setMethod('post');
         if ($redirect) {
             $redir = new Zend_Form_Element_Hidden('redirect');
             $redir->setValue($redirect);
             $form->addElement($redir);
         }
         $username = new Zend_Form_Element_Text('username');
         $username->setDecorators(array("ViewHelper"));
         $username->setAttrib('class', 'input-medium');
         $username->setAttrib('placeholder', $this->t('Username'));
         $username->addValidator('regex', false, array('/^[a-z]/i'));
         $username->setLabel($this->t('Username'));
         $username->setRequired(true);
         $username->addFilter('StringtoLower');
         $password = $form->createElement('password', 'password');
         $password->setDecorators(array("ViewHelper"));
         $password->setAttrib('class', 'input-medium');
         $username->setLabel($this->t('Password'));
         $password->addValidator('StringLength', false, array(6))->setRequired(true);
         $submit = new Zend_Form_Element_Submit('login');
         $submit->setAttrib('class', 'btn');
         $submit->setDecorators(array("ViewHelper"));
         $submit->setLabel($this->t('Login'));
         $form->addElement($username)->addElement($password)->addElement($submit);
         $form = $this->doQoolHook('post_loginform_create', $form);
         $this->toTpl('loginForm', $form);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
Exemple #6
0
 function getLoginForm($redirect)
 {
     $form = new Zend_Form();
     $form->setView($this->tpl);
     $form->setAttrib('class', 'form-inline');
     $form->removeDecorator('dl');
     $form->setAction($this->config->host->folder . '/dologin')->setMethod('post');
     if ($redirect) {
         $redir = new Zend_Form_Element_Hidden('redirect');
         $redir->setValue($redirect);
         $redir->setLabel($this->t('This action requires you login'));
         $form->addElement($redir);
     }
     $username = new Zend_Form_Element_Text('username');
     $username->setDecorators(array("ViewHelper"));
     $username->setAttrib('class', 'input-medium');
     $username->setAttrib('placeholder', $this->language['Username']);
     $username->addValidator('regex', false, array('/^[a-z]/i'));
     $username->setLabel($this->language['Username']);
     $username->setRequired(true);
     $username->addFilter('StringtoLower');
     $password = $form->createElement('password', 'password');
     $password->setDecorators(array("ViewHelper"));
     $password->setAttrib('class', 'input-medium');
     $username->setLabel($this->language['Password']);
     $password->addValidator('StringLength', false, array(6))->setRequired(true);
     $submit = new Zend_Form_Element_Submit('login');
     $submit->setAttrib('class', 'btn');
     $submit->setDecorators(array("ViewHelper"));
     $submit->setLabel($this->t('Login'));
     $form->addElement($username)->addElement($password)->addElement($submit);
     return $form;
 }
 /**
  * Get the form used for confirming deletions.
  *
  * @see deleteConfirmAction()
  * @see deleteAction()
  * @return Zend_Form
  */
 protected function _getDeleteForm()
 {
     $form = new Zend_Form();
     $form->setElementDecorators(array('ViewHelper'));
     $form->removeDecorator('HtmlTag');
     $form->addElement('hash', 'confirm_delete_hash');
     $form->addElement('submit', 'Delete', array('class' => 'delete red button'));
     $form->setAction($this->view->url(array('action' => 'delete')));
     return $form;
 }
Exemple #8
0
 /**
  * Creates a form for email sending and assigns it to the template or displays it
  *
  */
 public function mailtoAction()
 {
     $this->totpl('theInclude', 'general');
     Zend_Registry::set('module', 'Mailto User');
     $data = $this->_request->getParams();
     $form = new Zend_Form();
     $form->setView($this->tpl);
     $form->setAttrib('class', 'form');
     $form->removeDecorator('dl');
     $form->setAction($this->config->host->folder . '/admin/mailtouser')->setMethod('post');
     $addon = new Zend_Form_Element_Hidden('fid');
     $addon->setValue($data['id']);
     $form->addElement($addon);
     $form->addElement($this->getFormElement(array("name" => 'tomail', "value" => 'textinput', "title" => $this->t("To mail")), $data['mail']));
     $form->addElement($this->getFormElement(array("name" => 'cc', "value" => 'textinput', "title" => $this->t("MailCC"))));
     $form->addElement($this->getFormElement(array("name" => 'subject', "value" => 'textinput', "title" => $this->t("Subject"))));
     $form->addElement($this->getFormElement(array("name" => 'message', "value" => 'editor', "title" => $this->t("Message"), 'attributes' => array('class' => 'editor span5', 'rows' => 8))));
     $form->addElement('hidden', 'dummy', array('required' => false, 'ignore' => true, 'autoInsertNotEmptyValidator' => false, 'decorators' => array(array('HtmlTag', array('tag' => 'hr', 'id' => 'wmd-button-bar', 'class' => 'divider')))));
     $form->dummy->clearValidators();
     $submit = new Zend_Form_Element_Submit('save');
     $submit->setAttrib('class', 'btn btn-primary');
     $submit->setDecorators(array("ViewHelper"));
     $submit->setLabel($this->t("Send"));
     $form->addElement($submit);
     if ($data['ajaxcalled']) {
         echo $form;
         die;
     }
     $this->totpl('html', $form);
 }
 /**
  * @group ZF-5613
  */
 public function testAddSubFormsPerConfig()
 {
     // Create form
     $form = new Zend_Form(array('subForms' => array(array('form' => array('elements' => array('foo' => array('text', array('label' => 'Foo', 'decorators' => array('ViewHelper', 'Label')))), 'id' => 'subform1', 'decorators' => array('FormElements')), 'name' => 'subform1', 'order' => 2), array('form' => array('elements' => array('bar' => array('text', array('label' => 'Bar', 'decorators' => array('ViewHelper', 'Label')))), 'id' => 'subform2', 'decorators' => array('FormElements')), 'name' => 'subform2', 'order' => 1))));
     $form->removeDecorator('HtmlTag');
     // Tests
     $subForms = $form->getSubForms();
     $subForm1 = current($subForms);
     $subForm2 = next($subForms);
     $this->assertSame(array('subform1', 'subform2'), array($subForm1->getName(), $subForm2->getName()));
     $expected = '<form enctype="application/x-www-form-urlencoded" action="" method="post">' . PHP_EOL . PHP_EOL . '<label for="subform2-bar" class="optional">Bar</label>' . PHP_EOL . PHP_EOL . '<input type="text" name="subform2[bar]" id="subform2-bar" value="" />' . PHP_EOL . PHP_EOL . '<label for="subform1-foo" class="optional">Foo</label>' . PHP_EOL . PHP_EOL . '<input type="text" name="subform1[foo]" id="subform1-foo" value="" />' . '</form>';
     $this->assertSame($expected, $form->render($this->getView()));
 }
Exemple #10
0
 /**
  * Возвращает массив объектов Zend_Form мини-форм по типам 
  *
  * @return array
  */
 public function getForms()
 {
     $forms = array();
     foreach ($this->configs as $fieldtype => $template) {
         $form = new Zend_Form($template);
         $form->setElementsBelongTo('fields[]');
         $form->addDisplayGroup(array_keys($template['elements']), 'main', array('legend' => $template['label'], 'class' => 'ui-widget-content'));
         $form->removeDecorator('Form');
         $form->removeDecorator('DtDdWrapper');
         $form->setTranslator($this->translate);
         $forms[$fieldtype] = $form;
     }
     return $forms;
 }