setSalt() публичный Метод

Salt for CSRF token
public setSalt ( string $salt ) : Zend_Form_Element_Hash
$salt string
Результат Zend_Form_Element_Hash
Пример #1
0
 /**
  * (non-PHPdoc)
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->setTranslator();
     $txtTitle = $this->createElement('text', 'title')->setLabel('LBL_TITLE')->setRequired(TRUE)->addFilter('StripTags')->setAttrib('maxlength', 200);
     $this->addElement($txtTitle);
     $txtIntroContent = $this->createElement('textarea', 'introcontent')->setLabel('CONTENT_INTRO')->setRequired(true)->setAttrib('cols', 40)->setAttrib('rows', 5)->addValidator(new Zend_Validate_LessThan(1024));
     $this->addElement($txtIntroContent);
     $txtContent = $this->createElement('textarea', 'content')->setLabel('LBL_CONTENT')->setRequired(true)->setAttrib('cols', 40)->setAttrib('rows', 5)->addValidator(new Zend_Validate_LessThan(1024));
     $this->addElement($txtContent);
     $cbCategory = $this->createElement('select', 'category_id')->setLabel("LBL_CATEGORY")->setRequired(true);
     $this->addElement($cbCategory);
     $rbPublished = $this->createElement("radio", "published")->setLabel("LBL_PUBLISHED")->setValue(1)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbPublished);
     $id = $this->createElement('hidden', 'id');
     $id->setDecorators(array('ViewHelper'));
     $this->addElement($id);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(300);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default');
     $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
     $btnSubmit->setLabel('LBL_SUBMIT');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
     $btnSubmit->removeDecorator('Label');
     $this->addElement($btnSubmit);
 }
 function indexAction()
 {
     $perpage = 25;
     $page = $this->getRequest()->getParam('page', 1);
     if ($page < 1) {
         $page = 1;
     }
     $counts = Application_Model_FsThumbsMapper::i()->getCount();
     X_Debug::i("Thumbnails count: {$counts}");
     $totalSize = Application_Model_FsThumbsMapper::i()->getTotalSize();
     X_Debug::i("Thumbnails size: {$totalSize}");
     $pages = $counts / $perpage;
     X_Debug::i("Current page: {$page}");
     if ($counts % $perpage > 0 || $pages == 0) {
         $pages = (int) $pages + 1;
     }
     // add an extra page
     X_Debug::i("Total pages: {$pages}");
     if ($page > $pages) {
         throw new Exception(X_Env::_('p_fsthumbs_invalidpage', $page, $pages));
     }
     $csrf = new Zend_Form_Element_Hash('csrf');
     $csrf->setSalt(__CLASS__)->initCsrfToken();
     $thumbs = Application_Model_FsThumbsMapper::i()->fetchPage($page - 1, $perpage);
     $this->view->thumbs = $thumbs;
     $this->view->counts = $counts;
     $this->view->page = $page;
     $this->view->pages = $pages;
     $this->view->perpage = $perpage;
     $this->view->totalSize = $totalSize;
     $this->view->csrf = $csrf->getHash();
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
 }
Пример #3
0
 /**
  * (non-PHPdoc)
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->setTranslator();
     $id = $this->createElement('hidden', 'id');
     $id->setDecorators(array('ViewHelper'));
     $this->addElement($id);
     $name = $this->createElement('text', 'name')->setLabel('LBL_TITLE')->setRequired(TRUE)->setAttrib('size', 40);
     $this->addElement($name);
     /* @var $rbPublished Zend_Form_Element_Radio */
     $rbPublished = $this->createElement("radio", "published")->setLabel("LBL_PUBLISHED")->setValue(1);
     $rbPublished->addMultiOption(0, "LBL_NO");
     $rbPublished->addMultiOption(1, "LBL_YES");
     $this->addElement($rbPublished);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $btnSubmit = $this->createElement('submit', 'submit');
     $btnSubmit->setLabel('LBL_SUBMIT');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setAttrib('class', 'btn btn-info');
     $this->addElement($btnSubmit);
 }
