Ejemplo n.º 1
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;
		}
Ejemplo n.º 2
0
 /**
  * IS: 
  * FS: 
  * Desc: Mengatur tampilan form di halaman news
  */
 public function init()
 {
     $this->submit = new Zend_Form_Element_Submit('action');
     $this->draft = new Zend_Form_Element_Submit('action');
     $this->image = new Zend_Form_Element_File('image');
     $this->submit->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label')->setAttrib('class', 'btn btn-success');
     $this->draft->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label')->setLabel('Draft')->setAttrib('class', 'btn');
     $this->image->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label')->setLabel('Draft');
     $this->newsTitle = $this->createElement('text', 'newsTitle');
     $this->newsTitle->removeDecorator('HtmlTag');
     $this->newsTitle->removeDecorator('DtDdWrapper');
     $this->newsTitle->removeDecorator('Label');
     $this->newsTitle->setAttrib('class', 'span8');
     $this->newsContent = $this->createElement('textarea', 'newsContent');
     $this->newsContent->removeDecorator('HtmlTag');
     $this->newsContent->removeDecorator('DtDdWrapper');
     $this->newsContent->removeDecorator('Label');
     $this->newsContent->setAttribs(array('cols' => 5, 'rows' => 5));
     $this->PoiCounter = $this->createElement('hidden', 'PoiCounter');
     $this->PoiCounter->removeDecorator('HtmlTag');
     $this->PoiCounter->removeDecorator('DtDdWrapper');
     $this->PoiCounter->removeDecorator('Label');
     $this->PoiCounter->setValue(0);
     //        Related destination
     $this->newsPoi = $this->createElement('text', 'newsPoi');
     $this->newsPoi->removeDecorator('HtmlTag');
     $this->newsPoi->removeDecorator('DtDdWrapper');
     $this->newsPoi->removeDecorator('Label');
     $this->newsPoi->setAttrib('class', 'span4');
     $this->newsImage = $this->createElement('text', 'newsImage');
     $this->newsImage->removeDecorator('HtmlTag');
     $this->newsImage->removeDecorator('DtDdWrapper');
     $this->newsImage->removeDecorator('Label');
     $this->newsImage->setAttrib('class', 'smallele');
     $this->newsPublishDate = $this->createElement('text', 'newsPublishDate');
     $this->newsPublishDate->removeDecorator('HtmlTag');
     $this->newsPublishDate->removeDecorator('DtDdWrapper');
     $this->newsPublishDate->removeDecorator('Label');
     $this->newsPublishDate->setAttrib('class', 'smallele');
     $this->newsStatus = $this->createElement('hidden', 'newsStatus');
     $this->newsStatus->removeDecorator('HtmlTag');
     $this->newsStatus->removeDecorator('DtDdWrapper');
     $this->newsStatus->removeDecorator('Label');
     $this->newsStatus->setValue(1);
 }
Ejemplo n.º 3
0
    public function init()
    {
        $this->setMethod('post');
        $this->setAttrib('enctype', 'multipart/form-data');

        $photo = new Zend_Form_Element_File('photo');
        $photo->setLabel('photo.upload');
        $photo->setDestination($this->getAttrib('tmp'));

        $photo->addValidator('Count', false, 1);
        $photo->addValidator('Size', false, $this->getAttrib('filesize'));
        $photo->addValidator(
            'Extension', false, $this->getAttrib('extensions')
        );

        $photo->setRequired(true);
        $photo->removeDecorator('Errors');

        $this->addElement($photo, 'photo');

        $fbId = new Zend_Form_Element_Hidden('fbid');
        $fbId->addValidator(
            'Db_NoRecordExists', false,
            array(
                'table' => 'zdjecia',
                'field' => 'fbuserid'
            )
        );
        $fbId->setLabel('fbid');

        $fbId->setRequired(true);
        $fbId->removeDecorator('Errors');
        $fbId->removeDecorator('Label');

        $this->addElement($fbId);

        $save = new Zend_Form_Element_Submit('Save');
        $save->setLabel('Zgłoś Zdjęcie');
        $save->setAttrib('class', 'ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only');

        $this->addElement($save);

        $this->addDecorator(
                new Zend_Form_Decorator_FormErrors(
                    array(
                        'ignoreSubForms'=>true,
                        'markupListStart' => '<ul class="ui-state-error ui-corner-all">',
                    )
                )
            )
            ->addDecorator('FormElements')
            ->addDecorator('HtmlTag')
            ->addDecorator('Form');
    }
