示例#1
1
 /**
  * Hook for node form - if type is Filemanager Node, add extra fields
  *
  * @param Zend_Form $form
  * @param array $arguments
  */
 public function nodeForm(Zend_Form &$form, &$arguments)
 {
     $item =& array_shift($arguments);
     if (!Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest() && $item->type == "filemanager_file") {
         // Add Filemanager fields
         $form->setAttrib('enctype', 'multipart/form-data');
         $file = new Zend_Form_Element_File('filemanager_file');
         $file->setLabel("Select file")->setDestination(ZfApplication::$_data_path . DIRECTORY_SEPARATOR . "files")->setRequired(false);
         $form->addElement($file);
         $fields[] = 'filemanager_file';
         if ($item->id > 0) {
             // Fetch Filemanager object
             $factory = new Filemanager_File_Factory();
             $file_item = $factory->find($item->id)->current();
             if ($file_item) {
                 $existing = new Zend_Form_Element_Image('filemanager_image');
                 if (substr($file_item->mimetype, 0, 5) == "image") {
                     $imageid = $file_item->nid;
                 } else {
                     $imageid = 0;
                 }
                 $urlOptions = array('module' => 'filemanager', 'controller' => 'file', 'action' => 'show', 'id' => $imageid);
                 $existing->setImage(Zend_Controller_Front::getInstance()->getRouter()->assemble($urlOptions, 'default'));
                 $fields[] = 'filemanager_image';
             }
         }
         $options = array('legend' => Zoo::_("File upload"));
         $form->addDisplayGroup($fields, 'filemanager_fileupload', $options);
     } else {
         // Add content node image selector
     }
 }
示例#2
0
文件: FormTest.php 项目: lortnus/zf1
 public function testEmptyFormNameShouldNotRenderEmptyFormId()
 {
     $form = new Zend_Form();
     $form->setMethod('post')->setAction('/foo/bar')->setView($this->getView());
     $html = $form->render();
     $this->assertNotContains('id=""', $html, $html);
 }
示例#3
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;
		}
示例#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;
		}
 /**
  * Set form decorators.
  */
 protected function setupForm()
 {
     // remove default decorators and add own
     $this->form->clearDecorators();
     $this->form->addDecorator('FormElements');
     $this->form->addDecorator('HtmlTag', array('tag' => 'dl', 'id' => $this->form->getId(), 'class' => 'form_view'));
 }
示例#6
0
 /**
  * Adds an element JobFunctionId.<br/><br/>
  * Defaults:<br/>
  * name         = job_function_id<br/>
  * requires     = true<br/>
  * label        = Business unit<br/>
  * placeholder  = 'Choose a job function'<br/>
  * dimension    = 6<br/>
  * modelfield   = job_function_id<br/>
  * firstvaluenull  = true
  * 
  * @param Zend_Form $form The Zend_Form object where the element will be added
  * @param array $options The options to pass in the element
  */
 public function addElementJobFunctionId($form, $options = array())
 {
     $elementName = isset($options['name']) ? $options['name'] : 'job_function_id';
     $modelField = isset($options['modelfield']) ? $options['modelfield'] : 'job_function_id';
     $form->addElement('select', $elementName, array('filters' => array('StringTrim'), 'label' => isset($options['label']) ? $options['label'] : 'Job function', 'dimension' => isset($options['dimension']) ? $options['dimension'] : 6, 'placeholder' => 'Choose a job function', 'required' => isset($options['required']) ? $options['required'] : true, 'value' => $this->_model ? $this->_model->{$modelField} : ''));
     $el = $form->getElement($elementName);
     $firstvaluenull = isset($options['firstvaluenull']) ? $options['firstvaluenull'] : true;
     if ($firstvaluenull) {
         $el->addMultiOption(null, null);
     }
     /**
      * Add job functions
      */
     $jfd = new Staff_Domain_Jobfunction();
     $jf = $jfd->getAll('name');
     foreach ($jf as $item) {
         $el->addMultiOption($item->getId(), $item->getName());
     }
     // set value
     if ($this->_model && $this->_model->{$modelField}) {
         $el->setValue($this->_model->{$modelField});
     } else {
         $el->setValue(null);
     }
 }
 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;
 }
