Example #1
0
 public function testEmptyFormNameShouldNotRenderEmptyFormId()
 {
     $form = new Zend_Form();
     $form->setMethod('post')->setAction('/foo/bar')->setView($this->getView());
     $html = $form->render();
     $this->assertNotContains('id=""', $html, $html);
 }
Example #2
0
		function setForm()
		{
			
			$form=new Zend_Form;
			$form->setMethod('post')->setAction('');
			
			$category_name = new Zend_Form_Element_Text('category_name');
			$category_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên danh mục không được để trống'));
			/*
			$category_parent_id = new Zend_Form_Element_Select('category_parent_id');
			$category_parent_id->addMultiOption('', '0');
			foreach($this->mDanhmuc->getListDM() as $item)
			{
				$category_parent_id->addMultiOption($item['category_name'], $item['category_id']);
			}
			*/
			$is_active = $form->createElement("select","is_active",array(
                                                        "label" => "Kích hoạt",
                                                   "multioptions"=> array(
                                                                      "0" => "Chưa kích hoạt",
                                                                      "1" => "Đã kích hoạt")));
			$category_name->removeDecorator('HtmlTag')->removeDecorator('Label');	
			$is_active->removeDecorator('HtmlTag')->removeDecorator('Label');
			
			$form->addElements(array($category_name,$is_active));
			return $form;
		}
Example #3
0
		function setForm()
		{
			$form = new Zend_Form;
			$form->setMethod('post')->setAction('');
			//$this->setAttrib('enctype','multipart/form-data');
			
			$file = new Zend_Form_Element_File('video_file');
			//$file->setAttrib('class','file');
			$file->setLabel('video_file');
           	$file->setRequired(true);
           	
			$video_title = new Zend_Form_Element_Text('video_title');
			$video_title ->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tiêu đề không được để trống'));
			
			$video_thumbnail=new Zend_Form_Element_Textarea('video_thumbnail');
			$video_thumbnail->removeDecorator('HtmlTag')->removeDecorator('Label');
			
			$video_description = new Zend_Form_Element_Textarea('video_description');
			$video_description->setAttrib('rows','7');
			$video_description ->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Mô tả không được để trống'));
			
			$is_active = new Zend_Form_Element_Radio('is_active');
			$is_active->setRequired(true)
					->setLabel('is_active')
					->setMultiOptions(array("1" => "Có","0" => "Không"));
			
			$file->removeDecorator('HtmlTag')->removeDecorator('Label');	
			$video_title->removeDecorator('HtmlTag')->removeDecorator('Label');	
			$video_description->removeDecorator('HtmlTag')->removeDecorator('Label');
			$is_active->removeDecorator('HtmlTag')->removeDecorator('Label');		
			
			$form->addElements(array($file,$video_title,$video_description,$is_active,$video_thumbnail));
			return $form;
		}
Example #4
0
		function setForm()
		{
			$form=new Zend_Form;
			 
			$form->setMethod('post')->setAction('');
			
			$image_name = new Zend_Form_Element_Text('image_name');
			$image_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên ảnh không được để trống'));
			
			$image_link = new Zend_Form_Element_Textarea('image_link');
			$image_link->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Hình ảnh không được để trống'));
			
			
			$is_active = new Zend_Form_Element_Radio('is_active');
			$is_active->setRequired(true)
					->setLabel('is_active')
					->setMultiOptions(array("1" => "Có","0" => "Không"));
																	  
			$image_name->removeDecorator('HtmlTag')->removeDecorator('Label');
			$image_link->removeDecorator('HtmlTag')->removeDecorator('Label');
			$is_active->removeDecorator('HtmlTag')->removeDecorator('Label');	
			
			$form->addElements(array($image_name,$image_link,$is_active));
			return $form;
		}
