public function init()
 {
     $this->setAction(url('facet-by-metadata'));
     $elTable = get_db()->getTable('Element');
     $elements = array();
     $elementIds = json_decode(get_option('facet_by_metadata_elements'), true);
     foreach ($elementIds as $elementId) {
         $element = $elTable->find($elementId);
         $elements[$elementId] = metadata($element, 'name') . ': ' . metadata($this->item, array($element->getElementSet()->name, $element->name));
     }
     $checkboxes = new Zend_Form_Element_MultiCheckbox('elements');
     $checkboxes->setMultiOptions($elements);
     $this->addElement($checkboxes);
     $this->addElement('hidden', 'item_id', array('value' => $this->item->id));
     $this->addElement('submit', __('Find'));
 }
 public function init()
 {
     // profissional_beleza_nome
     $profissional_beleza_nome = new Zend_Form_Element_Text("profissional_beleza_nome");
     $profissional_beleza_nome->setLabel("Nome: ");
     $profissional_beleza_nome->setAttribs(array('class' => 'form-control'));
     $profissional_beleza_nome->setRequired();
     $profissional_beleza_nome->setDecorators(App_Forms_Decorators::$simpleElementDecorators);
     // profissional_beleza_email
     $profissional_beleza_email = new Zend_Form_Element_Text("profissional_beleza_email");
     $profissional_beleza_email->setLabel("E-mail: ");
     $profissional_beleza_email->setValidators(array('EmailAddress'));
     $profissional_beleza_email->addValidator(new App_Validate_ProfissionalBeleza());
     $profissional_beleza_email->setAttribs(array('class' => 'form-control'));
     $profissional_beleza_email->setRequired();
     $profissional_beleza_email->setDecorators(App_Forms_Decorators::$simpleElementDecorators);
     /**
      * profisional_beleza_sexo
      */
     $profissional_beleza_sexo = new Zend_Form_Element_Radio("profissional_beleza_sexo");
     $profissional_beleza_sexo->setLabel("Sexo:");
     $profissional_beleza_sexo->setRequired();
     $profissional_beleza_sexo->setDecorators(App_Forms_Decorators::$checkboxElementDecorators);
     $profissional_beleza_sexo->setMultiOptions(array('M' => ' Masculino', 'F' => ' Feminino'));
     // profissional_beleza_avatar
     $profissional_beleza_avatar = new Zend_Form_Element_File("profissional_beleza_avatar");
     $profissional_beleza_avatar->setLabel(" \n            Foto: \n        ");
     $profissional_beleza_avatar->addDecorators(App_Forms_Decorators::$ElementDecoratorFile);
     $profissional_beleza_avatar->setAttribs(array('class' => 'filestyle', 'data-buttonText' => 'Selecione a foto', 'data-iconName' => 'fa fa-user'));
     $profissional_beleza_avatar->setRequired();
     $profissional_beleza_avatar->setDestination(Zend_Registry::get('config')->profissional->avatar->path);
     $profissional_beleza_avatar->addValidators(array(array('Extension', false, 'jpg,jpeg,png')));
     $profissional_beleza_avatar->addFilter(new Skoch_Filter_File_Resize(array('width' => 160, 'keepRatio' => true)));
     // especialidade_id
     $especialidade_id = new Zend_Form_Element_MultiCheckbox("especialidade_id");
     $especialidade_id->setLabel("Selecione as especialidades: ");
     $especialidade_id->setAttribs(array('class' => ''));
     $especialidade_id->setRequired();
     $especialidade_id->setDecorators(App_Forms_Decorators::$checkboxElementDecorators);
     $especialidade_id->setSeparator(' ');
     $especialidade_id->setMultiOptions($this->getEspecialidades());
     // addElements
     $this->addElements(array($profissional_beleza_nome, $profissional_beleza_email, $profissional_beleza_sexo, $profissional_beleza_avatar, $especialidade_id));
     parent::init();
 }
 public function init()
 {
     // username
     $this->addElement('text', 'username', array('required' => true, 'validators' => array(array('Alnum', false, false), array('StringLength', false, array(6, 16)))));
     // email
     $EmailValidate = new My_Validator_Email();
     $this->addElement('text', 'email', array('required' => true, 'validators' => array(array('EmailAddress', false), array($EmailValidate, false))));
     // add checkboxes with user groups.
     // Perform translation here. (could as well have been titles from a DB
     // so it's not something the renderer should do, as opposed to labels
     // and error messages)
     $lang = new My_LanguagePack();
     $groupIds = array(1, 2, 3, 4);
     $groupOptions = array();
     foreach ($groupIds as $id) {
         $groupOptions[$id] = $lang->get('group.label.' . $id);
     }
     $elmGroup = new Zend_Form_Element_MultiCheckbox('group');
     $elmGroup->setMultiOptions($groupOptions);
     $elmGroup->setRequired(true);
     $this->addElement($elmGroup);
 }
 protected function addProviderElements()
 {
     $element = new Zend_Form_Element_Hidden('providerElements');
     $element->setLabel('Cross Kaltura Specific Configuration');
     $element->setDecorators(array('ViewHelper', array('Label', array('placement' => 'append')), array('HtmlTag', array('tag' => 'b'))));
     // add elements
     $this->addElement('text', 'target_service_url', array('label' => 'Target Service URL:', 'filters' => array('StringTrim'), 'required' => true));
     $this->addElement('text', 'target_account_id', array('label' => 'Target Account ID:', 'filters' => array('StringTrim'), 'required' => true));
     $this->addElement('text', 'target_login_id', array('label' => 'Target Login ID:', 'filters' => array('StringTrim'), 'required' => true));
     $this->addElement('text', 'target_login_password', array('label' => 'Target Login Password:'******'filters' => array('StringTrim'), 'required' => true));
     $this->addElement('textarea', 'metadata_xslt', array('label' => 'Metadata XSLT:', 'filters' => array('StringTrim')));
     $this->addElement('checkbox', 'distribute_remote_flavor_asset_content', array('label' => 'Distribute Remote Flavor Asset Content Instead Of Local:'));
     $this->addElement('checkbox', 'distribute_remote_thumb_asset_content', array('label' => 'Distribute Remote Thumb Asset Content Instead Of Local:'));
     $this->addElement('checkbox', 'distribute_remote_caption_asset_content', array('label' => 'Distribute Remote Caption Asset Content Instead Of Local:'));
     $this->addElement('checkbox', 'distribute_captions', array('label' => 'Distribute Captions:'));
     $this->addElement('checkbox', 'distribute_cue_points', array('label' => 'Distribute Cue Points:'));
     // add metadata fields that trigger update
     $metadataFields = $this->getMetadataFields();
     if (count($metadataFields)) {
         $xpathsElement = new Zend_Form_Element_MultiCheckbox(self::ELEMENT_METADATA_XPATHS_THAT_TRIGGER_UPDATE);
         $xpathsElement->setLabel('Metadata Fields That Trigger Update:');
         $xpathsElement->setMultiOptions($this->getMetadataFields());
         $this->addElement($xpathsElement);
     }
     // add source to target mapping tables
     $this->addElement('textarea', self::ELEMENT_MAP_ACCESS_CONTROL_IDS, array('label' => 'Access Control Profile IDs map:', 'filters' => array('StringTrim')));
     $this->addElement('textarea', self::ELEMENT_MAP_CONVERSION_PROFILE_IDS, array('label' => 'Conversion Profile IDs map:', 'filters' => array('StringTrim')));
     $this->addElement('textarea', self::ELEMENT_MAP_METADATA_PROFILE_IDS, array('label' => 'Metadata Profile IDs map:', 'filters' => array('StringTrim')));
     $this->addElement('textarea', self::ELEMENT_MAP_STORAGE_PROFILE_IDS, array('label' => 'Storage Profile IDs map:', 'filters' => array('StringTrim')));
     $this->addElement('textarea', self::ELEMENT_MAP_FLAVOR_PARAMS_IDS, array('label' => 'Flavor Params IDs map:', 'filters' => array('StringTrim')));
     $this->addElement('textarea', self::ELEMENT_MAP_THUMB_PARAMS_IDS, array('label' => 'Thumb Params IDs map:', 'filters' => array('StringTrim')));
     $this->addElement('textarea', self::ELEMENT_MAP_CAPTION_PARAMS_IDS, array('label' => 'Caption Params IDs map:', 'filters' => array('StringTrim')));
     // add display groups
     $this->addDisplayGroup(array('target_service_url', 'target_account_id', 'target_login_id', 'target_login_password'), 'target_account', array('legend' => 'Target', 'decorators' => array('FormElements', 'Fieldset')));
     $this->addDisplayGroup(array('distribute_captions', 'distribute_cue_points', 'distribute_remote_flavor_asset_content', 'distribute_remote_thumb_asset_content', 'distribute_remote_caption_asset_content'), 'distribution_behaviour', array('legend' => 'Distribution Behaviour', 'decorators' => array('FormElements', 'Fieldset')));
     $this->addDisplayGroup(array('metadata_xslt', self::ELEMENT_METADATA_XPATHS_THAT_TRIGGER_UPDATE), 'metadata_modifications', array('legend' => 'Metadata Modifications', 'decorators' => array('FormElements', 'Fieldset')));
     $this->addDisplayGroup(array(self::ELEMENT_MAP_ACCESS_CONTROL_IDS, self::ELEMENT_MAP_CONVERSION_PROFILE_IDS, self::ELEMENT_MAP_METADATA_PROFILE_IDS, self::ELEMENT_MAP_STORAGE_PROFILE_IDS, self::ELEMENT_MAP_FLAVOR_PARAMS_IDS, self::ELEMENT_MAP_THUMB_PARAMS_IDS, self::ELEMENT_MAP_CAPTION_PARAMS_IDS), 'object_id_maps', array('legend' => 'Source/Target ID Mapping', 'decorators' => array('FormElements', 'Fieldset')));
 }
