예제 #1
0
 public function buildForm()
 {
     $this->setAttribute('method', 'POST');
     $category = new Select('category');
     $category->setLabel('Category')->setValueOptions(array_combine($this->getCategories(), $this->getCategories()));
     $title = new Text('title');
     $title->setLabel('Title')->setAttributes(array('size' => 50, 'maxLength' => 128, 'required' => 'required', 'placeholder' => 'Title', 'title' => 'Title'));
     $photo = new Text('photo_filename');
     $photo->setLabel('Photo')->setAttribute('maxlength', 1024)->setAttribute('placeholder', 'Enter a valid image file URL');
     $name = new Text('contact_name');
     $name->setLabel('Contact Name')->setAttribute('title', 'Contact Name')->setAttribute('size', 50)->setAttribute('maxlength', 255);
     $email = new Email('contact_email');
     $email->setLabel('Contact Email')->setAttribute('title', 'Contact Email')->setAttribute('size', 50)->setAttribute('maxlength', 255);
     $phone = new Text('contact_phone');
     $phone->setLabel('Contact Phone Number')->setAttribute('title', 'Contact Phone Number')->setAttribute('size', 20)->setAttribute('maxlength', 32);
     $city = new Select('cityCode');
     $city->setLabel('Nearest City')->setValueOptions(array_combine(self::$cityCodes, self::$cityCodes))->setAttribute('id', 'cityCode');
     $price = new Text('price');
     $price->setLabel('Price')->setAttribute('title', 'Price as nnn.nn')->setAttribute('size', 16)->setAttribute('maxlength', 16);
     $expires = new Radio('expires');
     $expires->setLabel('Expires')->setAttribute('title', 'The expiration date from today')->setAttribute('class', 'expiresButton')->setValueOptions($this->getExpireDays());
     $deleteCode = new Text('delete_code');
     $deleteCode->setLabel('Delete Code')->setAttribute('title', 'Delete code for this item')->setAttribute('size', 16)->setAttribute('maxlength', 16);
     $description = new Textarea('description');
     $description->setLabel('Description')->setAttribute('title', 'Description')->setAttribute('rows', 5)->setAttribute('cols', 80);
     $captchaAdapter = new ImageCaptcha();
     $captchaAdapter->setWordlen(4)->setOptions($this->captchaOptions);
     $captcha = new Captcha('captcha');
     $captcha->setCaptcha($captchaAdapter)->setLabel('Help us to prevent SPAM!')->setAttribute('class', 'captchaStyle')->setAttribute('title', 'Help us to prevent SPAM');
     $submit = new Submit('submit');
     $submit->setAttribute('value', 'Post');
     $this->add($category)->add($title)->add($photo)->add($name)->add($email)->add($phone)->add($city)->add($price)->add($expires)->add($deleteCode)->add($description)->add($captcha)->add($submit);
 }
예제 #2
0
 public function prepareElements($topicList, $categoryList, $captchaOptions)
 {
     // repurpose $topicList and $categoryList
     $topics = array('---' => 'Choose');
     foreach ($topicList as $item) {
         $topics[$item->item] = $item->item;
     }
     $categories = array('---' => 'Choose');
     foreach ($categoryList as $item) {
         $categories[$item->item] = $item->item;
     }
     $author = new Element\Hidden('author');
     $category1 = new Element\Text('category');
     $category1->setLabel('Category')->setAttribute('title', 'Enter a category: i.e. zf2 or use the dropdown list below')->setAttribute('size', 16)->setAttribute('maxlength', 16);
     $category2 = new Element\Select('selectCategory');
     $category2->setValueOptions($categories);
     $topic1 = new Element\Text('topic');
     $topic1->setLabel('Topic')->setAttribute('title', 'Enter a topic code: i.e. zf2f-2013-02-25 or use the dropdown list below')->setAttribute('size', 60)->setAttribute('maxlength', 254);
     $topic2 = new Element\Select('selectTopic');
     $topic2->setValueOptions($topics);
     $title = new Element\Text('title');
     $title->setLabel('Title')->setAttribute('title', 'Enter a suitable title for this posting')->setAttribute('size', 60)->setAttribute('maxlength', 254);
     $body = new Element\Textarea('body');
     $body->setLabel('Body')->setAttribute('title', 'Enter the body for this posting')->setAttribute('rows', 4)->setAttribute('cols', 60);
     $captcha = new Element\Captcha('captcha');
     $captchaAdapter = new Captcha\Image();
     $captchaAdapter->setWordlen(4)->setOptions($captchaOptions);
     $captcha->setCaptcha($captchaAdapter)->setLabel('Help us to prevent SPAM!')->setAttribute('class', 'captchaStyle')->setAttribute('title', 'Help to prevent SPAM');
     $submit = new Element\Submit('submit');
     $submit->setAttribute('value', 'Post')->setAttribute('title', 'Click here when done');
     $this->add($author)->add($topic1)->add($topic2)->add($category1)->add($category2)->add($title)->add($body)->add($captcha)->add($submit);
 }