Example #5
0
 function form()
 {
     if (!isset($this->form)) {
         $form = new Zend_Form();
         $form->setAction($this->url());
         $form->setMethod('post');
         // Create and configure username element:
         $username = $form->createElement('text', 'username');
         $username->setLabel("Username");
         $username->addValidator('alnum');
         $username->addValidator('regex', false, array('/^[a-z]+/'));
         $username->addValidator('stringLength', false, array(6, 20));
         $username->setRequired(true);
         $username->addFilter('StringToLower');
         // Create and configure password element:
         $password = $form->createElement('password', 'password');
         $password->setLabel("Password");
         $password->addValidator('StringLength', false, array(6));
         $password->setRequired(true);
         // Add elements to form:
         $form->addElement($username);
         $form->addElement($password);
         // use addElement() as a factory to create 'Login' button:
         $form->addElement('submit', 'login', array('label' => 'Login'));
         // Since we're using this outside ZF, we need to supply a default view:
         $form->setView(new Zend_View());
         $this->form = $form;
     }
     return $this->form;
 }
 public function ajouterAction()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->addElement('text', 'TITRE_E', array('label' => 'Titre de l\'émission : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'THEME', array('label' => 'Theme : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'ANIMATEURS', array('label' => 'Animateur(s) : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'DUREE', array('label' => 'Durée de l\'émission : ', 'required' => true, 'filters' => array('Int')));
     $form->addElement('text', 'PATH_E', array('label' => 'Lien vers le podcast : ', 'required' => false, 'filters' => array('StringTrim')));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel('Ajouter');
     $form->addElement($submit);
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $dba = Zend_Registry::get('dba');
             $datas = array('THEME' => $formData["THEME"], 'ANIMATEURS' => $formData["ANIMATEURS"], 'DUREE' => $formData["DUREE"], 'TITRE_E' => $formData["TITRE_E"], 'PATH_E' => $formData["PATH_E"]);
             $dba->beginTransaction();
             try {
                 $dba->insert('EMISSION', $datas);
                 $dba->commit();
             } catch (Exception $e) {
                 $dba->rollBack();
                 echo $e->getMessage();
             }
             $this->_helper->redirector('index');
         } else {
             $form->populate($formData);
         }
     }
     $this->view->form = $form;
 }
Example #7
0
		function setForm()
		{
			$form=new Zend_Form;
			$form->setMethod('post')->setAction('');
			
			$youtube_username = new Zend_Form_Element_Text('youtube_username');
			$youtube_username->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên tài khoản không được để trống'));
			
			$password = new Zend_Form_Element_Text('password');
			$password->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Mật khẩu không được để trống'));
			
			$youtube_gallery = new Zend_Form_Element_Text('youtube_gallery');
			$youtube_gallery->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên album không được để trống'));
			
			$is_selected = $form->createElement("select","is_selected",array(
                                                        "label" => "Kích hoạt",
                                                   "multioptions"=> array(
                                                                      "0" => "Không",
                                                                      "1" => "Có")));

			$youtube_username->removeDecorator('HtmlTag')->removeDecorator('Label');	
			$password->removeDecorator('HtmlTag')->removeDecorator('Label');
			$youtube_gallery->removeDecorator('HtmlTag')->removeDecorator('Label');
			$is_selected->removeDecorator('HtmlTag')->removeDecorator('Label');	
			
			$form->addElements(array($youtube_username,$password,$youtube_gallery,$is_selected));
			return $form;
		}
Example #8
0
 /** Create assetstore form */
 public function createAssetstoreForm()
 {
     $form = new Zend_Form();
     $action = $this->webroot . '/assetstore/add';
     $form->setAction($action);
     $form->setName('assetstoreForm');
     $form->setMethod('post');
     $form->setAttrib('class', 'assetstoreForm');
     // Name of the assetstore
     $inputDirectory = new Zend_Form_Element_Text('name', array('label' => $this->t('Give a name'), 'id' => 'assetstorename'));
     $inputDirectory->setRequired(true);
     $form->addElement($inputDirectory);
     // Input directory
     $basedirectory = new Zend_Form_Element_Text('basedirectory', array('label' => $this->t('Pick a base directory'), 'id' => 'assetstoreinputdirectory'));
     $basedirectory->setRequired(true);
     $form->addElement($basedirectory);
     // Assetstore type
     $assetstoretypes = array('0' => $this->t('Managed by MIDAS'), '1' => $this->t('Remotely linked'));
     // Amazon support is not yet implemented, don't present it as an option
     //                          '2' => $this->t('Amazon S3'));
     $assetstoretype = new Zend_Form_Element_Select('assetstoretype', array('id' => 'assetstoretype'));
     $assetstoretype->setLabel('Select a type')->setMultiOptions($assetstoretypes);
     // Add a loading image
     $assetstoretype->setDescription('<div class="assetstoreLoading" style="display:none"><img src="' . $this->webroot . '/core/public/images/icons/loading.gif"/></div>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
     $form->addElement($assetstoretype);
     // Submit
     $addassetstore = new Zend_Form_Element_Submit('addassetstore', $this->t('Add this assetstore'));
     $form->addElement($addassetstore);
     return $form;
 }
Example #9
0
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report5Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_YEAR_SPEC');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_REPORTPLANKIND');
     $e = new Zend_Form_Element_Select('reportplankind', array('label' => 'Звіт/план', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUFORM', false);
     $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUBASIS', false);
     $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_COUNTRYTYPE', true);
     $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     if (@(!$this->params['establishment'])) {
         $e = new Zend_Form_Element_Checkbox('indpapers', array('label' => 'Індивідуальні аркуші'));
         $form->addElement($e);
     }
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 5));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
Example #10
0
 public function getAddContentForm($submitLabel, $contentTitle = null, $contentDescription = null)
 {
     $database = Zend_Db_Table::getDefaultAdapter();
     $content = $database->select()->from('content')->order('content_id DESC')->query()->fetch();
     $imageName = $content['content_id'] + 1;
     $form = new Zend_Form();
     $form->setMethod('post');
     if ($submitLabel == 'Add Content!') {
         $form->setAttrib('enctype', 'multipart/form-data');
         $image = new Zend_Form_Element_File('foo');
         $image->setLabel('Upload an image:')->setDestination('../images');
         $image->addFilter('Rename', array('target' => $imageName . '.jpg', 'overwrite' => TRUE));
         $image->addValidator('Count', false, 1);
         $image->addValidator('Extension', false, 'jpg,png,gif');
         $form->addElement($image, 'foo');
     }
     $title = $form->createElement('text', 'title');
     $title->setRequired(true);
     $title->setValue($contentTitle);
     $title->setLabel('Title');
     $form->addElement($title);
     $description = $form->createElement('textarea', 'description', array('rows' => 10));
     $description->setRequired(true);
     $description->setValue($contentDescription);
     $description->setLabel('Description');
     $form->addElement($description);
     $form->addElement('submit', 'submit', array('label' => $submitLabel));
     return $form;
 }
