public function saveAction()
 {
     $id = $this->_getParam("id");
     $table = new Formbuilder_Formbuilder();
     $name = $table->getName($id);
     $configuration = Zend_Json::decode($this->_getParam("configuration"));
     $values = Zend_Json::decode($this->_getParam("values"));
     if ($values["name"] != $name) {
         $values["name"] = $this->correctClassname($values["name"]);
         $table = new Formbuilder_Formbuilder();
         $table->rename($id, $values["name"]);
     }
     if (!is_dir(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/")) {
         mkdir(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/");
     }
     if (file_exists(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/main_" . $id . ".json")) {
         unlink(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/main_" . $id . ".json");
     }
     $settings = $values;
     $settings["mainDefinitions"] = $configuration;
     $config = new Zend_Config($settings, true);
     $writer = new Zend_Config_Writer_Json(array("config" => $config, "filename" => PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/main_" . $id . ".json"));
     $writer->write();
     $builder = new Formbuilder_Builder();
     $builder->setDatas($config->toArray());
     $builder->buildForm($id);
     $this->removeViewRenderer();
 }
Пример #2
0
 /**
  * If $dynamic equal true, the form form is completly rebuild. It is useful if you need to interact to the form with hooks.
  *
  * @param string $name
  * @param string $locale
  * @param boolean $dynamic
  * @param string Custom form class
  * @return Zend_Form
  */
 public function getForm($name, $locale = null, $dynamic = false, $formClass = null)
 {
     $this->getLanguages();
     $table = new Formbuilder_Formbuilder();
     $id = $table->getIdByName($name);
     if (is_numeric($id) == true) {
         $class = $formClass ?: $this->getFormClass();
         if ($dynamic == false) {
             $form = $this->getStaticForm($id, $locale, $class);
         } else {
             $form = $this->getDynamicForm($id, $locale, $class);
         }
         return $form;
     } else {
         return false;
     }
 }
Пример #3
0
 /**
  * If $dynamic equal true, the form form is completly rebuild. It is useful if you need to interact to the form with hooks.
  *
  * @param string $name
  * @param string $locale
  * @param boolean $dynamic
  * @param string Custom form class
  * @return Zend_Form
  */
 public function getForm($name, $locale = null, $dynamic = false, $formClass = null)
 {
     $this->getLanguages();
     $table = new Formbuilder_Formbuilder();
     $id = $table->getIdByName($name);
     if (is_numeric($id) == true) {
         $class = $formClass ?: $this->getFormClass();
         if ($dynamic == false) {
             $form = $this->getStaticForm($id, $locale, $class);
         } else {
             $form = $this->getDynamicForm($id, $locale, $class);
         }
         //correctly set recaptcha to https if request is over https
         if (Zend_Controller_Front::getInstance()->getRequest()->isSecure()) {
             /**@var Zend_Form $form */
             $elements = $form->getElements();
             foreach ($elements as $element) {
                 if (get_class($element) == 'Zend_Form_Element_Captcha') {
                     /**@var  Zend_Form_Element_Captcha $element */
                     $cap = $element->getCaptcha();
                     $cap->getService()->setParams(array('ssl' => true));
                 }
             }
         }
         return $form;
     } else {
         return false;
     }
 }