示例#8
0
 private function getFormLogin()
 {
     $form = new Zend_Form(array('disableLoadDefaultDecorators' => true));
     $email = new Zend_Form_Element_Text('login', array('disableLoadDefaultDecorators' => true));
     $email->addDecorator('ViewHelper');
     $email->addDecorator('Errors');
     $email->setRequired(true);
     $email->setAttrib('class', 'form-control');
     $email->setAttrib('placeholder', 'Login');
     $email->setAttrib('required', 'required');
     $email->setAttrib('autofocus', 'autofocus');
     $password = new Zend_Form_Element_Password('password', array('disableLoadDefaultDecorators' => true));
     $password->addDecorator('ViewHelper');
     $password->addDecorator('Errors');
     $password->setRequired(true);
     $password->setAttrib('class', 'form-control');
     $password->setAttrib('placeholder', 'Hasło');
     $password->setAttrib('required', 'required');
     $password->setAttrib('autofocus', 'autofocus');
     $submit = new Zend_Form_Element_Submit('submit', array('disableLoadDefaultDecorators' => true));
     $submit->setAttrib('class', 'btn btn-lg btn-primary btn-block');
     $submit->setOptions(array('label' => 'Zaloguj'));
     $submit->addDecorator('ViewHelper')->addDecorator('Errors');
     $form->addElement($email)->addElement($password)->addElement($submit);
     return $form;
 }
示例#9
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;
 }
示例#10
0
 public function editAction()
 {
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $userForm = new Zend_Form($configForm->user);
     $userId = $this->getRequest()->getParam('id', null);
     if ($this->getRequest()->isPost()) {
         if ($userForm->isValid($_POST)) {
             try {
                 $values = $userForm->getValues();
                 unset($values['password_repeat']);
                 $userId = $this->userRepository->saveEntity($values);
                 $this->_helper->systemMessages('notice', 'Nutzer erfolgreich gespeichert');
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 $this->_helper->systemMessages('error', 'Nutzer konnte nicht gespeichert werden');
             }
         }
     } else {
         try {
             $entity = $this->userRepository->fetchEntity($userId);
             $userForm->populate($entity->toArray());
         } catch (\Exception $e) {
             throw new \Exception($e->getMessage(), 404);
         }
     }
     $userForm->setAction('/admin/user/edit/' . $userId);
     $this->view->form = $userForm;
 }
示例#11
0
 /**
  * add subform element to stack
  *
  * @param Zend_Form $form
  * @return Centurion_Form_DisplayGroup
  */
 public function addSubForm(Zend_Form $form)
 {
     $this->_subForms[$form->getName()] = $form;
     $this->_orders[$form->getName()] = count($this->_order);
     $this->_groupUpdated = true;
     return $this;
 }
示例#12
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;
		}
示例#13
0
 public function loginAction()
 {
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $loginForm = new \Zend_Form($configForm->login);
     if ($this->getRequest()->isPost()) {
         if ($loginForm->isValid($_POST)) {
             try {
                 $auth = $this->getInvokeArg('bootstrap')->auth;
                 $auth->setIdentity($loginForm->getValue('login'))->setCredential($loginForm->getValue('password'));
                 $result = \Zend_Auth::getInstance()->authenticate($auth);
                 if ($result->isValid()) {
                     $this->_redirect('/admin');
                 } else {
                     $this->_helper->systemMessages('error', 'Anmeldung verweigert');
                 }
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 $this->_helper->systemMessages('error', 'Fehler bei der Anmeldung');
             }
         }
     }
     $loginForm->setAction('/login');
     $this->view->form = $loginForm;
 }
示例#14
0
 /**
  * Hook for node save - save parent (category)
  *
  * @param Zend_Form $form
  * @param array $arguments
  */
 public function nodeSave(&$form, &$arguments)
 {
     $item = array_shift($arguments);
     $arguments = $form->getValues();
     if (isset($arguments['rewrite_path'])) {
         $router = Zend_Controller_Front::getInstance()->getRouter();
         $default_url = $router->assemble(array('id' => $item->id), $item->type);
         $factory = new Rewrite_Path_Factory();
         $path = $factory->find($item->id)->current();
         if ($arguments['rewrite_path'] == $default_url) {
             if ($path) {
                 $path->delete();
             }
         } else {
             if (!$path) {
                 $path = $factory->createRow();
                 $path->nid = $item->id;
             }
             if ($arguments['rewrite_path'] != $path->path) {
                 $path->path = $arguments['rewrite_path'];
                 $path->save();
             }
         }
     }
 }