Пример #4
0
 /**
  * (non-PHPdoc)
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->setTranslator();
     $this->setMethod('post');
     $id = $this->createElement('hidden', 'id')->setDecorators(array('ViewHelper'));
     $this->addElement($id);
     $txtTitle = $this->createElement('text', 'title')->setLabel('LBL_TITLE')->setRequired(TRUE)->addFilter(new Zend_Filter_StripTags())->addFilter(new Zend_Filter_Alpha(true))->setAttrib('maxlength', 200);
     $this->addElement($txtTitle);
     $txtDescription = $this->createElement('textarea', 'description')->setAttrib('cols', 40)->setAttrib('rows', 5)->setLabel('LBL_DESCRIPTION')->setRequired(FALSE)->addValidator(new Zend_Validate_LessThan(1024));
     $this->addElement($txtDescription);
     $image = $this->createElement('file', 'image')->setLabel('LBL_IMAGE')->setRequired(false)->addValidator('Count', false, 1)->addValidator('Size', false, 102400)->addValidator('Extension', false, 'jpg, jpeg, png, gif')->addValidator('NotExists', false, DIR_MOD_CONTACT_IMG_UPLOADS)->setDestination(DIR_MOD_CONTACT_IMG_UPLOADS);
     $this->addElement($image);
     $rbPublished = $this->createElement("radio", "published")->setLabel("LBL_PUBLISHED")->setValue(1)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbPublished);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default');
     $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
     $btnSubmit->setLabel('LBL_SUBMIT');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
     $btnSubmit->removeDecorator('Label');
     $this->addElement($btnSubmit);
 }
Пример #5
0
 /**
  * (non-PHPdoc)
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->setTranslator();
     $id = $this->createElement('hidden', 'id');
     $id->setDecorators(array('ViewHelper'));
     $this->addElement($id);
     $name = $this->createElement('text', 'name')->setLabel('LBL_TITLE')->setRequired(TRUE)->setAttrib('size', 40);
     $this->addElement($name);
     /* @var $rbPublished Zend_Form_Element_Radio */
     $rbPublished = $this->createElement("radio", "published")->setLabel("LBL_PUBLISHED")->setValue(1);
     $rbPublished->addMultiOption(0, "LBL_NO");
     $rbPublished->addMultiOption(1, "LBL_YES");
     $this->addElement($rbPublished);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default');
     $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
     $btnSubmit->setLabel('LBL_SAVE');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
     $btnSubmit->removeDecorator('Label');
     $this->addElement($btnSubmit);
 }
Пример #6
0
 /**
  * (non-PHPdoc)
  * @see Zend_Form::init()
  */
 public function init()
 {
     #$this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->setTranslator();
     $txtName = $this->createElement('text', 'name');
     $txtName->setLabel('ACL_ROLE')->setRequired(TRUE)->setAttrib('size', '40')->addValidator(new Zend_Validate_NotEmpty());
     $this->addElement($txtName);
     $mdlRole = new Acl_Model_Role();
     $roles = $mdlRole->getRoles();
     $cbRole = $this->createElement("select", "parent_id");
     $cbRole->setLabel("ACL_ROLE_PARENT")->setRequired(FALSE);
     if ($roles->count() > 0) {
         foreach ($roles as $role) {
             $cbRole->addMultiOption($role->id, $role->name);
         }
     }
     $this->addElement($cbRole);
     $mdlSkin = new System_Model_Skin();
     $skin = $mdlSkin->getSkinSelected();
     $skinName = is_null($skin) ? 'default' : strtolower($skin->name);
     $layouts = new Zend_Config_Xml(APPLICATION_PATH . '/layouts/scripts/' . $skinName . '/layouts.xml');
     $layouts = $layouts->files->layout->toArray();
     $cbDesktopLayout = $this->createElement("select", "desktop_layout");
     $cbDesktopLayout->setLabel('LBL_DESKTOP_LAYOUT');
     $cbDesktopLayout->setRequired(true);
     $cbMobileLayout = $this->createElement("select", "mobile_layout");
     $cbMobileLayout->setLabel('LBL_MOBILE_LAYOUT');
     $cbMobileLayout->setRequired(true);
     foreach ($layouts as $layout) {
         $cbDesktopLayout->addMultiOption($layout, $layout);
         $cbMobileLayout->addMultiOption($layout, $layout);
     }
     $this->addElement($cbDesktopLayout);
     $this->addElement($cbMobileLayout);
     $txtPriority = $this->createElement('text', 'priority');
     $txtPriority->setLabel('ACL_PRIORITY')->setRequired(TRUE)->setAttrib('size', 10)->setAttrib('maxlength', 2)->addValidator(new Zend_Validate_NotEmpty());
     $this->addElement($txtPriority);
     $id = $this->createElement('hidden', 'id');
     $id->setDecorators(array('ViewHelper'));
     $this->addElement($id);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default');
     $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
     $btnSubmit->setLabel('LBL_SAVE');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
     $btnSubmit->removeDecorator('Label');
     $this->addElement($btnSubmit);
 }
