示例#1
0
文件: Sonda.php 项目: hYOUstone/tsg
 public function init()
 {
     $Ankieta = new Application_Model_DbTable_AnkietyPytania();
     $select = $Ankieta->select(array('id', 'pytanie', 'czy_obrazek'))->where('czy_wyswietlac = ?', 't')->where('sekcja = ?', 'lewa')->where('rodzaj = ?', 'normal')->order('kolejnosc DESC')->order('data_dodania DESC')->order('pytanie ASC')->limit(1);
     //echo $select->__toString();
     $ankieda = $Ankieta->fetchAll($select);
     foreach ($ankieda as $pytanie) {
         $pytania_id[] = $pytanie->id;
         $pytania[] = $pytanie->pytanie;
         $odpowiedziFetch = $pytanie->findApplication_Model_DbTable_AnkietyOdpowiedzi();
         // sortowanie
         $odpowiedziArray = $odpowiedziFetch->toArray();
         usort($odpowiedziArray, create_function('$a, $b', 'if ($a["kolejnosc"] == $b["kolejnosc"]) return 0; return ($a["kolejnosc"] < $b["kolejnosc"]) ? -1 : 1;'));
         // usort($odpowiedziArray, sort_answers($a, $b){
         // return strcmp($a["kolejnosc"], $b["kolejnosc"]);
         // });// sort
         foreach ($odpowiedziArray as $odpowiedz) {
             $odpowiedzi_id[] = $odpowiedz['id'];
             $odpowiedzi[] = $odpowiedz['odpowiedz'];
         }
     }
     $this->addElement('hidden', 'plaintext', array('description' => '<dt id="odpowiedzi-label"><h3 class="tytul">' . $pytania[0] . '</h3></dt>', 'decorators' => array(array('Description', array('escape' => false, 'tag' => '')))));
     $kontrolkaRadio = new Zend_Form_Element_Radio("odpowiedzi[]", array('multiOptions' => array_combine($odpowiedzi_id, $odpowiedzi), 'registerInArrayValidator' => false, 'validators' => array('NotEmpty' => array('validator' => 'NotEmpty', 'options' => array('messages' => 'Musisz wybrać jedną odpowiedź.')))));
     $kontrolkaRadio->setRequired(true);
     $kontrolkaRadio->removeDecorator('Label');
     $kontrolkaRadio->setSeparator(false);
     $this->addElement($kontrolkaRadio);
     if ($ankieda[0]->czy_obrazek == 't') {
         //first create an image type captcha
         $captchaimg = new Zend_Captcha_Image('captchaimg');
         $captchaimg->setFont(APPLICATION_PATH . '/../public/images/tresci/captcha/Tahoma.ttf');
         $captchaimg->setImgDir(APPLICATION_PATH . '/../public/images/tresci/captcha');
         $captchaimg->setImgUrl('/images/tresci/captcha');
         $captchaimg->setWordlen('5');
         $captchaimg->setMessages(array('badCaptcha' => 'Wpisany kod jest nieprawidłowy'));
         //            $captchaimg->generate();
         //create user input for captcha and include the captchaimg in form
         $adcaptcha = new Zend_Form_Element_Captcha('adcaptcha', array('captcha' => $captchaimg));
         $adcaptcha->setLabel('Wpisz kod z obrazka:');
         $adcaptcha->setRequired(true);
         $this->addElement($adcaptcha);
     }
     $kontrolkaSubmit = new Zend_Form_Element_Submit("submit", "Głosuj");
     //        $kontrolkaSubmit->removeDecorator('DtDdWrapper');
     //        $kontrolkaSubmit->setAttribs(array('style' => 'margin-left:130px;'));
     $kontrolkaSubmit->removeDecorator('Label');
     $this->addElement($kontrolkaSubmit);
     $this->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'sonda-content')), array('Form', array('class' => 'sonda-form'))));
     //echo $pytania_id[0];
     $this->setMethod('post');
     //$url = $view->url(array('controller' => 'sonda', 'action' => 'edit', 'id' => $pytania_id[0]), 'default');
     $url = $this->getView()->url(array('controller' => 'sonda', 'action' => 'edit', 'id' => $pytania_id[0]), 'default');
     $this->setAction($url);
 }