示例#15
0
 public function loadFromForm(Zend_Form $form)
 {
     $this->title = $form->getTitle();
     $this->body = $form->getBody();
     $this->permalink = $form->getPermalink();
     $this->owner = $form->getOwner();
 }
 public function saveFormData(Zend_Form $form)
 {
     $item = $this->_model;
     $item->setOptions($form->getValues());
     if ($this->_request->getParam('contentMarkdown')) {
         $context_html = Michelf\MarkdownExtra::defaultTransform($this->_request->getParam('contentMarkdown'));
         $item->setContentHtml($context_html);
     }
     $fullPath = $this->_request->getParam('path');
     if ($this->_request->getParam('parentId') != 0) {
         $parentCategory = $this->_modelMapper->find($this->_request->getParam('parentId'), new Pipeline_Model_PipelineCategories());
         if ($parentCategory) {
             $fullPath = $parentCategory->getFullPath();
         }
     }
     $item->setFullPath($fullPath);
     $this->setMetaData($item);
     $this->getModelMapper()->save($item);
     if ($item->getId() && $item->getId() != '') {
         $id = $item->getId();
     } else {
         $id = $this->getModelMapper()->getDbTable()->getAdapter()->lastInsertId();
     }
     $item = $this->getModelMapper()->find($id, $this->getModel());
     foreach ($form->getElements() as $key => $element) {
         if ($element instanceof Zend_Form_Element_File && $element->isUploaded()) {
             $item = $this->saveUploadFile($element, $item);
         }
     }
     return $item;
 }
示例#17
0
    /**
     * Returns the HTML for creating a form powered by JavaScript (or straight one).
     * The CSS, JS and other is included.
     *
     * @param Zend_Form $form The form object
     * @param Boolean $jsStayOnPage Should we post as a service and stay on the same page
     * @param String $srvurl The URL to post the data to or NONE will build the URL automatically
     */
    public function FormAdminGeneric(Zend_Form $form, $jsStayOnPage = true, $srvurl = '')
    {
        $formname = $form->getName();
        if ($srvurl == '') {
            $srvurl = '/' . $this->view->moduleName . '/services/edit' . $formname . '/format/json';
        }
        $form->setAction($srvurl);
        $html = '';
        if ($jsStayOnPage) {
            $html .= '
		<script>
		$(function(){
			$(\'#' . $formname . '\').formvalidator({\'url\':\'' . $srvurl . '\'});
		});
		</script>
		';
        }
        $html .= '
		<div class="box">
			<fieldset>
				' . $form . '
			</fieldset>
		</div>
		';
        return $html;
    }
示例#18
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;
		}
示例#19
0
 protected function _recursivelyPrepareForm(Zend_Form $form)
 {
     $belongsTo = $form instanceof Zend_Form ? $form->getElementsBelongTo() : null;
     $elementContent = '';
     $separator = $this->getSeparator();
     $translator = $form->getTranslator();
     $view = $form->getView();
     foreach ($form as $item) {
         $item->setView($view)->setTranslator($translator);
         if ($item instanceof Zend_Form_Element) {
             $item->setBelongsTo($belongsTo);
         } elseif (!empty($belongsTo) && $item instanceof Zend_Form) {
             if ($item->isArray()) {
                 $name = $this->mergeBelongsTo($belongsTo, $item->getElementsBelongTo());
                 $item->setElementsBelongTo($name, true);
             } else {
                 $item->setElementsBelongTo($belongsTo, true);
             }
             $this->_recursivelyPrepareForm($item);
         } elseif (!empty($belongsTo) && $item instanceof Zend_Form_DisplayGroup) {
             foreach ($item as $element) {
                 $element->setBelongsTo($belongsTo);
             }
         }
     }
 }
示例#20
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;
		}