Пример #7
0
 /**
  * L'inizializzazione del form, dove vengono scritti i vari campi che lo comporranno.
  */
 public function init()
 {
     $this->setName('form_login');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->addElement('text', 'email', array('filters' => array('StringTrim'), 'required' => true, 'label' => 'Email Address:'));
     $this->addElement('password', 'password', array('filters' => array('StringTrim'), 'required' => true, 'label' => 'Password:'******'submit', 'login', array('label' => 'Login'));
     $Token = new Zend_Form_Element_Hash('token');
     $Token->setSalt(sha1(uniqid(mt_rand(), true)));
     $Token->setTimeout(60);
     $this->addElement($Token);
 }
Пример #8
0
 /**
  * Init default fields for menu item form
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->setTranslator();
     $this->setMethod('post');
     $id = $this->createElement('hidden', 'id')->setOrder(1)->setDecorators(array('ViewHelper'));
     $this->addElement($id);
     $menuId = $this->createElement('hidden', 'menu_id')->setOrder(2)->setRequired(TRUE)->setDecorators(array('ViewHelper'));
     $this->addElement($menuId);
     $txtTitle = $this->createElement('text', 'title')->setOrder(3)->setLabel('LBL_TITLE')->setRequired(TRUE)->addFilter('StripTags')->setAttrib('size', 40)->setAttrib('maxlength', 50);
     $this->addElement($txtTitle);
     $txtDescription = $this->createElement('text', 'description')->setOrder(4)->setLabel('LBL_DESCRIPTION')->setRequired(FALSE)->addFilter('StripTags')->setAttrib('size', 40)->setAttrib('maxlength', 150)->addValidator(new Zend_Validate_LessThan(150));
     $this->addElement($txtDescription);
     $txtAlias = $this->createElement('text', 'id_alias')->setOrder(5)->setLabel('MENU_ITEM_ID_ALIAS')->addFilter('StripTags')->setAttrib('size', 40)->addValidator(new Zend_Validate_LessThan(50));
     #->addValidator( new Zend_Validate_Alnum() );
     $this->addElement($txtAlias);
     $cbParent = $this->createElement('select', 'parent_id')->setOrder(6)->setLabel("MENU_ITEM_PARENT")->setRequired(true);
     $this->addElement($cbParent);
     $cbWType = $this->createElement('select', 'wtype')->setOrder(7)->setLabel('MENU_ITEM_WINDOW_TYPE')->setRequired(true)->addMultiOption('_self', '_self')->addMultiOption('_parent', '_parent')->addMultiOption('_blank', '_blank');
     $this->addElement($cbWType);
     $rbPublished = $this->createElement("radio", "published")->setOrder(8)->setLabel("LBL_PUBLISHED")->setValue(1)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbPublished);
     $rbVisible = $this->createElement("radio", "isvisible")->setOrder(9)->setLabel("LBL_VISIBLE")->setValue(1)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbVisible);
     $txtCssClass = $this->createElement('text', 'css_class')->setOrder(10)->setLabel('LBL_CSS_CLASS')->setAttrib('maxlength', 50)->addValidator(new Zend_Validate_LessThan(50));
     $this->addElement($txtCssClass);
     $hExternal = $this->createElement("hidden", "external")->setValue(0)->setOrder(99995)->setDecorators(array('ViewHelper'));
     $this->addElement($hExternal);
     $mId = $this->createElement("hidden", "mid")->setOrder(99996)->setDecorators(array('ViewHelper'));
     $this->addElement($mId);
     $hResource = $this->createElement("hidden", "resource_id")->setOrder(99997)->setDecorators(array('ViewHelper'));
     $this->addElement($hResource);
     $hMod = $this->createElement("hidden", "mod")->setDecorators(array('ViewHelper'))->setOrder(99998);
     $this->addElement($hMod);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(300);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default');
     $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
     $btnSubmit->setLabel('LBL_SUBMIT');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setOrder(99999);
     $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
     $btnSubmit->removeDecorator('Label');
     $this->addElement($btnSubmit);
 }
Пример #9
0
 /**
  * (non-PHPdoc)
  *
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->setTranslator();
     // this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $txtFullname = $this->createElement('text', 'fullname')->setLabel("LBL_FULLNAME")->setRequired(true)->setAttrib('size', 40)->addFilters(array(new Zend_Filter_StringToLower(), new Zend_Filter_StringTrim(), new Zend_Filter_Alpha(true)))->addValidators(array(new Zend_Validate_Alpha(true), new Zend_Validate_StringLength(array('min' => 5, 'max' => 200))));
     $this->addElement($txtFullname);
     $txtEmail = $this->createElement('text', 'email')->setLabel("ACL_EMAIL")->setRequired(TRUE)->setAttrib('size', 40)->addFilters(array(new Zend_Filter_StringToLower(), new Zend_Filter_StringTrim()))->addValidator(new Zend_Validate_EmailAddress());
     $txtEmail->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'os_acl_account', 'field' => 'email')));
     $this->addElement($txtEmail);
     $txtEmailAlternative = $this->createElement('text', 'email_alternative')->setLabel("ACL_EMAIL_ALTERNATIVE")->setRequired(TRUE)->setAttrib('size', 40)->addFilters(array(new Zend_Filter_StringToLower(), new Zend_Filter_StringTrim()))->addValidator(new Zend_Validate_EmailAddress());
     $txtEmailAlternative->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'os_acl_account', 'field' => 'email_alternative')));
     $this->addElement($txtEmailAlternative);
     $txtPassword = $this->createElement('password', 'password')->setLabel('ACL_PASSWORD')->setRequired(TRUE)->setAttrib('size', 40)->addValidator(new Zend_Validate_StringLength(array('min' => '6')));
     $this->addElement($txtPassword);
     $txtPassword2 = $this->createElement('password', 'password2')->setLabel('ACL_REPEAT_PASSWORD')->setRequired(TRUE)->setAttrib('size', 40)->addValidator('Identical', false, array('password'))->addValidator(new Zend_Validate_StringLength(array('min' => '6')));
     $this->addElement($txtPassword2);
     $mdlRole = new Acl_Model_Role();
     $roles = $mdlRole->getRoles();
     $cbRole = $this->createElement("select", "role_id")->setLabel("ACL_ROLE")->setRequired(TRUE);
     // >addMultiOption ( 0, "LABEL_SELECT_ROLE" );
     if ($roles->count() > 0) {
         foreach ($roles as $role) {
             $cbRole->addMultiOption($role->id, $role->name);
         }
     }
     $this->addElement($cbRole);
     $id = $this->createElement('hidden', 'id');
     $id->setDecorators(array('ViewHelper'));
     $this->addElement($id);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default');
     $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
     $btnSubmit->setLabel('LBL_SAVE');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
     $btnSubmit->removeDecorator('Label');
     $this->addElement($btnSubmit);
 }
Пример #10
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     $this->setName('create_account');
     $element = new Zend_Form_Element_Text('email', array('disableLoadDefaultDecorators' => true));
     $element->addDecorator('ViewHelper')->setRequired(true)->addValidator('EmailAddress')->addErrorMessage('Fornire un indirizzo email');
     $this->addElement($element);
     $element = new Zend_Form_Element_Password('password', array('disableLoadDefaultDecorators' => true));
     $element->addDecorator('ViewHelper')->setRequired(true)->setAttrib('autocomplete', 'off')->addErrorMessage('Fornire una password');
     $this->addElement($element);
     $element = new Zend_Form_Element_Password('confirm_password', array('disableLoadDefaultDecorators' => true));
     $element->addDecorator('ViewHelper')->setRequired(true)->setAttrib('autocomplete', 'off')->addValidator(new Frontend_Form_Validate_IdenticalFormValues('password'), true)->addErrorMessage('Le due password non corrispondono');
     $this->addElement($element);
     $element = new Zend_Form_Element_Hash('___h', array('disableLoadDefaultDecorators' => true));
     $element->setSalt('unique')->addDecorator('ViewHelper')->addErrorMessage('Il form non puo\' essere reinviato');
     $this->addElement($element);
     /*
     $captcha_session = new Zend_Session_Namespace('captcha');
     if($captcha_session->tries > 3)
     {
         $recaptcha = new Zend_Service_ReCaptcha('6LfK4r0SAAAAABA5P5icMZayuRyiEOeot0k_uhW5', '6LfK4r0SAAAAAJu-NmK7-30Ng4-0J2oe0R15iIoo');
         $recaptcha->setOption('theme', 'clean');
         $element = new Zend_Form_Element_Captcha('captcha',
             array(
                 'disableLoadDefaultDecorators' => true,
                 'captcha' => 'ReCaptcha',
                 'captchaOptions' => array(
                     'captcha' => 'ReCaptcha',
                     'service' => $recaptcha
                 )
             )
         );
         $element->addErrorMessage('Codice di sicurezza non valido');
         $this->addElement($element);
     }
     */
     $this->clearDecorators();
     $this->addDecorator('FormElements');
     $this->addDecorator('Form');
 }