示例#2
0
 public function addReCaptcha($form)
 {
     $config = Zend_Registry::get("config");
     $publickey = $config->recaptcha->public->key;
     $privatekey = $config->recaptcha->private->key;
     $recaptcha = new Zend_Service_ReCaptcha($publickey, $privatekey);
     //Translate in your language
     $recaptcha_cn_translation = array('visual_challenge' => "图片验证", 'audio_challenge' => "音频验证", 'refresh_btn' => "看不清,换一张", 'instructions_visual' => "图片验证说明", 'instructions_audio' => "音频验证说明", 'help_btn' => "帮助", 'play_again' => "重放", 'cant_hear_this' => "听不到? 点这里", 'incorrect_try_again' => "验证码错误!");
     $recaptcha->setOption('custom_translations', $recaptcha_cn_translation);
     //Change theme
     $recaptcha->setOption('theme', 'clean');
     $captcha = new Zend_Form_Element_Captcha('challenge', array('captcha' => 'ReCaptcha', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha), 'ignore' => false));
     $captcha->setRequired(true);
     $form->addElement($captcha);
 }
 public function init()
 {
     $this->setMethod('post');
     $mail = new Zend_Form_Element_Text('mail');
     $mail->setLabel('Adresse Mail')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator(new Zend_Validate_EmailAddress())->addPrefixPath('SRCustom_Form_Decorator', 'SRCustom/Form/Decorator', 'decorator')->setDecorators(array('SRInput'));
     $nom = new Zend_Form_Element_Text('nom');
     $nom->setLabel('Identité')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addPrefixPath('SRCustom_Form_Decorator', 'SRCustom/Form/Decorator', 'decorator')->setOptions(array('class' => 'classNom'))->setDecorators(array('SRInput'));
     $equipe = new Zend_Form_Element_Text('equipe');
     $equipe->setLabel('Equipe')->addFilter('StripTags')->addFilter('StringTrim')->addPrefixPath('SRCustom_Form_Decorator', 'SRCustom/Form/Decorator', 'decorator')->setDecorators(array('SRInput'));
     $sujet = new Zend_Form_Element_Text('sujet');
     $sujet->setLabel('Sujet')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addPrefixPath('SRCustom_Form_Decorator', 'SRCustom/Form/Decorator', 'decorator')->setDecorators(array('SRInput'));
     $message = new Zend_Form_Element_Textarea('message');
     $message->setLabel('Message')->setAttrib('cols', '35')->setAttrib('rows', '10')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addPrefixPath('SRCustom_Form_Decorator', 'SRCustom/Form/Decorator', 'decorator')->setDecorators(array('SRInput'));
     $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => "Captcha", 'description' => "Merci de recopier le code ci-contre.", 'captcha' => array("captcha" => "Image", "wordLen" => 4, "font" => "libs/comic.ttf", "fontSize" => 14, "width" => 100, "imgDir" => "libs/", "imgUrl" => "libs/", "DotNoiseLevel" => 20, "LineNoiseLevel" => 2)));
     $captcha->setRequired(true)->addPrefixPath('SRCustom_Form_Decorator', 'SRCustom/Form/Decorator', 'decorator')->setDecorators(array('SRCaptcha'));
     $envoyer = new Zend_Form_Element_Submit('envoyer');
     $envoyer->setAttrib('id', 'boutonenvoyer')->setDecorators($this->buttonDecorators);
     $this->addElements(array($mail, $nom, $equipe, $sujet, $message, $captcha, $envoyer));
 }