예제 #3
0
파일: Comment.php 프로젝트: gotcms/gotcms
 /**
  * Init Module form
  *
  * @return void
  */
 public function init()
 {
     $showEmail = new Element\Checkbox('show_email');
     $showEmail->setLabel('Show email');
     $showEmail->setAttribute('required', 'required')->setAttribute('id', 'show-email');
     $username = new Element\Text('username');
     $username->setLabel('Username');
     $username->setAttribute('required', 'required')->setAttribute('id', 'username');
     $email = new Element\Text('email');
     $email->setLabel('Email');
     $email->setAttribute('required', 'required')->setAttribute('id', 'email');
     $message = new Element\Textarea('message');
     $message->setLabel('Message');
     $message->setAttribute('required', 'required')->setAttribute('id', 'message');
     $captchaImage = new CaptchaImage(array('font' => GC_PUBLIC_PATH . '/backend/fonts/arial.ttf', 'width' => 250, 'height' => 50, 'dotNoiseLevel' => 40, 'lineNoiseLevel' => 3));
     $captchaImage->setImgDir(GC_PUBLIC_PATH . '/frontend/tmp');
     $captchaImage->setImgUrl('/frontend/tmp');
     $captcha = new Element\Captcha('captcha');
     $captcha->setLabel('Please verify you are human')->setCaptcha($captchaImage)->setAttribute('required', 'required')->setAttribute('id', 'captcha');
     $this->add($showEmail);
     $this->add($username);
     $this->add($email);
     $this->add($message);
     $this->add($captcha);
     $inputFilterFactory = new InputFilterFactory();
     $inputFilter = $inputFilterFactory->createInputFilter(array('show_email' => array('name' => 'show_email', 'required' => false), 'username' => array('name' => 'username', 'required' => true), 'email' => array('name' => 'email', 'required' => true, 'validators' => array(array('name' => 'email_address'))), 'message' => array('name' => 'message', 'required' => true), 'captcha' => $captcha->getInputSpecification()));
     $this->setInputFilter($inputFilter);
 }
 public function __construct($useOldPassword = true)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'panel-body');
     if ($useOldPassword) {
         $oldPassword = new Password('oldPassword');
         $oldPassword->setLabel('old.password');
         $oldPassword->setAttribute('class', 'form-control');
         $this->add($oldPassword);
     }
     $password = new Password('password');
     $password->setLabel('password');
     $password->setAttribute('class', 'form-control');
     $this->add($password);
     $password2 = new Password('password2');
     $password2->setLabel('repeat.password');
     $password2->setAttribute('class', 'form-control');
     $this->add($password2);
     $captcha = new Captcha('register_captcha');
     $imageAdapter = new Image(['font' => __DIR__ . '/../../fonts/arial.ttf']);
     $imageAdapter->setHeight(100);
     $imageAdapter->setWidth(400);
     $imageAdapter->setFontSize(48);
     $imageAdapter->setDotNoiseLevel(400);
     $imageAdapter->setLineNoiseLevel(40);
     $captcha->setCaptcha($imageAdapter);
     $captcha->setLabel('enter.text.from.the.picture');
     $captcha->setAttribute('class', 'form-control');
     $this->add($captcha);
     $submit = new Submit('save');
     $submit->setValue('save');
     $submit->setAttribute('class', 'btn btn-primary');
     $this->add($submit);
 }
예제 #5
0
 public function __construct()
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'panel-body');
     $mail = new Email('email');
     $mail->setLabel('email');
     $mail->setAttribute('class', 'form-control');
     $this->add($mail);
     $captcha = new Captcha('register_captcha');
     $imageAdapter = new Image(['font' => __DIR__ . '/../../fonts/arial.ttf']);
     $imageAdapter->setHeight(100);
     $imageAdapter->setWidth(400);
     $imageAdapter->setFontSize(48);
     $imageAdapter->setDotNoiseLevel(400);
     $imageAdapter->setLineNoiseLevel(40);
     $captcha->setCaptcha($imageAdapter);
     $captcha->setLabel('enter.text.from.the.picture');
     $captcha->setAttribute('class', 'form-control');
     $this->add($captcha);
     $submit = new Submit('send');
     $submit->setValue('send');
     $submit->setAttribute('class', 'btn btn-primary');
     $this->add($submit);
 }
예제 #6
0
 public function __construct()
 {
     parent::__construct();
     $this->setName('mega');
     $this->setAttribute('method', 'post');
     // hidden
     $this->add(array('name' => 'one', 'attributes' => array('type' => 'hidden')));
     // Text
     $this->add(array('name' => 'two', 'attributes' => array('type' => 'text', 'label' => 'Two')));
     // Textarea
     $this->add(array('name' => 'three', 'attributes' => array('type' => 'textarea', 'label' => 'Three')));
     // MultiCheckbox
     $this->add(array('name' => 'four', 'attributes' => array('type' => 'multiCheckbox', 'label' => 'Four', 'options' => array('one' => '1', 'two' => '2'))));
     // Radio
     $this->add(array('name' => 'five', 'attributes' => array('type' => 'radio', 'label' => 'Five', 'options' => array('one' => '1', 'two' => '2'))));
     // Select
     $this->add(array('name' => 'six', 'attributes' => array('type' => 'select', 'label' => 'Six', 'options' => array('one' => '1', 'two' => '2'))));
     // Captcha
     $captcha = new Element\Captcha('seven');
     $captcha->setCaptcha(new DumbCaptchaAdapter());
     $captcha->setAttribute('label', 'Seven');
     $this->add($captcha);
     // Csrf
     $this->add(new Element\Csrf('csrf'));
     // Submit button
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'label' => 'Go')));
 }