Пример #11
0
 /**
  * Init default fields for widget form
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->translator = Zend_Registry::get('Zend_Translate');
     $this->setTranslator();
     $hId = $this->createElement("hidden", "id")->setOrder($this->order++);
     $this->addElement($hId);
     $wId = $this->createElement("hidden", "wid")->setOrder($this->order++);
     $this->addElement($wId);
     $txtTitle = $this->createElement("text", "title")->setOrder($this->order++)->setLabel("LBL_TITLE")->addFilter('StripTags')->addValidator(new Zend_Validate_LessThan(100))->setRequired(true);
     $this->addElement($txtTitle);
     $rbShowTitle = $this->createElement("radio", "showtitle");
     $rbShowTitle->setRequired(TRUE)->setOrder($this->order++)->setLabel("LBL_SHOWTITLE")->setValue(0)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbShowTitle);
     $cbPosition = $this->createElement("select", "position")->setOrder($this->order++)->setLabel("LBL_POSITION")->setRequired(true);
     $this->addElement($cbPosition);
     $rbPublished = $this->createElement("radio", "published")->setOrder($this->order++)->setLabel("LBL_PUBLISHED")->setValue(1)->setRequired(true)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbPublished);
     $rbRenderFor = $this->createElement("radio", "renderfor")->setOrder($this->order++)->setLabel("MENU_RENDER_FOR")->setValue(0)->setRequired(true)->setMultiOptions(array($this->translator->translate("LBL_ALL"), $this->translator->translate("LBL_SELECTED_ONLY")));
     $this->addElement($rbRenderFor);
     $cbMenuItem = $this->createElement("multiselect", "menuitem")->setOrder($this->order++)->setLabel("MENU_ITEM");
     $this->addElement($cbMenuItem);
     $hMod = $this->createElement("hidden", "mod")->setOrder(99998);
     $this->addElement($hMod);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default');
     $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
     $btnSubmit->setLabel('LBL_SUBMIT');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setOrder(99999);
     $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
     $btnSubmit->removeDecorator('Label');
     $this->addElement($btnSubmit);
 }
Пример #12
0
 /**
  * (non-PHPdoc)
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->setTranslator();
     /*$mdlResource = new Acl_Model_Resource();
       $resources = $mdlResource->getRegisteredList();
       $cbResource = $this->createElement("multiselect", "resources_id");
       $cbResource->setLabel("LABEL_RESOURCES")
       				->setRequired( FALSE );
       if ( $resources->count() > 0 ) {
        foreach ( $resources as $resource ) {
        	$lblResource = $resource->module.' > '.$resource->controller.' > '.$resource->actioncontroller; 
        	$cbResource->addMultiOption( $resource->id, $lblResource );
        }
       }
       $this->addElement( $cbResource );*/
     $id = $this->createElement('hidden', 'id');
     $id->setDecorators(array('ViewHelper'));
     $this->addElement($id);
     #$hRs = $this->createElement('hidden', 'hrs');
     #$this->addElement($hRs);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default');
     $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
     $btnSubmit->setLabel('LBL_SAVE');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
     $btnSubmit->removeDecorator('Label');
     $this->addElement($btnSubmit);
     #$this->clearDecorators();
     #$this->addDecorator('HtmlTag', array('tag'=>'ul'));
     #$this->addDecorator('form');
 }