Example #11
0
		function setForm()
		{
			
			$form=new Zend_Form;
			$form->setMethod('post')->setAction('');
			
			$ads_banner = new Zend_Form_Element_Textarea('ads_banner');
			$ads_banner->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Biểu ngữ không được để trống'));
			
			$ads_position = new Zend_Form_Element_Text('ads_position');
			$ads_position->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Vị trí không được để trống'));
			
			$ads_name = new Zend_Form_Element_Text('ads_name');
			$ads_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên quảng cáo không được để trống'));
			
			$ads_link = new Zend_Form_Element_Text('ads_link');
			$ads_link->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Đường dẫn không được để trống'));
			
			$ads_position = $form->createElement("select","ads_position",array(
                                                        "label" => "Vị trí",
                                                   "multioptions"=> array(
                                                                      "1" => "Trên",
                                                                      "2" => "Giữa",
                                                                      "3" => "Trái",
																	  "4" => "Phải",
																	  "5" => "Nội dung")));
			$ads_banner->removeDecorator('HtmlTag')->removeDecorator('Label');
			$ads_position->removeDecorator('HtmlTag')->removeDecorator('Label');
			$ads_name->removeDecorator('HtmlTag')->removeDecorator('Label');
			$ads_link->removeDecorator('HtmlTag')->removeDecorator('Label');
			
			$form->addElements(array($ads_banner,$ads_position,$ads_name,$ads_link));
			return $form;
		}
