/** * Returns options configuration from file. * * @return array */ public function getOptions() { if (is_null($this->_options)) { $this->_options = array(); $config = new Zend_Config_Json(APPLICATION_PATH . self::OPTIONS_CONFIG_FILE); $options = $config->toArray(); foreach ($options as $name => $parameters) { $this->_options[$name] = new Admin_Model_Option($name, $parameters); } } return $this->_options; }
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; } }
public function removeDocuments() { $file = sprintf('%s/documents.json', $this->baseDir); $docs = new \Zend_Config_Json($file); $root = reset($docs->toArray()); $doc = Document::getByPath('/' . ltrim($root['parent'] . '/' . $root['key'], '/')); if ($doc) { $doc->delete(); } }
public function testWriteAndReadOriginalFile() { $config = new Zend_Config_Json(dirname(__FILE__) . '/files/allsections.json', null, array('skip_extends' => true)); $writer = new Zend_Config_Writer_Json(array('config' => $config, 'filename' => $this->_tempName)); $writer->write(); $config = new Zend_Config_Json($this->_tempName, null); $this->assertEquals('multi', $config->staging->one->two->three, var_export($config->toArray(), 1)); $config = new Zend_Config_Json($this->_tempName, null, array('skip_extends' => true)); $this->assertFalse(isset($config->staging->one)); }
private function _applySql($themeName) { try { $dataJson = new Zend_Config_Json($this->_websiteHelper->getPath() . $this->_themesConfig['path'] . $themeName . '/' . self::THEME_DATA_FILE); } catch (Exception $e) { error_log($e->getMessage()); return false; } try { /** * @var $dbAdapter Zend_Db_Adapter_Abstract */ $dbAdapter = Zend_Registry::get('dbAdapter'); $dbAdapter->beginTransaction(); $dbAdapter->query('SET foreign_key_checks = 0;'); $themeData = $dataJson->toArray(); //clean optimize table if (array_key_exists('page', $themeData)) { $dbAdapter->query('DELETE FROM `optimized`;'); } if (!empty($themeData)) { foreach ($themeData as $table => $data) { if (empty($data)) { continue; } else { $dbAdapter->delete($table); } foreach ($data as $row) { try { $dbAdapter->insert($table, $row); } catch (Exception $exc) { Tools_System_Tools::debugMode() && error_log($exc->getMessage()); continue; } } } } $dbAdapter->query('SET foreign_key_checks = 1;'); $dbAdapter->commit(); } catch (Exception $e) { Tools_System_Tools::debugMode() && error_log($e->getMessage()); $dbAdapter->rollBack(); return false; } }
public function getimportAction() { $id = $this->_getParam("id"); if (file_exists(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/import/import_" . $id)) { $config = new Zend_Config_Json(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/import/import_" . $id); unlink(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/import/import_" . $id); $data = $config->toArray(); unset($data["name"]); unset($data["id"]); $this->_helper->json($data); } else { $this->_helper->json(null); } }