Пример #5
0
 public function init()
 {
     $roleDt = new Application_Model_DbTable_Role();
     $primaryKey = $roleDt->getPrimaryKey();
     $this->setMethod('post');
     $this->setEnctype('multipart/form-data');
     $this->setAttrib('idrol', $primaryKey);
     $this->setAction('/admin/role/edit');
     $objType2 = new Admin_Model_Acl();
     $objfea = new Admin_Model_AclRole();
     $e = new Zend_Form_Element_Hidden($primaryKey);
     $this->addElement($e);
     $e = new Zend_Form_Element_MultiCheckbox('idacl');
     $e->setMultiOptions($objType2->getGreatAll());
     if ($this->_idrol !== null) {
         $ma = $objfea->getRoleAcl($this->_idrol);
         $idsgreat = array();
         foreach ($ma as $resulta) {
             $idsgreat[] = $resulta['idacl'];
         }
         $e->setValue($idsgreat);
         $role = new Admin_Model_Role();
         $b = $role->getRoleId($this->_idrol);
     }
     $this->addElement($e);
     $e = new Zend_Form_Element_Text('name');
     $e->setAttrib('class', 'inpt-medium');
     $e->setAttrib('placeholder', 'Nombre');
     $this->addElement($e);
     $e = new Zend_Form_Element_Checkbox('state');
     $e->setValue(true);
     $this->addElement($e);
     foreach ($this->getElements() as $element) {
         $element->removeDecorator('Label');
         $element->removeDecorator('DtDdWrapper');
         $element->removeDecorator('HtmlTag');
     }
 }