Пример #13
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     $this->setName('login');
     $element = new Zend_Form_Element_Text('email', array('disableDefaultDecorators' => true));
     $element->addDecorator('ViewHelper')->addValidator('EmailAddress')->setRequired(true)->addErrorMessage('La mail e\' obbligatoria');
     $this->addElement($element);
     $element = new Zend_Form_Element_Password('password', array('disableDefaultDecorators' => true));
     $element->addDecorator('ViewHelper')->setRequired(true)->addErrorMessage('La password e\' obbligatoria');
     $this->addElement($element);
     $element = new Zend_Form_Element_Hash('___h', array('disableDefaultDecorators' => true));
     $element->setSalt('unique')->addDecorator('ViewHelper')->addErrorMessage('Il form non deve essere reinviato.');
     $this->addElement($element);
     /*
     $captcha_session = new Zend_Session_Namespace('captcha');
     
     if($captcha_session->tries > 3)
     {
         $recaptcha = new Zend_Service_ReCaptcha('6LfK4r0SAAAAABA5P5icMZayuRyiEOeot0k_uhW5', '6LfK4r0SAAAAAJu-NmK7-30Ng4-0J2oe0R15iIoo');
         $recaptcha->setOption('theme', 'clean');
         $element = new Zend_Form_Element_Captcha('captcha', array(
                 'disableDefaultDecorators' => true,
                 'captcha' => 'ReCaptcha',
                 'captchaOptions' => array(
                     'captcha' => 'ReCaptcha',
                     'service' => $recaptcha
                 )
             )
         );
         $element->addErrorMessage('Codice di sicurezza non valido');
         $this->addElement($element);
     }
     */
     $this->clearDecorators();
     $this->addDecorator('FormElements')->addDecorator('Form');
 }