Ejemplo n.º 4
0
 /**
  * Inicializace formulare
  *
  */
 public function init()
 {
     $this->setMethod(self::METHOD_POST);
     // ################## FIRST COLUMN ###################
     // Photo (id_foto)
     // File picker
     $profilePhotoPicker = new Zend_Form_Element_File('profilePhoto');
     $profilePhotoPicker->setDestination(PUBLIC_PATH . '/temp');
     $profilePhotoPicker->addValidator('Count', false, 1);
     $profilePhotoPicker->addValidator('Size', false, 2097152);
     $profilePhotoPicker->removeDecorator('Label');
     $this->addElement($profilePhotoPicker, 'profilePhoto');
     $avatar = new Zend_Form_Element_Image('avatar');
     $avatar->setAttrib('class', array("profile-user-img", "img-responsive", "img-circle"));
     $this->addElement($avatar, 'avatar');
     // First name (jmeno)
     $firstName = $this->createElement('text', 'jmeno');
     $firstName->addFilter('StringTrim');
     $firstName->setRequired(true);
     $firstName->setAttrib('class', 'form-control');
     $firstName->setAttrib('placeholder', 'First name');
     $firstName->removeDecorator('Label');
     $this->addElement($firstName);
     // Last name (prijmeni)
     $lastName = $this->createElement('text', 'prijmeni');
     $lastName->addFilter('StringTrim');
     $lastName->setRequired(true);
     $lastName->setAttrib('class', 'form-control');
     $lastName->setAttrib('placeholder', 'Surname');
     $lastName->removeDecorator('Label');
     $this->addElement($lastName);
     // E-mail (email)
     $lastName = $this->createElement('text', 'email');
     $lastName->addFilter('StringTrim');
     $lastName->setRequired(true);
     $lastName->setAttrib('class', 'form-control');
     $lastName->setAttrib('placeholder', 'E-mail');
     $lastName->removeDecorator('Label');
     $this->addElement($lastName);
     //heslo
     $pass = $this->createElement('password', 'heslo');
     $pass->setAttrib('class', 'form-control');
     $pass->setAttrib('placeholder', 'Password');
     $pass->removeDecorator('Label');
     $login = Zend_Auth::getInstance()->getIdentity();
     $user = My_Model::get('Users')->getUserByEmail($login);
     if ($user !== NULL) {
         $this->addElement($pass);
     }
     // ###################### BUTTON ######################
     $close = new Zend_Form_Element_Submit('closeButton');
     $close->setLabel('Back');
     $close->setAttrib('class', 'btn btn-default');
     $close->setDecorators(array('ViewHelper'));
     $this->addElement($close, 'closeButton');
     $save = new Zend_Form_Element_Submit('saveButton');
     $save->setLabel('Save');
     $save->setAttrib('class', 'btn btn-success');
     $save->setDecorators(array('ViewHelper'));
     $this->addElement($save, 'saveButton');
     $delete = new Zend_Form_Element_Submit('deleteButton');
     $delete->setLabel('Delete');
     $delete->setAttrib('class', 'btn btn-danger');
     $delete->setAttrib('onclick', 'if (confirm("Are you sure?")) { document.form.submit(); } return false;');
     $delete->setDecorators(array('ViewHelper'));
     $this->addElement($delete, 'deleteButton');
 }
