/** * Do detection of content type, and retrieve parameters from raw body if * present * * @return void */ protected function _loadParams() { $request = $this->getRequest(); $contentType = $request->getHeader('Content-Type'); $rawBody = $request->getRawBody(); if (!$rawBody) { return; } switch (true) { case strstr($contentType, 'application/json'): $this->setBodyParams(Zend_Json::decode($rawBody)); break; case strstr($contentType, 'application/xml'): $config = new Zend_Config_Xml($rawBody); $this->setBodyParams($config->toArray()); break; default: if ($request->isPut()) { parse_str($rawBody, $params); $this->setBodyParams($params); } break; } self::$_paramsLoaded = true; }
/** * */ public function __construct($object = null) { $this->_object = $object; if (file_exists('/var/www/html/MaisVenda/cron.php')) { $this->_documentRoot = '/var/www/html/MaisVenda'; } else { $this->_documentRoot = str_replace("\\", "/", realpath('.')); } /** * Busca as configurações do ambiente PHP */ $filenameConfig = $this->_documentRoot . "/job/Config.xml"; if (file_exists($filenameConfig)) { $xml = file_get_contents($filenameConfig); $config = new Zend_Config_Xml($xml); $this->_config = $config->toArray(); } if (!isset($this->_config['Config']['Path'])) { $this->_config['Config']['Path'] = $this->_documentRoot . '/job/data'; } if (!isset($this->_config['Config']['OperationSystem'])) { $this->_config['Config']['OperationSystem'] = 'Linux'; } if (!isset($this->_config['Config']['PathPhpExe'])) { $this->_config['Config']['PathPhpExe'] = 'php'; } if (!isset($this->_config['Config']['PathPhpExe'])) { $this->_config['Config']['PathPhpIni'] = '/etc/php.ini'; } $this->_path = $this->_config['Config']['Path']; $this->_path = str_replace('\\', '/', $this->_path) . '/'; //$this->_clearFiles(); }
/** * Склеивает все файлы в единый конфиг, попутно задействуя кеш * * @param string $path Путь к папке с файлами * @param string $env APPLICATION_ENV * @return array */ public static function load($path, $env) { $masterfiles = array(); if (file_exists($path . 'application.xml')) { $handler = opendir($path); while (($file = readdir($handler)) !== false) { if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'xml') { $masterfiles[] = $path . $file; } } sort($masterfiles); closedir($handler); $cache = self::getCache($masterfiles); $cacheid = md5($path); if ($cache->test($cacheid)) { return $cache->load($cacheid); } else { $config = new Zend_Config_Xml($path . 'application.xml', $env, array('allowModifications' => true)); foreach ($masterfiles as $file) { if ($file != 'application.xml') { $config->merge(new Zend_Config_Xml($file, $env)); } } $config = $config->toArray(); $cache->save($config, $cacheid); return $config; } } return false; }
/** * @param String $rawXmlResponse The response that comes back directly from the AT SOAP service. * @param String $methodName Name of the SOAP method called. */ public function __construct($rawXmlResponse, $methodName) { $resultKey = $methodName . 'Result'; $xml = $rawXmlResponse->{$resultKey}; $xmlParser = new Zend_Config_Xml($xml); $resultArray = $xmlParser->toArray(); $this->exchangeArray($resultArray); }
public static function getConfig() { if (!self::$pluginConfig) { $xml = new \Zend_Config_Xml(self::getConfigFile()); self::$pluginConfig = $xml->toArray(); } return self::$pluginConfig; }
function navbarMainMenu() { $config = new Zend_Config_Xml(APPLICATION_PATH . '/modules/admin/configs/navbar.xml', 'main'); $container = new Zend_Navigation(); $container->setPages($config->toArray()); $view = new Zend_View(); echo $view->navigation($container)->menu()->setUlClass('nav navbar-nav')->setMaxDepth(0)->render(); }
function sidebarMenu() { $config = new Zend_Config_Xml(APPLICATION_PATH . '/modules/admin/configs/sidebar.xml', 'sidebar'); $container = new Zend_Navigation(); $container->setPages($config->toArray()); $view = new Zend_View(); echo $view->navigation($container)->menu()->setMaxDepth(1)->render(); }
public function __construct() { try { $config = new Zend_Config_Xml(SPHINX_VAR . DIRECTORY_SEPARATOR . "config.xml"); $this->config = $config->toArray(); } catch (Zend_Config_Exception $e) { $this->config = $this->defaults; } }
public function country($elementName = "countryId", $selectedValue) { $config = new Zend_Config_Xml(CONFIG_PATH . '/countries.xml', 'countries'); $aCountries = array(); foreach ($config->get('country') as $country) { $aCountries[$country->alpha2] = $country->name; } return $this->formSelect($elementName, $selectedValue, null, $aCountries); }
public function formSelectCountries($elementName = "countryId", $selectedValue) { $config = new Zend_Config_Xml(KUTU_ROOT_DIR . '/application/configs/countries.xml', 'countries'); $aCountries = array(); foreach ($config->get('country') as $country) { //echo $country->name." ($country->alpha2)<br>"; $aCountries[$country->alpha2] = $country->name; } return $this->formSelect($elementName, $selectedValue, null, $aCountries); }
protected function _initNavigation() { $this->bootstrap('view'); $this->bootstrap('frontController'); $this->bootstrap('acl'); $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav'); $resource = new Zend_Application_Resource_Navigation(array('pages' => $config->toArray())); $resource->setBootstrap($this); return $resource->init(); }
public function unsetClassmap() { $classmapXml = PIMCORE_CONFIGURATION_DIRECTORY . '/classmap.xml'; try { $conf = new Zend_Config_Xml($classmapXml); $classmap = $conf->toArray(); unset($classmap['Object_BlogEntry']); $writer = new Zend_Config_Writer_Xml(array('config' => new Zend_Config($classmap), 'filename' => $classmapXml)); $writer->write(); } catch (Exception $e) { } }
/** * (non-PHPdoc) * * @see Zend_Auth_Adapter_Interface::authenticate() */ public function authenticate() { $users = new Zend_Config_Xml(APPLICATION_PATH . "/modules/utils/configs/auth.xml"); foreach ($users->toArray() as $user) { if ($user['email'] == $this->user) { if ($user['password'] == sha1($this->password)) { return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, (object) $user); } else { return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $user); } } } return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $user); }
function navbarRightMenu() { $config = new Zend_Config_Xml(APPLICATION_PATH . '/modules/admin/configs/navbar.xml', 'nav'); $container = new Zend_Navigation(); $container->setPages($config->toArray()); /*$container->addPage( array( 'label' => Zend_Auth::getInstance()->getIdentity()->email, 'title' => 'Dashboard', 'uri' => '/admin/' ));*/ $view = new Zend_View(); echo $view->navigation($container)->menu()->setUlClass('dropdown-menu')->render(); }
function databaseDetails() { switch ($this->whichShoppingCart()) { case 'prestashop': require_once $this->shoppingCartRoot() . '/config/settings.inc.php'; return array('dbname' => _DB_NAME_, 'username' => _DB_USER_, 'password' => _DB_PASSWD_, 'product_table' => 'ps_product', 'product_sku_field' => 'reference', 'product_id_field' => 'id_product'); case 'magento': $config = new \Zend_Config_Xml($this->shoppingCartRoot() . 'app/etc/local.xml'); $dbConfig = $config->toArray(); $dbinfo = $dbConfig['global']['resources']['default_setup']['connection']; $dbinfo = $dbinfo + array('product_table' => 'catalog_product_entity', 'product_sku_field' => 'sku', 'product_id_field' => 'entity_id'); return $dbinfo; default: throw new \Exception('Unable to detect shopping cart'); } }
/** * Prepares the environment before running a test * */ protected function setUp() { // read navigation config $this->_files = dirname(__FILE__) . '/_files/navigation'; $config = new Zend_Config_Xml($this->_files . '/navigation.xml'); // create nav structures $this->_nav1 = new Zym_Navigation($config->get('nav_test1')); $this->_nav2 = new Zym_Navigation($config->get('nav_test2')); // create view $view = new Zend_View(); $view->addHelperPath('Zym/View/Helper', 'Zym_View_Helper'); // create helper $this->_helper = new $this->_helperName(); $this->_helper->setView($view); // set nav1 in helper as default $this->_helper->setNavigation($this->_nav1); }
/** * creates a class called "unittest" containing all Object_Class_Data Types currently available. * @return void * @depends testFieldCollectionCreate */ public function testClassCreate() { $conf = new Zend_Config_Xml(TESTS_PATH . "/resources/objects/class-import.xml"); $importData = $conf->toArray(); $layout = Object_Class_Service::generateLayoutTreeFromArray($importData["layoutDefinitions"]); $class = Object_Class::create(); $class->setName("unittest"); $class->setUserOwner(1); $class->save(); $id = $class->getId(); $this->assertTrue($id > 0); $class = Object_Class::getById($id); $class->setLayoutDefinitions($layout); $class->setUserModification(1); $class->setModificationDate(time()); $class->save(); }
/** * @static * @return mixed|Zend_Config */ public static function getWebsiteConfig() { try { $config = Zend_Registry::get("pimcore_config_website"); } catch (Exception $e) { $cacheKey = "website_config"; if (!($config = Pimcore_Model_Cache::load($cacheKey))) { $websiteSettingFile = PIMCORE_CONFIGURATION_DIRECTORY . "/website.xml"; $settingsArray = array(); if (is_file($websiteSettingFile)) { $rawConfig = new Zend_Config_Xml($websiteSettingFile); $arrayData = $rawConfig->toArray(); foreach ($arrayData as $key => $value) { $s = null; if ($value["type"] == "document") { $s = Document::getByPath($value["data"]); } else { if ($value["type"] == "asset") { $s = Asset::getByPath($value["data"]); } else { if ($value["type"] == "object") { $s = Object_Abstract::getByPath($value["data"]); } else { if ($value["type"] == "bool") { $s = (bool) $value["data"]; } else { if ($value["type"] == "text") { $s = (string) $value["data"]; } } } } } if ($s) { $settingsArray[$key] = $s; } } } $config = new Zend_Config($settingsArray, true); Pimcore_Model_Cache::save($config, $cacheKey, array("websiteconfig", "system", "config"), null, 998); } self::setWebsiteConfig($config); } return $config; }
private function _loadConfig() { $coreConfig = new Zend_Config_Xml($this->dir . 'configs/core.xml', 'core', true); if ($coreConfig->mode == 'staging') { $config = new Zend_Config_Xml($this->dir . 'configs/core.xml', $coreConfig->mode, true); $config->merge($coreConfig); } else { /* załadowanie konfigiracji z cache'a */ if (!($config = $this->_cache->load('config'))) { $config = new Zend_Config_Xml($this->dir . 'configs/core.xml', $coreConfig->mode, true); $config->merge($coreConfig); $this->_cache->save($config, 'config', array('config')); } } $this->_config = $config; $this->_config->serviceDir = substr(__FILE__, 0, strpos(__FILE__, 'core' . DIRECTORY_SEPARATOR . 'Bootstrap.php')); Zend_Registry::set('config', $this->_config); }
/** * Load the config file * * @param string $fullpath * @return array */ protected function _loadOptions($fullpath) { if (file_exists($fullpath)) { switch (substr(trim(strtolower($fullpath)), -3)) { case 'ini': $cfg = new Zend_Config_Ini($fullpath, $this->getBootstrap()->getEnvironment()); break; case 'xml': $cfg = new Zend_Config_Xml($fullpath, $this->getBootstrap()->getEnvironment()); break; default: throw new Zend_Config_Exception('Invalid format for config file'); break; } } else { throw new Zend_Application_Resource_Exception('File does not exist'); } return $cfg->toArray(); }
public function saveAction() { $this->_helper->layout()->setLayout("nolayout"); $modelname = $this->_request->getParam("model", 'Eau_Model_Company'); $suffixname = "model-config.xml"; $modelnameAr = explode("_", $modelname); $packet = strtolower($modelnameAr[0]); $configfile = $packet . "-" . $suffixname; $config = new Zend_Config_Xml(CONFIG_PATH . "{$configfile}", null, true); $allfield = array(); $arrayKey = array(); $i = 0; foreach (App_Model_Config::get($modelname)->getProperties() as $element) { $allfield[] = $element->name; $arrayKey[$element->name] = $i++; } $config->production->classes->{$modelname}->text = "2"; $props = $config->production->classes->{$modelname}->prop->toArray(); foreach ($_POST as $key => $value) { list($field, $property) = explode("_", $key); if (in_array($field, $allfield)) { $index = $arrayKey[$field]; foreach ($props as $key => $prop) { if ($prop['name'] == $field) { $props[$key][$property] = $value; //$config->classes->{$modelname}->props->$field->$property = $value; } //echo $prop->name,"<br/>"; } //$config->classes->{$modelname}->prop->$property = $value; } } $config->production->classes->{$modelname}->prop = $props; $config->staging = array(); $config->setExtend('staging', 'production'); $config->development = array(); $config->setExtend('development', 'production'); $writer = new Zend_Config_Writer_Xml(); $writer->write(CONFIG_PATH . $configfile, $config); $this->render('blank', null, true); }
/** * @return void */ public function load() { $configXml = new \Zend_Config_Xml($this->getConfigFile()); $configArray = $configXml->toArray(); foreach ($configArray as $key => $value) { $setter = "set" . ucfirst($key); if (method_exists($this, $setter)) { $this->{$setter}($value); } } return true; }
/** * Initializes the configuration. * * @param string $xml File or XML text representing the configuration. * @param string|null $section Which section of the configuration to load. */ public function __construct($xml, $section = null) { parent::__construct($xml, $section, true); if (!isset($this->paths)) { $this->paths = new Zend_Config(array(), true); } $this->paths->application = realpath(dirname(__FILE__) . '/../../..'); $this->paths->data = realpath($this->paths->application . '/data'); $this->paths->templates = realpath($this->paths->data . '/themes'); $this->paths->themes = $this->paths->templates; $this->mergeTemplateConfigurations(); }
/** * Do detection of content type, and retrieve parameters from raw body if present * * @return void */ public function init() { // Allows for \App\Engine\Exception to be thrown AND caught by default error controller // For full explanation, see: http://stackoverflow.com/questions/4076578/do-action-helpers-with-hooks-to-auto-run-throw-exceptions-or-not if ($this->getRequest()->getActionName() == 'error' && $this->getRequest()->getControllerName() == 'error') { return; } $request = $this->getRequest(); $contentType = $request->getHeader('Content-Type'); $rawBody = $request->getRawBody(); if (!$rawBody) { return; } switch (true) { case stristr($contentType, 'application/json'): $data = Zend_Json::decode($rawBody); $this->setBodyParams($data['request']); break; case stristr($contentType, 'application/xml'): try { $config = new Zend_Config_Xml($rawBody); } catch (Exception $e) { $error = substr($e, 0, stripos($e, "\n")); throw new \App\Engine\Exception('Malformed XML: ' . $error, 400); } $this->setBodyParams($config->toArray()); break; case stristr($contentType, 'application/x-www-form-urlencoded'): if ($request->isPut()) { parse_str($rawBody, $params); $this->setBodyParams($params); } break; default: throw new \App\Engine\Exception('Unsupported Content-Type provided.', 501); // http://trac.agavi.org/browser/tags/1.0.2/src/request/AgaviWebRequest.class.php // use above to possibly handle files sent via post/put break; } }
/** * Retourne un tableau formaté des caractéristiques d'un article * * @param string $detailsXml Détails de l'article dans le format XML * @return array() Détail de l'article (ensemble des caractéristiques dans * un tableau formaté */ public static function formatDetails($detailsXml) { // initialisation $details = array(); $keepTrying = true; $i = 1; $detailsXml = '<?xml version="1.0" encoding="ISO-8859-1"?>' . html_entity_decode($detailsXml); // on charge les librairies de Zend Framework ProjectConfiguration::registerZend(); // on format les details de l'article do { try { // on recupere une à une les caractéristiques de l'article $caract = new Zend_Config_Xml($detailsXml, 'caract_' . $i); $details[] = $caract->toArray(); $i++; } catch (Zend_Config_Exception $e) { $keepTrying = false; } } while ($keepTrying); return $details; }
/** * Prepares the environment before running a test * */ protected function setUp() { $cwd = dirname(__FILE__); // read navigation config $this->_files = $cwd . '/_files'; $config = new Zend_Config_Xml($this->_files . '/navigation.xml'); // setup containers from config $this->_nav1 = new Zend_Navigation($config->get('nav_test1')); $this->_nav2 = new Zend_Navigation($config->get('nav_test2')); // setup view $view = new Zend_View(); $view->setScriptPath($cwd . '/_files/mvc/views'); // setup front $front = Zend_Controller_Front::getInstance(); $this->_oldControllerDir = $front->getControllerDirectory('test'); $front->setControllerDirectory($cwd . '/_files/mvc/controllers'); // create helper $this->_helper = new $this->_helperName(); $this->_helper->setView($view); // set nav1 in helper as default $this->_helper->setContainer($this->_nav1); }
/** * @param array $config */ public function config($config = array()) { $settings = null; // check for an initial configuration template // used eg. by the demo installer $configTemplatePath = PIMCORE_CONFIGURATION_DIRECTORY . "/system.xml.template"; if (file_exists($configTemplatePath)) { try { $configTemplate = new \Zend_Config_Xml($configTemplatePath); if ($configTemplate->general) { // check if the template contains a valid configuration $settings = $configTemplate->toArray(); // unset database configuration unset($settings["database"]["params"]["host"]); unset($settings["database"]["params"]["port"]); } } catch (\Exception $e) { } } // set default configuration if no template is present if (!$settings) { // write configuration file $settings = array("general" => array("timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "debugloglevel" => "debug", "custom_php_logfile" => "1", "extjs6" => "1"), "database" => array("adapter" => "Mysqli", "params" => array("username" => "root", "password" => "", "dbname" => "")), "documents" => array("versions" => array("steps" => "10"), "default_controller" => "default", "default_action" => "default", "error_pages" => array("default" => "/"), "createredirectwhenmoved" => "", "allowtrailingslash" => "no", "allowcapitals" => "no", "generatepreview" => "1"), "objects" => array("versions" => array("steps" => "10")), "assets" => array("versions" => array("steps" => "10")), "services" => array(), "cache" => array("excludeCookie" => ""), "httpclient" => array("adapter" => "Zend_Http_Client_Adapter_Socket")); } $settings = array_replace_recursive($settings, $config); // convert all special characters to their entities so the xml writer can put it into the file $settings = array_htmlspecialchars($settings); // create initial /website/var folder structure // @TODO: should use values out of startup.php (Constants) $varFolders = array("areas", "assets", "backup", "cache", "classes", "config", "email", "log", "plugins", "recyclebin", "search", "system", "tmp", "versions", "webdav"); foreach ($varFolders as $folder) { \Pimcore\File::mkdir(PIMCORE_WEBSITE_VAR . "/" . $folder); } $config = new \Zend_Config($settings, true); $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM)); $writer->write(); }
/** * return template filename if set * * @return string|NULL */ protected function _getTemplateFilename() { $templateFile = $this->_config->get('template', NULL); if ($templateFile !== NULL) { // check if template file has absolute path if (strpos($templateFile, '/') !== 0) { $templateFile = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . $this->_applicationName . DIRECTORY_SEPARATOR . 'Export' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $templateFile; } if (file_exists($templateFile)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Using template file "' . $templateFile . '" for ' . $this->_modelName . ' export.'); } else { throw new Tinebase_Exception_NotFound('Template file ' . $templateFile . ' not found'); } } return $templateFile; }
/** * 取得指定游戏的配置信息 * * @param integer $gameType * @param string $section * @return array * @throws ZtChart_Model_Identification_Exception */ public function getInfo($gameType, $section = null) { while ($this->_config->valid()) { foreach ($this->_config->current()->TypePara as $typePara) { if ($gameType == $typePara->Value) { $info = $this->_config->current()->toArray(); if (!empty($section)) { if (!array_key_exists($section, $info)) { throw new ZtChart_Model_Identification_Exception("The section {$section} is not exist."); } $info = $info[$section]; } return $info; } } $this->_config->next(); } throw new ZtChart_Model_Identification_Exception("The gametype is not exist."); }
public function removeClassmap($from) { $classmapXml = PIMCORE_CONFIGURATION_DIRECTORY . '/classmap.xml'; try { $conf = new \Zend_Config_Xml($classmapXml); $classmap = $conf->toArray(); unset($classmap[$from]); $writer = new \Zend_Config_Writer_Xml(array('config' => new \Zend_Config($classmap), 'filename' => $classmapXml)); $writer->write(); } catch (\Exception $e) { } }