Пример #14
0
 /**
  * Init default fields for widget form
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->translator = Zend_Registry::get('Zend_Translate');
     $this->setTranslator();
     $hId = $this->createElement("hidden", "id")->setOrder($this->order++);
     $this->addElement($hId);
     $wId = $this->createElement("hidden", "wid")->setOrder($this->order++);
     $this->addElement($wId);
     $txtTitle = $this->createElement("text", "title")->setOrder($this->order++)->setLabel("LBL_TITLE")->addFilter('StripTags')->addValidator(new Zend_Validate_LessThan(100))->setRequired(true);
     $this->addElement($txtTitle);
     $rbShowTitle = $this->createElement("radio", "showtitle");
     $rbShowTitle->setRequired(TRUE)->setOrder($this->order++)->setLabel("LBL_SHOWTITLE")->setValue(0)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbShowTitle);
     $cbPosition = $this->createElement("select", "position")->setOrder($this->order++)->setLabel("LBL_POSITION")->setRequired(true);
     $this->addElement($cbPosition);
     $rbPublished = $this->createElement("radio", "published")->setOrder($this->order++)->setLabel("LBL_PUBLISHED")->setValue(1)->setRequired(true)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbPublished);
     $rbRenderFor = $this->createElement("radio", "renderfor")->setOrder($this->order++)->setLabel("MENU_RENDER_FOR")->setValue(0)->setRequired(true)->setMultiOptions(array($this->translator->translate("LBL_ALL"), $this->translator->translate("LBL_SELECTED_ONLY")));
     $this->addElement($rbRenderFor);
     $cbMenuItem = $this->createElement("multiselect", "menuitem")->setOrder($this->order++)->setLabel("MENU_ITEM");
     $this->addElement($cbMenuItem);
     $hMod = $this->createElement("hidden", "mod")->setOrder(99998);
     $this->addElement($hMod);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $btnSubmit = $this->createElement('submit', 'submit');
     $btnSubmit->setLabel('LBL_SUBMIT');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setAttrib('class', 'btn btn-info');
     $this->addElement($btnSubmit);
 }
Пример #15
0
 /**
  * Render a front-end contact form
  */
 public function publicDisplay()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->setTranslator();
     $txtFullName = $this->createElement('text', 'fullname')->setLabel('LBL_FULLNAME')->setRequired(true)->addFilter(new Zend_Filter_Alpha(true))->addValidator(new Zend_Validate_Alpha(true))->addFilter(new Zend_Filter_StripTags())->setAttrib('maxlength', 255);
     $this->addElement($txtFullName);
     $txtTelephone = $this->createElement('text', 'telephone')->setLabel('LBL_TELEPHONE')->setRequired(true)->addFilter(new Zend_Filter_Digits())->addValidator(new Zend_Validate_Digits())->setAttrib('maxlength', 255);
     $this->addElement($txtTelephone);
     $txtEmail = $this->createElement('text', 'email')->setLabel('LBL_EMAIL')->setRequired(true)->addValidator(new Zend_Validate_EmailAddress())->setAttrib('maxlength', 200);
     $this->addElement($txtEmail);
     $txtWebpage = $this->createElement('text', 'webpage')->setLabel('LBL_WEBPAGE')->setRequired(FALSE)->addValidator(new OS_Application_Validators_Url())->setAttrib('maxlength', 200);
     $this->addElement($txtWebpage);
     $txtCountry = $this->createElement('text', 'country')->setLabel('LBL_COUNTRY')->setRequired(false)->addFilter(new Zend_Filter_StripTags())->addFilter(new Zend_Filter_Alpha(true))->addValidator(new Zend_Validate_Alpha(true))->setAttrib('maxlength', 100);
     $this->addElement($txtCountry);
     $txtCity = $this->createElement('text', 'city')->setLabel('LBL_CITY')->setRequired(false)->addFilter(new Zend_Filter_StripTags())->addFilter(new Zend_Filter_Alpha(true))->addValidator(new Zend_Validate_Alpha(true))->setAttrib('maxlength', 100);
     $this->addElement($txtCity);
     $txtMessage = $this->createElement('textarea', 'message')->setAttrib('cols', 40)->setAttrib('rows', 3)->setLabel('LBL_MESSAGE')->setRequired(TRUE)->addFilter(new Zend_Filter_Alnum(true))->addValidator(new Zend_Validate_Alnum(true))->addValidator(new Zend_Validate_LessThan(1024));
     $this->addElement($txtMessage);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default');
     $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
     $btnSubmit->setLabel('LBL_SUBMIT');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
     $btnSubmit->removeDecorator('Label');
     $this->addElement($btnSubmit);
 }
Пример #16
0
 /**
  * @return Zend_Form_Element_Hash
  */
 protected function _csrfToken()
 {
     $uniqueSalt = Zend_Crypt::hash('MD5', 'csrf' . microtime());
     $element = new Zend_Form_Element_Hash('csrf_token');
     $element->setAttrib('id', 'csrf_token_' . strtolower(get_class($this)));
     $element->setSalt($uniqueSalt);
     $element->setDecorators($this->_inputDecorators);
     return $element;
 }