Пример #6
0
 public function __construct($options = null, $data = null, $contentId = 0, $contentType = 'problem', $lang = 'en')
 {
     parent::__construct($options);
     $translate = Zend_Registry::get('Zend_Translate');
     $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
     $this->setDisableLoadDefaultDecorators(true);
     $this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => 'div'))->addDecorator('Form')->removeDecorator('DtDdWrapper');
     $this->setName('add_content_form');
     $this->setAction($baseUrl . '/' . $lang . '/content/edit/' . $contentId);
     $this->addElementPrefixPath('Oibs_Decorators', 'Oibs/Decorators/', 'decorator');
     $this->setAttrib('enctype', 'multipart/form-data');
     // Content header input form element
     $header = new Zend_Form_Element_Text('content_header');
     $header->setValue($data['content_header'])->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'content-add-field-empty'))), array('StringLength', true, array(1, 140, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'content-add-field-too-long')))))->setLabel($translate->_("content-add-header"))->setDecorators(array('FormElementDecorator'));
     // if ($data['published_cnt']) { // Disable editing of header if data is already published
     //	$header->setAttrib('readonly', true);
     // }
     // Content keywords input form element
     $keywords = new Zend_Form_Element_Text('content_keywords');
     $keywords->addFilter('StringtoLower')->setValue($data['content_keywords'])->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'content-add-field-empty'))), array('StringLength', true, array(1, 120, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'content-add-field-too-long'))), array('Regex', true, array('/^[\\p{L}0-9, ]*$/'))))->setLabel($translate->_("content-add-keywords"))->setDescription($translate->_("content-add-keywords-help-text"))->setDecorators(array('FormElementDecorator'));
     $content_type = new Zend_Form_Element_Hidden('content_type');
     $content_type->setValue($data['content_type'])->setDecorators(array('FormHiddenElementDecorator'));
     // Content lead text input form element
     $textlead = new Zend_Form_Element_Textarea('content_textlead');
     $textlead->setValue($data['content_textlead'])->setRequired(true)->setAttrib('class', 'textlead')->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'content-add-field-empty'))), array('StringLength', true, array(1, 320, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'content-add-field-too-long')))))->setLabel($translate->_("content-add-textlead"))->setDescription($translate->_("content-add-textlead-help-text"))->setDecorators(array('FormElementDecorator'));
     // Content text input form element
     $text = new Zend_Form_Element_Textarea('content_text');
     $text->setValue($data['content_text'])->setAttrib('class', 'textbody')->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'content-add-field-empty'))), array('StringLength', true, array(0, 4000, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooShort' => 'content-add-field-too-short', 'stringLengthTooLong' => 'content-add-field-too-long')))))->setLabel($translate->_("content-add-text"))->setDescription($translate->_('content-add-' . $contentType . '-textbody-help-text'))->setDecorators(array('FormOptionalElementDecorator'));
     // Content keywords input form element
     $related_companies = new Zend_Form_Element_Text('content_related_companies');
     $related_companies->setRequired(false)->addValidators(array(array('StringLength', true, array(0, 120, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'content-add-field-too-long')))))->setLabel($translate->_("content-add-related_companies"))->setDescription($translate->_("content-add-related_companies-help-text"))->setDecorators(array('FormOptionalElementDecorator'));
     // Problem research question input form element
     $research = new Zend_Form_Element_Text('content_research');
     $research->setValue($data['content_research'])->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'content-add-field-empty'))), array('StringLength', true, array(1, 120, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'field-too-long')))))->setLabel($translate->_("content-add-research"))->setDescription($translate->_("content-add-research-help-text"))->setDecorators(array('FormElementDecorator'));
     // Future info opportunity
     $opportunity = new Zend_Form_Element_Text('content_opportunity');
     $opportunity->setValue($data['content_opportunity'])->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'content-add-field-empty'))), array('StringLength', true, array(1, 120, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'field-too-long')))))->setLabel($translate->_("content-add-opportunity"))->setDescription($translate->_("content-add-opportunity-help-text"))->setDecorators(array('FormElementDecorator'));
     // Future info threat
     $threat = new Zend_Form_Element_Text('content_threat');
     $threat->setValue($data['content_threat'])->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'content-add-field-empty'))), array('StringLength', true, array(1, 120, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'field-too-long')))))->setLabel($translate->_("content-add-threat"))->setDescription($translate->_("content-add-threat-help-text"))->setDecorators(array('FormElementDecorator'));
     // Idea/solution in one sentence
     $solution = new Zend_Form_Element_Text('content_solution');
     $solution->setValue($data['content_solution'])->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'content-add-field-empty'))), array('StringLength', true, array(1, 120, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'field-too-long')))))->setLabel($translate->_("content-add-solution"))->setDecorators(array('FormElementDecorator'));
     // File upload
     $file = new Zend_Form_Element_File('content_file_upload');
     $file->setDestination('../www/upload')->removeDecorator('DtDdWrapper')->addValidator('Size', false, 2097152)->addValidator('Extension', false, 'png,gif,jpg,jpeg,doc,zip,xls,mpp,pdf,wmv,avi,mkv,mov,mpeg,mp4,divx,flv,ogg,3gp');
     $file->setLabel($translate->_("content-add-upload-file"))->setDescription($translate->_("content-add-file-upload-help-text"))->setDecorators(array('UploadDecorator'))->setAttrib("onchange", "multiFile(this, '" . $translate->_("content-add-file-delete-file-button") . "');");
     $uploadedFilesBoxes = new Zend_Form_Element_MultiCheckbox('uploadedFiles');
     $uploadedFilesBoxes->setMultiOptions($data['filenames'])->setRequired(false)->setDecorators(array('FormElementDecorator'))->setLabel($translate->_('content-add-file-delete-files-label'));
     // References
     $references = new Zend_Form_Element_Textarea('content_references');
     $references->setValue($data['content_references'])->setAttrib('class', 'textlead')->addValidators(array(array('StringLength', true, array(0, 2000, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'field-too-long')))))->setLabel($translate->_("content-add-references"))->setDescription($translate->_("content-add-references-help-text"))->setDecorators(array('FormOptionalElementDecorator'));
     // Language select form element
     $language = new Zend_Form_Element_Select('content_language');
     $language->addFilter('StringtoLower')->setLabel($translate->_("content-add-language"))->setDecorators(array('FormElementDecorator'))->setMultiOptions($data['languages']);
     // Future info classification
     $finfoClasses = new Zend_Form_Element_Select('content_finfo_class');
     $finfoClasses->setLabel($translate->_("content-add-finfo-classification"))->setDecorators(array('FormElementDecorator'))->setMultiOptions($data['FutureinfoClasses']);
     /*
     		// Industry select form element
     		$industry = new Zend_Form_Element_Select('content_industry');
     		$industry->addFilter('StringtoLower')
             ->setValue($data['industryIds'][0])
             ->setLabel($translate->_("content-view-industry-classification"))
     				->setDecorators(array('FormElementDecorator'))
     				->setAttrib('onchange', "getItems('".$baseUrl."/".$lang."/content/division/industry/'+this.value, 
                         'content_division_div', this.value);")
     				->setMultiOptions($data['Industries']);	
     
     		$division = new Zend_Form_Element_Select('content_division');
     		$division->addFilter('StringtoLower')
             ->setValue($data['industryIds'][1])
     				->setDecorators(array('FormElementDecorator'))
             ->setAttrib('onchange', "getItems('".$baseUrl."/".$lang."/content/group/division/'+this.value, 
                         'content_group_div', this.value);")
     				->setMultiOptions($data['Divisions'])
             ->setRegisterInArrayValidator(false);
     		
     		$group = new Zend_Form_Element_Select('content_group');
     		$group->addFilter('StringtoLower')
             ->setValue($data['industryIds'][2])
     				->setDecorators(array('FormElementDecorator'))
             ->setAttrib('onchange', "getItems('".$baseUrl."/".$lang."/content/class/group/'+this.value, 
                         'content_class_div', this.value);")
     				->setMultiOptions($data['Groups'])
             ->setRegisterInArrayValidator(false);
     				
     		$class = new Zend_Form_Element_Select('content_class');
     		$class->addFilter('StringtoLower')
             ->setValue($data['industryIds'][3])
     				->setDecorators(array('FormElementDecorator'))
     				->setMultiOptions($data['Classes'])
             ->setRegisterInArrayValidator(false);
     */
     $innovation = new Zend_Form_Element_Select('innovation_type');
     $innovation->setLabel($translate->_("content-view-innovationtype-classification"))->setDecorators(array('FormElementDecorator'))->setMultiOptions($data['InnovationTypes']);
     // Used for track button clicks
     $hidden_content_publish = new Zend_Form_Element_Hidden('content_publish');
     $hidden_content_publish->setDecorators(array('FormHiddenElementDecorator'));
     $hidden_content_save = new Zend_Form_Element_Hidden('content_save');
     $hidden_content_save->setDecorators(array('FormHiddenElementDecorator'));
     // Form buttons
     $publish = new Zend_Form_Element_Button('content_publish_button');
     $publish->setLabel($translate->_("content-add-publish"))->setAttrib('class', 'content_manage_button')->removeDecorator('DtDdWrapper');
     $save = new Zend_Form_Element_Button('content_save_button');
     $save->setLabel($translate->_("content-add-save"))->setAttrib('class', 'content_manage_button')->removeDecorator('DtDdWrapper');
     $preview = new Zend_Form_Element_Button('content_preview_button');
     $preview->setLabel($translate->_("content-add-preview"))->setAttrib('class', 'content_manage_button')->removeDecorator('DtDdWrapper');
     // Add elements to form
     $elements = array($header, $keywords, $content_type, $textlead, $text, $related_companies);
     if ($contentType == "problem") {
         array_push($elements, $research);
     } else {
         if ($contentType == "finfo") {
             array_push($elements, $opportunity, $threat);
         } else {
             if ($contentType == "idea") {
                 array_push($elements, $solution);
             }
         }
     }
     array_push($elements, $file);
     if (count($data['filenames'])) {
         array_push($elements, $uploadedFilesBoxes);
     }
     array_push($elements, $references, $language, $hidden_content_save, $hidden_content_publish);
     /*
     if($contentType == "finfo") {
         array_push($elements, $finfoClasses);
     }
     
     array_push($elements, $industry, $division, $group, $class);
     
     if($contentType == "idea") {
         array_push($elements, $innovation);
     }
     */
     // If data is published dont draw the publish button
     if ($data['published_cnt'] == false) {
         array_push($elements, $publish, $save, $preview);
     } else {
         $save->setLabel("Publish changes");
         array_push($elements, $save, $preview);
     }
     // Set custom form layout
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/contentAddForm.phtml', 'placement' => false))));
     $this->addElements($elements);
     /*$this->addElements(array($innovation, $industry, 
       $division, $group,
       $class, $header,
       $keywords, $content_type,
       $content_relatesto_id, $textlead,
       $text, $submit,
       $preview, $publish));*/
 }
