public function novoAction() { $this->captcha = new Captcha(); $this->captcha->setFont(getcwd() . "/../www/imobiliaria/fonts/Ubuntu-C.ttf"); $this->captcha->setImgDir(getcwd() . "/../www/imobiliaria/img"); $this->captcha->setWordlen(3); $this->captcha->setDotNoiseLevel(0); //echo "captcha ". $this->captcha->getSession()->word; return new ViewModel(array("captcha" => $this->captcha->generate(), "idCaptcha" => $this->captcha->getWord())); }
public function __construct() { parent::__construct('login'); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'form-horizontal'); $this->setAttribute('enctype', 'multipart/form-data'); $this->add(array('name' => 'username', 'attributes' => array('type' => 'text', 'class' => 'form-control', 'placeholder' => 'nombre de usuario'), 'options' => array('label' => 'username', 'label_attributes' => array('class' => 'col-sm-3 control-label')))); $this->add(array('name' => 'password', 'attributes' => array('type' => 'password', 'id' => 'password', 'maxlength' => 20, 'class' => 'form-control', 'placeholder' => 'Contraseña'), 'options' => array('label' => 'password', 'label_attributes' => array('class' => 'col-sm-3 control-label')))); $captchaImage = new CaptchaImage(); $captchaImage->setFont("public/resource/fonts/arial.ttf"); $captchaImage->setImgDir("public/resource/images"); $captchaImage->setImgUrl("/resource/images"); $captchaImage->setImgAlt("Captcha"); $captchaImage->setWidth(250); $captchaImage->setHeight(80); $captchaImage->setDotNoiseLevel(50); $captchaImage->setLineNoiseLevel(5); $captchaImage->setFontSize(38); $captchaImage->setExpiration(1); $captchaImage->setWordlen(6); $captchaImage->setMessage("El código no coincide, actualízalo y vuelve a intentarlo", $captchaImage::BAD_CAPTCHA); $this->add(array('type' => 'Zend\\Form\\Element\\Captcha', 'attributes' => array('type' => 'password', 'class' => 'form-control', 'placeholder' => 'captcha'), 'name' => 'captcha', 'options' => array('captcha' => $captchaImage, 'id' => 'captcha', 'label' => 'captcha', 'label_attributes' => array('class' => 'col-sm-2 control-label')))); $this->add(array('type' => 'Zend\\Form\\Element\\Csrf', 'name' => 'csrf', 'options' => array('csrf_options' => array('timeout' => 600)))); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Ingresar', 'class' => 'btn btn-primary btn-sm btn-sm'))); }
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); }
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); }
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); }
/** * {@inheritdoc} */ public function buildView(FormView $view, FormInterface $form, array $options) { $sessionKey = sprintf('%s_zend_captcha_session_key_%s', $form->getParent()->getName(), $form->getName()); $captcha = new Image(); if (isset($options['suffix'])) { $captcha->setSuffix($options['suffix']); } if (isset($options['height'])) { $captcha->setHeight($options['height']); } if (isset($options['width'])) { $captcha->setWidth($options['width']); } if (isset($options['img_alt'])) { $captcha->setImgAlt($options['img_alt']); } if (isset($options['font_size'])) { $captcha->setFontSize($options['font_size']); } if (isset($options['dot_noise_level'])) { $captcha->setDotNoiseLevel($options['dot_noise_level']); } if (isset($options['line_noise_level'])) { $captcha->setLineNoiseLevel($options['line_noise_level']); } if (isset($options['word_len'])) { $captcha->setWordlen($options['word_len']); } if (isset($options['expiration'])) { $captcha->setExpiration($options['expiration']); } if (isset($options['gc_freq'])) { $captcha->setGcFreq($options['gc_freq']); } $captcha->setImgDir($this->options['img_dir']); $captcha->setFont($this->options['font']); $captcha->setImgUrl($this->options['img_url']); $captcha->getWord(); $captcha->generate(); $this->session->set($sessionKey, $captcha->getSession()->getName()); $view->vars = array_merge($view->vars, array('img_url' => $captcha->getImgUrl() . $captcha->getId() . $captcha->getSuffix(), 'height' => $captcha->getHeight(), 'width' => $captcha->getWidth(), 'img_alt' => $captcha->getImgAlt(), 'img_id' => $captcha->getId(), 'value' => "")); }
/** * 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); }
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' ) ), ) )); */ }