Ejemplo n.º 1
0
 public function init()
 {
     $firstName = new Monkeys_Form_Element_Text('firstname');
     translate('First Name');
     $firstName->setLabel('First Name')->setRequired(true);
     $lastName = new Monkeys_Form_Element_Text('lastname');
     translate('Last Name');
     $lastName->setLabel('Last Name')->setRequired(true);
     $email = new Monkeys_Form_Element_Text('email');
     translate('E-mail');
     $email->setLabel('E-mail')->addFilter('StringToLower')->setRequired(true)->addValidator('EmailAddress');
     $username = new Monkeys_Form_Element_Text('username');
     translate('Username');
     $username->setLabel('Username')->addValidator(new Monkeys_Validate_Username())->setRequired(true);
     $password1 = new Monkeys_Form_Element_Password('password1');
     translate('Enter desired password');
     $passwordValidator = new Monkeys_Validate_Password();
     $password1->setLabel('Enter desired password')->setRequired(true)->addValidator(new Monkeys_Validate_PasswordConfirmation())->addValidator($passwordValidator);
     if ($restrictions = $passwordValidator->getPasswordRestrictionsDescription()) {
         $password1->setDescription($restrictions);
     }
     $password2 = new Monkeys_Form_Element_Password('password2');
     translate('Enter password again');
     $password2->setLabel('Enter password again')->setRequired(true);
     // ZF has some bugs when using mutators here, so I have to use the config array
     translate('Please enter the text below');
     $captcha = new Monkeys_Form_Element_Captcha('captcha', array('label' => 'Please enter the text below', 'captcha' => array('captcha' => 'Image', 'sessionClass' => get_class(Zend_Registry::get('appSession')), 'font' => APP_DIR . '/libs/Monkeys/fonts/Verdana.ttf', 'imgDir' => WEB_DIR . '/captchas', 'imgUrl' => $this->_baseWebDir . '/captchas', 'wordLen' => 4, 'fontSize' => 30, 'timeout' => 300)));
     $this->addElements(array($firstName, $lastName, $email, $username, $password1, $password2, $captcha));
 }
Ejemplo n.º 2
0
 public function init()
 {
     $hostname = new Monkeys_Form_Element_Text('hostname');
     translate('Hostname');
     translate('usually localhost');
     $hostname->setLabel('Hostname')->setDescription('usually localhost')->setRequired(true)->setDecoratorOptions(array('dontMarkRequired' => true))->setValue('localhost');
     $dbname = new Monkeys_Form_Element_Text('dbname');
     translate('Database name');
     $dbname->setLabel('Database name')->setRequired(true)->setDecoratorOptions(array('dontMarkRequired' => true))->setValue(Zend_Registry::get('config')->database->params->dbname);
     $dbusername = new Monkeys_Form_Element_Text('dbusername');
     translate('Database username');
     $dbusername->setLabel('Database username')->setRequired(true)->setDecoratorOptions(array('dontMarkRequired' => true));
     $dbpassword = new Monkeys_Form_Element_Password('dbpassword');
     translate('Database password');
     $dbpassword->setLabel('Database password');
     $supportemail = new Monkeys_Form_Element_Text('supportemail');
     translate('Support E-mail');
     translate('Will be used as the sender for any message sent by the system, and as the recipient for user feedback');
     $supportemail->setLabel('Support E-mail')->setDescription('Will be used as the sender for any message sent by the system, and as the recipient for user feedback')->addFilter('StringToLower')->addValidator('EmailAddress')->setRequired(true)->setDecoratorOptions(array('dontMarkRequired' => true));
     $username = new Monkeys_Form_Element_Text('username');
     $username->setLabel('Username')->setRequired(true)->setDecoratorOptions(array('dontMarkRequired' => true));
     $password1 = new Monkeys_Form_Element_Password('password1');
     translate('Enter password');
     $passwordValidator = new Monkeys_Validate_Password();
     $password1->setLabel('Enter password')->setRequired(true)->setDecoratorOptions(array('dontMarkRequired' => true))->addValidator(new Monkeys_Validate_PasswordConfirmation())->addValidator($passwordValidator);
     if ($restrictions = $passwordValidator->getPasswordRestrictionsDescription()) {
         $password1->setDescription($restrictions);
     }
     $password2 = new Monkeys_Form_Element_Password('password2');
     translate('Enter password again');
     $password2->setLabel('Enter password again')->setRequired(true)->setDecoratorOptions(array('dontMarkRequired' => true));
     $this->addElements(array($hostname, $dbname, $dbusername, $dbpassword, $supportemail, $username, $password1, $password2));
 }