Пример #7
0
 /**
  * @group ZF-9689
  */
 public function testRenderWithListSeparatorForMulticheckbox()
 {
     require_once 'Zend/Form/Element/MultiCheckbox.php';
     $element = new Zend_Form_Element_MultiCheckbox('foo');
     $options = array('foo' => 'Foo', 'bar' => 'Bar');
     $element->setMultiOptions($options);
     $element->setSeparator('</p><p>');
     $element->setDecorators(array(array('ViewHelper', array('separator' => '')), array('HtmlTag', array('tag' => 'p'))));
     $expected = '<p><label><input type="checkbox" name="foo[]" id="foo-foo" value="foo">Foo</label></p>' . '<p><label><input type="checkbox" name="foo[]" id="foo-bar" value="bar">Bar</label></p>';
     $actual = $element->render($this->getView());
     $this->assertEquals($expected, $actual);
 }
Пример #8
0
 protected function buildAutoForm()
 {
     //
     global $gANNOTATION_KEYS;
     extract($gANNOTATION_KEYS);
     if ($this->recurseSubEntities) {
         $this->addSaveButton('upper_submit');
     }
     foreach ($this->entityColumns as $propertyName => $def) {
         if (!isset($def['annotations'][$annoKeyAwe])) {
             continue;
         }
         $elementType = false;
         $element = false;
         // annotation keys
         $anno = $def['annotations'];
         // determine element type
         if (isset($anno[$annoKeyId])) {
             $elementType = 'hidden_primary_key';
         } else {
             if (isset($anno[$annoKeyM21])) {
                 $elementType = $this->recurseSubEntities ? 'foreign_dropdown' : 'hidden_foreign_key';
             } else {
                 if (isset($anno[$annoKey12m]) && $this->recurseSubEntities && $anno[$annoKeyAwe]->editInline && $this->repopData && !$this->isRestful) {
                     $elementType = 'foreign_editInline';
                 } else {
                     if (isset($anno[$annoKeyM2m])) {
                         $elementType = 'foreign_multi_checkbox';
                     } else {
                         if (isset($anno[$annoKeyCol])) {
                             $elementType = 'entity';
                         }
                     }
                 }
             }
         }
         // Render that type of element
         switch ($elementType) {
             case 'hidden_primary_key':
                 //
                 $element = new Zend_Form_Element_Hidden('id');
                 $element->setDecorators(array('ViewHelper'));
                 if ($this->repopData) {
                     $element->setValue($this->repopData->id);
                 }
                 break;
             case 'hidden_foreign_key':
                 //
                 $elementName = isset($anno[$annoKeyJoinColumn]->name) ? $anno[$annoKeyJoinColumn]->name : $propertyName . '_id';
                 $element = new Zend_Form_Element_Hidden($elementName);
                 $element->setDecorators(array('ViewHelper'));
                 $element->setValue($this->repopData->{$propertyName}->id);
                 break;
             case 'entity':
                 //
                 // setup properties
                 // use a label param if set,
                 // otherwise use the @Column annotation's name property
                 // replace underscores with spaces and capitalize each word
                 // otherwise default to the property name of the object
                 $label = $anno[$annoKeyAwe]->label ? $anno[$annoKeyAwe]->label : ucwords(str_replace('_', ' ', preg_replace('[^a-zA-Z0-9_]', '', isset($anno[$annoKeyCol]) && $anno[$annoKeyCol]->name ? $anno[$annoKeyCol]->name : $propertyName)));
                 $type = $anno[$annoKeyAwe]->type ? $anno[$annoKeyAwe]->type : $this->getDefaultElementType($anno[$annoKeyCol]->type);
                 $colType = $anno[$annoKeyCol]->type;
                 $params = isset($anno[$annoKeyAwe]->params) ? $anno[$annoKeyAwe]->params : array();
                 $validators = count((array) $anno[$annoKeyAwe]->validators) ? (array) $anno[$annoKeyAwe]->validators : $this->getDefaultElementValidators($anno[$annoKeyCol]);
                 // build element
                 $element = new $type($propertyName, $params);
                 $element->setLabel($label);
                 $validatorList = array();
                 foreach ($validators as $v => $args) {
                     $validatorList[] = new $v((array) $args);
                 }
                 $element->setValidators($validatorList);
                 // repopulate data
                 if ($this->repopData) {
                     if ($colType == 'datetime' || $colType == 'date') {
                         $value = $this->repopData->{$propertyName}->format('Y-m-d');
                     } else {
                         $value = $this->repopData->{$propertyName};
                     }
                     $element->setValue($value);
                 }
                 break;
             case 'foreign_dropdown':
                 //
                 // setup properties
                 $label = $anno[$annoKeyAwe]->label ? $anno[$annoKeyAwe]->label : ucwords(str_replace('_', ' ', preg_replace('[^a-zA-Z0-9_]', '', isset($anno[$annoKeyCol]) && $anno[$annoKeyCol]->name ? $anno[$annoKeyCol]->name : $propertyName)));
                 $targetEntity = $anno[$annoKeyM21]->targetEntity;
                 $displayColumn = $anno[$annoKeyAwe]->displayColumn;
                 $join_column = $anno[$annoKeyJoinColumn]->name;
                 // get related entities
                 $dql = "select e from {$targetEntity} e";
                 $foreignEntities = $this->_doctrine->createQuery($dql)->getResult();
                 $dropdowns = array();
                 $dropdowns[''] = '';
                 foreach ($foreignEntities as $id => $f) {
                     $dropdowns[$f->id] = $f->{$displayColumn};
                 }
                 // build element
                 $element = new Zend_Form_Element_Select($join_column);
                 $element->setMultiOptions($dropdowns);
                 $element->setLabel($label);
                 // repopulate data
                 if ($this->repopData && $this->repopData->{$propertyName}) {
                     $element->setValue($this->repopData->{$propertyName}->id);
                 }
                 break;
             case 'foreign_multi_checkbox':
                 //
                 // setup properties
                 $label = $anno[$annoKeyAwe]->label ? $anno[$annoKeyAwe]->label : ucwords(str_replace('_', ' ', preg_replace('[^a-zA-Z0-9_]', '', isset($anno[$annoKeyCol]) && $anno[$annoKeyCol]->name ? $anno[$annoKeyCol]->name : $propertyName)));
                 $targetEntity = $anno[$annoKeyM2m]->targetEntity;
                 $displayColumn = $anno[$annoKeyAwe]->displayColumn;
                 $inverseColumn = $anno[$annoKeyJoinTable]->inverseJoinColumns[0]->name;
                 $targetId = str_replace('\\', '_', $targetEntity);
                 $attribute = str_replace('_id', '', "{$inverseColumn}s");
                 // get related entities
                 $dql = "select e from {$targetEntity} e";
                 $foreignEntities = $this->_doctrine->createQuery($dql)->getResult();
                 $foreignColumns = $this->getEntityColumnDefs($targetEntity);
                 $options = array();
                 if (count($foreignEntities)) {
                     foreach ($foreignEntities as $fe) {
                         $options[$fe->id] = $fe->{$displayColumn};
                     }
                 }
                 // build element
                 $element = new Zend_Form_Element_MultiCheckbox("{$inverseColumn}s");
                 $element->setMultiOptions($options);
                 $element->setLabel($label);
                 // repopulate data
                 $values = array();
                 foreach ($this->repopData->{$attribute} as $subEntity) {
                     $values[] = $subEntity->id;
                 }
                 $element->setValue($values);
                 break;
             case 'foreign_editInline':
                 //
                 // setup properties
                 $label = $anno[$annoKeyAwe]->label ? $anno[$annoKeyAwe]->label : ucwords(str_replace('_', ' ', preg_replace('[^a-zA-Z0-9_]', '', isset($anno[$annoKeyCol]) && $anno[$annoKeyCol]->name ? $anno[$annoKeyCol]->name : $propertyName)));
                 $targetEntity = $anno[$annoKey12m]->targetEntity;
                 $editInline = $anno[$annoKeyAwe]->editInline;
                 $targetId = str_replace('\\', '_', $targetEntity);
                 $subformName = "{$targetId}_subform";
                 // get sub entities
                 $sub_entities = $this->repopData->{$propertyName};
                 $subEntityColumns = $this->getEntityColumnDefs($targetEntity);
                 // build sub forms
                 $subform = new Zend_Form_SubForm();
                 $subform->setLegend($label);
                 $recurse = false;
                 $parent = $this->repopData;
                 $x = 0;
                 foreach ($sub_entities as $subEntity) {
                     $autoCrudForm = new Awe_Form_AutoMagic($subformName, $subEntityColumns, $subEntity, $recurse, $parent);
                     $subform->addSubform($autoCrudForm, $x++);
                 }
                 $this->addSubform($subform, $targetId);
                 break;
         }
         if ($element) {
             $this->getAutoSubform('entity')->addElement($element);
         }
     }
     if ($this->recurseSubEntities) {
         $this->addSaveButton('lower_submit');
     }
 }