示例#21
0
 /**
  * Ensures that enhance() does not modify the provided form.
  */
 public function testEnhanceDoesNotModifyForm()
 {
     $form = new Zend_Form();
     $form->addElement(new Zend_Form_Element_Text('name'));
     $this->plugin->enhance($form);
     $this->assertEquals(1, count($form->getElements()));
 }
 /**
  * This returns the form for the collections.
  *
  * @return Zend_Form
  * @author Eric Rochester <*****@*****.**>
  **/
 protected function _collectionsForm()
 {
     $ctable = $this->_helper->db->getTable('Collection');
     $private = (int) get_option('solr_search_display_private_items');
     if ($private) {
         $collections = $ctable->findAll();
     } else {
         $collections = $ctable->findBy(array('public' => 1));
     }
     $form = new Zend_Form();
     $form->setAction(url('solr-search/collections'))->setMethod('post');
     $collbox = new Zend_Form_Element_MultiCheckbox('solrexclude');
     $form->addElement($collbox);
     foreach ($collections as $c) {
         $title = metadata($c, array('Dublin Core', 'Title'));
         $collbox->addMultiOption("{$c->id}", $title);
     }
     $etable = $this->_helper->db->getTable('SolrSearchExclude');
     $excludes = array();
     foreach ($etable->findAll() as $exclude) {
         $excludes[] = "{$exclude->collection_id}";
     }
     $collbox->setValue($excludes);
     $form->addElement('submit', 'Exclude');
     return $form;
 }
示例#23
0
 private function getPartnerFilterFromForm(Zend_Form $form)
 {
     $filter = new KalturaPartnerFilter();
     $filterType = $form->getValue('filter_type');
     $filterInput = $form->getValue('filter_input');
     $includeActive = $form->getValue('include_active');
     $includeBlocked = $form->getValue('include_blocked');
     $includeRemoved = $form->getValue('include_removed');
     if ($filterType == 'byid') {
         $filter->idIn = $filterInput;
     } else {
         if ($filterType == 'byname') {
             $filter->nameLike = $filterInput;
         } elseif ($filterType == 'free' && $filterInput) {
             $filter->partnerNameDescriptionWebsiteAdminNameAdminEmailLike = $filterInput;
         }
     }
     $statuses = array();
     if ($includeActive) {
         $statuses[] = KalturaPartnerStatus::ACTIVE;
     }
     if ($includeBlocked) {
         $statuses[] = KalturaPartnerStatus::BLOCKED;
     }
     if ($includeRemoved) {
         $statuses[] = KalturaPartnerStatus::FULL_BLOCK;
     }
     $filter->statusIn = implode(',', $statuses);
     $filter->orderBy = KalturaPartnerOrderBy::ID_DESC;
     return $filter;
 }
示例#24
0
 public function detailAction()
 {
     $newsUrl = $this->getRequest()->getParam('url', null);
     try {
         $news = $this->newsRepository->fetchEntityByUrl($newsUrl);
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage(), 404);
     }
     $this->view->headTitle($news->headline);
     $this->view->headMeta()->setName('description', $this->_helper->truncate($news->content, 255));
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $commentForm = new \Zend_Form($configForm->comment);
     if ($this->getRequest()->isPost()) {
         if ($commentForm->isValid($_POST)) {
             try {
                 $values = $commentForm->getValues();
                 unset($values['csrf']);
                 unset($values['firstname']);
                 # SpamDetection
                 $values['news'] = $news;
                 $this->commentRepository->saveEntity($values);
                 $commentForm->reset();
                 #$this->_helper->systemMessages('notice', 'Kommentar erfolgreich gespeichert');
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 #$this->_helper->systemMessages('error', 'Kommentar konnte nicht gespeichert werden');
             }
         }
     }
     $commentForm->setAction('/news/' . $newsUrl);
     $this->view->form = $commentForm;
     $this->view->news = $news;
 }