示例#4
0
 public function init()
 {
     $this->setName('forgotpwd');
     $this->setAttrib('id', 'forgotpwd');
     // Add userId Id Element
     $userId = new Zend_Form_Element_Text('userId');
     $userId->setLabel('User id :')->addFilters(array('StripTags', 'StringTrim', 'StringToLower'))->setRequired(true)->addValidator('NotEmpty')->addValidator(new Zend_Validate_Alnum(array('allowWhiteSpace' => false)))->addValidator(new Zend_Validate_StringLength(array('max' => 100, 'min' => 8)));
     // Add an Email Id Element
     $EmailId = new Zend_Form_Element_Text('email');
     $EmailId->setLabel('Email :')->addFilters(array('StripTags', 'StringTrim', 'StringToLower'))->setRequired(true)->addValidator('NotEmpty')->addValidator(new Zend_Validate_EmailAddress());
     $this->addElements(array($userId, $EmailId));
     // create captcha
     $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => 'Figlet', 'captchaOptions' => array('captcha' => 'Figlet', 'wordLen' => 6, 'timeout' => 300)));
     $captcha->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $captcha->setLabel('Verification code * :')->setOptions(array('size' => '45'));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('class', 'form-submit-button');
     $this->addElements(array($captcha, $submit));
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'viewscripts/forgotPwdVwScript.phtml'))));
 }
示例#5
0
 public function __construct($action, $options = null)
 {
     parent::__construct($options);
     $this->setName('postcomment')->setAction($action)->setMethod('post')->setAttrib('id', 'postcomment');
     # author
     $authorValidatorDB = new FansubCMS_Validator_NoRecordExists('User_Model_User', 'name');
     $authorValidatorDB->setMessages(array(FansubCMS_Validator_NoRecordExists::RECORD_EXISTS => 'news_comment_form_error_author_user_exists'));
     $author = $this->createElement('text', 'author');
     $author->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->addValidator('stringLength', true, array('min' => 3, 'max' => 32, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'news_comment_form_error_author_length', Zend_Validate_StringLength::TOO_SHORT => 'news_comment_form_error_author_length')))->addValidator($authorValidatorDB)->setRequired(true)->setLabel('news_comment_field_author');
     # email
     $email = $this->createElement('text', 'email');
     $email->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->addFilter('StripTags')->addFilter('StringTrim')->addValidator('EmailAddress', false, array('allow' => Zend_Validate_Hostname::ALLOW_DNS, 'domain' => true, 'messages' => array(Zend_Validate_EmailAddress::DOT_ATOM => 'default_form_error_email', Zend_Validate_EmailAddress::INVALID_FORMAT => 'default_form_error_email', Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'default_form_error_email', Zend_Validate_EmailAddress::INVALID_LOCAL_PART => 'default_form_error_email', Zend_Validate_EmailAddress::INVALID_MX_RECORD => 'default_form_error_email', Zend_Validate_EmailAddress::INVALID_SEGMENT => 'default_form_error_email', Zend_Validate_EmailAddress::LENGTH_EXCEEDED => 'default_form_error_email', Zend_Validate_EmailAddress::QUOTED_STRING => 'default_form_error_email')))->setRequired(true)->setLabel('news_comment_field_email');
     # url
     $url = $this->createElement('text', 'url');
     $url->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->setLabel('news_comment_field_website');
     # comment
     $comment = $this->createElement('Textarea', 'comment');
     $comment->setRequired(true)->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->setAttrib('rows', 15)->setAttrib('cols', 40)->setLabel('news_comment_field_text');
     #captcha
     if (!User_Model_User::isLoggedIn()) {
         $imgUrl = substr($_SERVER['PHP_SELF'], 0, -9) . '/media/common/images/tmp';
         // little hack to have the correct baseurl
         $imgUrl = str_replace('//', '/', $imgUrl);
         $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => 'captcha', 'captcha' => array('captcha' => 'Image', 'wordLen' => 6, 'timeout' => 300, 'height' => 80, 'width' => 150, 'startImage' => null, 'font' => realpath(APPLICATION_PATH . '/data/ttf') . '/captcha.ttf', 'imgurl' => $imgUrl, 'imgDir' => HTTP_PATH . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'tmp'), 'errorMessages' => array('default_form_error_captcha_wrong')));
         $captcha->setRequired(true);
     }
     # add elements to the form
     if (!User_Model_User::isLoggedIn()) {
         $this->addElement($author)->addElement($email);
     }
     $this->addElement($url)->addElement($comment);
     if (!User_Model_User::isLoggedIn()) {
         $this->addElement($captcha);
     }
     # commit button
     $this->addElement('submit', 'submit', array('label' => 'news_comment_field_submit', 'class' => 'button'));
 }
