/** * @param jIniFileModifier $mainConfig the mainconfig.ini.php file * @param string $configFile the path of the configuration file, relative * to the var/config directory * @param string $file the filename of the entry point * @param string $type type of the entry point ('classic', 'cli', 'xmlrpc'....) */ function __construct($mainConfig, $configFile, $file, $type) { $this->type = $type; $this->isCliScript = $type == 'cmdline'; $this->configFile = $configFile; $this->scriptName = $this->isCliScript ? $file : '/' . $file; $this->file = $file; $this->configIni = new jIniMultiFilesModifier($mainConfig, jApp::configPath($configFile)); $this->config = jConfigCompiler::read($configFile, true, $this->isCliScript, $this->scriptName); }
/** * initialize a full jelix environment with a coordinator, a request object etc. * * it initializes a coordinator, a classic request object. It sets jApp::coord(), * @param string $url the full requested URL (with http://, the domaine name etc.) * @param string $config the configuration file to use, as if you were inside an entry point * @param string $entryPoint the entrypoint name as indicated into project.xml */ protected static function initClassicRequest($url, $config = 'index/config.ini.php', $entryPoint = 'index.php') { self::$fakeServer = new jelix\FakeServerConf\ApacheMod(jApp::wwwPath(), '/' . $entryPoint); self::$fakeServer->setHttpRequest($url); $config = jConfigCompiler::read($config, true, false, '/' . $entryPoint); $coord = new jCoordinatorForTest($config, false); jApp::setCoord($coord); $request = new jClassicRequest(); $coord->testSetRequest($request); }
/** * load and read the configuration of the application * The combination of all configuration files (the given file * and the defaultconfig.ini.php) is stored * in a single temporary file. So it calls the jConfigCompiler * class if needed * @param string $configFile the config file name * @return object it contains all configuration options * @see jConfigCompiler */ public static function load($configFile) { $config = array(); if (BYTECODE_CACHE_EXISTS) { $file = JELIX_APP_TEMP_PATH . str_replace('/', '~', $configFile) . '.conf.php'; } else { $file = JELIX_APP_TEMP_PATH . str_replace('/', '~', $configFile) . '.resultini.php'; } $compil = false; if (!file_exists($file)) { // pas de cache, on compile $compil = true; } else { $t = filemtime($file); $dc = JELIX_APP_CONFIG_PATH . 'defaultconfig.ini.php'; if (file_exists($dc) && filemtime($dc) > $t || filemtime(JELIX_APP_CONFIG_PATH . $configFile) > $t) { // le fichier de conf ou le fichier defaultconfig.ini.php ont ete modifié : on compile $compil = true; } else { // on lit le fichier de conf du cache if (BYTECODE_CACHE_EXISTS) { include $file; $config = (object) $config; } else { $config = parse_ini_file($file, true); $config = (object) $config; } // on va verifier tous les chemins if ($config->compilation['checkCacheFiletime']) { foreach ($config->_allBasePath as $path) { if (!file_exists($path) || filemtime($path) > $t) { $compil = true; break; } } } } } if ($compil) { require JELIX_LIB_CORE_PATH . 'jConfigCompiler.class.php'; return jConfigCompiler::read($configFile); } else { return $config; } }
function loadAppConfig() { if (jApp::config()) { return; } $xml = simplexml_load_file(jApp::appPath('project.xml')); $configFile = ''; foreach ($xml->entrypoints->entry as $entrypoint) { $file = (string) $entrypoint['file']; if ($file == $this->entryPointName) { $configFile = (string) $entrypoint['config']; break; } } if ($configFile == '') { throw new Exception("Entry point is unknown"); } require_once JELIX_LIB_PATH . "core/jConfigCompiler.class.php"; jApp::setConfig(jConfigCompiler::read($configFile, true, true, $this->entryPointName)); }
function jelix_init_test_env() { require_once JELIX_LIB_CORE_PATH . 'jConfigCompiler.class.php'; global $gJConfig; $gJConfig = jConfigCompiler::read('index/config.ini.php', false, true); }
protected function _installModules(&$modules, $epId, $installWholeApp, $flags = 3) { $this->notice('install.entrypoint.start', $epId); $ep = $this->entryPoints[$epId]; jApp::setConfig($ep->config); if ($ep->config->disableInstallers) { $this->notice('install.entrypoint.installers.disabled'); } $result = $this->checkDependencies($modules, $epId); if (!$result) { $this->error('install.bad.dependencies'); $this->ok('install.entrypoint.bad.end', $epId); return false; } $this->ok('install.dependencies.ok'); $componentsToInstall = array(); foreach ($this->_componentsToInstall as $item) { list($component, $toInstall) = $item; try { if ($flags == self::FLAG_MIGRATION_11X) { $this->installerIni->setValue($component->getName() . '.installed', 1, $epId); $this->installerIni->setValue($component->getName() . '.version', $component->getSourceVersion(), $epId); if ($ep->config->disableInstallers) { $upgraders = array(); } else { $upgraders = $component->getUpgraders($ep); foreach ($upgraders as $upgrader) { $upgrader->preInstall(); } } $componentsToInstall[] = array($upgraders, $component, false); } else { if ($toInstall) { if ($ep->config->disableInstallers) { $installer = null; } else { $installer = $component->getInstaller($ep, $installWholeApp); } $componentsToInstall[] = array($installer, $component, $toInstall); if ($flags & self::FLAG_INSTALL_MODULE && $installer) { $installer->preInstall(); } } else { if ($ep->config->disableInstallers) { $upgraders = array(); } else { $upgraders = $component->getUpgraders($ep); } if ($flags & self::FLAG_UPGRADE_MODULE && count($upgraders)) { foreach ($upgraders as $upgrader) { $upgrader->preInstall(); } } $componentsToInstall[] = array($upgraders, $component, $toInstall); } } } catch (jInstallerException $e) { $result = false; $this->error($e->getLocaleKey(), $e->getLocaleParameters()); } catch (Exception $e) { $result = false; $this->error('install.module.error', array($component->getName(), $e->getMessage())); } } if (!$result) { $this->warning('install.entrypoint.bad.end', $epId); return false; } $installedModules = array(); try { foreach ($componentsToInstall as $item) { list($installer, $component, $toInstall) = $item; if ($toInstall) { if ($installer && $flags & self::FLAG_INSTALL_MODULE) { $installer->install(); } $this->installerIni->setValue($component->getName() . '.installed', 1, $epId); $this->installerIni->setValue($component->getName() . '.version', $component->getSourceVersion(), $epId); $this->installerIni->setValue($component->getName() . '.version.date', $component->getSourceDate(), $epId); $this->installerIni->setValue($component->getName() . '.firstversion', $component->getSourceVersion(), $epId); $this->installerIni->setValue($component->getName() . '.firstversion.date', $component->getSourceDate(), $epId); $this->ok('install.module.installed', $component->getName()); $installedModules[] = array($installer, $component, true); } else { $lastversion = ''; foreach ($installer as $upgrader) { if ($flags & self::FLAG_UPGRADE_MODULE) { $upgrader->install(); } $this->installerIni->setValue($component->getName() . '.version', $upgrader->version, $epId); $this->installerIni->setValue($component->getName() . '.version.date', $upgrader->date, $epId); $this->ok('install.module.upgraded', array($component->getName(), $upgrader->version)); $lastversion = $upgrader->version; } if ($lastversion != $component->getSourceVersion()) { $this->installerIni->setValue($component->getName() . '.version', $component->getSourceVersion(), $epId); $this->installerIni->setValue($component->getName() . '.version.date', $component->getSourceDate(), $epId); $this->ok('install.module.upgraded', array($component->getName(), $component->getSourceVersion())); } $installedModules[] = array($installer, $component, false); } $ep->configIni->save(); $ep->config = jConfigCompiler::read($ep->configFile, true, $ep->isCliScript, $ep->scriptName); jApp::setConfig($ep->config); } } catch (jInstallerException $e) { $result = false; $this->error($e->getLocaleKey(), $e->getLocaleParameters()); } catch (Exception $e) { $result = false; $this->error('install.module.error', array($component->getName(), $e->getMessage())); } if (!$result) { $this->warning('install.entrypoint.bad.end', $epId); return false; } foreach ($installedModules as $item) { try { list($installer, $component, $toInstall) = $item; if ($toInstall) { if ($installer && $flags & self::FLAG_INSTALL_MODULE) { $installer->postInstall(); $component->installFinished($ep); } } else { if ($flags & self::FLAG_UPGRADE_MODULE) { foreach ($installer as $upgrader) { $upgrader->postInstall(); $component->upgradeFinished($ep, $upgrader); } } } $ep->configIni->save(); $ep->config = jConfigCompiler::read($ep->configFile, true, $ep->isCliScript, $ep->scriptName); jApp::setConfig($ep->config); } catch (jInstallerException $e) { $result = false; $this->error($e->getLocaleKey(), $e->getLocaleParameters()); } catch (Exception $e) { $result = false; $this->error('install.module.error', array($component->getName(), $e->getMessage())); } } $this->ok('install.entrypoint.end', $epId); return $result; }
/** * core of the installation * @param array $modules list of jInstallerComponentModule * @param string $epId the entrypoint id * @param boolean $installWholeApp true if the installation is done during app installation * @param integer $flags to know what to do * @return boolean true if the installation is ok */ protected function _installModules(&$modules, $epId, $installWholeApp, $flags = 3) { $this->notice('install.entrypoint.start', $epId); $ep = $this->entryPoints[$epId]; jApp::setConfig($ep->config); if ($ep->config->disableInstallers) { $this->notice('install.entrypoint.installers.disabled'); } // first, check dependencies of the component, to have the list of component // we should really install. It fills $this->_componentsToInstall, in the right // order $result = $this->checkDependencies($modules, $epId); if (!$result) { $this->error('install.bad.dependencies'); $this->ok('install.entrypoint.bad.end', $epId); return false; } $this->ok('install.dependencies.ok'); // ----------- pre install // put also available installers into $componentsToInstall for // the next step $componentsToInstall = array(); foreach ($this->_componentsToInstall as $item) { list($component, $toInstall) = $item; try { if ($flags == self::FLAG_MIGRATION_11X) { $this->installerIni->setValue($component->getName() . '.installed', 1, $epId); $this->installerIni->setValue($component->getName() . '.version', $component->getSourceVersion(), $epId); if ($ep->config->disableInstallers) { $upgraders = array(); } else { $upgraders = $component->getUpgraders($ep); foreach ($upgraders as $upgrader) { $upgrader->preInstall(); } } $componentsToInstall[] = array($upgraders, $component, false); } else { if ($toInstall) { if ($ep->config->disableInstallers) { $installer = null; } else { $installer = $component->getInstaller($ep, $installWholeApp); } $componentsToInstall[] = array($installer, $component, $toInstall); if ($flags & self::FLAG_INSTALL_MODULE && $installer) { $installer->preInstall(); } } else { if ($ep->config->disableInstallers) { $upgraders = array(); } else { $upgraders = $component->getUpgraders($ep); } if ($flags & self::FLAG_UPGRADE_MODULE && count($upgraders)) { foreach ($upgraders as $upgrader) { $upgrader->preInstall(); } } $componentsToInstall[] = array($upgraders, $component, $toInstall); } } } catch (jInstallerException $e) { $result = false; $this->error($e->getLocaleKey(), $e->getLocaleParameters()); } catch (Exception $e) { $result = false; $this->error('install.module.error', array($component->getName(), $e->getMessage())); } } if (!$result) { $this->warning('install.entrypoint.bad.end', $epId); return false; } $installedModules = array(); // ----- installation process try { foreach ($componentsToInstall as $item) { list($installer, $component, $toInstall) = $item; if ($toInstall) { if ($installer && $flags & self::FLAG_INSTALL_MODULE) { $installer->install(); } $this->installerIni->setValue($component->getName() . '.installed', 1, $epId); $this->installerIni->setValue($component->getName() . '.version', $component->getSourceVersion(), $epId); $this->installerIni->setValue($component->getName() . '.version.date', $component->getSourceDate(), $epId); $this->installerIni->setValue($component->getName() . '.firstversion', $component->getSourceVersion(), $epId); $this->installerIni->setValue($component->getName() . '.firstversion.date', $component->getSourceDate(), $epId); $this->ok('install.module.installed', $component->getName()); $installedModules[] = array($installer, $component, true); } else { $lastversion = ''; foreach ($installer as $upgrader) { if ($flags & self::FLAG_UPGRADE_MODULE) { $upgrader->install(); } // we set the version of the upgrade, so if an error occurs in // the next upgrader, we won't have to re-run this current upgrader // during a future update $this->installerIni->setValue($component->getName() . '.version', $upgrader->version, $epId); $this->installerIni->setValue($component->getName() . '.version.date', $upgrader->date, $epId); $this->ok('install.module.upgraded', array($component->getName(), $upgrader->version)); $lastversion = $upgrader->version; } // we set the version to the component version, because the version // of the last upgrader could not correspond to the component version. if ($lastversion != $component->getSourceVersion()) { $this->installerIni->setValue($component->getName() . '.version', $component->getSourceVersion(), $epId); $this->installerIni->setValue($component->getName() . '.version.date', $component->getSourceDate(), $epId); $this->ok('install.module.upgraded', array($component->getName(), $component->getSourceVersion())); } $installedModules[] = array($installer, $component, false); } // we always save the configuration, so it invalidates the cache $ep->configIni->save(); // we re-load configuration file for each module because // previous module installer could have modify it. $ep->config = jConfigCompiler::read($ep->configFile, true, $ep->isCliScript, $ep->scriptName); jApp::setConfig($ep->config); } } catch (jInstallerException $e) { $result = false; $this->error($e->getLocaleKey(), $e->getLocaleParameters()); } catch (Exception $e) { $result = false; $this->error('install.module.error', array($component->getName(), $e->getMessage())); } if (!$result) { $this->warning('install.entrypoint.bad.end', $epId); return false; } // post install foreach ($installedModules as $item) { try { list($installer, $component, $toInstall) = $item; if ($toInstall) { if ($installer && $flags & self::FLAG_INSTALL_MODULE) { $installer->postInstall(); $component->installFinished($ep); } } else { if ($flags & self::FLAG_UPGRADE_MODULE) { foreach ($installer as $upgrader) { $upgrader->postInstall(); $component->upgradeFinished($ep, $upgrader); } } } // we always save the configuration, so it invalidates the cache $ep->configIni->save(); // we re-load configuration file for each module because // previous module installer could have modify it. $ep->config = jConfigCompiler::read($ep->configFile, true, $ep->isCliScript, $ep->scriptName); jApp::setConfig($ep->config); } catch (jInstallerException $e) { $result = false; $this->error($e->getLocaleKey(), $e->getLocaleParameters()); } catch (Exception $e) { $result = false; $this->error('install.module.error', array($component->getName(), $e->getMessage())); } } $this->ok('install.entrypoint.end', $epId); return $result; }
function loadAppConfig() { if (jApp::config()) { return; } $xml = simplexml_load_file(jApp::appPath('project.xml')); $configFile = ''; foreach ($xml->entrypoints->entry as $entrypoint) { $file = (string) $entrypoint['file']; if ($file == $this->entryPointName) { $configFile = (string) $entrypoint['config']; break; } } if ($configFile == '') { throw new Exception($this->name . ": Entry point is unknown"); } jApp::setConfig(jConfigCompiler::read($configFile, true, true, $this->entryPointName)); }
/** * since urls.xml declare all entrypoints, current entry point does not have * access to all modules, so doesn't know all their paths. * this method retrieve all module paths declared in the configuration * of an entry point or the global configuration * @param string $configFile the config file name */ protected function retrieveModulePaths($configFile, $entrypoint = '') { $conf = jConfigCompiler::read($configFile, true, false, $entrypoint); $this->modulesPath = array_merge($this->modulesPath, jConfigCompiler::getModulesPaths($conf)); }
/** * since urls.xml declare all entrypoints, current entry point does not have * access to all modules, so doesn't know all their paths. * this method retrieve all module paths declared in the configuration * of an entry point or the global configuration * @param string $configFile the config file name */ protected function retrieveModulePaths($configFile) { $conf = jConfigCompiler::read($configFile); $this->modulesPath = array_merge($this->modulesPath, jConfigCompiler::getModulesPaths($conf)); }