Ejemplo n.º 5
0
 public function indexAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Configure"), $this->view->translate("CNL Update")));
     $config = Zend_Registry::get('config');
     $this->view->pathweb = $config->system->path->web;
     // verification procedure
     $db = Zend_Registry::get('db');
     $select = $db->select()->from('state');
     $stmt = $select->query();
     $result = $stmt->fetchAll();
     // insert state data
     if (count($result) < 26) {
         $brStates = array('AC' => 'Acre', 'AL' => 'Alagoas', 'AM' => 'Amazonas', 'AP' => 'Amapá', 'BA' => 'Bahia', 'CE' => 'Ceará', 'DF' => 'Distrito Federal', 'ES' => 'Espírito Santo', 'GO' => 'Goiás', 'MA' => 'Maranhão', 'MG' => 'Minas Gerais', 'MS' => 'Mato Grosso do Sul', 'MT' => 'Mato Grosso', 'PA' => 'Pará', 'PB' => 'Paraíba', 'PE' => 'Pernambuco', 'PI' => 'Piauí', 'PR' => 'Paraná', 'RJ' => 'Rio de Janeiro', 'RN' => 'Rio Grande do Norte', 'RO' => 'Rondônia', 'RR' => 'Roraima', 'RS' => 'Rio Grande do Sul', 'SC' => 'Santa Catarina', 'SE' => 'Sergipe', 'SP' => 'São Paulo', 'TO' => 'Tocantins');
         foreach ($brStates as $uf => $state) {
             $db->beginTransaction();
             try {
                 $_state = array('ds_code' => $uf, 'ds_name' => $state);
                 $db->insert('state', $_state);
                 $db->commit();
             } catch (Exception $ex) {
                 $db->rollBack();
                 throw $ex;
             }
         }
     }
     $form = new Snep_Form();
     $form->setAction($this->getFrontController()->getBaseUrl() . "/default/cnl/index");
     $this->view->formAction = $this->getFrontController()->getBaseUrl() . "/default/cnl/index";
     $element = new Zend_Form_Element_File('cnl');
     $element->setLabel($this->view->translate('CNL File'))->setDestination('/tmp/')->setRequired(true);
     $element->addValidator('Extension', false, array('bz2', 'json'));
     $element->removeDecorator('DtDdWrapper');
     $form->addElement($element, 'cnl');
     $form->getElement("submit")->setLabel($this->view->translate("Save"));
     $form->setAttrib('enctype', 'multipart/form-data');
     $this->view->valid = true;
     if ($this->_request->getPost()) {
         $form_isValid = $form->isValid($_POST);
         $this->view->valid = $form_isValid;
         if ($form_isValid) {
             $data = $_POST;
             $adapter = new Zend_File_Transfer_Adapter_Http();
             if ($adapter->isValid()) {
                 $adapter->receive();
                 $fileName = $adapter->getFileName();
                 $json = file_get_contents($fileName);
                 $cnl = Zend_Json_Decoder::decode($json, Zend_Json::TYPE_ARRAY);
                 $data = $cnl["operadoras"];
                 unset($cnl["operadoras"]);
                 $db->delete('city_code');
                 $db->delete('carrier_prefix');
                 $db->delete('city');
                 foreach ($data as $carrier => $id) {
                     Snep_Cnl::addOperadora($id, $carrier);
                 }
                 foreach ($cnl as $data => $id) {
                     foreach ($id as $state => $es) {
                         foreach ($es as $ddd => $d) {
                             foreach ($d as $city => $pre) {
                                 $stateId = Snep_Cnl::fetchStateId($state);
                                 $cityId = Snep_Cnl::addCidade($city);
                                 Snep_Cnl::addDDD($ddd, $stateId, $cityId);
                                 foreach ($pre as $prefix => $op) {
                                     Snep_Cnl::addPrefixo($prefix, $cityId, $op);
                                 }
                             }
                         }
                     }
                 }
                 $this->view->message = $this->view->translate('A lista de informações CNL foi atualizada com sucesso.');
             } else {
                 throw new ErrorException($this->view->translate("File format is not valid"));
             }
         }
     }
     $this->view->form = $form;
 }
