コード例 #1
0
 /**
  * Setup decorators and properties and return render output
  * 
  * @return string
  */
 public function render()
 {
     $this->addElements();
     $this->setupElementsCommon();
     $this->setupElementsUnique();
     $this->setupForm();
     return $this->form->render();
 }
コード例 #2
0
 /**
  * Render
  * @param  Zend_View_Interface $view
  * @return Zend_View
  */
 public function render(Zend_View_Interface $view = null)
 {
     if (!empty($this->_type)) {
         $this->setAttrib('class', trim('form-' . $this->_type . ' ' . $this->getAttrib('class')));
     }
     return parent::render($view);
 }
コード例 #3
0
ファイル: Form.php プロジェクト: nvdnkpr/Enlight
 /**
  * Render form
  *
  * @param  Zend_View_Interface $view
  * @return string
  */
 public function render(Zend_View_Interface $view = null)
 {
     if (null === $view && $this->_view === null) {
         $view = new Zend_View();
     }
     return parent::render($view);
 }
コード例 #4
0
ファイル: SimplifiedForm.php プロジェクト: relyd/aidstream
 public function render()
 {
     $requiredSuffx = '<span title="This field is required." class="form-required">*</span>';
     foreach ($this->getElements() as $element) {
         $decorator = $element->getDecorator('Label');
         if ($decorator) {
             if ($element->getLabel()) {
                 // need to check this, since label decorator can be blank
                 $element->setLabel($element->getLabel() . "&nbsp;");
             }
             $decorator->setOption('requiredSuffix', $requiredSuffx);
             $decorator->setOption('escape', false);
         }
         if ($element->getErrors()) {
             $this->addElementClass($element, 'error');
         }
         // Add a wrapper div to all elements other than add and remove buttons.
         if ($element->getName() != 'add' && $element->getName() != 'remove') {
             if ($element->getName() == 'id' || $element->getType() == 'Zend_Form_Element_Hidden' && preg_match('/_id/', $element->getName())) {
                 $element->addDecorators(array(array(array('wrapperAll' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-item ele-id clearfix'))));
             } else {
                 if ($element->getName() == 'save_and_view' || $element->getName() == 'save') {
                     $element->addDecorators(array(array(array('wrapperAll' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-item ele-submit-buttons clearfix'))));
                 } else {
                     $element->addDecorators(array(array(array('wrapperAll' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-item clearfix'))));
                 }
             }
         } else {
             $element->removeDecorator('label');
         }
     }
     $output = parent::render();
     return $output;
 }
コード例 #5
0
ファイル: Abstract.php プロジェクト: robertsonmello/projetos
 public function render(Zend_View_Interface $view = null)
 {
     $decorators = array(array('ViewHelper'), array('Label'));
     $elements = $this->getElements();
     $elements_name = array();
     foreach ($elements as $element) {
         $type = explode('_', $element->getType());
         $type = strtolower(array_pop($type));
         $element->setAttrib('class', $type);
         if ($type == 'hidden' || $type == 'submit' || $type == 'button' || $type == 'reset') {
             $element->setDecorators($decorators[0]);
         } else {
             if ($type == 'file') {
                 $element->setDecorators(array('File', $decorators[1]));
             } else {
                 $element->setDecorators($decorators);
             }
         }
         array_push($elements_name, $element->getName());
     }
     if (count($elements_name) > 0) {
         $this->addDisplayGroup($elements_name, $this->getName(), array('legend' => $this->getLegend()));
         $this->setDisplayGroupDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div', 'id' => 'div-' . $this->getName()))));
     }
     return parent::render($view);
 }
コード例 #6
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);
 }
コード例 #7
0
ファイル: FormTest.php プロジェクト: vicfryzel/zf
 /**
  * @group ZF-5370
  */
 public function testEnctypeDefaultsToMultipartWhenFileElementIsAttachedToDisplayGroup()
 {
     $this->form->addElement('file', 'txt')->addDisplayGroup(array('txt'), 'txtdisplay')->setView(new Zend_View());
     $html = $this->form->render();
     $this->assertContains('id="txt"', $html);
     $this->assertContains('name="txt"', $html);
     $this->assertRegexp('#<form[^>]+enctype="multipart/form-data"#', $html, $html);
 }
コード例 #8
0
ファイル: SubFormTest.php プロジェクト: lortnus/zf1
 /**
  * @see ZF-3272
  */
 public function testRenderedSubFormDtShouldContainNoBreakSpace()
 {
     $subForm = new Zend_Form_SubForm(array('elements' => array('foo' => 'text', 'bar' => 'text')));
     $form = new Zend_Form();
     $form->addSubForm($subForm, 'foobar')->setView(new Zend_View());
     $html = $form->render();
     $this->assertContains('<dt>&nbsp;</dt>', $html);
 }
コード例 #9
0
 /**
  * @see ZF-2883
  */
 public function testDisplayGroupsShouldInheritSubFormNamespace()
 {
     $this->form->addElement('text', 'foo')->addElement('text', 'bar')->addDisplayGroup(array('foo', 'bar'), 'foobar');
     $form = new Zend_Form();
     $form->addSubForm($this->form, 'attributes');
     $html = $form->render(new Zend_View());
     $this->assertContains('name="attributes[foo]"', $html);
     $this->assertContains('name="attributes[bar]"', $html);
 }
コード例 #10
0
ファイル: BaseForm.php プロジェクト: relyd/aidstream
 /**
  * Overriding zend form render.
  */
 public function render()
 {
     $requiredSuffx = '<span title="This field is required." class="form-required">*</span>';
     foreach ($this->getElements() as $element) {
         $element = $this->decorateElement($element);
     }
     $output = parent::render();
     return $output;
 }
コード例 #11
0
ファイル: FigletTest.php プロジェクト: stunti/zf2
 public function testLabelIdIsCorrect()
 {
     $form = new \Zend_Form();
     $form->setElementsBelongTo('comment');
     $this->element->setLabel("My Captcha");
     $form->addElement($this->element);
     $html = $form->render($this->getView());
     $expect = sprintf('for="comment-%s-input"', $this->element->getName());
     $this->assertRegexp("/<label [^>]*?{$expect}/", $html, $html);
 }
コード例 #12
0
 /**
  * Wrap parent to provide a default Zend_View if none
  * is given
  *
  * @param Zend_View_Interface $view
  * @return string
  */
 public function render(Zend_View_Interface $view = NULL)
 {
     if (NULL === $view) {
         if (NULL == $this->getView()) {
             $this->setView(new Zend_View());
         }
         $view = $this->getView();
     }
     return parent::render($view);
 }
コード例 #13
0
 public function testRenderElement()
 {
     $form = new Zend_Form();
     $form->addElement($this->element);
     $view = new Zend_View();
     $view->addHelperPath('Application/View/Helper', 'Application_View_Helper');
     $form->setAction('/foo.php?bar')->setView($view);
     $html = $form->render();
     $this->assertContains('<input type="date" name="foo" id="foo" value="" disabled="1">', $html);
 }
コード例 #14
0
ファイル: Form.php プロジェクト: hartum/basezf
 /**
  * Set default render
  */
 public function render($content = null)
 {
     $this->setAttrib('class', $this->getAttrib('class') . ' formLayout');
     $defaultDecorators = array('FormElements', 'Form');
     $defaultGroupDecorators = array('FormElements', 'Fieldset');
     $this->setElementDecorators(array('Composite'));
     $this->setDisplayGroupDecorators($defaultGroupDecorators);
     $this->setSubFormDecorators($defaultDecorators);
     $this->setDecorators($defaultDecorators);
     return parent::render($content);
 }
コード例 #15
0
ファイル: Form.php プロジェクト: Konstnantin/zf-app
    public function render(Zend_View_Interface $view = null)
    {
        jQuery::evalScript('
			$(".z-form fieldset legend").click(function(){
				$(this).parent().find(">dl").toggle("blind",200);
			})
		');
        if (!$this->getAttrib('id')) {
            $this->setAttrib('id', 'z-admin-form-' . rand(1000000, 10000000));
        }
        return parent::render($view);
    }
コード例 #16
0
ファイル: Form.php プロジェクト: sp1ke77/MLM-1
 public function render(\Zend_View_Interface $view = null)
 {
     $elementsGroup = array();
     foreach ($this->getElements() as $element) {
         $elementsGroup[] = $element->getName();
     }
     $this->addDisplayGroup($elementsGroup, "elements");
     $this->setLegend("testowa");
     $this->_addDisplayGroupWithButtons();
     $this->_setDisplayGroupDecorators();
     $this->_addValuesForElements();
     return parent::render($view);
 }
コード例 #17
0
ファイル: Settings.php プロジェクト: joobsbox/joobsbox
 function indexAction()
 {
     $form = new Zend_Form();
     $form->setAction($_SERVER['REQUEST_URI'])->setMethod('post')->setAttrib("id", "formPublish");
     $jobs_per_categ = $form->createElement('text', 'jobs_per_categ')->setLabel('Job title:')->addFilter('StripTags')->addFilter('StringTrim')->addFilter('HtmlEntities')->addValidator('notEmpty')->setDescription('Ex: "Flash Designer" or "ASP.NET Programmer"')->setRequired(true);
     $submit = $form->createElement('submit', 'submit')->setLabel("Set");
     $config = Zend_Registry::get("conf");
     foreach ($this->textItems as $category => $items) {
         foreach ($items as $key => $label) {
             $item = $form->createElement('text', $key)->setLabel($label)->addValidator('notEmpty')->setRequired(true)->setValue($config->{$category}->{$key});
             $form->addElement($item);
         }
         $form->addDisplayGroup(array_keys($items), $category, array('legend' => ucfirst($category)));
     }
     foreach ($this->checkItems as $category => $items) {
         foreach ($items as $key => $label) {
             $item = $form->createElement('checkbox', $key)->setLabel($label)->setChecked($config->{$category}->{$key});
         }
         $form->getDisplayGroup($category)->addElement($item);
     }
     // Locale select
     $locales = Zend_Registry::get("Zend_Locale")->getTranslationList('language', 'en');
     foreach ($locales as $key => $value) {
         if (!file_exists("Joobsbox/Languages/{$key}")) {
             unset($locales[$key]);
         }
     }
     $locale = $form->createElement('select', 'locale')->setMultiOptions($locales)->setLabel($this->view->translate("Language"))->setValue($config->general->locale);
     $form->getDisplayGroup('general')->addElement($locale);
     // Timezone select
     $tzfile = file("config/timezones.ini.php");
     $timezones = array();
     foreach ($tzfile as $value) {
         $value = trim($value);
         $value = str_replace('"', '', $value);
         $timezones[$value] = $value;
     }
     $timezone = $form->createElement('select', 'site_timezone')->setMultiOptions($timezones)->setLabel($this->view->translate("Timezone"))->setValue($config->general->timezone);
     $form->getDisplayGroup('general')->addElement($timezone);
     $form->addElement($submit);
     $this->form = $form;
     $this->view->form = $form->render();
     if ($this->getRequest()->isPost()) {
         $this->validateForm();
         return;
     }
     $this->view->form = $this->form->render();
 }
コード例 #18
0
 /**
  * Adds decorators and calls parent
  * @return string
  */
 public function render()
 {
     // set view, do only when rendering
     $view = new Zend_View();
     $view->doctype('XHTML1_TRANSITIONAL');
     $this->setView($view);
     // add submit, only having viewHelper decorator
     $this->addElement('submit', 'submit');
     $this->getElement('submit')->setIgnore(true);
     $this->getElement('submit')->clearDecorators();
     $this->getElement('submit')->AddDecorator('ViewHelper');
     $this->addDecorator('FormElements');
     $this->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'taskWeek'));
     $this->addDecorator('Form');
     return parent::render();
 }
コード例 #19
0
ファイル: Form.php プロジェクト: Tony133/zf-web
 public function render(Zend_View_Interface $view = null)
 {
     // Set rendering for the form itself
     $this->setDisplayGroupDecorators(array('FormElements', 'Fieldset'));
     $this->addDecorator('HtmlTag', array('tag' => 'ul', 'class' => 'zend_form'));
     // Check all elements
     foreach ($this->_elements as $element) {
         // Set decorators for all elements
         if ($element instanceof Zend_Form_Element_Submit === false) {
             $outerClasses = array();
             $label = $element->getLabel();
             if (empty($label) === true and $element instanceof App_Form_Element_Headline === false and $element instanceof App_Form_Element_Info === false) {
                 $outerClasses[] = 'indent';
             }
             if ($element instanceof App_Form_Element_Checkbox === true or $element instanceof Zend_Form_Element_MultiCheckbox === true or $element instanceof Zend_Form_Element_Radio === true) {
                 $outerClasses[] = 'checkbox-radio';
             } else {
                 $labelOptions = array();
             }
             if ($element instanceof Zend_Form_Element_MultiCheckbox and $element->getName() === 'tags') {
                 $outerClasses[] = 'tags';
             }
             if (count($outerClasses) > 0) {
                 $outerOptions = array('tag' => 'li', 'class' => implode(' ', $outerClasses));
             } else {
                 $outerOptions = array('tag' => 'li');
             }
             $decorators = array('ViewHelper', array('decorator' => array('Floater' => 'HtmlTag'), 'options' => array('tag' => 'div', 'class' => 'input-container')), array('Label', array('requiredSuffix' => ':', 'optionalSuffix' => ':')), array('decorator' => array('FloatClear' => 'HtmlTag'), 'options' => array('tag' => 'div', 'class' => 'clear', 'placement' => Zend_Form_Decorator_HtmlTag::APPEND)), 'Errors', array('HtmlTag', $outerOptions));
         } else {
             $decorators = array('ViewHelper', array('HtmlTag', array('tag' => 'li', 'class' => 'submit')));
         }
         $element->setDecorators($decorators);
         // Set seperator for multi elements
         if ($element instanceof Zend_Form_Element_Multi === true) {
             $element->setSeparator(' ');
         }
     }
     return parent::render($view);
 }
コード例 #20
0
ファイル: Form.php プロジェクト: relyd/aidstream
 public function render()
 {
     $requiredSuffx = '<span title="This field is required." class="form-required">*</span>';
     foreach ($this->getElements() as $element) {
         $decorator = $element->getDecorator('Label');
         if ($decorator) {
             if ($element->getLabel()) {
                 // need to check this, since label decorator can be blank
                 $element->setLabel($element->getLabel() . ":&nbsp;");
             }
             $decorator->setOption('requiredSuffix', $requiredSuffx);
             $decorator->setOption('escape', false);
         }
         if ($element->getErrors()) {
             $this->addElementClass($element, 'error');
         }
         if ($element->getName() == 'add' || $element->getName() == 'remove') {
             $element->removeDecorator('label');
         }
     }
     $output = parent::render();
     return $output;
 }
コード例 #21
0
ファイル: Users.php プロジェクト: joobsbox/joobsbox
 function indexAction()
 {
     // Edit your current profile
     $currentUsername = Zend_Auth::getInstance()->getIdentity();
     $this->userData = $this->_model->getData($currentUsername);
     if ($this->userData !== FALSE) {
         $form = new Zend_Form();
         $form->setAction($_SERVER['REQUEST_URI'])->setMethod('post');
         $username = $form->createElement('text', 'username')->setLabel('Username:'******'StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setValue($this->userData['username'])->setRequired(true);
         $old_password = $form->createElement('password', 'old_password')->addFilter('StringTrim')->setLabel('Current password:'******'password', 'password')->addFilter('StringTrim')->setLabel('Password:'******'password', 'password_v')->addFilter('StringTrim')->setLabel('Password (verification):');
         $email = $form->createElement('text', 'email')->setLabel('Email:')->addFilter('StringTrim')->setValue($this->userData['email']);
         $submit = $form->createElement('submit', 'submit')->setLabel("Modify");
         $form->addElement($username)->addElement($old_password)->addElement($password)->addElement($password_v)->addElement($email)->addElement($submit);
         $this->form = $form;
         $this->view->form = $form->render();
         if ($this->getRequest()->isPost()) {
             $this->validateForm();
             return;
         }
         $this->view->form = $this->form->render();
     }
 }
コード例 #22
0
ファイル: Customer.php プロジェクト: baisoo/axiscommerce
 /**
  *
  * @param Zend_View_Interface $view
  * @param boolean $skipFormTag
  * @return string
  */
 public function render(Zend_View_Interface $view = null, $skipFormTag = false)
 {
     $content = parent::render($view);
     if ($skipFormTag) {
         $patterns[0] = '/<form.*?>/';
         $patterns[1] = '/<\\/form.*?>/';
         $content = preg_replace($patterns, '', $content);
     }
     return $content;
 }
コード例 #23
0
 /**
  * @see   ZF-4038
  * @group ZF-4038
  */
 public function testCaptchaShouldRenderFullyQualifiedElementName()
 {
     require_once 'Zend/Form.php';
     require_once 'Zend/View.php';
     $form = new Zend_Form();
     $form->addElement($this->element)->setElementsBelongTo('bar');
     $html = $form->render(new Zend_View());
     $this->assertContains('name="bar[foo', $html, $html);
     $this->assertContains('id="bar-foo-', $html, $html);
     $this->form = $form;
 }
コード例 #24
0
 /**
  * Render form
  *
  * @param  Zend_View_Interface $view
  * @return string
  */
 public function render(Zend_View_Interface $view = null)
 {
     /**
      * Getting elements.
      */
     $elements = $this->getElements();
     foreach ($elements as $eachElement) {
         /**
          * Removing label from buttons before render.
          */
         if ($eachElement instanceof Zend_Form_Element_Submit) {
             $eachElement->removeDecorator('Label');
         }
         if ($eachElement instanceof Zend_Form_Element_Hidden) {
             $eachElement->clearDecorators()->addDecorator('ViewHelper');
         }
     }
     /**
      * Rendering.
      */
     return parent::render($view);
 }
コード例 #25
0
 /**
  * @group ZF-2828
  */
 public function testCanPopulateCheckboxOptionsFromPostedData()
 {
     $form = new Zend_Form(array('elements' => array('100_1' => array('MultiCheckbox', array('multiOptions' => array('100_1_1' => 'Agriculture', '100_1_2' => 'Automotive', '100_1_12' => 'Chemical', '100_1_13' => 'Communications'), 'required' => true)))));
     $data = array('100_1' => array('100_1_1', '100_1_2', '100_1_12', '100_1_13'));
     $form->populate($data);
     $html = $form->render($this->getView());
     foreach ($form->getElement('100_1')->getMultiOptions() as $key => $value) {
         if (!preg_match('#(<input[^>]*' . $key . '[^>]*>)#', $html, $m)) {
             $this->fail('Missing input for a given multi option: ' . $html);
         }
         $this->assertContains('checked="checked"', $m[1]);
     }
 }
コード例 #26
0
 /**
  * Render
  * @param  Zend_View_Interface $view
  * @return Zend_View
  */
 public function render(Zend_View_Interface $view = null)
 {
     $formTypes = array('horizontal', 'inline', 'vertical', 'search');
     $set = false;
     foreach ($formTypes as $type) {
         if ($this->getAttrib($type)) {
             $this->addDecorator("Form", array("class" => "form-{$type}"));
             $set = true;
         }
     }
     if (true !== $set) {
         // if neither type was set, we set the default vertical class
         $this->addDecorator("Form", array("class" => "form-vertical"));
     }
     return parent::render($view);
 }
コード例 #27
0
 /**
  * Render form
  *
  * @param  Zend_View_Interface $view
  * @return string
  */
 public function render(Zend_View_Interface $view = null)
 {
     /**
      * Getting elements.
      */
     $elements = $this->getElements();
     foreach ($elements as $eachElement) {
         /**
          * Add required attribute to required elements
          * https://github.com/manticorp
          */
         if ($eachElement->isRequired()) {
             $eachElement->setAttrib('required', '');
         }
         /**
          * Removing label from buttons before render.
          */
         if ($eachElement instanceof Zend_Form_Element_Submit) {
             $eachElement->removeDecorator('Label');
         }
         /**
          * No decorators for hidden elements
          */
         if ($eachElement instanceof Zend_Form_Element_Hidden) {
             $eachElement->clearDecorators()->addDecorator('ViewHelper');
         }
         /**
          * No decorators for hash elements
          */
         if ($eachElement instanceof Zend_Form_Element_Hash) {
             $eachElement->clearDecorators()->addDecorator('ViewHelper');
         }
     }
     /**
      * Rendering.
      */
     return parent::render($view);
 }
コード例 #28
0
ファイル: Table.php プロジェクト: ocpyosep78/Booking
 /**
  * Here we go....
  *
  * @return string
  */
 public function deploy()
 {
     if ($this->getSource() === null) {
         throw new Bvb_Grid_Exception('Please Specify your source');
     }
     if ($this->getRequest()->isPost() && $this->getRequest()->getPost('postMassIds' . $this->getGridId())) {
         $this->_redirect($this->getUrl(array('zfmassedit', 'send_', 'gridAction_', 'massActionsAll_')));
         die;
     }
     if ($this->_allowDelete == 1 || $this->_allowEdit == 1 || $this->_allowAdd == 1) {
         $this->setAjax(false);
     }
     $this->_view = $this->getView();
     $this->_placePageAtRecord();
     if (isset($this->_ctrlParams['_zfgid']) && $this->_ctrlParams['_zfgid'] != $this->getGridId()) {
         return;
     }
     parent::deploy();
     $this->_applyConfigOptions(array());
     $this->_processForm();
     if (!$this->_temp['table'] instanceof Bvb_Grid_Template_Table) {
         $this->setTemplate('table', 'table', $this->_templateParams);
     } else {
         $this->setTemplate($this->_temp['table']->options['name'], 'table', $this->_templateParams);
     }
     $images = $this->_temp['table']->images($this->getImagesUrl());
     if ($this->_allowDelete == 1 || $this->_allowEdit == 1 || is_array($this->_detailColumns)) {
         $pkUrl = $this->getSource()->getIdentifierColumns($this->_data['table']);
         $urlFinal = '';
         $failPk = false;
         $pkUrl2 = $pkUrl;
         foreach ($pkUrl as $key => $value) {
             foreach ($this->getFields(true) as $field) {
                 if ($field['field'] == $value) {
                     unset($pkUrl2[$key]);
                     break 2;
                 }
             }
             // throw new Bvb_Grid_Exception("You don't have your primary key in your query.
             // So it's not possible to perform CRUD operations.
             // Change your select object to include your Primary Key: " . implode(';', $pkUrl2));
         }
         foreach ($pkUrl as $value) {
             if (strpos($value, '.') !== false) {
                 $urlFinal .= '{{' . substr($value, strpos($value, '.') + 1) . '}}-';
             } else {
                 $urlFinal .= '{{' . $value . '}}-';
             }
         }
         $urlFinal = trim($urlFinal, '-');
     }
     $removeParams = array('add', 'edit');
     $url = $this->getUrl($removeParams);
     if ($this->_allowEdit == 1 && is_object($this->_crud) && $this->_crud->getBulkEdit() !== true) {
         $urlEdit = $url;
         $this->_actionsUrls['edit'] = "{$urlEdit}/edit" . $this->getGridId() . "/" . $urlFinal;
         if ($this->_crud->getEditColumn() !== false) {
             $this->addExtraColumn(array('position' => $this->getCrudColumnsPosition(), 'name' => 'E', 'decorator' => "<a href=\"" . $this->_actionsUrls['edit'] . "\" > " . $images['edit'] . "</a>", 'edit' => true, 'order' => -2));
         }
     }
     if ($this->_allowDelete && is_object($this->_crud) && $this->_crud->getBulkDelete() !== true) {
         if ($this->_deleteConfirmationPage == true) {
             $this->_actionsUrls['delete'] = "{$url}/delete" . $this->getGridId() . "/{$urlFinal}" . "/detail" . $this->getGridId() . "/1";
             if ($this->_crud->getDeleteColumn() !== false) {
                 $this->addExtraColumn(array('position' => $this->getCrudColumnsPosition(), 'name' => 'D', 'class' => 'gridDeleteColumn', 'decorator' => "<a href=\"" . $this->_actionsUrls['delete'] . "\" > " . $images['delete'] . "</a>", 'delete' => true, 'order' => -3));
             }
         } else {
             $this->_actionsUrls['delete'] = "{$url}/delete/" . $urlFinal;
             if ($this->_crud->getDeleteColumn() !== false) {
                 $this->addExtraColumn(array('position' => $this->getCrudColumnsPosition(), 'name' => 'D', 'class' => 'gridDeleteColumn', 'decorator' => "<a href=\"#\" onclick=\"_" . $this->getGridId() . "confirmDel('" . $this->__('Are you sure?') . "','" . $this->_actionsUrls['delete'] . "');\" > " . $images['delete'] . "</a>", 'delete' => true, 'order' => -3));
             }
         }
     }
     if (is_array($this->_detailColumns) && $this->_isDetail == false) {
         $removeParams = array('add', 'edit');
         $url = $this->getUrl($removeParams);
         $this->_actionsUrls['detail'] = "{$url}/detail" . $this->getGridId() . "/" . $urlFinal;
         if ($this->_showDetailColumn === true) {
             $this->addExtraColumn(array('position' => $this->getCrudColumnsPosition(), 'name' => 'V', 'class' => 'gridDetailColumn', 'decorator' => "<a href=\"" . $this->_actionsUrls['detail'] . "\" >" . $images['detail'] . "</a>", 'detail' => true, 'order' => -1));
         }
     }
     if ($this->_allowAdd == 0 && $this->_allowDelete == 0 && $this->_allowEdit == 0) {
         $this->_gridSession->unsetAll();
     }
     if (!in_array('add' . $this->getGridId(), array_keys($this->getParams())) && !in_array('edit' . $this->getGridId(), array_keys($this->getParams()))) {
         if ($this->_gridSession->correct === null || $this->_gridSession->correct === 0) {
             $this->_gridSession->unsetAll();
         }
     }
     if (strlen($this->_gridSession->message) > 0) {
         $this->_render['message'] = $this->_temp['table']->formMessage($this->_gridSession->messageOk, $this->_gridSession->message);
         $this->_renderDeploy['message'] = $this->_render['message'];
     }
     if ($this->getParam('edit') && $this->_allowEdit == 1 || $this->getParam('add') && $this->_allowAdd == 1 || $this->getInfo("doubleTables") == 1) {
         if ($this->_allowAdd == 1 || $this->_allowEdit == 1) {
             // Remove the unnecessary URL params
             $removeParams = array('filters', 'add');
             $url = $this->getUrl($removeParams);
             $this->_orderFormElements();
             $this->_renderDeploy['form'] = $this->_form->render();
             $this->_render['form'] = $this->_form->render();
             $this->_showsForm = true;
         }
     }
     $showsForm = $this->getWillShow();
     if (isset($showsForm['form']) && $showsForm['form'] == 1 && $this->getInfo("doubleTables") == 1 || !isset($showsForm['form'])) {
         $this->_render['start'] = $this->_temp['table']->globalStart();
         $this->_renderDeploy['start'] = $this->_render['start'];
     }
     if (!$this->getParam('edit') && !$this->getParam('add') || $this->getInfo("doubleTables") == 1) {
         if ($this->_isDetail == true || $this->_deleteConfirmationPage == true && $this->getParam('delete')) {
             $columnsTemp = $this->getSource()->fetchDetail($this->getIdentifierColumnsFromUrl());
             $columns = array();
             foreach ($this->_fields as $orderValue) {
                 $columns[$orderValue] = $columnsTemp[$orderValue];
             }
             $this->_render['detail'] = $this->_temp['table']->globalStart();
             if (count($this->_detailColumns) > 0) {
                 $columns = array_intersect_key($columns, array_flip($this->_detailColumns));
             }
             foreach ($columns as $field => $options) {
                 $this->updateColumn($field, array('hidden' => false));
             }
             $result = array($columns);
             $result = parent::_buildGrid($result);
             $this->_render['detail'] .= $this->_temp['table']->startDetail($this->getDetailViewTitle());
             foreach ($result[0] as $value) {
                 if (!isset($value['field'])) {
                     continue;
                 }
                 if ($value['type'] == 'extraField' && !in_array($value['field'], $this->_detailColumns)) {
                     continue;
                 }
                 $field = $value['field'];
                 if (isset($value['field']) && isset($this->_data['fields'][$value['field']]['title'])) {
                     $field = $this->__($this->_data['fields'][$value['field']]['title']);
                 } else {
                     $field = $this->__(ucwords(str_replace('_', ' ', $field)));
                 }
                 $this->_render['detail'] .= $this->_temp['table']->detail($field, $value['value']);
             }
             if ($this->getParam('delete')) {
                 $localCancel = $this->getUrl(array('detail', 'delete'));
                 $localDelete = $this->getUrl(array('delete', 'detail')) . "/delete" . $this->getGridId() . "/" . str_replace("view", 'delete', $this->getParam('delete'));
                 $buttonRemove = $this->getView()->formButton('delRecordGrid', $this->__('Remove Record'), array('onclick' => "window.location='{$localDelete}'"));
                 $buttonCancel = $this->getView()->formButton('delRecordGrid', $this->__('Cancel'), array('onclick' => "window.location='{$localCancel}'"));
                 $this->_render['detail'] .= $this->_temp['table']->detailDelete($buttonRemove . ' ' . $buttonCancel);
             } else {
                 $this->_render['detail'] .= $this->_temp['table']->detailEnd($this->getUrl(array('detail')), $this->__($this->getDetailViewReturnLabel()));
             }
             $this->_render['detail'] .= $this->_temp['table']->globalEnd();
             $this->_renderDeploy['detail'] = $this->_render['detail'];
         } else {
             $this->_buildGridRender();
         }
     } else {
         $this->_render['start'] = $this->_temp['table']->globalStart();
         $this->_buildGridRender(false);
         $this->_render['end'] = $this->_temp['table']->globalEnd();
     }
     if (isset($showsForm['form']) && $showsForm['form'] == 1 && $this->getInfo("doubleTables") == 1 || !isset($showsForm['form'])) {
         $this->_render['end'] = $this->_temp['table']->globalEnd();
         $this->_renderDeploy['end'] = $this->_render['end'];
     }
     //Build JS
     $this->_printScript();
     $gridId = $this->getGridId();
     if (strlen($gridId) == 0) {
         $gridId = 'grid';
     }
     if ($this->getParam('gridmod') == 'ajax' && $this->getInfo("ajax") !== false || $this->getRequest()->isXmlHttpRequest()) {
         $layout = Zend_Layout::getMvcInstance();
         if ($layout instanceof Zend_Layout) {
             $layout->disableLayout();
         }
         $response = Zend_Controller_Front::getInstance()->getResponse();
         $response->clearBody();
         $response->setBody(implode($this->_renderDeploy))->sendHeaders()->sendResponse();
         die;
     }
     if ($this->getInfo("ajax") !== false) {
         $gridId = $this->getInfo("ajax");
     }
     $grid = "<div id='{$gridId}'>" . implode($this->_renderDeploy) . "</div>";
     if ($this->_gridSession->correct == 1) {
         $this->_gridSession->unsetAll();
     }
     $this->_deploymentContent = $grid;
     return $this;
 }
コード例 #29
0
ファイル: Form.php プロジェクト: jeremykendall/spaz-api
 /**
  * Render form
  *
  * @param  Zend_View_Interface $view
  * @return string
  */
 public function render(Zend_View_Interface $view = null)
 {
     $this->prepare();
     return parent::render($view);
 }
コード例 #30
0
$view = new Zend_View();
$view->setScriptPath(__DIR__);
// Tell all the elements in the form which view to use when rendering
foreach ($form as $item) {
    $item->setView($view);
}
// process or display the form
if (isset($_POST['submit']) && $form->isValid($_POST)) {
    $uploadHandler = new Zend_File_Transfer_Adapter_Http();
    $uploadHandler->setDestination(__DIR__ . '/uploads/');
    try {
        $uploadHandler->receive();
        $data = $form->getValues();
        Zend_Debug::dump($data, 'Form Data:');
        $fullPath = $uploadHandler->getFileName('file');
        $size = $uploadHandler->getFileSize('file');
        $mimeType = $uploadHandler->getMimeType('file');
        $fileInfo = pathinfo($fullPath);
        $name = $fileInfo['basename'] . '<br>';
        // rename the file for security purpose
        $newName = 'RM_' . time() . '_' . $fileInfo['basename'];
        $fullFilePath = __DIR__ . '/uploads/' . $newName;
        $filterFileRename = new Zend_Filter_File_Rename(array('target' => $fullFilePath, 'overwrite' => true));
        $filterFileRename->filter($fullPath);
        echo 'thanks <br />';
    } catch (Zend_File_Transfer_Exception $e) {
        echo $e->getMessage();
    }
} else {
    echo $form->render($view);
}