Example #12
0
		function setForm()
		{
			$form=new Zend_Form;
			 
			$form->setMethod('post')->setAction('');
			
			$user_login = new Zend_Form_Element_Text('user_login');
			$user_login->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên đăng nhập không được để trống'));
			
			$user_pass = new Zend_Form_Element_Password('user_pass');
			$user_pass->setAttrib('renderPassword', true);
			$user_pass->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Mật khẩu không được để trống'));
			
			$user_fullname = new Zend_Form_Element_Text('user_fullname');
			$user_fullname->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên người dùng không được để trống'));
			
			$user_email = new Zend_Form_Element_Text('user_email');
			$user_email->addValidator('EmailAddress',true,array('messages'=>'Địa chỉ email không hợp lệ'));
			$user_email->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Email không được để trống'));
			
			$user_address = new Zend_Form_Element_Text('user_address');
			$user_address->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Địa chỉ không được để trống'));
			
			$user_login->removeDecorator('HtmlTag')->removeDecorator('Label');	
			$user_pass->removeDecorator('HtmlTag')->removeDecorator('Label');
			$user_fullname->removeDecorator('HtmlTag')->removeDecorator('Label');
			$user_email->removeDecorator('HtmlTag')->removeDecorator('Label');
			$user_address->removeDecorator('HtmlTag')->removeDecorator('Label');	
			
			$form->addElements(array($user_login,$user_pass,$user_fullname,$user_email,$user_address));
			return $form;
		}
 public function removeAction()
 {
     $form = new Zend_Form();
     $form->setView(new Zend_View());
     $form->setMethod('post');
     $form->setAction('');
     $form->setAttrib('class', 'devel');
     $form->setAttrib('title', 'Remove wizard - ' . $this->getRequest()->getParam('name'));
     $handleOptions = explode(',', $this->getRequest()->getParam('handles'));
     $referenceOptions = explode(',', $this->getRequest()->getParam('references'));
     $handleOptionsUsed = explode(',', $this->getRequest()->getParam('handles_used'));
     $handleOptionsHidden = $form->createElement('hidden', 'handles', array('decorators' => array('ViewHelper')));
     $referenceOptionsHidden = $form->createElement('hidden', 'references', array('decorators' => array('ViewHelper')));
     $handleOptionsUsedHidden = $form->createElement('hidden', 'handles_used', array('decorators' => array('ViewHelper')));
     $handle = $form->createElement('radio', 'handle', array('label' => 'Handle', 'required' => true, 'multiOptions' => array_combine($handleOptions, $handleOptions), 'description' => 'NOTE: This are the handles that this block appears in: ' . $this->getRequest()->getParam('handles_used')));
     $reference = $form->createElement('radio', 'reference', array('label' => 'Reference', 'required' => true, 'multiOptions' => array_combine($referenceOptions, $referenceOptions)));
     $name = $form->createElement('text', 'name', array('label' => 'Name', 'required' => true));
     $submit = $form->createElement('submit', 'submit', array('label' => 'Submit'));
     $form->addElements(array($handleOptionsHidden, $referenceOptionsHidden, $handleOptionsUsedHidden, $handle, $reference, $name, $submit));
     if ($form->isValid($this->getRequest()->getParams())) {
         $localXmlWriter = Mage::getModel('devel/writer_localxml');
         $localXmlWriter->addRemove($form->handle->getValue(), $form->reference->getValue(), $form->name->getValue());
         $localXmlWriter->save();
         die('DONE. You need to reload to see changes!');
     } else {
         $this->loadLayout();
         $this->getLayout()->getUpdate()->load('devel_layout_wizard');
         $this->getLayout()->generateXml();
         $this->loadLayout();
         $this->getLayout()->getBlock('devel_wizard_form')->setForm($form);
         $this->renderLayout();
     }
 }
Example #14
0
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report4Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_PLAN_YEAR');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Період', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUFORM', false);
     $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUBASIS', false);
     $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_COUNTRYTYPE', false);
     $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 4));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