Ejemplo n.º 6
0
 /**
  * Inicializace formulare
  *
  */
 public function init()
 {
     $this->setMethod(self::METHOD_POST);
     // ################## FIRST COLUMN ###################
     // Photo (id_foto)
     // File picker
     $profilePhotoPicker = new Zend_Form_Element_File('profilePhoto');
     $profilePhotoPicker->setDestination(PUBLIC_PATH . '/temp');
     $profilePhotoPicker->addValidator('Count', false, 1);
     $profilePhotoPicker->addValidator('Size', false, 2097152);
     $profilePhotoPicker->removeDecorator('Label');
     $this->addElement($profilePhotoPicker, 'profilePhoto');
     $avatar = new Zend_Form_Element_Image('avatar');
     $avatar->setAttrib('class', array("profile-user-img", "img-responsive", "img-circle"));
     $this->addElement($avatar, 'avatar');
     // First name (jmeno)
     $firstName = $this->createElement('text', 'jmeno');
     $firstName->addFilter('StringTrim');
     $firstName->setRequired(true);
     $firstName->setAttrib('class', 'form-control');
     $firstName->setAttrib('placeholder', 'First name');
     $firstName->removeDecorator('Label');
     $this->addElement($firstName);
     // Last name (prijmeni)
     $lastName = $this->createElement('text', 'prijmeni');
     $lastName->addFilter('StringTrim');
     $lastName->setRequired(true);
     $lastName->setAttrib('class', 'form-control');
     $lastName->setAttrib('placeholder', 'Surname');
     $lastName->removeDecorator('Label');
     $this->addElement($lastName);
     // Date of birth (datum_narozeni)
     // Date picker
     $birthdate = $this->createElement('text', 'datum_narozeni');
     $birthdate->setRequired(true);
     $birthdate->setAttrib('class', array('form-control', 'date-picker'));
     $birthdate->removeDecorator('Label');
     $birthdate->setAttrib('placeholder', 'Birthdate');
     $this->addElement($birthdate);
     // ################## SECOND COLUMN ##################
     // Status (id_status)
     // Select box
     $status = new Zend_Form_Element_Select('id_status');
     $status->removeDecorator('Label');
     $status->setAttrib('class', 'form-control');
     $this->addElement($status, 'id_status');
     // Position (id_pozice)
     // Select box
     $position = new Zend_Form_Element_Select('id_pozice');
     $position->removeDecorator('Label');
     $position->setAttrib('class', 'form-control');
     $this->addElement($position, 'id_pozice');
     // Technology (kandidat_technologie)
     // Multi select
     $technology = new Zend_Form_Element_Multiselect('kandidat_technologie');
     $technology->removeDecorator('Label');
     $technology->setAttrib('class', 'form-control');
     $this->addElement($technology, 'kandidat_technologie');
     // Seniority (id_seniorita)
     // Select box
     $seniority = new Zend_Form_Element_Select('id_seniorita');
     $seniority->removeDecorator('Label');
     $seniority->setAttrib('class', 'form-control');
     $this->addElement($seniority, 'id_seniorita');
     // Comment (komentar)
     $comment = $this->createElement('textarea', 'komentar');
     $comment->addFilter('StringTrim');
     $comment->setAttrib('class', 'form-control');
     $comment->setAttrib('rows', '3');
     $comment->setAttrib('placeholder', 'Enter your comment…');
     $comment->removeDecorator('Label');
     $this->addElement($comment);
     // ################### ATTACHEMENTS ###################
     // Attchements (kandidat_priloha)
     // File picker
     $attachments = new Zend_Form_Element_File('attachments');
     $attachments->setDestination(PUBLIC_PATH . '/temp');
     $attachments->addValidator('Count', false, array('min' => 0, 'max' => 4));
     $attachments->addValidator('Size', false, 2097152);
     $attachments->setMultiFile(4);
     $attachments->removeDecorator('Label');
     $this->addElement($attachments, 'attachments');
     $attachmentsCheckGroup = new Zend_Form_Element_MultiCheckbox('attachmentsCheckGroup');
     $comment->removeDecorator('Label');
     $this->addElement($attachmentsCheckGroup, 'attachmentsCheckGroup');
     // ###################### BUTTON ######################
     $close = new Zend_Form_Element_Submit('closeButton');
     $close->setLabel('Back');
     $close->setAttrib('class', 'btn btn-default');
     $close->setDecorators(array('ViewHelper'));
     $this->addElement($close, 'closeButton');
     $save = new Zend_Form_Element_Submit('saveButton');
     $save->setLabel('Save');
     $save->setAttrib('class', 'btn btn-success');
     $save->setDecorators(array('ViewHelper'));
     $this->addElement($save, 'saveButton');
     $delete = new Zend_Form_Element_Submit('deleteButton');
     $delete->setLabel('Delete');
     $delete->setAttrib('class', 'btn btn-danger');
     $delete->setAttrib('onclick', 'if (confirm("Are you sure?")) { document.form.submit(); } return false;');
     $delete->setDecorators(array('ViewHelper'));
     $this->addElement($delete, 'deleteButton');
 }
