/** * Initialize plugins hook system */ function init_plugins() { include APPPATH . 'config/cache.php'; $feEngine = $config['plugins_frontend_engine']; $feOptions = $config['plugins_frontend']; $beEngine = $config['plugins_backend_engine']; $beOptions = $config['plugins_backend']; if (isset($beOptions['cache_dir']) && !file_exists($beOptions['cache_dir'])) { mkdir($beOptions['cache_dir']); chmod($beOptions['cache_dir'], 0777); } $cache = Zend_Cache::factory($feEngine, $beEngine, $feOptions, $beOptions); $pluginsConfigArray = $cache->load('pluginsConfig'); if (!$pluginsConfigArray) { $pluginsConfigArray = array(); $pluginConfDirHandler = opendir(APPPATH . 'config/plugins'); while (false !== ($pluginConfigFile = readdir($pluginConfDirHandler))) { if (preg_match('~^.*?\\.ini$~si', $pluginConfigFile)) { try { $pluginConfig = new Zend_Config_Ini(APPPATH . 'config/plugins/' . $pluginConfigFile, 'plugins'); $pluginsConfigArray = array_merge_recursive($pluginsConfigArray, $pluginConfig->toArray()); } catch (Exception $e) { } } } closedir($pluginConfDirHandler); $cache->save($pluginsConfigArray, 'pluginsConfig'); } Zend_Registry::getInstance()->set('pluginsConfig', new Zend_Config($pluginsConfigArray)); }
function loadApplicationConfig() { require_once 'Zend/Config/Ini.php'; $default = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV, array('allowModifications' => true)); $options = $default->toArray(); return $options; }
/** * * @return Zend_Application */ public static function getApplication() { $application = new Zend_Application(APPLICATION_ENV); $applicationini = new Zend_Config_Ini(APPLICATION_PATH . "/configs/application.ini", APPLICATION_ENV); $options = $applicationini->toArray(); foreach (self::$_ini as $value) { $iniFile = APPLICATION_PATH . self::$_pathConfig . $value; if (is_readable($iniFile)) { $config = new Zend_Config_Ini($iniFile); $options = $application->mergeOptions($options, $config->toArray()); } else { throw new Zend_Exception('error en la configuracion de los .ini'); } } // foreach (self::$_ini as $value) { // $iniFile = APPLICATION_PATH . self::$_pathConfig . $value; // // if (is_readable($iniFile)) { // $config = new Zend_Config_Ini($iniFile); // $options = $application->mergeOptions($options, // $config->toArray()); // } else { // throw new Zend_Exception('error en la configuracion de los .ini'); // } // } Zend_Registry::set('config', $options); $a = $application->setOptions($options); return $application; }
/** * Initialize module config options * * @return void */ protected function _initConfig() { // load ini file $config = new Zend_Config_Ini(MODULES_PATH . '/' . $this->_module['folder'] . '/configs/module.ini', APPLICATION_ENV); $this->setOptions($config->toArray()); Zend_Registry::set($this->_module['folder'] . 'Config', $this->_config = $config); }
protected function _initSession() { $configSession = new Zend_Config_Ini(APPLICATION_PATH . '/configs/session.ini', APPLICATION_ENV); if (!$this->_request->isInstalling()) { $config = array('name' => 'session', 'primary' => 'session_id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime', 'lifetime' => $configSession->gc_maxlifetime); Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config)); } if (!$this->_request->isInstalling() or is_writable(Core_Model_Directory::getSessionDirectory(true))) { $types = array(); $options = $configSession->toArray(); if (isset($options['types'])) { $types = $options['types']; unset($options['types']); } Zend_Session::start($options); $session_type = $this->_request->isApplication() ? 'mobile' : 'front'; $session = new Core_Model_Session($session_type); foreach ($types as $type => $class) { $session->addType($type, $class); } $language_session = new Core_Model_Session('language'); if (!$language_session->current_language) { $language_session->current_language = null; } Core_Model_Language::setSession($language_session); Core_View_Default::setSession($session); Core_Controller_Default::setSession($session); } }
protected function _initSession() { $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/sessions.ini', 'development'); Zend_Session::setOptions($config->toArray()); // start session Zend_Session::start(); }
private static function getRecipients($docid, $rec_num = -1) { $db = Zend_Db_Table_Abstract::getDefaultAdapter(); $sql = "select AV.VAL\r\nfrom V_ADD_VALUES AV\r\nwhere AV.NODEID = ?\r\nand AV.FIELDNAME = '_ADD_RECIPIENTS'"; $rec = $db->fetchOne($sql, $docid); $rec = new Zend_Config_Ini('data://,' . $rec); return $rec->toArray(); }
/** * Save all values from config to ZendRegistry */ protected function _initLocalConfigs() { $allconfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/config.ini'); $envconfig = $allconfig->toArray(); $registry = new Zend_Registry($envconfig[APPLICATION_ENV], ArrayObject::ARRAY_AS_PROPS); foreach ($registry as $key => $value) { Zend_Registry::set($key, $value); } }
protected function _initConfig() { $config = new Zend_Config($this->getOptions(), true); Zend_Registry::set('config', $config); // TODO faut-il utiliser les sessions ou les registres ? $configSession = new Zend_Config_Ini(__DIR__ . '/configs/session.ini', APPLICATION_ENV); Zend_Session::setOptions($configSession->toArray()); return $config; }
public function addNewsAction() { $options = $this->getInvokeArg('bootstrap')->getOptions(); $configDir = $options['path']['configs']; $config = new Zend_Config_Ini($configDir . '/agregator.ini', 'korespondent'); $data = $config->toArray(); $news = new Spider_News($data); $news->setLogger($this->getLog()); $news->process(); }
public function load($file, $type = null) { $file = $this->locator->locate($file); $type = $type ?: pathinfo($file, PATHINFO_EXTENSION); switch ($type) { case 'php': $data = (require $file); $config = new \Zend_Config($data); break; case 'xml': $config = new \Zend_Config_Xml($file); break; case 'ini': $config = new \Zend_Config_Ini($file, "routes"); break; } $data = $config->toArray(); if (isset($data['routes'])) { $data = $data['routes']; } $collection = new RouteCollection(); foreach ($data as $routeName => $config) { if (isset($config['type']) && $config['type'] == "Zend_Controller_Router_Route_Regex") { throw new \InvalidArgumentException("Not supported"); } if (!isset($config['reqs'])) { $config['reqs'] = array(); } if (!isset($config['defaults'])) { $config['defaults'] = array(); } if (!isset($config['options'])) { $config['options'] = array(); } if (!isset($config['defaults']['module'])) { // TODO: DefaultModule config $config['defaults']['module'] = 'Default'; } if (!isset($config['defaults']['controller'])) { $config['defaults']['controller'] = 'Index'; } if (!isset($config['defaults']['action'])) { $config['defaults']['action'] = 'index'; } $config['defaults']['_controller'] = sprintf('%sBundle:%s:%s', $config['defaults']['module'], $config['defaults']['controller'], $config['defaults']['action']); if (preg_match_all('(:([^/]+)+)', $config['route'], $matches)) { for ($i = 0; $i < count($matches[0]); $i++) { $config['route'] = str_replace($matches[0][$i], "{" . $matches[1][$i] . "}", $config['route']); } } $route = new Route($config['route'], $config['defaults'], $config['reqs'], $config['options']); $collection->add($routeName, $route); } return $collection; }
/** * * @throws ZendT_Exception */ private function _init() { $_config = new Zend_Config_Ini($this->_configIni, APPLICATION_ENV); $this->_configs = $_config->toArray(); if ($this->_documentRoot == '') { throw new ZendT_Exception('"documentRoot" não configurado!'); } if ($this->_object == '') { throw new ZendT_Exception('"object" não informado!'); } }
private function getModuleConfig($moduleName) { $aConfig = array(); try { $config = new Zend_Config_Ini(APPLICATION_PATH . DS . 'configs' . DS . $moduleName . DS . 'view.ini', APPLICATION_ENV); $aConfig = $config->toArray(); } catch (Zend_Config_Exception $e) { Zend_Debug::dump($e->getMessage()); } return $aConfig; }
protected function _findModules() { $moduleInfoFiles = (array) glob(MODULES_PATH . '/*/info.ini') + (array) glob(HEAP_PATH . '/*/info.ini'); sort($moduleInfoFiles); $return = array(); $returnDeveloper = array(); foreach ($moduleInfoFiles as $row) { $config = new Zend_Config_Ini($row); preg_match('|.*/(.*)/info.ini$|i', $row, $matches); /* регистрируем плагин вывода панели администрирования на frontend */ if (Zetta_Acl::getInstance()->isAllowed('admin_module_' . System_String::StrToLower($matches[1]), 'deny')) { if (false == $config->developer) { $return[] = array_merge($config->toArray(), array('module' => $matches[1])); } else { $returnDeveloper[] = array_merge($config->toArray(), array('module' => $matches[1])); } } } return array($return, $returnDeveloper); }
protected function _bootstrap() { //Now let's parse the module specific configuration //Path might change however this is probably the one you won't ever need to change... //And also don't forget to use the current staging environment by sending the APP_ENV parameter to the Zend_Config $_conf = new Zend_Config_Ini(APPLICATION_PATH . "/modules/" . strtolower($this->getModuleName()) . "/config/application.ini", APPLICATION_ENV); $this->_options = array_merge($this->_options, $_conf->toArray()); //Let's merge the both arrays so that we can use them together... parent::_bootstrap(); //Well our custom bootstrap logic should end with the actual bootstrapping, now that we have merged both configs, we can go on... }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->db = \Zend_Db::factory('pdo_sqlite', array('dbname' => ':memory:')); \Zend_Registry::set('db', $this->db); $settings = new \Zend_Config_Ini(GEMS_ROOT_DIR . '/configs/application.example.ini', APPLICATION_ENV); $sa = $settings->toArray(); $this->loader = new \Gems_Loader(\Zend_Registry::getInstance(), $sa['loaderDirs']); \Zend_Registry::set('loader', $this->loader); $this->tracker = $this->loader->getTracker(); \Zend_Registry::set('tracker', $this->tracker); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { parent::setUp(); $this->db = $this->getConnection()->getConnection(); \Zend_Registry::set('db', $this->db); \Zend_Db_Table::setDefaultAdapter($this->db); $settings = new \Zend_Config_Ini(GEMS_ROOT_DIR . '/configs/application.example.ini', APPLICATION_ENV); $sa = $settings->toArray(); $this->loader = new \Gems_Loader(\Zend_Registry::getInstance(), $sa['loaderDirs']); \Zend_Registry::set('loader', $this->loader); }
public function getStatuses() { $cache = Zend_Registry::get('cache'); $key = md5('httpStatuses'); if (!$cache->test($key)) { $ini = new Zend_Config_Ini(APPLICATION_PATH . '/config/statuses.ini', 'production'); $codes = $ini->toArray(); $cache->save($codes); } else { $codes = $cache->load($key); } return $codes['status']; }
public function _initDoctrine() { $conn = new Zend_Config_Ini(APPLICATION_PATH . '/configs/doctrine.ini'); $config = new Configuration(); $cache = new Cache(); $config->setMetadataCacheImpl($cache); AnnotationRegistry::registerFile('Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); $driver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver(new Doctrine\Common\Annotations\AnnotationReader(), array(APPLICATION_PATH . '/models/entities')); $config->setMetadataDriverImpl($driver); $config->setProxyDir(APPLICATION_PATH . '/models/entities/proxies'); $config->setProxyNamespace('Application\\Models\\Proxies'); $this->_entityManager = EntityManager::create($conn->toArray(), $config); }
protected function parseFrameworkConfig() { if (!$this->isValidFrameworkFiles()) { return; } $frameworkIni = $this->getFrameworkIni(); require_once 'Zend/Config/Ini.php'; $objConfig = new \Zend_Config_Ini(realpath($frameworkIni), $this->getEnvironment()); $arrConfig = $objConfig->toArray(); if (isset($arrConfig['resources']['db'])) { $this->config = $arrConfig['resources']['db']; } }
/** * Configura os módulos */ protected function _initAutoload() { $oIniConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini'); $aIniConfig = $oIniConfig->toArray(); $aModules = array(); if (isset($aIniConfig['production']['app']['module'])) { $aModules = $aIniConfig['production']['app']['module']; } // Estancia os modulos foreach ($aModules as $sModule => $sNamespace) { $oModule = new Zend_Application_Module_Autoloader(array('namespace' => (string) ucfirst($sNamespace), 'basePath' => APPLICATION_PATH . "/modules/{$sModule}")); $oModule->addResourceTypes(array('library' => array('path' => 'library/', 'namespace' => 'Lib'), 'dao' => array('path' => 'dao/', 'namespace' => 'Dao'), 'form' => array('path' => 'forms/', 'namespace' => 'Form'), 'model' => array('path' => 'models/', 'namespace' => 'Model'), 'interface' => array('path' => 'interfaces/', 'namespace' => 'Interface'))); } }
/** * facebook oauth 2 workflow start * * https://developers.facebook.com/docs/howtos/login/server-side-login/ * https://developers.facebook.com/docs/opengraph/getting-started/ * */ public function indexAction() { //Zend_Debug::dump('IndexController indexAction'); // retrieve the facebook api configuration $facebookOAuth2Configuration = new Zend_Config_Ini(APPLICATION_PATH . '/configs/facebook_api.ini'); // create a secret state, insert it in the options and put it into the // session to validate it during the next step $state = $facebookOAuth2Configuration->stateSecret . md5(uniqid(rand(), TRUE)); $oauthSessionNamespace = new Zend_Session_Namespace('oauthSessionNamespace'); $oauthSessionNamespace->state = $state; $facebookOAuth2ConfigurationArray = $facebookOAuth2Configuration->toArray(); $facebookOAuth2ConfigurationArray['state'] = $state; // start the facebook oauth 2 workflow $chriswebOauth2 = new Chrisweb_Oauth2($facebookOAuth2ConfigurationArray); $chriswebOauth2->authorizationRedirect(); }
/** * * @throws ZendT_Exception */ private function _init() { $_config = new Zend_Config_Ini($this->_configIni, APPLICATION_ENV); $this->_configs = $_config->toArray(); if ($this->_documentRoot == '') { throw new ZendT_Exception('"documentRoot" não configurado!'); } if ($this->_processId == '') { throw new ZendT_Exception('"processId" não informado!'); } //$path = $this->_documentRoot . $this->_dirTmp; $this->_fileNameIn = $this->_dirTmp . "/" . $this->_processId . ".in"; $this->_fileNameXml = $this->_dirTmp . "/" . $this->_processId . ".xml"; $this->_fileNameOut = $this->_dirTmp . "/" . $this->_processId . ".out"; $this->_fileNameError = $this->_dirTmp . "/" . $this->_processId . ".err"; }
/** * Read project configuration file and put data into a global variable */ protected function _initProjectConfig() { $filename = APPLICATION_PATH . '/configs/project.ini'; if (file_exists($filename)) { $projectConfig = new Zend_Config_Ini($filename, $this->getEnvironment()); $config = $projectConfig->toArray(); } else { throw new Exception('File "' . $filename . '" not found'); } if (!is_array($config)) { throw new Exception('$tmpArrayConfig is not an array'); } $projectConfig = new Zmz_Object($config); $projectConfig->setThrowException(true); Zend_Registry::set('projectConfig', $projectConfig); }
function getFileSyncWorkers($iniDir) { $configFileName = kEnvironment::get('cache_root_path') . DIRECTORY_SEPARATOR . 'batch' . DIRECTORY_SEPARATOR . 'fileSyncStatus-config.ini'; @mkdir(dirname($configFileName), 0777, true); $filePaths = getIniFilePaths($iniDir); implodeDirectoryFiles($filePaths, $configFileName); $config = new Zend_Config_Ini($configFileName); $batchConfig = $config->toArray(); $result = array(); foreach ($batchConfig as $section) { if (!isset($section["id"]) || !isset($section["scriptPath"]) || strpos($section["scriptPath"], 'KAsyncFileSyncImportExe') === false) { continue; } $result[] = array('id' => $section["id"], 'name' => $section["friendlyName"], 'filter' => $section["filter"]); } return $result; }
public function loadTemplate($template_path = null, $fileConfig = 'template.ini', $sectionConfig = 'default') { $this->view->headScript()->getContainer()->exchangeArray(array()); $this->view->headMeta()->getContainer()->exchangeArray(array()); $this->view->headLink()->getContainer()->exchangeArray(array()); $filename = $template_path . '/' . $fileConfig; $config = new Zend_Config_Ini($filename, $sectionConfig); $arrConfig = $config->toArray(); $this->view->headTitle($arrConfig['title'], true); $metaHttp = $arrConfig['metaHttp']; if (count($metaHttp) > 0) { foreach ($metaHttp as $val) { $tmp = explode('||', $val); $this->view->headMeta()->appendHttpEquiv($tmp[0], $tmp[1]); } } $metaName = $arrConfig['metaName']; if (count($metaName) > 0) { foreach ($metaName as $val) { $tmp = explode('||', $val); $this->view->headMeta()->appendName($tmp[0], $tmp[1]); } } $cssUrl = $arrConfig['url'] . $arrConfig['dirCss']; $fileCss = $arrConfig['fileCss']; if (count($fileCss) > 0) { foreach ($fileCss as $val) { $this->view->headLink()->appendStylesheet($cssUrl . $val, 'screen'); } } $jsUrl = $arrConfig['url'] . $arrConfig['dirJs']; $fileJs = $arrConfig['fileJs']; if (count($fileJs) > 0) { foreach ($fileJs as $val) { $this->view->headScript()->appendFile($jsUrl . $val); } } if (count($arrConfig['dirs']) > 0) { foreach ($arrConfig['dirs'] as $val) { $arrDir[$val] = $arrConfig['url'] . '/' . $val; } } $options = array('layout' => $arrConfig['layout'], 'layoutPath' => $template_path, 'viewSuffix' => 'phtml'); Zend_Layout::startMvc($options); $this->view->arrDir = $arrDir; }
protected function _initConfig() { // Default languages $use_lang = false; if (isset($setup_session->language)) { $use_lang = $setup_session->language; } // Config file $cfg_file = APPLICATION_PATH . '/configs/config.ini'; // Load version $version_conf = new Zend_Config_Ini(APPLICATION_PATH . '/configs/version.ini', 'version'); Zend_Registry::set("gd.version", $version_conf->gd->version); // Initialise language to english in case of a "fallback" mode // Mainly for using _e and _r if something else fails. GD_Translate::init("english"); // Set default database adapter if (file_exists($cfg_file)) { $db_conf = new Zend_Config_Ini($cfg_file, 'database'); $adapter = Zend_Db::factory($db_conf->adapter, $db_conf->toArray()); Zend_Db_Table::setDefaultAdapter($adapter); Zend_Registry::set("db", $db_conf); // If we're not on the /error/database page, do a DB test, else // we return out to ensure no DB errors later in this Bootstrap fn. if (stripos($_SERVER['REQUEST_URI'], '/error/database') === false) { // Do a database test to ensure we can run queries on the DB. If not // redirect to the error controller in a hacky way. try { $adapter->query("SELECT 1"); } catch (Zend_Db_Adapter_Exception $ex) { header("Location: /error/database"); die; } } else { return; } $lang = GD_Config::get("language"); if ($lang !== false) { $use_lang = $lang; } } if (!$use_lang) { $use_lang = "english"; } $translate = GD_Translate::init($use_lang); }
/** * Defined by Zend_Application_Resource_Resource * * @return Zend_Acl */ public function init() { $this->getBootstrap()->bootstrap('FrontController')->bootstrap('Logger')->bootstrap('Session'); $front = $this->getBootstrap()->getResource('FrontController'); $log = $this->getBootstrap()->getResource('Logger'); if (!$front->hasPlugin('Streamwide_Web_Controller_Plugin_Acl')) { $front->registerPlugin(new Streamwide_Web_Controller_Plugin_Acl($this->_options), 2); //2: the very first plugin after Log } $ini = $this->_options['definition']; $definitions = new Zend_Config_Ini($ini, 'resource'); $acl = $this->getAcl(); $acl->addRole('visitor')->addRole('developer')->addResource(new Streamwide_Web_Acl_Resource_Mca('*', '*', '*')); $acl->deny('visitor'); foreach ($definitions->toArray() as $definition) { $rules = array(); list($module, $controller, $action, $roles) = $this->_getDef($definition, $rules); $mca = new Streamwide_Web_Acl_Resource_Mca($module, $controller, $action); if (!$acl->has($mca)) { $acl->addResource($mca); } foreach ($roles as $role => $allow) { if (!$acl->hasRole($role)) { $acl->addRole($role); } if ($allow) { $acl->allow($role, $mca); } else { $acl->deny($role, $mca); } } } $acl->allow('developer'); $role = getenv('APPLICATION_ROLE'); if (!empty($role)) { $this->_role = $role; } else { if (!Zend_Session::isStarted()) { Zend_Session::start(true); } $this->_role = isset($_SESSION['APPLICATION_ROLE']) ? $_SESSION['APPLICATION_ROLE'] : 'visitor'; } $log->setEventItem('role', $this->_role); return $acl; }
public static function getAssetVariables($section = 'web') { static $assetVariables = array(); if (!isset($assetVariables[$section])) { $assetVariables[$section] = Kwf_Config::getValueArray('assetVariables'); if (file_exists('assetVariables.ini')) { $cfg = new Zend_Config_Ini('assetVariables.ini', $section); $assetVariables[$section] = array_merge($assetVariables[$section], $cfg->toArray()); } foreach ($assetVariables[$section] as $k => $i) { //also support lowercase variables if (strtolower($k) != $k) { $assetVariables[$section][strtolower($k)] = $i; } } } return $assetVariables[$section]; }
private function loadFromFile($filename) { $currentFile = new File($this->yamlarh->getFilename()); $file = new File($filename); if (!$file->isFile()) { $file->setFolder($currentFile->getFolder() . $file->getFolder()); } if (!$file->isFile()) { throw new SphringException("Property file '%s' cannot be found.", $file->getName()); } $properties = FileLoader::loadFile($file); if ($properties === null && in_array($file->getExtension(), self::$extIni)) { $ini = new \Zend_Config_Ini($file->absolute()); $properties = $ini->toArray(); } elseif ($properties === null) { return; } $this->injectInYamlarh($properties); }