예제 #7
0
 public function getForm($hasCaptcha, $url = '', $captchaPath = '')
 {
     if (!$this->form) {
         $form = new Form();
         $txtUser = new Element\Text('username');
         $txtUser->setLabel('User Name')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'User name');
         $password = new Element\Password('password');
         $password->setLabel('Password')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'Password');
         $remember = new Element\Checkbox('remember');
         $remember->setLabel('Save authentication?')->setAttribute('class', 'form-control');
         if ($hasCaptcha) {
             $captchaImage = new Image();
             $captchaImage->setFont('./data/font/CAMBRIA.TTC')->setWidth(200)->setHeight(60)->setDotNoiseLevel(40)->setLineNoiseLevel(4)->setExpiration(90);
             $captchaImage->setImgUrl($url);
             $captchaImage->setImgDir($captchaPath);
             $captcha = new Element\Captcha('isHuman');
             $captcha->setCaptcha($captchaImage)->setAttributes(array('class' => 'form-control'));
             $form->add($captcha);
         }
         $form->setAttribute('class', 'form-horizontal');
         $form->add($txtUser);
         $form->add($password);
         $form->add($remember);
         $this->form = $form;
     }
     return $this->form;
 }
예제 #8
0
 /**
  * @group 3446
  */
 public function testAllowsPassingTraversableOptionsToConstructor()
 {
     $options = new TestAsset\IteratorAggregate(new ArrayIterator(array('captcha' => array('class' => 'dumb', 'options' => array('sessionClass' => 'ZendTest\\Captcha\\TestAsset\\SessionContainer')))));
     $element = new CaptchaElement('captcha', $options);
     $captcha = $element->getCaptcha();
     $this->assertInstanceOf('Zend\\Captcha\\Dumb', $captcha);
 }