Example #15
0
 public static function getMailForm($docid)
 {
     $form = new Zend_Form();
     $form->setMethod('post')->setAttrib('onsubmit', 'return checkReply(this);')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table', 'class' => 'zend_form')), 'Form'));
     $form->addElements(array(array('select', 'to', array('label' => 'To', 'required' => true, 'multiOptions' => array_merge(array('' => ''), array_keys(self::getRecipients($docid))))), array('text', 'replyto', array('label' => 'Your e-mail address', 'validators' => array(array('EmailAddress')))), array('textarea', 'body', array('label' => 'Message body', 'required' => true, 'rows' => '7', 'cols' => '70', 'validators' => array(array('StringLength', true, array(0, 5000))), 'filters' => array('StringTrim')))));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))));
     $form->addElements(array(array('captcha', 'captcha', array('label' => 'Enter safety code', 'required' => true, 'ignore' => true, 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 5, 'timeout' => 600), 'decorators' => array('Captcha', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))))), array('submit', 'submit', array('label' => 'Send', 'decorators' => array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array(array('Label' => 'HtmlTag'), array('tag' => 'td', 'placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))))));
     return $form;
 }
Example #16
0
 public function testMethodLimitedToGetPostPutAndDelete()
 {
     foreach (array('get', 'post', 'put', 'delete') as $method) {
         $this->form->setMethod($method);
         $this->assertEquals($method, $this->form->getMethod());
     }
     $this->setExpectedException('Zend\\Form\\Exception\\InvalidArgumentException', 'invalid');
     $this->form->setMethod('bogus');
 }
Example #17
0
 /** Main form */
 public function createMigrateForm($assetstores)
 {
     // Setup the form
     $form = new Zend_Form();
     $form->setAction('migratemidas2');
     $form->setName('migrateForm');
     $form->setMethod('post');
     $form->setAttrib('class', 'migrateForm');
     // Input directory
     $midas2_hostname = new Zend_Form_Element_Text('midas2_hostname', array('label' => $this->t('MIDAS2 Hostname'), 'size' => 60, 'value' => 'localhost'));
     $midas2_hostname->setRequired(true);
     $form->addElement($midas2_hostname);
     $midas2_port = new Zend_Form_Element_Text('midas2_port', array('label' => $this->t('MIDAS2 Port'), 'size' => 4, 'value' => '5432'));
     $midas2_port->setRequired(true);
     $midas2_port->setValidators(array(new Zend_Validate_Digits()));
     $form->addElement($midas2_port);
     $midas2_user = new Zend_Form_Element_Text('midas2_user', array('label' => $this->t('MIDAS2 User'), 'size' => 60, 'value' => 'midas'));
     $midas2_user->setRequired(true);
     $form->addElement($midas2_user);
     $midas2_password = new Zend_Form_Element_Password('midas2_password', array('label' => $this->t('MIDAS2 Password'), 'size' => 60, 'value' => 'midas'));
     $midas2_password->setRequired(true);
     $form->addElement($midas2_password);
     $midas2_database = new Zend_Form_Element_Text('midas2_database', array('label' => $this->t('MIDAS2 Database'), ' size' => 60, 'value' => 'midas'));
     $midas2_database->setRequired(true);
     $form->addElement($midas2_database);
     $midas2_assetstore = new Zend_Form_Element_Text('midas2_assetstore', array('label' => $this->t('MIDAS2 Assetstore Path'), 'size' => 60, 'value' => 'C:/xampp/midas/assetstore'));
     $midas2_assetstore->setRequired(true);
     $form->addElement($midas2_assetstore);
     // Button to select the directory on the server
     $midas2_assetstore_button = new Zend_Form_Element_Button('midas2_assetstore_button', $this->t('Choose'));
     $midas2_assetstore_button->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'browse-button')), array('Label', array('tag' => 'div', 'style' => 'display:none'))));
     $form->addElement($midas2_assetstore_button);
     // Assetstore
     $assetstoredisplay = array();
     $assetstoredisplay[0] = $this->t('Choose one...');
     // Initialize with the first type (MIDAS)
     foreach ($assetstores as $assetstore) {
         if ($assetstore->getType() == 0) {
             $assetstoredisplay[$assetstore->getAssetstoreId()] = $assetstore->getName();
         }
     }
     $assetstore = new Zend_Form_Element_Select('assetstore');
     $assetstore->setLabel($this->t('MIDAS3 Assetstore'));
     $assetstore->setMultiOptions($assetstoredisplay);
     $assetstore->setDescription(' <a class="load-newassetstore" href="#newassetstore-form" rel="#newassetstore-form" title="' . $this->t('Add a new assetstore') . '"> ' . $this->t('Add a new assetstore') . '</a>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
     $assetstore->setRequired(true);
     $assetstore->setValidators(array(new Zend_Validate_GreaterThan(array('min' => 0))));
     $assetstore->setRegisterInArrayValidator(false);
     // This array is dynamic so we disable the validator
     $form->addElement($assetstore);
     // Submit
     $submit = new Zend_Form_Element_Button('migratesubmit', $this->t('Migrate'));
     $form->addElement($submit);
     return $form;
 }
Example #18
0
	function setForm()
	{
		$form = new Zend_Form;
		$form->setMethod('post')->setAction('');
		
		$comment_name = new Zend_Form_Element_Text('comment_name');
		$comment_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Vui lòng nhập tên người gửi !'));
		$comment_name->setAttrib('class','n');
		$comment_name->setAttrib("onfocus","if (this.value == 'Nhập tên của bạn') {this.value = '';}");
		$comment_name->setAttrib("onblur","if (this.value == '') {this.value = 'Nhập tên của bạn';}");
		$comment_name->setValue("Nhập tên của bạn");
		
		$comment_email = new Zend_Form_Element_Text('comment_email');
		$comment_email->addValidator('EmailAddress',true,array('messages'=>'Địa chỉ email không hợp lệ'));
		$comment_email->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Vui lòng nhập địa chỉ email !'));
		$comment_email->setAttrib('class','e');
		$comment_email->setAttrib('onfocus',"if (this.value == 'Nhập địa chỉ email của bạn') {this.value = '';}");
		$comment_email->setAttrib('onblur',"if (this.value == '') {this.value = 'Nhập địa chỉ email của bạn';}");
		$comment_email->setValue('Nhập địa chỉ email của bạn');
		
		$comment_content = new Zend_Form_Element_Textarea('comment_content');
		$comment_content->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Vui lòng nhập nội dung bình luận!'));
		$comment_content->setAttrib('class','m');
		$comment_content->setAttrib('onfocus',"if (this.value == 'Nhập nội dung bình luận') {this.value = '';}");
		$comment_content->setAttrib('onblur',"if (this.value == '') {this.value = 'Nhập nội dung bình luận';}");
		$comment_content->setValue('Nhập nội dung bình luận');
		
		$comment_captcha = new Zend_Form_Element_Captcha('comment_captcha',array( 
                            'label' => 'Captcha_image', 
                             'captcha' => array( 
                                    'captcha' => 'Image', 
                                    'wordLen' => 6, 
                                    'timeout' => 300, 
                                    'font' => APPLICATION_PATH.'/templates/front/fonts/tiennd.TTF', 
                                    'imgDir' => APPLICATION_PATH.'/templates/front/captcha/', 
                                    'imgUrl' => $this->view->baseUrl().'/application/templates/front/captcha/', 
                                    'height' => 100, 
                                    'width' => 200, 
                                    'fontSize' => 50, 
                                ), 
        ));
        $comment_captcha->setAttrib('class','captcha_image1');
        $comment_captcha->setAttrib('onfocus',"if (this.value == 'Nhập hình ảnh xác nhận') {this.value = '';}");
		$comment_captcha->setAttrib('onblur',"if (this.value == '') {this.value = 'Nhập hình ảnh xác nhận';}");
        $comment_captcha->setValue('Nhập hình ảnh xác nhận');
		
		$comment_name->removeDecorator('HtmlTag')->removeDecorator('Label');
		$comment_email->removeDecorator('HtmlTag')->removeDecorator('Label');
		$comment_content->removeDecorator('HtmlTag')->removeDecorator('Label');
		$comment_captcha->removeDecorator('HtmlTag')->removeDecorator('Label');
		
		$form->addElements(array($comment_name,$comment_email,$comment_content,$comment_captcha));
		return $form;
	}