Ejemplo n.º 3
0
 public function init()
 {
     $username = new Monkeys_Form_Element_Text('username');
     translate('Username');
     $username->setLabel('Username')->addValidator(new Monkeys_Validate_Username())->setRequired(true);
     $firstname = new Monkeys_Form_Element_Text('firstname');
     translate('First Name');
     $firstname->setLabel('First Name')->setRequired(true);
     $lastname = new Monkeys_Form_Element_Text('lastname');
     translate('Last Name');
     $lastname->setLabel('Last Name')->setRequired(true);
     $email = new Monkeys_Form_Element_Text('email');
     translate('E-mail');
     $email->setLabel('E-mail')->addFilter('StringToLower')->setRequired(true)->addValidator('EmailAddress');
     $authMethod = new Monkeys_Form_Element_Select('authMethod');
     translate('Auth Method');
     $authMethod->setLabel('Auth Method')->addMultiOption(Users_Model_User::AUTH_PASSWORD, 'Password')->addMultiOption(Users_Model_User::AUTH_YUBIKEY, 'YubiKey')->setAttrib('onchange', 'COMMID.general.toggleYubikey()');
     $yubikey = new Monkeys_Form_Element_Text('yubikey');
     translate('Associated YubiKey');
     $yubikey->setLabel('Associated YubiKey')->setAttrib('class', 'yubiKeyInput');
     $this->addElements(array($username, $firstname, $lastname, $email, $authMethod, $yubikey));
     if (!$this->_targetUser->id) {
         $password1 = new Monkeys_Form_Element_Password('password1');
         translate('Enter password');
         $passwordValidator = new Monkeys_Validate_Password();
         $password1->setLabel('Enter password')->setRequired(true)->addValidator(new Monkeys_Validate_PasswordConfirmation())->addValidator($passwordValidator);
         if ($restrictions = $passwordValidator->getPasswordRestrictionsDescription()) {
             $password1->setDescription($restrictions);
         }
         $password2 = new Monkeys_Form_Element_Password('password2');
         translate('Enter password again');
         $password2->setLabel('Enter password again')->setRequired(true);
         $this->addElements(array($password1, $password2));
     }
 }
Ejemplo n.º 4
0
 public function init()
 {
     if ($this->_sregProps) {
         foreach ($this->_sregProps as $fieldName => $mandatory) {
             if (isset($this->_formElements[$fieldName])) {
                 $element = $this->_formElements[$fieldName]['element'];
                 if ($mandatory) {
                     // override label
                     $element->setLabel($this->_formElements[$fieldName]['field']->name);
                     $element->setRequired(true);
                 }
             } else {
                 $element = new Monkeys_Form_Element_Text("openid.sreg.{$fieldName}");
                 $element->setLabel($fieldName);
                 if ($mandatory) {
                     $element->setRequired(true);
                 }
             }
             // user openid standard notation for the field names, instead of
             // our field IDs.
             $element->setName('openid_sreg_' . $fieldName);
             $this->addElement($element);
         }
     } else {
         $profileName = new Monkeys_Form_Element_Text('profileName');
         translate('Profile Name');
         $profileName->setLabel('Profile Name')->setRequired(true)->setValue($this->_profile->name);
         $this->addElement($profileName);
         foreach ($this->_formElements as $formElement) {
             $this->addElement($formElement['element']);
         }
     }
 }
Ejemplo n.º 5
0
 public function init()
 {
     $username = new Monkeys_Form_Element_Text('username');
     translate('Username');
     $username->setLabel('Username')->addValidator(new Monkeys_Validate_Username())->setRequired(true);
     $password = new Monkeys_Form_Element_Password('password');
     translate('Password');
     $password->setLabel('Password')->setRequired(true);
     $this->addElements(array($username, $password));
 }
Ejemplo n.º 6
0
 public function init()
 {
     $subject = new Monkeys_Form_Element_Text('subject');
     translate('Subject');
     $subject->setLabel('Subject')->setRequired(true);
     $cc = new Monkeys_Form_Element_Text('cc');
     translate('CC');
     $cc->setLabel('CC');
     $bodyPlain = new Monkeys_Form_Element_Textarea('bodyPlain');
     $bodyPlain->setDecoratorOptions(array('separateLine' => true));
     $bodyHTML = new Monkeys_Form_Element_Richtextarea('bodyHTML');
     $bodyHTML->setDecoratorOptions(array('separateLine' => true))->setAttrib('width', '510px');
     $this->addElements(array($subject, $cc, $bodyPlain, $bodyHTML));
 }