예제 #9
0
 /**
  * @param null|string $name
  */
 public function __construct($serviceLocator, $options = null)
 {
     parent::__construct('passwordForgot');
     $this->setServiceLocator($serviceLocator);
     $this->setAttribute('method', 'post');
     $filter = $this->getInputFilter();
     $groupBasic = new DisplayGroup('groupBasic');
     $this->add($groupBasic);
     $email = new Text('email');
     $email->setLabel('Email:');
     $email->setAttributes(['maxlength' => 255, 'autocomplete' => 'off']);
     $email->setOptions(['descriptions' => ['Nhập email khi bạn đăng ký tài khoản']]);
     $this->add($email);
     $groupBasic->addElement($email);
     $filter->add(array('name' => 'email', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập email'))), array('name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('max' => 50, 'min' => 4, 'messages' => array(StringLength::TOO_LONG => 'Tên đăng nhập giới hạn 4-50 kí tự', StringLength::TOO_SHORT => 'Tên đăng nhập giới hạn 4-50 kí tự'))), array('name' => 'EmailAddress', 'break_chain_on_failure' => true, 'options' => array('messages' => array('emailAddressInvalidFormat' => 'Địa chỉ email không hợp lệ'))))));
     $config = $this->getServiceLocator()->get('Config');
     $this->captcha = new ReCaptcha(array('pubkey' => $config['captcha']['reCAPTCHA']['publicKey'], 'privkey' => $config['captcha']['reCAPTCHA']['privateKey'], 'ssl' => !isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off' ? false : true));
     $this->captcha->setPrivkey($config['captcha']['reCAPTCHA']['privateKey']);
     $this->captcha->setPubkey($config['captcha']['reCAPTCHA']['publicKey']);
     $captcha = new Captcha('captcha');
     $captcha->setLabel('Mã bảo mật:');
     $captcha->setCaptcha($this->captcha);
     $this->add($captcha);
     $groupBasic->addElement($captcha);
     $filter->add(array('name' => 'captcha', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập email'))), $this->captcha)));
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Khôi phục mật khẩu', 'id' => 'btnSubmit', 'class' => 'htmlBtn first btn btn-primary'), 'options' => array('clearBefore' => true, 'decorator' => array('type' => 'li', 'attributes' => array('class' => 'btns')))));
 }
예제 #10
0
파일: Signin.php 프로젝트: projectHN/mentor
 /**
  * @param null|string $name
  */
 public function __construct($serviceLocator, $options = null)
 {
     parent::__construct('signin');
     $this->setServiceLocator($serviceLocator);
     $this->setAttribute('method', 'post');
     $this->setOptions(['layout' => 'fluid']);
     $filter = $this->getInputFilter();
     //$groupBasic = new DisplayGroup('groupBasic');
     //$this->add($groupBasic);
     $csrf = new Csrf('csrf');
     $this->add($csrf);
     $filter->add(array('name' => 'csrf', 'required' => false, 'filters' => array(array('name' => 'StringTrim'))));
     $mail = new Text('mail');
     $mail->setLabel('Email:');
     $mail->setAttributes(array('type' => 'text', 'id' => 'mail'));
     $this->add($mail);
     //$groupBasic->addElement($username);
     $filter->add(array('name' => 'mail', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập email đăng nhập'))), array('name' => 'EmailAddress', 'break_chain_on_failure' => true, 'options' => array('messages' => array('emailAddressInvalidFormat' => 'Địa chỉ email không hợp lệ'))))));
     $password = new Password('password');
     $password->setAttributes(array('type' => 'password', 'id' => 'password'));
     $password->setLabel('Mật khẩu:');
     $this->add($password);
     //$groupBasic->addElement($password);
     $filter->add(array('name' => 'password', 'required' => true, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập mật khẩu'))))));
     $config = $this->getServiceLocator()->get('Config');
     $this->captcha = new ReCaptcha(array('pubkey' => $config['captcha']['reCAPTCHA']['publicKey'], 'privkey' => $config['captcha']['reCAPTCHA']['privateKey'], 'ssl' => !isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off' ? false : true));
     $captcha = new Captcha('captcha');
     $captcha->setLabel('Mã bảo mật:');
     $captcha->setCaptcha($this->captcha);
     $this->add($captcha);
     //$groupBasic->addElement($captcha);
     $filter->add(array('name' => 'captcha', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập captcha'))), $this->captcha)));
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Đăng nhập', 'id' => 'btnSignin', 'class' => 'btn btn-primary col-md-12')));
     //$groupBasic->addElement($this->get('submit'));
 }
예제 #11
0
 public function addCaptcha()
 {
     $dumb = new Captcha\Dumb();
     $dumb->setLabel('Copia e incolla la seguente stringa:');
     $captcha = new Element\Captcha('captcha');
     $captcha->setCaptcha($dumb)->setLabel('Captcha');
     $this->add($captcha);
 }
예제 #12
0
 public function __construct($name = null)
 {
     parent::__construct($name);
     $image = (include __DIR__ . '/Captcha/imageCaptcha.php');
     $captcha = new Captcha('captcha');
     $captcha->setCaptcha($image)->setLabel('Please verify the characters in the image. (do not have numbers)')->setAttributes(array('type' => 'captcha', 'class' => 'input-sm', 'style' => 'display: block; margin: 10px 0 10px 0;'));
     $this->add($captcha);
 }
예제 #13
0
 public function testProvidesInputSpecificationThatIncludesCaptchaAsValidator()
 {
     $element = new CaptchaElement();
     $captcha = new Captcha\Dumb(array('sessionClass' => 'ZendTest\\Captcha\\TestAsset\\SessionContainer'));
     $element->setCaptcha($captcha);
     $inputSpec = $element->getInputSpecification();
     $this->assertArrayHasKey('validators', $inputSpec);
     $this->assertInternalType('array', $inputSpec['validators']);
     $test = array_shift($inputSpec['validators']);
     $this->assertSame($captcha, $test);
 }
예제 #14
0
 /**
  * PwLost constructor.
  * @param AdapterInterface $adapterInterface
  */
 public function __construct(AdapterInterface $adapterInterface)
 {
     parent::__construct();
     $this->add(['type' => Form\Element\Csrf::class, 'name' => 'eugzhoe45gh3o49ug2wrtu7gz50']);
     $this->add(['name' => 'username', 'options' => ['label' => 'Username'], 'attributes' => ['class' => 'form-control', 'type' => 'text', 'required' => true]]);
     $captcha = new Form\Element\Captcha('captcha');
     $captcha->setCaptcha($adapterInterface)->setOptions(['label' => 'Please verify you are human.'])->setAttributes(['class' => 'form-control', 'type' => 'text', 'required' => true]);
     $this->add($captcha);
     $submitElement = new Form\Element\Button('submit');
     $submitElement->setLabel('PwLost')->setAttributes(['class' => 'btn btn-default', 'type' => 'submit']);
     $this->add($submitElement, ['priority' => -100]);
 }
예제 #15
0
 public function init()
 {
     $name = $this->getName();
     if (null === $name) {
         $this->setName('contact');
     }
     $this->add(array('name' => 'from', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => _('From'))));
     $this->add(array('name' => 'subject', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => _('Subject'))));
     $this->add(array('name' => 'body', 'type' => 'Zend\\Form\\Element\\Textarea', 'options' => array('label' => _('Your message'))));
     $captcha = new Element\Captcha('captcha');
     $captcha->setCaptcha($this->captchaAdapter);
     $captcha->setOptions(array('label' => _('Please verify you are human.')));
     $this->add($captcha);
     $this->add(new Element\Csrf('csrf'));
     $this->add(array('name' => 'Send', 'type' => 'Zend\\Form\\Element\\Submit', 'attributes' => array('value' => _('Send'))));
 }
예제 #16
0
 public function testRendersCaptchaAsExpected()
 {
     $captcha = new Captcha\Dumb(array('sessionClass' => 'ZendTest\\Captcha\\TestAsset\\SessionContainer'));
     $element = new Element\Captcha('foo');
     $element->setCaptcha($captcha);
     $markup = $this->helper->render($element);
     $this->assertContains($captcha->getLabel(), $markup);
 }
예제 #17
0
 public function buildForm()
 {
     $this->setAttributes(array('id' => 'delete-form', 'method' => 'post'));
     $listingsId = new Element\Text('listings_id');
     $listingsId->setLabel('ID do Post');
     $listingsId->setAttributes(array('class' => 'form-control'));
     $deleteCode = new Element\Text('delete_code');
     $deleteCode->setAttribute('class', 'form-control');
     $deleteCode->setLabel('Código de deleção');
     $captcha = new Element\Captcha('captcha');
     $captchaAdapter = new ImageCaptcha(array('font' => './public/fonts/arial.ttf', 'imgDir' => './public/img/captcha', 'imgUrl' => '/img/captcha'));
     $captchaAdapter->setWordlen(4);
     $captcha->setCaptcha($captchaAdapter)->setLabel('Você é um ser humano ou um robô?')->setAttribute('class', 'captchaStyle')->setAttribute('title', 'Você é um ser humano ou um robô?');
     $csrf = new Element\Csrf('security');
     $submit = new Element\Submit('submit');
     $submit->setAttributes(array('class' => 'btn btn-default', 'value' => 'Enviar formulário'));
     $this->add($listingsId)->add($deleteCode)->add($captcha)->add($csrf)->add($submit);
 }
예제 #18
0
 public function __construct()
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'panel-body');
     $username = new Text('username');
     $username->setLabel('username');
     $username->setAttribute('class', 'form-control');
     $username->setAttribute('data-urr', '/isusernameinuse');
     $this->add($username);
     $mail = new Email('email');
     $mail->setLabel('email');
     $mail->setAttribute('class', 'form-control');
     $this->add($mail);
     $password = new Password('password');
     $password->setLabel('password');
     $password->setAttribute('class', 'form-control');
     $this->add($password);
     $password2 = new Password('password2');
     $password2->setLabel('repeat.password');
     $password2->setAttribute('class', 'form-control');
     $this->add($password2);
     $captcha = new Captcha('registerCaptcha');
     $imageAdapter = new Image(['font' => __DIR__ . '/../../fonts/arial.ttf']);
     $imageAdapter->setHeight(100);
     $imageAdapter->setWidth(400);
     $imageAdapter->setFontSize(48);
     $imageAdapter->setDotNoiseLevel(400);
     $imageAdapter->setLineNoiseLevel(40);
     $captcha->setCaptcha($imageAdapter);
     $captcha->setLabel('enter.text.from.the.picture');
     $captcha->setAttribute('class', 'form-control');
     $this->add($captcha);
     $agb = new Checkbox('gtcAccept');
     $agb->setLabel('accept.terms.of.gtc');
     $agb->setAttribute('class', 'form-control');
     $agb->setLabelAttributes(['class' => 'checkboxLabel']);
     $this->add($agb);
     $submit = new Submit('register');
     $submit->setValue('register');
     $submit->setAttribute('class', 'btn btn-primary');
     $this->add($submit);
 }
예제 #19
0
 /**
  * Categories will be retrieved from the service manager
  * @param array $captchaOptions
  */
 public function buildForm()
 {
     /******************************************************************
      * Isto é um exemplo de como realizar a configurações do formulario,
      * O importante é registrar o campos do formulário pedidos no exercícios
      **********************************************************************/
     // form tag attributes
     $this->setAttribute('method', 'POST');
     // define elements
     $category = new Element\Select('category');
     $category->setLabel('Category')->setValueOptions(array_combine($this->getCategories(), $this->getCategories()));
     $title = new Element\Text('title');
     $title->setLabel('Title')->setAttributes(array('size' => 60, 'maxLength' => 128, 'required' => 'required', 'placeholder' => 'Listing header'));
     $photo = new Element\Text('photo_filename');
     $photo->setLabel('Photo')->setAttribute('maxlength', 1024)->setAttribute('placeholder', 'Enter URL of a JPG');
     $price = new Element\Text('price');
     $price->setLabel('Price')->setAttribute('title', 'Enter price as nnn.nn')->setAttribute('size', 16)->setAttribute('maxlength', 16)->setAttribute('placeholder', 'Enter some value');
     $expires = new Element\Radio('expires');
     $expires->setLabel('Expires')->setAttribute('title', 'The expiration date will be calculated from today')->setAttribute('class', 'expiresButton')->setValueOptions($this->getExpireDays());
     $city = new Element\Text('cityCode');
     $city->setLabel('Nearest City')->setAttribute('title', 'Select the city of the item')->setAttribute('id', 'cityCode')->setAttribute('placeholder', 'Start typing and choose the city');
     $name = new Element\Text('contact_name');
     $name->setLabel('Contact Name')->setAttribute('title', 'Enter the name of the person to contact for this item')->setAttribute('size', 40)->setAttribute('maxlength', 255);
     $phone = new Element\Text('contact_phone');
     $phone->setLabel('Contact Phone Number')->setAttribute('title', 'Enter the phone number of the person to contact for this item')->setAttribute('size', 20)->setAttribute('maxlength', 32);
     $email = new Element\Email('contact_email');
     $email->setLabel('Contact Email')->setAttribute('title', 'Enter the email address of the person to contact for this item')->setAttribute('size', 40)->setAttribute('maxlength', 255);
     $description = new Element\Textarea('description');
     $description->setLabel('Description')->setAttribute('title', 'Enter a suitable description for this posting')->setAttribute('rows', 4)->setAttribute('cols', 80);
     $delCode = new Element\Text('delete_code');
     $delCode->setLabel('Delete Code')->setAttribute('title', 'Enter the delete code for this item')->setAttribute('size', 16)->setAttribute('maxlength', 16);
     $captcha = new Element\Captcha('captcha');
     $captchaAdapter = new ImageCaptcha();
     $captchaAdapter->setWordlen(4)->setOptions($this->captchaOptions);
     $captcha->setCaptcha($captchaAdapter)->setLabel('Help us to prevent SPAM!')->setAttribute('class', 'captchaStyle')->setAttribute('title', 'Help to prevent SPAM');
     $submit = new Element\Submit('submit');
     $submit->setAttribute('value', 'Post');
     $this->add($category)->add($title)->add($photo)->add($price)->add($expires)->add($city)->add($name)->add($phone)->add($email)->add($description)->add($delCode)->add($captcha)->add($submit);
 }
예제 #20
0
 public function __construct($urlcaptcha = null)
 {
     parent::__construct('User Register Form');
     $this->setAttribute('method', 'post');
     $this->add(array('name' => 'username', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => '帳號'), 'attributes' => array('type' => 'text')));
     $this->add(array('name' => 'first_name', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => '姓')));
     $this->add(array('name' => 'last_name', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => '名')));
     $this->add(array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'birthday', 'options' => array('label' => '生日', 'description' => '請輸入西元年月日,例: 2000-1-1')));
     $this->add(array('name' => 'sex', 'type' => 'Zend\\Form\\Element\\Select', 'options' => array('label' => '性別', 'value_options' => array('' => '請選擇', 'male' => '男', 'female' => '女'))));
     $this->add(array('type' => 'Zend\\Form\\Element\\Email', 'name' => 'email', 'options' => array('label' => '電子郵件')));
     $this->add(array('name' => 'password', 'options' => array('label' => '密碼'), 'attributes' => array('type' => 'password', 'placeholder' => '請輸入您的密碼')));
     $this->add(array('name' => 're_password', 'options' => array('label' => '確認密碼'), 'attributes' => array('type' => 'password', 'placeholder' => '再輸入一次密碼')));
     $this->add(new Element\Csrf('security'));
     $dirdata = './data';
     $captchaImage = new CaptchaImage(array('font' => $dirdata . '/fonts/arial.ttf', 'width' => 200, 'height' => 80, 'wordlen' => 5, 'dotNoiseLevel' => 40, 'lineNoiseLevel' => 8));
     $captchaImage->setImgDir($dirdata . '/captcha');
     $captchaImage->setImgUrl($urlcaptcha);
     $captcha = new Element\Captcha('captcha');
     $captcha->setCaptcha($captchaImage);
     $captcha->setLabel('請輸入驗證碼');
     $this->add($captcha);
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => '註冊', 'class' => 'btn btn-primary')));
 }