Ejemplo n.º 7
0
 public function init()
 {
     $tableArea = new Model_DbTable_Area();
     $tableCategory = new Model_DbTable_Category();
     $dateValidator = new Zend_Validate_Date();
     $this->name = new Zend_Form_Element_Text('Name');
     $this->name->setRequired(true)->setAttrib('class', 'span7')->setAttrib('placeholder', 'Masukan Nama Kebudayaan Disini...')->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label');
     $this->featured = new Zend_Form_Element_Checkbox('Featured');
     $this->featured->setAttrib('class', 'checkbox')->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label');
     $this->description = new Zend_Form_Element_Textarea('Description');
     $this->description->setAttrib('style', 'width:100%')->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label');
     $this->header_image = new Zend_Form_Element_File('Header_image');
     $this->header_image->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label');
     $this->submit = new Zend_Form_Element_Submit('Submit');
     $this->submit->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label')->setAttribs(array('class' => 'btn btn-success', 'id' => 'submit-btn'));
     $this->draft = new Zend_Form_Element_Submit('Draft');
     $this->draft->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label')->setAttribs(array('class' => 'btn', 'id' => 'draft-btn'));
     $this->videos = new Zend_Form_SubForm();
     $category = $tableCategory->getAllParentIdNameForSelectByLangId(1);
     $this->Category_Select = $this->createElement('select', 'CategorySelect', $category);
     $this->Category_Select->removeDecorator('HtmlTag');
     $this->Category_Select->removeDecorator('DtDdWrapper');
     $this->Category_Select->removeDecorator('Label');
     $this->Category_Select->setAttrib('onchange', 'getChildCategory(this.value);');
     $category_child = $tableCategory->getAllChildIdNameByParentIdLangId();
     $this->Category_Child = $this->createElement('select', 'CategoryChild', $category_child);
     $this->Category_Child->removeDecorator('HtmlTag');
     $this->Category_Child->removeDecorator('DtDdWrapper');
     $this->Category_Child->removeDecorator('Label');
     $data = $tableArea->setAreaForSelectElement(1);
     $temp = array(0 => 'Pilih Area');
     $area_data = $temp + $data;
     $data = array("multiOptions" => $area_data);
     $this->Island_Select = $this->createElement('select', 'IslandListOptions', $data);
     $this->Island_Select->removeDecorator('HtmlTag');
     $this->Island_Select->removeDecorator('DtDdWrapper');
     $this->Island_Select->removeDecorator('Label');
     $this->Island_Select->setAttrib('onchange', 'getAreaList(this.value,0);');
     $this->Poi_x = $this->createElement('hidden', 'pointx');
     $this->Poi_x->removeDecorator('HtmlTag');
     $this->Poi_x->setAttrib('class', 'required');
     $this->Poi_x->removeDecorator('DtDdWrapper');
     $this->Poi_x->removeDecorator('Label');
     $this->Poi_x->setAttrib('onkeyup', 'updatePosition();');
     $this->Poi_x->setAttrib('class', 'smallele');
     $this->Poi_x->setRequired(TRUE);
     $this->Poi_y = $this->createElement('hidden', 'pointy');
     $this->Poi_y->removeDecorator('HtmlTag');
     $this->Poi_y->setAttrib('class', 'required');
     $this->Poi_y->removeDecorator('DtDdWrapper');
     $this->Poi_y->removeDecorator('Label');
     $this->Poi_y->setAttrib('onkeyup', 'updatePosition();');
     $this->Poi_y->setAttrib('class', 'smallele');
     $this->Poi_y->setRequired(TRUE);
     /* hidden element */
     $this->relPoi_counter = $this->createElement('hidden', 'relPoi_counter');
     $this->relPoi_counter->removeDecorator('HtmlTag');
     $this->relPoi_counter->removeDecorator('DtDdWrapper');
     $this->relPoi_counter->removeDecorator('Label');
     $this->relPoi_counter->setValue(0);
     $this->SaveStatus = $this->createElement('hidden', 'SaveStatus');
     $this->SaveStatus->removeDecorator('HtmlTag');
     $this->SaveStatus->removeDecorator('DtDdWrapper');
     $this->SaveStatus->removeDecorator('Label');
     $this->SaveStatus->setValue(1);
     /**
      * This element will be used for maximum area counter storage, 
      * when you remove an area this counter number wont be decreased
      */
     $this->Count_area = $this->createElement('hidden', 'MaxArea');
     $this->Count_area->removeDecorator('HtmlTag');
     $this->Count_area->removeDecorator('DtDdWrapper');
     $this->Count_area->removeDecorator('Label');
     $this->Count_area->setValue(0);
     /**
      * This element will be used for maximum category counter storage, 
      * when you remove a category this counter number wont be decreased
      */
     $this->Count_category = $this->createElement('hidden', 'MaxCategory');
     $this->Count_category->removeDecorator('HtmlTag');
     $this->Count_category->removeDecorator('DtDdWrapper');
     $this->Count_category->removeDecorator('Label');
     $this->Count_category->setValue(0);
     $this->Area_counter = $this->createElement('hidden', 'AreaCounter');
     $this->Area_counter->removeDecorator('HtmlTag');
     $this->Area_counter->removeDecorator('DtDdWrapper');
     $this->Area_counter->removeDecorator('Label');
     $this->Area_counter->setValue(0);
     $this->Category_counter = $this->createElement('hidden', 'CategoryCounter');
     $this->Category_counter->removeDecorator('HtmlTag');
     $this->Category_counter->removeDecorator('DtDdWrapper');
     $this->Category_counter->removeDecorator('Label');
     $this->Category_counter->setValue(0);
     $this->Main_category = $this->createElement('hidden', 'MainCategory');
     $this->Main_category->removeDecorator('HtmlTag');
     $this->Main_category->removeDecorator('DtDdWrapper');
     $this->Main_category->removeDecorator('Label');
     $this->Main_category->setValue(0);
 }