Example #19
0
 public function contactFormAction()
 {
     //create the form
     $form = new Zend_Form();
     //this page should post back to itself
     $form->setAction($_SERVER['REQUEST_URI']);
     $form->setMethod('post');
     $name = $form->createElement('text', 'name');
     $name->setLabel($this->view->getTranslation('Your Name') . ': ');
     $name->setRequired(TRUE);
     $name->addFilter('StripTags');
     $name->addErrorMessage($this->view->getTranslation('Your name is required!'));
     $name->setAttrib('size', 30);
     $email = $form->createElement('text', 'email');
     $email->setLabel($this->view->getTranslation('Your Email') . ': ');
     $email->setRequired(TRUE);
     $email->addValidator('EmailAddress');
     $email->addErrorMessage($this->view->getTranslation('Invalid email address!'));
     $email->setAttrib('size', 30);
     $subject = $form->createElement('text', 'subject');
     $subject->setLabel($this->view->getTranslation('Subject') . ': ');
     $subject->setRequired(TRUE);
     $subject->addFilter('StripTags');
     $subject->addErrorMessage($this->view->getTranslation('The subject is required!'));
     $subject->setAttrib('size', 40);
     $message = $form->createElement('textarea', 'message');
     $message->setLabel($this->view->getTranslation('Message') . ': ');
     $message->setRequired(TRUE);
     $message->addErrorMessage($this->view->getTranslation('The message is required!'));
     $message->setAttrib('cols', 35);
     $message->setAttrib('rows', 10);
     $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $this->view->getTranslation('Please verify you\'re a human'), 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 6, 'timeout' => 300)));
     $form->addElement($name);
     $form->addElement($email);
     $form->addElement($subject);
     $form->addElement($message);
     $form->addElement($captcha);
     $form->addElement('submit', 'submitContactForm', array('label' => $this->view->getTranslation('Send Message')));
     $this->view->form = $form;
     if ($this->_request->isPost() && Digitalus_Filter_Post::has('submitContactForm')) {
         if ($form->isValid($_POST)) {
             //get form data
             $data = $form->getValues();
             //get the module data
             $module = new Digitalus_Module();
             $moduleData = $module->getData();
             //render the message
             $this->view->data = $data;
             $htmlMessage = $this->view->render('public/message.phtml');
             $mail = new Digitalus_Mail();
             $this->view->isSent = $mail->send($moduleData->email, array($data['email'], $data['name']), $data['subject'], $htmlMessage);
         }
     }
 }
Example #20
0
 function staffSelector($allOption = true, $serviceId = null)
 {
     $staff = $this->listStaff($serviceId);
     $form = new \Zend_Form();
     $form->setMethod("GET");
     if ($allOption) {
         $form->addElement('select', 'staff', array('label' => 'Staff', 'multiOptions' => array('All' => 'All') + $staff, 'value' => $this->params()->fromQuery('staff') == 'All' ? null : $this->params()->fromQuery('staff')));
     } else {
         $form->addElement('select', 'staff', array('label' => 'Staff', 'multiOptions' => $staff, 'value' => $this->params()->fromQuery('staff')));
     }
     $form->addElement('submit', 'submitbutton', array('label' => 'Go', 'class' => 'btn'));
     return $form;
 }