예제 #21
0
 /**
  * Register constructor.
  * @param EntityManager $entityManager
  * @param AdapterInterface $sanCaptcha
  * @param Collection $collection
  */
 public function __construct(EntityManager $entityManager, AdapterInterface $sanCaptcha, Collection $collection)
 {
     parent::__construct();
     $this->entityManager = $entityManager;
     $this->sanCaptcha = $sanCaptcha;
     $this->collection = $collection;
     $this->add(['type' => Form\Element\Csrf::class, 'name' => 'eugzhoe45gh3o49ug2wrtu7gz50']);
     $this->add(['name' => 'username', 'options' => ['label' => 'Username'], 'attributes' => ['placeholder' => 'Username', 'class' => 'form-control', 'type' => 'text', 'required' => true]]);
     $this->add(['name' => 'email', 'options' => ['label' => 'Email'], 'attributes' => ['placeholder' => 'Email', 'class' => 'form-control', 'type' => 'email', 'required' => true]]);
     $this->add(['name' => 'emailVerify', 'options' => ['label' => 'Email Verify'], 'attributes' => ['placeholder' => 'Email Verify', 'class' => 'form-control', 'type' => 'email', 'required' => true]]);
     $this->add(['name' => 'password', 'options' => ['label' => 'Password'], 'attributes' => ['placeholder' => 'Password', 'class' => 'form-control', 'type' => 'password', 'required' => true]]);
     $this->add(['name' => 'passwordVerify', 'options' => ['label' => 'Password Verify'], 'attributes' => ['placeholder' => 'Password Verify', 'class' => 'form-control', 'type' => 'password', 'required' => true]]);
     if ($this->collection->getConfig()['password']['secret_question']) {
         $entityOptions = $this->collection->getEntityOptions();
         $this->add(['name' => 'question', 'type' => 'DoctrineModule\\Form\\Element\\ObjectSelect', 'options' => ['object_manager' => $this->entityManager, 'target_class' => $entityOptions->getSecretQuestion(), 'property' => 'question', 'label' => 'SecretQuestion', 'empty_option' => '-- select --', 'is_method' => true, 'find_method' => ['name' => 'getQuestions']], 'attributes' => ['class' => 'form-control', 'required' => true]]);
         $this->add(['name' => 'answer', 'options' => ['label' => 'SecretAnswer'], 'attributes' => ['placeholder' => 'Answer', 'class' => 'form-control', 'type' => 'text', 'required' => true]]);
     }
     $captcha = new Form\Element\Captcha('captcha');
     $captcha->setCaptcha($this->sanCaptcha)->setOptions(['label' => 'Please verify you are human.'])->setAttributes(['class' => 'form-control', 'type' => 'text', 'required' => true]);
     $this->add($captcha, ['priority' => -90]);
     $submitElement = new Form\Element\Button('submit');
     $submitElement->setLabel('Register')->setAttributes(['class' => 'btn btn-default', 'type' => 'submit']);
     $this->add($submitElement, ['priority' => -100]);
 }