示例#6
0
文件: Forms.php 项目: ei-grad/phorm
 /**
  * Строит форму
  * 
  * @param array $fields Массив данных о полях формы
  * 
  * @return Zend_Form
  */
 public function buildForm($fields)
 {
     $form = Phorm_Form::makeForm();
     foreach ($fields as $data) {
         $fieldname = "field_" . $data["fieldid"];
         switch ($data["fieldtype"]) {
             /**
              * Однострочное текстовое поле
              */
             case "Text":
                 $field = new Zend_Form_Element_Text($fieldname);
                 // Типы валидаторов
                 if ($data["fieldvalidators"] == "Email") {
                     $field->addValidator("EmailAddress", true, array("messages" => array("emailAddressInvalid" => $this->_translate->_("Неверно указан email"), "emailAddressInvalidHostname" => $this->_translate->_("Неверно указан email"), "emailAddressInvalidMxRecord" => $this->_translate->_("Неверно указан email"), "emailAddressInvalidSegment" => $this->_translate->_("Неверно указан email"), "emailAddressDotAtom" => $this->_translate->_("Неверно указан email"), "emailAddressQuotedString" => $this->_translate->_("Неверно указан email"), "emailAddressInvalidLocalPart" => $this->_translate->_("Неверно указан email"), "emailAddressLengthExceeded" => $this->_translate->_("Неверно указан email"), "emailAddressInvalidFormat" => $this->_translate->_("Неверный формат"))));
                 } elseif ($data["fieldvalidators"] == "Date") {
                     $field->addValidator("Date", true, array("messages" => array("dateInvalid" => $this->_translate->_("Неверная дата"), "dateInvalidDate" => $this->_translate->_("Неверная дата"), "dateFalseFormat" => $this->_translate->_("Неверная дата"))));
                 } elseif ($data["fieldvalidators"] == "Int") {
                     $field->addValidator("Int", true, array("messages" => array("notInt" => $this->_translate->_("Значение должно быть числом"), "intInvalid" => $this->_translate->_("Значение должно быть числом"))));
                 } elseif ($data["fieldvalidators"] == "Hostname") {
                     $field->addValidator("Hostname", true, array("messages" => array("hostnameInvalid" => $this->_translate->_("Неверный адрес"), "hostnameIpAddressNotAllowed" => $this->_translate->_("Неверный адрес"), "hostnameUnknownTld" => $this->_translate->_("Неверный адрес"), "hostnameDashCharacter" => $this->_translate->_("Неверный адрес"), "hostnameInvalidHostnameSchema" => $this->_translate->_("Неверный адрес"), "hostnameUndecipherableTld" => $this->_translate->_("Неверный адрес"), "hostnameInvalidHostname" => $this->_translate->_("Неверный адрес"), "hostnameInvalidLocalName" => $this->_translate->_("Неверный адрес"), "hostnameLocalNameNotAllowed" => $this->_translate->_("Неверный адрес"), "hostnameCannotDecodePunycode" => $this->_translate->_("Неверный адрес"))));
                 }
                 // Если разрешен HTML
                 if ($data["htmlallowed"] == "yes") {
                     $field->addFilter("StringTrim");
                 } else {
                     $field->addFilter("StripTags");
                 }
                 break;
                 /**
                  * Многострочное текстовое поле
                  */
             /**
              * Многострочное текстовое поле
              */
             case "Textarea":
                 $field = new Zend_Form_Element_Textarea($fieldname);
                 // Если разрешен HTML
                 if ($data["htmlallowed"] == "yes") {
                     $field->addFilter("StringTrim");
                 } else {
                     $field->addFilter("StripTags");
                 }
                 break;
                 /**
                  * Чекбокс
                  */
             /**
              * Чекбокс
              */
             case "Checkbox":
                 $field = new Zend_Form_Element_Checkbox($fieldname);
                 break;
                 /**
                  * Радиоточка
                  */
             /**
              * Радиоточка
              */
             case "Radio":
                 $field = new Zend_Form_Element_Radio($fieldname);
                 break;
                 /**
                  * Список
                  */
             /**
              * Список
              */
             case "Select":
                 $field = new Zend_Form_Element_Select($fieldname);
                 $haystack = array();
                 $optionsdata = explode("\n", $data["optionsdata"]);
                 foreach ($optionsdata as $k => $v) {
                     $haystack[$k] = trim($v);
                 }
                 $field->addMultiOption("", $this->_translate->_("---Выберите---"));
                 foreach ($haystack as $value) {
                     $field->addMultiOption($value, $value);
                 }
                 $haystack[$this->_translate->_("---Выберите---")] = "";
                 $field->addValidator("InArray", true, array("haystack" => $haystack, "messages" => array("notInArray" => $this->_translate->_("Не выбрано ни одного значения"))));
                 break;
                 /**
                  * Список с множественным выбором
                  */
             /**
              * Список с множественным выбором
              */
             case "Multiselect":
                 $field = new Zend_Form_Element_Multiselect($fieldname);
                 $haystack = array();
                 $optionsdata = explode("\n", $data["optionsdata"]);
                 foreach ($optionsdata as $k => $v) {
                     $haystack[$k] = trim($v);
                 }
                 foreach ($optionsdata as $value) {
                     $field->addMultiOption($value, $value);
                 }
                 $field->addValidator("InArray", true, array("haystack" => $haystack, "messages" => array("notInArray" => $this->_translate->_("Не выбрано ни одного значения"))));
                 break;
                 /**
                  * Файл
                  */
             /**
              * Файл
              */
             case "File":
                 $field = new Zend_Form_Element_File($fieldname);
                 if ($data["filestypes"] == "Images") {
                     $field->addValidator("Extension", false, array("extension" => "png,jpg,gif,jpeg,bmp", "messages" => array("fileExtensionFalse" => $this->_translate->_("Файл '%value%' не является изображением"))));
                 } elseif ($data["filestypes"] == "Documents") {
                     $field->addValidator("Extension", false, array("extension" => "doc,xls,odt,docx,xlsx,pdf,txt", "messages" => array("fileExtensionFalse" => $this->_translate->_("Файл '%value%' не является документом"))));
                 } elseif ($data["filestypes"] == "Archives") {
                     $field->addValidator("Extension", false, array("extension" => "zip,rar,7z,gz,tgz", "messages" => array("fileExtensionFalse" => $this->_translate->_("Файл '%value%' не является файловым архивом"))));
                 }
                 //$field -> setDestination($this->paths["html"]."forms/files/");
                 $field->setValueDisabled(true);
                 break;
                 /**
                  * Refferer
                  */
             /**
              * Refferer
              */
             case "Refferer":
                 $field = new Zend_Form_Element_Hidden($fieldname);
                 if (isset($_SERVER["HTTP_REFERER"])) {
                     $field->setValue($_SERVER["HTTP_REFERER"]);
                 }
                 break;
                 /**
                  * CAPTCHA
                  */
             /**
              * CAPTCHA
              */
             case "Captcha":
                 $captcha = Phorm_Captcha_Image::getCaptcha();
                 $captcha->setOptions(array("messages" => array("badCaptcha" => $this->_translate->_("Неверно указан код подтверждения"), "missingID" => $this->_translate->_("Неверный идентификатор Captcha"))));
                 $field = new Zend_Form_Element_Captcha($fieldname, array("captcha" => $captcha));
                 break;
             default:
                 continue;
         }
         // Если поле обязательно для заполнения
         if ($data["isrequired"] == "yes") {
             $field->setRequired(true)->addValidator("NotEmpty", true, array("messages" => array("isEmpty" => $this->_translate->_("Не заполнено поле"))));
         }
         // Устанавливаем заголовок и описание поля
         if ($field instanceof Zend_Form_Element_Hidden) {
             $field->removeDecorator("label")->removeDecorator("HtmlTag");
         } else {
             $field->setLabel($data["fieldname"])->setDescription($data["fieldtxt"]);
         }
         $form->addElement($field);
     }
     $form->addElement(new Zend_Form_Element_Submit("Send", $this->_translate->_("Отправить")));
     $form->setAttrib('enctype', 'multipart/form-data');
     return $form;
 }