Example #21
0
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod(Zend_Form::METHOD_POST);
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'requests/reqForm.phtml'))));
     $items = $this->getGuideYears();
     $e = new Zend_Form_Element_Select('year', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'value' => reset($items)));
     $form->addElement($e);
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити'));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
Example #22
0
 public function testMethodLimitedToGetPostPutAndDelete()
 {
     foreach (array('get', 'post', 'put', 'delete') as $method) {
         $this->form->setMethod($method);
         $this->assertEquals($method, $this->form->getMethod());
     }
     try {
         $this->form->setMethod('bogus');
         $this->fail('Invalid method type should throw exception');
     } catch (Zend_Form_Exception $e) {
         $this->assertContains('invalid', $e->getMessage());
     }
 }
Example #23
0
 /**
  * Present a login form and handle user authentication.
  */
 public function loginAction()
 {
     /*
      * Build the login form
      */
     $form = new Zend_Form();
     $form->setMethod('post');
     $username = $form->createElement('text', 'username');
     $username->setLabel($this->view->translate->_('Username'));
     $username->setRequired(true);
     $username->addValidator('alnum');
     $password = $form->createElement('password', 'password');
     $password->setLabel($this->view->translate->_('Password'));
     $password->setRequired(true);
     $form->addElement($username);
     $form->addElement($password);
     $form->addElement('submit', 'login', array('label' => $this->view->translate->_('Login')));
     /*
      * Handle authentication
      */
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             try {
                 Model_DbTable_User::authenticate($form->getValue('username'), $form->getValue('password'));
                 /*
                  * Set the current user session
                  */
                 $user = Model_DbTable_User::findByUsername($form->getValue('username'));
                 $currentUser = new Zend_Session_Namespace('currentUser');
                 $currentUser->id = $user->id;
                 $currentUser->username = $user->username;
                 $currentUser->apiKey = $user->apiKey;
                 $currentUser->language = $user->language;
                 $currentUser->skin = $user->skin;
                 $currentUser->isAdmin = $user->isAdmin;
                 /*
                  * Redirect back to the index page.
                  */
                 $this->_helper->_redirector->goToRouteAndExit(array('controller' => 'index', 'action' => 'index'));
             } catch (Exception $e) {
                 $this->view->errorMessage = $this->view->translate->_('Login failed.') . ' ' . $e->getMessage();
             }
         } else {
             $this->view->errorMessage = $this->view->translate->_('Login failed.') . ' ' . $this->view->translate->_('Please completely fill out the login form.');
             $form->populate($formData);
         }
     }
     $this->view->headTitle($this->view->translate->_('Login'));
     $this->view->form = $form;
 }
Example #24
0
 public function getLoginForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $email = $form->createElement('text', 'email');
     $email->setRequired(true)->addFilter('StringToLower');
     $email->addValidator(new Zend_Validate_EmailAddress());
     $email->setLabel('Email Address');
     $form->addElement($email);
     $password = $form->createElement('password', 'password');
     $password->setRequired(true)->addFilter('StringToLower');
     $password->setLabel('Password');
     $form->addElement($password);
     $form->addElement('submit', 'register', array('label' => 'Login!'));
     return $form;
 }