예제 #22
0
파일: Captcha.php 프로젝트: gridguyz/zork
 /**
  * Retrieve captcha (if any)
  *
  * @return null|ZendCaptcha\AdapterInterface
  */
 public function getCaptcha()
 {
     if (null === $this->captcha) {
         $serviceLocator = $this->getServiceLocator();
         if ($serviceLocator && $serviceLocator->has('Zend\\Session\\ManagerInterface')) {
             $defaultManager = SessionContainer::getDefaultManager();
             $serviceManager = $serviceLocator->get('Zend\\Session\\ManagerInterface');
             if ($defaultManager !== $serviceManager) {
                 SessionContainer::setDefaultManager($serviceManager);
             }
         }
         if ($this->defaultCaptcha instanceof AdapterInterface) {
             $captcha = clone $this->defaultCaptcha;
         } else {
             $captcha = $this->defaultCaptcha;
         }
         $this->setCaptcha($captcha);
     }
     return parent::getCaptcha();
 }
예제 #23
0
use Zend\Form\Element;
use Zend\Form\Fieldset;
use Zend\Form\Form;
use Zend\InputFilter\Input;
use Zend\InputFilter\InputFilter;
$name = new Element('name');
$name->setLabel('Your name');
$name->setAttributes(array('type' => 'text'));
$email = new Element\Email('email');
$email->setLabel('Your email address');
$subject = new Element('subject');
$subject->setLabel('Subject');
$subject->setAttributes(array('type' => 'text'));
$message = new Element\Textarea('message');
$message->setLabel('Message');
$captcha = new Element\Captcha('captcha');
$captcha->setCaptcha(new Captcha\Dumb());
$captcha->setLabel('Please verify you are human');
$csrf = new Element\Csrf('security');
$send = new Element('send');
$send->setValue('Submit');
$send->setAttributes(array('type' => 'submit'));
$form = new Form('contact');
$form->add($name);
$form->add($email);
$form->add($subject);
$form->add($message);
$form->add($captcha);
$form->add($csrf);
$form->add($send);
$nameInput = new Input('name');
예제 #24
0
 public function getElement()
 {
     $element = new CaptchaElement('foo');
     $element->setCaptcha($this->captcha);
     return $element;
 }
예제 #25
0
 public function buildForm()
 {
     $this->setAttributes(array('id' => 'post-form', 'method' => 'post'));
     $category = new Element\Select('category');
     $category->setLabel('Categoria');
     $category->setValueOptions(array_combine($this->categories, $this->categories));
     $category->setAttribute('class', 'form-control');
     $title = new Element\Text('title');
     $title->setLabel('Título');
     $title->setAttributes(array('maxlength' => 128, 'class' => 'form-control'));
     $description = new Element\Textarea('description');
     $description->setAttribute('class', 'form-control');
     $description->setLabel('Descrição');
     $photoFilename = new Element\Url('photo_filename');
     $photoFilename->setAttribute('class', 'form-control');
     $photoFilename->setLabel('Foto');
     $contactName = new Element\Text('contact_name');
     $contactName->setAttribute('class', 'form-control');
     $contactName->setLabel('Nome completo');
     $contactEmail = new Element\Email('contact_email');
     $contactEmail->setAttribute('class', 'form-control');
     $contactEmail->setLabel('E-mail');
     $contactPhone = new Element\Text('contact_phone');
     $contactPhone->setAttribute('class', 'form-control');
     $contactPhone->setLabel('Contato');
     $cityCode = new Element\Select('cityCode');
     $cityCode->setAttribute('class', 'form-control');
     $cityCode->setValueOptions($this->cities);
     $cityCode->setLabel('Cidade');
     $deleteCode = new Element\Number('delete_code');
     $deleteCode->setAttribute('class', 'form-control');
     $deleteCode->setLabel('Código de deleção');
     $captcha = new Element\Captcha('captcha');
     $captchaAdapter = new ImageCaptcha(array('font' => './public/fonts/arial.ttf', 'imgDir' => './public/img/captcha', 'imgUrl' => '/img/captcha'));
     $captchaAdapter->setWordlen(4);
     $captcha->setCaptcha($captchaAdapter)->setLabel('Você é um ser humano ou um robô?')->setAttribute('class', 'captchaStyle')->setAttribute('title', 'Você é um ser humano ou um robô?');
     /*$captcha = new Element\Captcha('captcha');
             $captcha->setCaptcha(new \Zend\Captcha\Dumb());
             $captcha->setAttribute('class', 'form-control');
             $captcha->setOptions(array('label' => 'Você é um ser humano ou um robô?'));
     */
     $price = new Element\Number('price');
     $price->setAttributes(array('class' => 'form-control', 'maxlength' => 12, 'min' => 0, 'max' => '999999999999'));
     $price->setLabel('Preço');
     $dateExpires = new Element\Radio('date_expires');
     $dateExpires->setLabel('Expira em (dias)');
     $dateExpires->setValueOptions(array_combine($this->dateExpires, $this->dateExpires));
     $csrf = new Element\Csrf('security');
     $submit = new Element\Submit('submit');
     $submit->setAttributes(array('class' => 'btn btn-default', 'value' => 'Enviar formulário'));
     $this->add($category)->add($title)->add($price)->add($dateExpires)->add($description)->add($photoFilename)->add($contactName)->add($contactEmail)->add($contactPhone)->add($cityCode)->add($deleteCode)->add($captcha)->add($csrf)->add($submit);
     /*
             $factory = new \Zend\Form\Factory();
             $factory->createForm(array(
                 'hydrator' => 'Zend\Stdlib\Hydrator\ArraySerializable',
                 'elements' => array(
                     array(
                         'name' => 'category',
                         'type' => 'text',
                         'options' => array(
                             'label' => 'Category'
                         )
                     ),
                     array(
                         'name' => 'title',
                         'type' => 'text',
                         'options' => array(
                             'label' => 'Title'
                         )
                     ),
                 )
             )); */
 }
예제 #26
0
 /**
  * @group ZF-11609
  */
 public function testIndividualDecoratorsBeforeAndAfterRendering()
 {
     // Disable default decorators is true
     $element = new CaptchaElement('foo', array('captcha' => 'Dumb', 'captchaOptions' => array('sessionClass' => 'ZendTest\\Form\\Element\\TestAsset\\SessionContainer'), 'disableLoadDefaultDecorators' => true, 'decorators' => array('Description', 'Errors', 'Captcha\\Word', 'Captcha', 'Label')));
     // Before rendering
     $decorators = array_keys($element->getDecorators());
     $this->assertSame(array('Zend\\Form\\Decorator\\Description', 'Zend\\Form\\Decorator\\Errors', 'Zend\\Form\\Decorator\\Captcha\\Word', 'Zend\\Form\\Decorator\\Captcha', 'Zend\\Form\\Decorator\\Label'), $decorators, var_export($decorators, true));
     $element->render();
     // After rendering
     $decorators = array_keys($element->getDecorators());
     $this->assertSame(array('Zend\\Form\\Decorator\\Description', 'Zend\\Form\\Decorator\\Errors', 'Zend\\Form\\Decorator\\Captcha\\Word', 'Zend\\Form\\Decorator\\Captcha', 'Zend\\Form\\Decorator\\Label'), $decorators, var_export($decorators, true));
     // Disable default decorators is false
     $element = new CaptchaElement('foo', array('captcha' => 'Dumb', 'captchaOptions' => array('sessionClass' => 'ZendTest\\Form\\Element\\TestAsset\\SessionContainer'), 'decorators' => array('Description', 'Errors', 'Captcha\\Word', 'Captcha', 'Label')));
     // Before rendering
     $decorators = array_keys($element->getDecorators());
     $this->assertSame(array('Zend\\Form\\Decorator\\Description', 'Zend\\Form\\Decorator\\Errors', 'Zend\\Form\\Decorator\\Captcha\\Word', 'Zend\\Form\\Decorator\\Captcha', 'Zend\\Form\\Decorator\\Label'), $decorators, var_export($decorators, true));
     $element->render();
     // After rendering
     $decorators = array_keys($element->getDecorators());
     $this->assertSame(array('Zend\\Form\\Decorator\\Description', 'Zend\\Form\\Decorator\\Errors', 'Zend\\Form\\Decorator\\Captcha\\Word', 'Zend\\Form\\Decorator\\Captcha', 'Zend\\Form\\Decorator\\Label'), $decorators, var_export($decorators, true));
 }