示例#7
0
    public function __construct($options = null)
    {
        $this->_disabledDefaultActions = true;
        parent::__construct($options);
        $baseDir = $this->getView()->baseUrl();
        if (!empty($options['mode']) && $options['mode'] == 'edit') {
            $this->_mode = 'edit';
        } else {
            $this->_mode = 'add';
        }
        $langId = Zend_Registry::get('languageID');
        $this->setAttrib('id', 'accountManagement');
        //            $addressParams = array(
        //                "fieldsValue" => array(),
        //                "display"   => array(),
        //                "required" => array(),
        //            );
        // Salutation
        $salutation = new Zend_Form_Element_Select('salutation');
        $salutation->setLabel($this->getView()->getCibleText('form_label_salutation'))->setAttrib('class', 'smallSelect')->setAttrib('tabindex', '1')->setOrder(1);
        $greetings = $this->getView()->getAllSalutation();
        foreach ($greetings as $greeting) {
            $salutation->addMultiOption($greeting['S_ID'], $greeting['ST_Value']);
        }
        // Language
        $languages = new Zend_Form_Element_Select('language');
        $languages->setLabel($this->getView()->getCibleText('form_label_language'))->setAttrib('class', 'stdSelect')->setAttrib('tabindex', '9')->setOrder(9);
        foreach (Cible_FunctionsGeneral::getAllLanguage() as $lang) {
            $languages->addMultiOption($lang['L_ID'], $lang['L_Title']);
        }
        // FirstName
        $firstname = new Zend_Form_Element_Text('firstName');
        $firstname->setLabel($this->getView()->getCibleText('form_label_fName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '2')->setOrder(2);
        // LastName
        $lastname = new Zend_Form_Element_Text('lastName');
        $lastname->setLabel($this->getView()->getCibleText('form_label_lName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '3')->setOrder(3);
        // email
        $regexValidate = new Cible_Validate_Email();
        $regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch');
        $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email');
        $emailNotFoundInDBValidator->setMessage($this->getView()->getClientText('validation_message_email_already_exists'), 'recordFound');
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel($this->getView()->getCibleText('form_label_email'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator($regexValidate)->setAttribs(array('maxlength' => 50, 'class' => 'stdTextInput'))->setAttrib('tabindex', '5')->setOrder(5);
        if ($this->_mode == 'add') {
            $email->addValidator($emailNotFoundInDBValidator);
        }
        // email
        // password
        $password = new Zend_Form_Element_Password('password');
        if ($this->_mode == 'add') {
            $password->setLabel($this->getView()->getCibleText('form_label_password'));
        } else {
            $password->setLabel($this->getView()->getCibleText('form_label_newPwd'));
        }
        $password->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setAttrib('tabindex', '6')->setRequired(true)->setOrder(6)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))));
        // password
        // password confirmation
        $passwordConfirmation = new Zend_Form_Element_Password('passwordConfirmation');
        if ($this->_mode == 'add') {
            $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd'));
        } else {
            $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd'));
        }
        //                $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmNewPwd'));
        $passwordConfirmation->addFilter('StripTags')->addFilter('StringTrim')->setRequired(true)->setOrder(7)->setAttrib('class', 'stdTextInput')->setAttrib('tabindex', '7')->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd')), array('label', array('class' => 'test', 'tag' => 'dt', 'tagClass' => 'alignVertical'))));
        if (!empty($_POST['identification']['password'])) {
            $passwordConfirmation->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('error_message_password_isEmpty'))));
            $Identical = new Zend_Validate_Identical($_POST['identification']['password']);
            $Identical->setMessages(array('notSame' => $this->getView()->getCibleText('error_message_password_notSame')));
            $passwordConfirmation->addValidator($Identical);
        }
        // password confirmation
        // Company name
        $company = new Zend_Form_Element_Text('company');
        $company->setLabel($this->getView()->getCibleText('form_label_company'))->setRequired(false)->setAttrib('tabindex', '4')->setOrder(4)->setAttribs(array('class' => 'stdTextInput'));
        // Account number
        $account = new Zend_Form_Element_Text('accountNum');
        $account->setLabel($this->getView()->getCibleText('form_label_account'))->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setOrder(8)->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '8')->setDecorators(array('ViewHelper', 'Errors', array(array('row' => 'HtmlTag'), array('tag' => 'dd')), array('label', array('class' => 'test', 'tag' => 'dt', 'tagClass' => 'alignVertical'))));
        // Text Subscribe
        $textSubscribe = $this->getView()->getCibleText('form_label_subscribe');
        $textSubscribe = str_replace('%URL_PRIVACY_POLICY%', Cible_FunctionsPages::getPageLinkByID($this->_config->privacyPolicy->pageId), $textSubscribe);
        // Newsletter subscription
        $newsletterSubscription = new Zend_Form_Element_Checkbox('newsletterSubscription');
        $newsletterSubscription->setLabel($textSubscribe);
        if ($this->_mode == 'add') {
            $newsletterSubscription->setChecked(1);
        }
        $newsletterSubscription->setAttrib('class', 'long-text');
        $newsletterSubscription->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'id' => 'subscribeNewsletter', 'class' => 'label_after_checkbox'))));
        if ($this->_mode == 'add') {
            $termsAgreement = new Zend_Form_Element_Checkbox('termsAgreement');
            $termsAgreement->setLabel(str_replace('%URL_TERMS_CONDITIONS%', Cible_FunctionsPages::getPageLinkByID($this->_config->termsAndConditions->pageId), $this->getView()->getClientText('form_label_terms_agreement')));
            $termsAgreement->setAttrib('class', 'long-text');
            $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
            $termsAgreement->setRequired(true);
            $termsAgreement->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'You must agree to the terms')));
        } else {
            $termsAgreement = new Zend_Form_Element_Hidden('termsAgreement', array('value' => 1));
        }
        // Submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submitLabel = $this->getView()->getCibleText('form_account_button_submit');
        if ($this->_mode == 'edit') {
            $submitLabel = $this->getView()->getCibleText('button_submit');
        }
        $submit->setLabel($submitLabel)->setAttrib('class', 'stdButton subscribeButton1-' . Zend_Registry::get("languageSuffix"));
        // Captcha
        // Refresh button
        $refresh_captcha = new Zend_Form_Element_Button('refresh_captcha');
        $refresh_captcha->setLabel($this->getView()->getCibleText('button_refresh_captcha'))->setAttrib('onclick', "refreshCaptcha('captcha-id')")->setAttrib('class', 'stdButton')->removeDecorator('Label')->removeDecorator('DtDdWrapper');
        $refresh_captcha->addDecorators(array(array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'dd-refresh-captcha-button'))));
        $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $this->getView()->getCibleText('form_label_securityCaptcha'), 'captcha' => 'Image', 'captchaOptions' => array('captcha' => 'Word', 'wordLen' => 5, 'fontSize' => 28, 'height' => 67, 'width' => 169, 'timeout' => 300, 'dotNoiseLevel' => 0, 'lineNoiseLevel' => 0, 'font' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/fonts/ARIAL.TTF", 'imgDir' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/tmp", 'imgUrl' => "{$baseDir}/captcha/tmp")));
        $captcha->setAttrib('class', 'stdTextInputCatcha');
        $captcha->setRequired(true);
        $captcha->addDecorators(array(array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'id' => 'dd_captcha'))))->addDecorator('Label', array('class' => 'clear'));
        $french = array('badCaptcha' => 'Veuillez saisir la chaîne ci-dessus correctement.');
        $english = array('badCaptcha' => 'Captcha value is wrong');
        $translate = new Zend_Translate('array', $french, 'fr');
        $this->setTranslator($translate);
        $this->getView()->jQuery()->enable();
        $script = <<<EOS

            function refreshCaptcha(id){
                \$.getJSON('{$this->getView()->baseUrl()}/newsletter/index/captcha-reload',
                    function(data){

                        \$("dd#dd_captcha img").attr({src : data['url']});
                        \$("#"+id).attr({value: data['id']});

                });
            }