Ejemplo n.º 7
0
 public function init()
 {
     $title = new Monkeys_Form_Element_Text('title');
     translate('Title');
     $title->setLabel('Title')->setRequired(true)->setAttrib('style', 'width:350px');
     $date = new Monkeys_Form_Element_DateTime('date');
     translate('Publication date');
     $date->setLabel('Publication date')->setShowEmptyValues(false)->setStartEndYear(1900, date('Y') + 1)->setReverseYears(true)->setValue(date('Y-m-d H:i'));
     $excerpt = new Monkeys_Form_Element_Textarea('excerpt');
     translate('Excerpt');
     $excerpt->setLabel('Excerpt')->setAttrib('style', 'width:350px')->setAttrib('rows', 4);
     $content = new Monkeys_Form_Element_Richtextarea('content');
     $content->setDecoratorOptions(array('separateLine' => true))->setAttrib('width', '510px')->setRequired(true);
     $this->addElements(array($title, $date, $excerpt, $content));
 }
Ejemplo n.º 8
0
 public function init()
 {
     $name = new Monkeys_Form_Element_Text('name');
     translate('Enter your name');
     $name->setLabel('Enter your name')->setRequired(true);
     $email = new Monkeys_Form_Element_Text('email');
     translate('Enter your E-mail');
     $email->setLabel('Enter your E-mail')->addFilter('StringToLower')->setRequired(true)->addValidator('EmailAddress');
     $feedback = new Monkeys_Form_Element_Textarea('feedback');
     translate('Enter your questions or comments');
     $feedback->setLabel('Enter your questions or comments')->setRequired(true)->setAttrib('cols', 60)->setAttrib('rows', 4);
     // ZF has some bugs when using mutators here, so I have to use the config array
     translate('Please enter the text below');
     $captcha = new Monkeys_Form_Element_Captcha('captcha', array('label' => 'Please enter the text below', 'captcha' => array('captcha' => 'Image', 'sessionClass' => get_class(Zend_Registry::get('appSession')), 'font' => APP_DIR . '/libs/Monkeys/fonts/Verdana.ttf', 'imgDir' => WEB_DIR . '/captchas', 'imgUrl' => $this->_baseWebDir . '/captchas', 'wordLen' => 4, 'fontSize' => 30, 'timeout' => 300)));
     $this->addElements(array($name, $email, $feedback, $captcha));
 }
Ejemplo n.º 9
0
 public function init()
 {
     $openIdIdentity = new Monkeys_Form_Element_Text('openIdIdentity');
     translate('OpenID URL');
     $openIdIdentity->setLabel('OpenID URL')->setDecoratorOptions(array('dontMarkRequired' => true))->setAttrib('style', 'width:300px')->setRequired(false);
     $password = new Monkeys_Form_Element_Password('password');
     translate('Password');
     $password->setLabel('Password')->setAttrib('style', 'width:300px');
     $yubikey = new Monkeys_Form_Element_Text('yubikey');
     $yubikey->setLabel('YubiKey')->setAttrib('class', 'yubiKeyInput');
     $this->addElements(array($openIdIdentity, $password, $yubikey));
     if ($this->_useCaptcha) {
         $captcha = new Monkeys_Form_Element_Captcha('captcha', array('label' => 'Please enter the text below', 'captcha' => array('captcha' => 'Image', 'sessionClass' => get_class(Zend_Registry::get('appSession')), 'font' => APP_DIR . '/libs/Monkeys/fonts/Verdana.ttf', 'imgDir' => WEB_DIR . '/captchas', 'imgUrl' => $this->_baseWebDir . '/captchas', 'wordLen' => 4, 'fontSize' => 30, 'timeout' => 300)));
         $captcha->setDecoratorOptions(array('dontMarkRequired' => true));
         $this->addElement($captcha);
     }
 }
Ejemplo n.º 10
0
 public function getFormElement()
 {
     $varname = 'field_' . $this->id;
     switch ($this->type) {
         case self::TYPE_TEXT:
             $el = new Monkeys_Form_Element_Text($varname);
             break;
         case self::TYPE_DATE:
             $el = new Monkeys_Form_Element_Date($varname);
             $el->addValidator('date', false, array('format_type' => 'Y-m-d'))->setShowEmptyValues(true)->setStartEndYear(1900, date('Y') - 7)->setReverseYears(true);
             break;
         case self::TYPE_GENDER:
             translate('Male');
             translate('Female');
             $el = new Monkeys_Form_Element_Radio($varname);
             $el->setSeparator(' &nbsp')->addMultiOption('M', 'Male')->addMultiOption('F', 'Female');
             break;
         case self::TYPE_COUNTRY:
             $el = new Monkeys_Form_Element_Country($varname);
             break;
         case self::TYPE_LANGUAGE:
             $el = new Monkeys_Form_Element_Language($varname);
             break;
         case self::TYPE_TIMEZONE:
             $el = new Monkeys_Form_Element_Timezone($varname);
             break;
         case self::TYPE_EMAIL:
             $el = new Monkeys_Form_Element_Text($varname);
             $el->addValidator('EmailAddress');
             break;
         default:
             throw new Exception('Unknown field type: ' . $this->type);
             break;
     }
     $el->setLabel($this->name);
     $el->setValue($this->value);
     return $el;
 }