Ejemplo n.º 1
0
 protected function getDynamicForm($id, $locale, $className = 'Zend_Form')
 {
     if (file_exists(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/main_" . $id . ".json")) {
         $config = new Zend_Config_Json(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/main_" . $id . ".json");
         $datas = $config->toArray();
         $builder = new Formbuilder_Builder();
         $builder->setDatas($datas);
         $builder->setLocale($locale);
         $array = $builder->buildDynamicForm();
         $form = $this->createInstance($array, $className);
         $this->initTranslation($form, $id, $locale);
         return $form;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 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();
 }