Пример #9
0
 public function __construct($parent = null, $options = null)
 {
     parent::__construct($options);
     $parentId = 0;
     if ($parent != null) {
         $parentId = $parent;
     }
     $translate = Zend_Registry::get('Zend_Translate');
     $this->setName('add_group_form');
     $this->addElementPrefixPath('Oibs_Form_Decorator', 'Oibs/Form/Decorator/', 'decorator');
     $clear = '<div class="clear"></div>';
     // Group name (must be unique).
     $groupname = new Zend_Form_Element_Text('groupname');
     $groupname->setLabel('Name')->setRequired(true)->setFilters(array('StringTrim'))->setValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty'))), array('StringLength', false, array(1, 140, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'Name too long.'))), array(new Oibs_Validators_GroupExists($options), false)))->setDescription('<div id="progressbar_groupname" class="limit ok"></div>')->setDecorators(array('FieldDecorator'));
     $groupname_clear = new Oibs_Form_Element_Note('groupname_clear');
     $groupname_clear->setValue($clear)->setDecorators(array('ViewHelper'));
     // Group type
     $groupTypes_model = new Default_Model_GroupTypes();
     $groupTypes = $groupTypes_model->getAllTypes();
     $grouptype = new Zend_Form_Element_Select('grouptype');
     $grouptype->setLabel('Type')->setAttrib('id', 'grouptype');
     foreach ($groupTypes as $type) {
         $grouptype->addMultiOption($type['id_gtp'], $type['name_gtp']);
     }
     $grouptype->setDecorators(array('FieldDecorator'));
     $grouptype_clear = new Oibs_Form_Element_Note('grouptype_clear');
     $grouptype_clear->setValue($clear)->setDecorators(array('ViewHelper'));
     // Lead paragraph (description)
     $groupdesc = new Zend_Form_Element_Textarea('groupdesc');
     $groupdesc->setAttrib('cols', '45')->setAttrib('rows', '6')->setLabel('Lead paragraph')->setRequired(true)->setValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => "Description can't be empty."))), array('StringLength', false, array(1, 320, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'Description too long.')))))->setDescription('<div id="progressbar_groupdesc" class="limit ok"></div>')->setDecorators(array('FieldDecorator'));
     $groupdesc_clear = new Oibs_Form_Element_Note('groupdesc_clear');
     $groupdesc_clear->setValue($clear)->setDecorators(array('ViewHelper'));
     // Body text.
     $groupbody = new Zend_Form_Element_Textarea('groupbody');
     $groupbody->setAttrib('cols', '45')->setAttrib('rows', '20')->setLabel('Body')->setValidators(array(array('StringLength', false, array(1, 4000, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'Body text too long.')))))->setDecorators(array('FieldDecorator'));
     $groupbody_clear = new Oibs_Form_Element_Note('groupbody_clear');
     $groupbody_clear->setValue($clear)->setDecorators(array('ViewHelper'));
     $weblinks_websites = new Oibs_Form_Element_Note('weblinks_websites');
     $weblinks_websites->setValue('<div class="input-column-website1"><label><strong>Links to websites:</strong></label></div>');
     $weblinks_name = new Oibs_Form_Element_Note('weblinks_name');
     $weblinks_name->setValue('<div class="input-column-website2">Name</div>');
     $weblinks_url = new Oibs_Form_Element_Note('weblinks_url');
     $weblinks_url->setValue('<div class="input-column-website3">Url</div><div class="clear"></div>');
     $nameTooLongText = 'Name too long (max 45)';
     $urlTooLongText = 'URL too long (max 150)';
     $weblinks_name_site1 = new Zend_Form_Element_Text('weblinks_name_site1');
     $weblinks_name_site1->setLabel('Web site 1')->setAttrib('id', 'website1-name')->addValidators(array(array('StringLength', false, array(0, 45, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site1 = new Zend_Form_Element_Text('weblinks_url_site1');
     $weblinks_url_site1->setAttrib('id', 'website1-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_name_site2 = new Zend_Form_Element_Text('weblinks_name_site2');
     $weblinks_name_site2->setLabel('Web site 2')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site2 = new Zend_Form_Element_Text('weblinks_url_site2');
     $weblinks_url_site2->setAttrib('id', 'website2-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_name_site3 = new Zend_Form_Element_Text('weblinks_name_site3');
     $weblinks_name_site3->setLabel('Web site 3')->setAttrib('id', 'website3-name')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site3 = new Zend_Form_Element_Text('weblinks_url_site3');
     $weblinks_url_site3->setAttrib('id', 'website3-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_name_site4 = new Zend_Form_Element_Text('weblinks_name_site4');
     $weblinks_name_site4->setLabel('Web site 4')->setAttrib('id', 'website4-name')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site4 = new Zend_Form_Element_Text('weblinks_url_site4');
     $weblinks_url_site4->setAttrib('id', 'website4-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_name_site5 = new Zend_Form_Element_Text('weblinks_name_site5');
     $weblinks_name_site5->setLabel('Web site 5')->setAttrib('id', 'website5-name')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site5 = new Zend_Form_Element_Text('weblinks_url_site5');
     $weblinks_url_site5->setAttrib('id', 'website5-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_websites->setDecorators(array('ViewHelper'));
     $weblinks_name->setDecorators(array('ViewHelper'));
     $weblinks_url->setDecorators(array('ViewHelper'));
     $weblinks_name_site1->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site1->setDecorators(array('InputWebsiteUrlDecorator'));
     $weblinks_name_site2->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site2->setDecorators(array('InputWebsiteUrlDecorator'));
     $weblinks_name_site3->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site3->setDecorators(array('InputWebsiteUrlDecorator'));
     $weblinks_name_site4->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site4->setDecorators(array('InputWebsiteUrlDecorator'));
     $weblinks_name_site5->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site5->setDecorators(array('InputWebsiteUrlDecorator'));
     // File upload
     $file = new Zend_Form_Element_File('content_file_upload');
     $file->setDestination('../www/upload')->removeDecorator('DtDdWrapper')->addValidator('Size', false, 2097152)->addValidator('Extension', false, 'png,gif,jpg,jpeg,doc,zip,xls,mpp,pdf,wmv,avi,mkv,mov,mpeg,mp4,divx,flv,ogg,3gp');
     $file->setLabel($translate->_("content-add-upload-file"))->setDescription($translate->_("content-add-file-upload-help-text"))->setDecorators(array('UploadDecorator'))->setAttrib("onchange", "multiFile(this, '" . $translate->_("content-add-file-delete-file-button") . "');");
     $uploadedFilesBoxes = array();
     if ($options['mode'] == 'edit' && !empty($options['fileNames'])) {
         $uploadedFilesBoxes = new Zend_Form_Element_MultiCheckbox('uploadedFiles');
         $uploadedFilesBoxes->setMultiOptions($options['fileNames'])->setRequired(false)->setDecorators(array('FormElementDecorator'))->setLabel($translate->_('content-add-file-delete-files-label'));
     }
     $save = new Zend_Form_Element_Submit('save');
     if (is_array($options) && $options['mode'] == 'edit') {
         $save->setLabel('Save');
     } else {
         $save->setLabel('Create');
     }
     $save->setAttrib('id', 'publish')->setAttrib('class', 'submit-button')->setAttrib('style', 'float: none;');
     $this->addElements(array($groupname, $groupname_clear, $grouptype, $grouptype_clear, $groupdesc, $groupdesc_clear, $groupbody, $groupbody_clear, $weblinks_websites, $weblinks_name, $weblinks_url, $weblinks_name_site1, $weblinks_url_site1, $weblinks_name_site2, $weblinks_url_site2, $weblinks_name_site3, $weblinks_url_site3, $weblinks_name_site4, $weblinks_url_site4, $weblinks_name_site5, $weblinks_url_site5, $file, $uploadedFilesBoxes, $save));
     $save->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'openOnly' => true, 'id' => 'submit', 'style' => 'clear: both;'))));
 }
Пример #10
0
 public function productDetailReport($data = null)
 {
     $db = new Application_Model_DbTable_DbGlobal();
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $tr = Application_Form_FrmLanguages::getCurrentlanguage();
     $location = $data["LocationId"];
     $brand = $data["branch_id"];
     $category = $data["category_id"];
     //     	$item = new report_Model_DbQuery();
     //     	$rs = $item->getItem($data);
     //     	$a= count($rs);
     //print_r($rs);exit();
     $rs = $db->getGlobalDb('SELECT pro_id, item_name,item_code FROM tb_product WHERE item_name!="" ORDER BY item_name ');
     $options = array('' => $tr->translate('Select_Products'));
     foreach ($rs as $read) {
         $options[$read['pro_id']] = $read['item_code'] . " " . $read['item_name'];
     }
     $pro_id = new Zend_Form_Element_Select('item');
     $pro_id->setMultiOptions($options);
     $proValue = $request->getParam('item');
     $pro_id->setAttribs(array('id' => 'item'));
     $pro_id->setValue($proValue);
     $this->addElement($pro_id);
     $reportTypeElement = new Zend_Form_Element_Select("report_type");
     $opt = array("" => $tr->translate('REPORT_TYPE'), 1 => "All Report", 2 => "Purchase Report", 3 => "Sales Report", 4 => "Transfer Report", 5 => "Poduct Information Report", 6 => "Customize Report");
     $reportTypeElement->setMultiOptions($opt);
     $reportTypeElement->setAttribs(array('onChange' => 'report()'));
     $reportTypeValue = $request->getParam('report_type');
     $reportTypeElement->setValue($reportTypeValue);
     $this->addElement($reportTypeElement);
     $check = new Zend_Form_Element_MultiCheckbox("report_num");
     $check->setAttribs(array("class" => "validate[required]"));
     $opt_check = array(1 => 'Purchase Report', 2 => 'Sales Report', 3 => 'Transfer Report', 4 => 'Poduct Information Report');
     $check->setMultiOptions($opt_check);
     $check_value = $request->getParam("report_num");
     $check->setValue($check_value);
     $this->addElement($check);
     $sql = 'SELECT DISTINCT Name,LocationId FROM tb_sublocation WHERE Name!="" AND status=1 ';
     $user = $this->GetuserInfo();
     if ($user["level"] != 1 and $user["level"] != 2) {
         $sql .= " AND LocationId= " . $user["location_id"];
     }
     $rs = $db->getGlobalDb($sql);
     $options = array('' => $tr->translate('Please_Select_Location'));
     $locationValue = $request->getParam('LocationId');
     foreach ($rs as $read) {
         $options[$read['LocationId']] = $read['Name'];
     }
     $location_id = new Zend_Form_Element_Select('LocationId');
     $location_id->setMultiOptions($options);
     $location_id->setAttribs(array('id' => 'LocationId', 'onchange' => 'getProductByLocation();'));
     $location_id->setValue($locationValue);
     $rs = $db->getGlobalDb('SELECT CategoryId, Name FROM tb_category WHERE Name!="" ORDER BY CategoryId');
     $options = array('' => $tr->translate('Please_Select'));
     $cateValue = $request->getParam('category_id');
     foreach ($rs as $read) {
         $options[$read['CategoryId']] = $read['Name'];
     }
     $cate_element = new Zend_Form_Element_Select('category_id');
     $cate_element->setMultiOptions($options);
     $cate_element->setAttribs(array('id' => 'category_id', 'onchange' => 'this.form.submit()'));
     $cate_element->setValue($cateValue);
     $this->addElement($cate_element);
     $rs = $db->getGlobalDb('SELECT branch_id, Name FROM tb_branch WHERE Name!="" ORDER BY branch_id ');
     $options = array('' => $tr->translate('Please_Select'));
     $branchValue = $request->getParam('branch_id');
     foreach ($rs as $read) {
         $options[$read['branch_id']] = $read['Name'];
     }
     $branch_element = new Zend_Form_Element_Select('branch_id');
     $branch_element->setMultiOptions($options);
     $branch_element->setAttribs(array('id' => 'branch_id', 'onchange' => 'getProductByBrand()'));
     $branch_element->setValue($branchValue);
     $this->addElement($branch_element);
     $date = new Zend_Date();
     $startDate = new Zend_Form_Element_Text("start_date");
     $startDatevalue = $request->getParam("start_date");
     //$startDate->setAttribs(array("class"=>"validate[required]"));
     $startDate->setValue($startDatevalue);
     $endDate = new Zend_Form_Element_Text("end_date");
     //$endDate->setValue($date->get("DD-MM-YY"));
     $endDatevalue = $request->getParam("end_date");
     //$endDate->setAttribs(array("class"=>"validate[required]"));
     $endDate->setValue($endDatevalue);
     $this->addElements(array($startDate, $endDate, $location_id));
     Application_Form_DateTimePicker::addDateField(array('start_date', 'end_date'));
     return $this;
 }
Пример #11
0
 public function __construct($parent = null, $options = null)
 {
     parent::__construct($options);
     $parentId = 0;
     if ($parent != null) {
         $parentId = $parent;
     }
     $translate = Zend_Registry::get('Zend_Translate');
     $this->setName('Create a campaign');
     $this->addElementPrefixPath('Oibs_Form_Decorator', 'Oibs/Form/Decorator/', 'decorator');
     // Clear div
     $clear = '<div class="clear"></div>';
     // Campaign name
     $campaignname = new Zend_Form_Element_Text('campaign_name');
     $campaignname->setLabel('Name')->setRequired(true)->setFilters(array('StringTrim'))->setValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty'))), array('StringLength', false, array(1, 140, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'Name too long.')))))->setDescription('<div id="progressbar_campaign_name" class="limit ok"></div>')->setDecorators(array('FieldDecorator'));
     $campaignname_clear = new Oibs_Form_Element_Note('campaignname_clear');
     $campaignname_clear->setValue($clear)->setDecorators(array('ViewHelper'));
     // Ingress
     $campaigningress = new Zend_Form_Element_Textarea('campaign_ingress');
     $campaigningress->setAttrib('cols', '45')->setAttrib('rows', '6')->setLabel('Lead paragraph')->setRequired(true)->setValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => "Lead paragraph can't be empty."))), array('StringLength', false, array(1, 320, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'Lead paragraph too long.')))))->setDescription('<div id="progressbar_campaign_ingress" class="limit ok"></div>')->setDecorators(array('FieldDecorator'));
     $campaigningress_clear = new Oibs_Form_Element_Note('campaigningress_clear');
     $campaigningress_clear->setValue($clear)->setDecorators(array('ViewHelper'));
     // Body text
     $campaigndesc = new Zend_Form_Element_Textarea('campaign_desc');
     $campaigndesc->setAttrib('cols', '45')->setAttrib('rows', '20')->setLabel('Body text')->setValidators(array(array('StringLength', false, array(1, 4000, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => 'Body text too long.')))))->setDecorators(array('FieldDecorator'));
     $campaigndesc_clear = new Oibs_Form_Element_Note('campaigndesc_clear');
     $campaigndesc_clear->setValue($clear)->setDecorators(array('ViewHelper'));
     // Start date
     $campaignstart = new Zend_Form_Element_Text('campaign_start');
     $campaignstart->setAttrib('id', 'campaign_start')->setAttrib('name', 'campaign_start')->setLabel('Start date (empty means current date)')->setAttrib('invalidMessage', 'Invalid date specified')->setAttrib('formalLength', 'long')->setValidators(array(new Zend_Validate_Date('yyyy-MM-dd'), new Oibs_Validators_StartdateValidator('campaign_start')))->setDecorators(array('FieldDecorator'));
     $campaignstart_clear = new Oibs_Form_Element_Note('campaignstart_clear');
     $campaignstart_clear->setValue($clear)->setDecorators(array('ViewHelper'));
     //$validator = new Zend_Validate_Date('yyyy-MM-dd');
     // End date
     $campaignend = new Zend_Form_Element_Text('campaign_end');
     $campaignend->setAttrib('id', 'campaign_end')->setLabel('End date (empty means permanent campaign)')->setAttrib('invalidMessage', 'Invalid date specified')->setAttrib('formalLength', 'long')->setValidators(array(new Zend_Validate_Date('yyyy-MM-dd'), new Oibs_Validators_EnddateValidator('campaign_start')))->setDecorators(array('FieldDecorator'));
     $campaignend_clear = new Oibs_Form_Element_Note('campaignend_clear');
     $campaignend_clear->setValue($clear)->setDecorators(array('ViewHelper'));
     $weblinks_websites = new Oibs_Form_Element_Note('weblinks_websites');
     $weblinks_websites->setValue('<div class="input-column-website1"><label><strong>Links to websites:</strong></label></div>');
     $weblinks_name = new Oibs_Form_Element_Note('weblinks_name');
     $weblinks_name->setValue('<div class="input-column-website2">Name</div>');
     $weblinks_url = new Oibs_Form_Element_Note('weblinks_url');
     $weblinks_url->setValue('<div class="input-column-website3">Url</div><div class="clear"></div>');
     $nameTooLongText = 'Name too long (max 45)';
     $urlTooLongText = 'URL too long (max 150)';
     $weblinks_name_site1 = new Zend_Form_Element_Text('weblinks_name_site1');
     $weblinks_name_site1->setLabel('Web site 1')->setAttrib('id', 'website1-name')->addValidators(array(array('StringLength', false, array(0, 45, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site1 = new Zend_Form_Element_Text('weblinks_url_site1');
     $weblinks_url_site1->setAttrib('id', 'website1-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_name_site2 = new Zend_Form_Element_Text('weblinks_name_site2');
     $weblinks_name_site2->setLabel('Web site 2')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site2 = new Zend_Form_Element_Text('weblinks_url_site2');
     $weblinks_url_site2->setAttrib('id', 'website2-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_name_site3 = new Zend_Form_Element_Text('weblinks_name_site3');
     $weblinks_name_site3->setLabel('Web site 3')->setAttrib('id', 'website3-name')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site3 = new Zend_Form_Element_Text('weblinks_url_site3');
     $weblinks_url_site3->setAttrib('id', 'website3-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_name_site4 = new Zend_Form_Element_Text('weblinks_name_site4');
     $weblinks_name_site4->setLabel('Web site 4')->setAttrib('id', 'website4-name')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site4 = new Zend_Form_Element_Text('weblinks_url_site4');
     $weblinks_url_site4->setAttrib('id', 'website4-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_name_site5 = new Zend_Form_Element_Text('weblinks_name_site5');
     $weblinks_name_site5->setLabel('Web site 5')->setAttrib('id', 'website5-name')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site5 = new Zend_Form_Element_Text('weblinks_url_site5');
     $weblinks_url_site5->setAttrib('id', 'website5-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'encoding' => 'UTF-8', 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_websites->setDecorators(array('ViewHelper'));
     $weblinks_name->setDecorators(array('ViewHelper'));
     $weblinks_url->setDecorators(array('ViewHelper'));
     $weblinks_name_site1->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site1->setDecorators(array('InputWebsiteUrlDecorator'));
     $weblinks_name_site2->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site2->setDecorators(array('InputWebsiteUrlDecorator'));
     $weblinks_name_site3->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site3->setDecorators(array('InputWebsiteUrlDecorator'));
     $weblinks_name_site4->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site4->setDecorators(array('InputWebsiteUrlDecorator'));
     $weblinks_name_site5->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site5->setDecorators(array('InputWebsiteUrlDecorator'));
     // File upload
     $file = new Zend_Form_Element_File('content_file_upload');
     $file->setDestination('../www/upload')->removeDecorator('DtDdWrapper')->addValidator('Size', false, 2097152)->addValidator('Extension', false, 'png,gif,jpg,jpeg,doc,zip,xls,mpp,pdf,wmv,avi,mkv,mov,mpeg,mp4,divx,flv,ogg,3gp');
     $file->setLabel($translate->_("content-add-upload-file"))->setDescription($translate->_("content-add-file-upload-help-text"))->setDecorators(array('UploadDecorator'))->setAttrib("onchange", "multiFile(this, '" . $translate->_("content-add-file-delete-file-button") . "');");
     $uploadedFilesBoxes = array();
     if ($options['mode'] == 'edit' && !empty($options['fileNames'])) {
         $uploadedFilesBoxes = new Zend_Form_Element_MultiCheckbox('uploadedFiles');
         $uploadedFilesBoxes->setMultiOptions($options['fileNames'])->setRequired(false)->setDecorators(array('FormElementDecorator'))->setLabel($translate->_('content-add-file-delete-files-label'));
     }
     $save = new Zend_Form_Element_Submit('save');
     $save->setAttrib('id', 'publish')->setAttrib('class', 'submit-button')->setAttrib('style', 'float: none;');
     if ($options['mode'] == 'edit') {
         $save->setLabel('Save');
     } else {
         $save->setLabel('Create');
     }
     // Group admin can edit campaign start day only before campaign has started
     $date = new Zend_Date(date("Y-m-d", time()), Zend_Date::ISO_8601);
     $startdate = new Zend_Date($options['startdate'], Zend_Date::ISO_8601);
     if ($date->compare($startdate) == -1) {
         $this->addElements(array($campaignname, $campaignname_clear, $campaigningress, $campaigningress_clear, $campaigndesc, $campaigndesc_clear, $campaignstart, $campaignstart_clear, $campaignend, $campaignend_clear, $weblinks_websites, $weblinks_name, $weblinks_url, $weblinks_name_site1, $weblinks_url_site1, $weblinks_name_site2, $weblinks_url_site2, $weblinks_name_site3, $weblinks_url_site3, $weblinks_name_site4, $weblinks_url_site4, $weblinks_name_site5, $weblinks_url_site5, $file, $uploadedFilesBoxes, $save));
     } else {
         $this->addElements(array($campaignname, $campaignname_clear, $campaigningress, $campaigningress_clear, $campaigndesc, $campaigndesc_clear, $weblinks_websites, $weblinks_name, $weblinks_url, $weblinks_name_site1, $weblinks_url_site1, $weblinks_name_site2, $weblinks_url_site2, $weblinks_name_site3, $weblinks_url_site3, $weblinks_name_site4, $weblinks_url_site4, $weblinks_name_site5, $weblinks_url_site5, $file, $uploadedFilesBoxes, $save));
     }
     $save->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'id' => 'submit', 'style' => 'clear: both;'))));
 }