示例#25
0
 /**
  * Adds an element BusUnitId.<br/><br/>
  * Defaults:<br/>
  * name         = busunit_id<br/>
  * requires     = true<br/>
  * label        = Business unit<br/>
  * placeholder  = 'Choose a business unit'<br/>
  * dimension    = 6<br/>
  * modelfield   = busunit_id<br/>
  * firstvaluenull  = true
  * 
  * @param Zend_Form $form The Zend_Form object where the element will be added
  * @param array $options The options to pass in the element
  */
 public function addElementBusunitId($form, $options = array())
 {
     $elementName = isset($options['name']) ? $options['name'] : 'busunit_id';
     $modelField = isset($options['modelfield']) ? $options['modelfield'] : 'busunit_id';
     $form->addElement('select', $elementName, array('filters' => array('StringTrim'), 'label' => isset($options['label']) ? $options['label'] : 'Business unit', 'dimension' => isset($options['dimension']) ? $options['dimension'] : 6, 'placeholder' => 'Choose a business unit', 'required' => isset($options['required']) ? $options['required'] : true, 'value' => $this->_model ? $this->_model->{$modelField} : ''));
     $el = $form->getElement($elementName);
     $firstvaluenull = isset($options['firstvaluenull']) ? $options['firstvaluenull'] : true;
     if ($firstvaluenull) {
         $el->addMultiOption(null, null);
     }
     /////////////////////
     // Add Headquarters
     $bud = new Busunit_Domain_Headquarters();
     $bu = $bud->getByAppAccount(Zend_Auth::getInstance()->getIdentity()->appaccount_id);
     $el->addMultiOption($bu->getId(), $bu->getName());
     // Add Branchs
     $bud = new Busunit_Domain_Branch();
     $bu = $bud->getAll('name');
     foreach ($bu as $busunit) {
         $el->addMultiOption($busunit->getId(), $busunit->getName());
     }
     // set value
     if ($this->_model && $this->_model->{$modelField}) {
         $el->setValue($this->_model->{$modelField});
     } else {
         $el->setValue(null);
     }
 }
 /**
  * Ensures that the plugin does not modify the autocomplete attribute if it
  * is already defined in the form.
  */
 public function testPluginDoesNotModifyAutocompleteAttributeIfItIsAlreadyDefinedInTheForm()
 {
     $form = new Zend_Form();
     $form->setAttrib('autocomplete', 'any-value');
     $this->plugin->enhance($form);
     $this->assertEquals('any-value', $form->getAttrib('autocomplete'));
 }
 public function setModel(Zend_Form $form, \Model\EmployeeTraining $model)
 {
     $em = EntityManager::getInstance();
     $values = $form->getValue("basic");
     $model->training = $em->find("Training", $values['training']);
     $model->employee = $em->find("Employee", $form->getValue("parent"));
 }
示例#28
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;
		}
 /** THis is where they pick the duration */
 function bookingAction()
 {
     $this->layout('layout/layout-appointment-summary');
     $layoutViewModel = $this->layout();
     $progress = new ViewModel(['step' => 3]);
     $progress->setTemplate('application/progress');
     $layoutViewModel->addChild($progress, 'progress');
     $service = $this->serviceDataMapper()->find($this->params('service'));
     $durations = array();
     foreach ($service['durations'] as $duration) {
         $durations[$duration] = $this->durationLabels[$duration];
     }
     $form = new \Zend_Form();
     $form->addElement('radio', 'appointment_duration', array('label' => 'Appointment Duration', 'multiOptions' => $durations, 'separator' => ''));
     if ($this->getRequest()->isPost() && $form->isValid($this->params()->fromPost())) {
         $url = $this->url()->fromRoute('make-booking', array('action' => 'booking2', 'duration' => $form->getValue('appointment_duration'), 'service' => $this->params('service'), 'day' => $this->params('day')));
         $this->redirect()->toUrl($url);
         return;
     }
     $this->viewParams['form'] = $form;
     $summary = new ViewModel($this->params()->fromRoute());
     $summary->setTemplate('application/summary');
     $layoutViewModel->addChild($summary, 'appointment_summary');
     $viewModel = new ViewModel($this->viewParams);
     $viewModel->setTemplate('application/booking');
     return $viewModel;
 }
示例#30
0
 public static function addOptionsToForm(Zend_Form $form, $options, $fieldName, $attributeName)
 {
     $arr = array();
     foreach ($options as $option) {
         $arr[$option->id] = $option->{$attributeName};
     }
     $form->getElement($fieldName)->setMultiOptions($arr);
 }