EOS;
        $this->getView()->headScript()->appendScript($script);
        // Captcha
        /*  Identification sub form */
        $identificationSub = new Cible_Form_SubForm();
        $identificationSub->setName('identification')->removeDecorator('DtDdWrapper');
        $identificationSub->setLegend($this->getView()->getCibleText('form_account_subform_identification_legend'));
        $identificationSub->setAttrib('class', 'identificationClass subFormClass');
        $identificationSub->addElement($languages);
        $identificationSub->addElement($salutation);
        $identificationSub->addElement($lastname);
        $identificationSub->addElement($firstname);
        $identificationSub->addElement($email);
        $identificationSub->addElement($password);
        $identificationSub->addElement($passwordConfirmation);
        $identificationSub->addElement($company);
        $identificationSub->addElement($account);
        $identificationSub->addDisplayGroup(array('salutation', 'firstName', 'company', 'password', 'accountNum'), 'leftColumn');
        $identificationSub->addDisplayGroup(array('lastName', 'email', 'passwordConfirmation', 'language'), 'rightColumn')->removeDecorator('DtDdWrapper');
        $leftColGroup = $identificationSub->getDisplayGroup('leftColumn');
        $rightColGroup = $identificationSub->getDisplayGroup('rightColumn');
        $leftColGroup->removeDecorator('DtDdWrapper');
        $rightColGroup->removeDecorator('DtDdWrapper');
        $this->addSubForm($identificationSub, 'identification');
        // Billing address
        $addressFacturationSub = new Cible_Form_SubForm();
        $addressFacturationSub->setName('addressFact')->removeDecorator('DtDdWrapper');
        $addressFacturationSub->setLegend($this->getView()->getCibleText('form_account_subform_addBilling_legend'));
        $addressFacturationSub->setAttrib('class', 'addresseBillingClass subFormClass');
        $billingAddr = new Cible_View_Helper_FormAddress($addressFacturationSub);
        $billingAddr->enableFields(array('firstAddress', 'secondAddress', 'cityTxt', 'zipCode', 'country', 'state', 'firstTel', 'secondTel', 'fax'));
        $billingAddr->formAddress();
        $addrBill = new Zend_Form_Element_Hidden('addrBill');
        $addrBill->removeDecorator('label');
        $addressFacturationSub->addElement($addrBill);
        $this->addSubForm($addressFacturationSub, 'addressFact');
        /* delivery address */
        $addrShip = new Zend_Form_Element_Hidden('addrShip');
        $addrShip->removeDecorator('label');
        $addressShippingSub = new Cible_Form_SubForm();
        $addressShippingSub->setName('addressShipping')->removeDecorator('DtDdWrapper');
        $addressShippingSub->setLegend($this->getView()->getCibleText('form_account_subform_addShipping_legend'));
        $addressShippingSub->setAttrib('class', 'addresseShippingClass subFormClass');
        $shipAddr = new Cible_View_Helper_FormAddress($addressShippingSub);
        $shipAddr->duplicateAddress($addressShippingSub);
        $shipAddr->setProperty('addScriptState', false);
        $shipAddr->enableFields(array('firstAddress', 'secondAddress', 'cityTxt', 'zipCode', 'country', 'state', 'firstTel', 'secondTel', 'fax'));
        $shipAddr->formAddress();
        $addressShippingSub->addElement($addrShip);
        $this->addSubForm($addressShippingSub, 'addressShipping');
        if ($this->_mode == 'add') {
            $this->getView()->jQuery()->enable();
            $script = <<<EOS

                function refreshCaptcha(id){
                    \$.getJSON('{$this->getView()->baseUrl()}/order/index/captcha-reload',
                        function(data){
                            \$("dd#dd_captcha img").attr({src : data['url']});
                            \$("#"+id).attr({value: data['id']});
                    });
                }

EOS;
            //                $this->getView()->headScript()->appendScript($script);
            //                $this->addElement($refresh_captcha);
            //                $this->addElement($captcha);
            $this->addElement($newsletterSubscription);
            $this->addElement($termsAgreement);
        }
        $this->addElement($submit);
        $submit->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'account-submit'))));
        if ($this->_mode == 'add') {
            $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox', 'id' => 'dd-terms-agreement'))));
        }
        $captchaError = array('badCaptcha' => $this->getView()->getCibleText('validation_message_captcha_error'));
        $translate = new Zend_Translate('array', $captchaError, $this->getView()->registryGet('languageSuffix'));
        $this->setTranslator($translate);
    }