Example #25
0
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report9Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_YEAR_SPEC');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
     $form->addElement($e);
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 9));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
 private function _getLoginForm()
 {
     $form = new Zend_Form();
     $form->setMethod('POST');
     $form->setName('userLoginForm');
     $username = new Zend_Form_Element_Text('username');
     $username->setLabel('User name')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('Alnum')->addValidator('StringLength', false, array(3, 24));
     $password = new Zend_Form_Element_Password('password');
     $password->setLabel('Password')->setRequired(true)->setValue(null)->addValidator('StringLength', false, array(6));
     $realm = new Zend_Form_Element_Select('realm');
     $realm->setLabel('Role')->addMultiOptions(array('user' => 'User', 'admin' => 'Admin'))->setRequired(true)->setValue('user');
     $rememberMe = new Zend_Form_Element_Checkbox('rememberMe');
     $rememberMe->setLabel('Remember Me');
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel('Login');
     $form->addElements(array($realm, $username, $password, $rememberMe, $submit));
     return $form;
 }
 public function ajouterAction()
 {
     $form = new Zend_Form();
     // On prépare le formulaire à afficher
     $form->setMethod('post');
     $form->addElement('text', 'NOM_M', array('label' => 'Nom : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'PRENOM', array('label' => 'Prénom : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'LOGIN', array('label' => 'Login : '******'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'MAIL', array('label' => 'Votre Adresse e-mail : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'PASSWORD', array('label' => 'Mot de passe : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'ROLE', array('label' => 'Rôle : ', 'required' => false));
     $form->addElement('text', 'DATE_ENTREE', array('label' => "Date d'entrée : ", 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'ECOLE', array('label' => 'Ecole : ', 'required' => false));
     $form->addElement('text', 'PROMO', array('label' => 'Promotion : ', 'required' => false));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel('Ajouter');
     $form->addElement($submit);
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $dba = Zend_Registry::get('dba');
             // On récupère l'instance de la BDD
             $datas = array('PRENOM' => $formData["PRENOM"], 'LOGIN' => $formData["LOGIN"], 'MAIL' => $formData["MAIL"], 'PASSWORD' => md5($formData["PASSWORD"]), 'ROLE' => $formData["ROLE"], 'DATE_ENTREE' => new Zend_Db_Expr('now()'), 'ECOLE' => $formData["ECOLE"], 'PROMO' => $formData["PROMO"], 'NOM_M' => $formData["NOM_M"], 'ACTIVE_M' => true);
             $dba->beginTransaction();
             try {
                 $dba->insert('MEMBRE', $datas);
                 // On prépare le commit
                 $dba->commit();
                 // On tente d'inserer les datas dans la table MEMBRE
             } catch (Exception $e) {
                 $dba->rollBack();
                 // En cas de problèmes avec la base de donnée on annule les changements et on affiche le message d'erreur
                 echo $e->getMessage();
             }
             $this->_helper->redirector('index');
             // Permet de rediriger vers la page index Membre
         } else {
             $form->populate($formData);
             // Si il y a une erreur on pre-remplie les champs déjà renseigner et affiche les éventuelles erreurs
         }
     }
     $this->view->form = $form;
     // On met le formulaire ds la variable form
 }
Example #28
0
		function setForm()
		{
			$form=new Zend_Form;
			 
			$form->setMethod('post')->setAction('');
			
			$danhmuc = new Zend_Form_Element_Text('danhmuc');
			$noidung = new Zend_Form_Element_Text('noidung');
			$noidung->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Nội dung không được để trống'));
			$lienket = new Zend_Form_Element_Text('lienket');
			$lienket->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Liên kết không được để trống'));
																	  
			$danhmuc->removeDecorator('HtmlTag')->removeDecorator('Label');
			$noidung->removeDecorator('HtmlTag')->removeDecorator('Label');
			$lienket->removeDecorator('HtmlTag')->removeDecorator('Label');
			
			$form->addElements(array($danhmuc,$noidung,$lienket));
			return $form;
		}
 public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $this->_redirect("/accueil");
         //  echo "identity remove";
         // $auth->clearIdentity();
     }
     $this->view->menu = "index";
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->addElement('text', 'LOGIN', array('label' => 'Login : '******'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('password', 'PASSWORD', array('label' => 'Password : '******'required' => true, 'filters' => array('StringTrim')));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel('Se Connecter')->setAttrib('class', 'valid_button gros-bouton');
     $form->addElement($submit);
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             MyAcl::setCache(Zend_Cache::factory("Core", "File"));
             $acl = MyAcl::getInstance();
             Acl_Db_Table_Row::setAcl($acl);
             $dba = Zend_Registry::get('dba');
             $TMembres = new Application_Model_Membre($dba);
             $membre = $TMembres->createRow();
             $membre->LOGIN = $formData["LOGIN"];
             // ceci pourrait provenir d'un formulaire
             $membre->PASSWORD = $formData["PASSWORD"];
             // ceci pourrait provenir d'un formulaire
             $result = $membre->authenticate();
             // si OK : persistance 30min en session
             if (!$result->isValid()) {
                 echo 'login ou mot de passe incorrect';
             } else {
                 echo "ok";
                 $this->_redirect("/accueil");
             }
         } else {
             $form->populate($formData);
         }
     }
     $this->view->form = $form;
 }
Example #30
0
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report8Form.phtml'))));
     $items = $this->getPeriodItems('REQ_EDUSTAT_FAIL');
     $e = new Zend_Form_Element_Select('period', array('label' => 'На дату', 'multiOptions' => $items, 'required' => true));
     $form->addElement($e);
     $items = $this->getGuideItems('T_DEPARTMENT', true);
     $e = new Zend_Form_Element_Select('department', array('label' => 'Факультет', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 8));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }