protected function readConfigFiles($configFile, $additionalOptions) { $appConfigPath = App::appConfigPath(); $configPath = App::configPath(); // this is the defaultconfig file of JELIX itself $config = IniFileMgr::read(__DIR__ . '/defaultconfig.ini.php', true); // read the main configuration of the app $mcf = App::mainConfigFile(); if ($mcf) { IniFileMgr::readAndMergeObject($mcf, $config); } $this->commonConfig = clone $config; // read the local configuration of the app if (file_exists($configPath . 'localconfig.ini.php')) { IniFileMgr::readAndMergeObject($configPath . 'localconfig.ini.php', $config); } // read the configuration specific to the entry point if ($configFile == 'mainconfig.ini.php') { throw new Exception("Entry point configuration file cannot be mainconfig.ini.php", 5); } if (file_exists($appConfigPath . $configFile)) { if (false === IniFileMgr::readAndMergeObject($appConfigPath . $configFile, $config)) { throw new Exception("Syntax error in the configuration file -- {$configFile}", 6); } } else { if (!$additionalOptions) { throw new Exception("Configuration file is missing -- {$configFile}", 5); } } if ($additionalOptions) { IniFileMgr::mergeIniObjectContents($config, $additionalOptions); } return $config; }
/** * @param \Jelix\IniFile\MultiIniModifier $mainConfig the mainconfig.ini.php file combined with defaultconfig.ini.php * @param \Jelix\IniFile\MultiIniModifier $localConfig the localconfig.ini.php file combined with $mainConfig * @param string $configFile the path of the configuration file, relative * to the app/config directory * @param string $file the filename of the entry point * @param string $type type of the entry point ('classic', 'cli', 'xmlrpc'....) */ function __construct(\Jelix\IniFile\MultiIniModifier $mainConfig, \Jelix\IniFile\MultiIniModifier $localConfig, $configFile, $file, $type) { $this->type = $type; $this->isCliScript = $type == 'cmdline'; $this->configFile = $configFile; $this->scriptName = $this->isCliScript ? $file : '/' . $file; $this->file = $file; $this->mainConfigIni = $mainConfig; $this->localConfigIni = $localConfig; $appConfigPath = \Jelix\Core\App::appConfigPath($configFile); if (!file_exists($appConfigPath)) { \jFile::createDir(dirname($appConfigPath)); file_put_contents($appConfigPath, ';<' . '?php die(\'\');?' . '>'); } $this->epConfigIni = new \Jelix\IniFile\IniModifier($appConfigPath); $varConfigPath = \Jelix\Core\App::configPath($configFile); if (!file_exists($varConfigPath)) { \jFile::createDir(dirname($varConfigPath)); file_put_contents($varConfigPath, ';<' . '?php die(\'\');?' . '>'); } $this->localEpConfigIni = new \Jelix\IniFile\IniModifier($varConfigPath); $this->fullConfigIni = new \Jelix\IniFile\MultiIniModifier($localConfig, $this->epConfigIni); $this->fullConfigIni = new \Jelix\IniFile\MultiIniModifier($this->fullConfigIni, $this->localEpConfigIni); $compiler = new \Jelix\Core\Config\Compiler($configFile, $this->scriptName, $this->isCliScript); $this->config = $compiler->read(true); $this->modulesInfos = $compiler->getModulesInfos(); }
protected function expandPath($path) { if (strpos($path, 'www:') === 0) { $path = str_replace('www:', App::wwwPath(), $path); } elseif (strpos($path, 'jelixwww:') === 0) { $p = $this->config->getValue('jelixWWWPath', 'urlengine'); if (substr($p, -1) != '/') { $p .= '/'; } $path = str_replace('jelixwww:', App::wwwPath($p), $path); } elseif (strpos($path, 'config:') === 0) { $path = str_replace('config:', App::configPath(), $path); } elseif (strpos($path, 'appconfig:') === 0) { $path = str_replace('appconfig:', App::appConfigPath(), $path); } elseif (strpos($path, 'epconfig:') === 0) { $p = dirname(App::appConfigPath($this->entryPoint->getConfigFile())); $path = str_replace('epconfig:', $p . '/', $path); } return $path; }
function checkAppPaths() { $ok = true; if (!defined('JELIX_LIB_PATH') || !App::isInit()) { throw new \Exception($this->messages->get('path.core')); } if (!file_exists(App::tempBasePath()) || !is_writable(App::tempBasePath())) { $this->error('path.temp'); $ok = false; } if (!file_exists(App::logPath()) || !is_writable(App::logPath())) { $this->error('path.log'); $ok = false; } if (!file_exists(App::varPath())) { $this->error('path.var'); $ok = false; } if (!file_exists(App::appConfigPath())) { $this->error('path.config'); $ok = false; } if (!file_exists(App::configPath())) { $this->error('path.config'); $ok = false; } elseif ($this->checkForInstallation) { if (!is_writable(App::configPath())) { $this->error('path.config.writable'); $ok = false; } if (file_exists(App::configPath('profiles.ini.php')) && !is_writable(App::configPath('profiles.ini.php'))) { $this->error('path.profiles.writable'); $ok = false; } if (file_exists(App::configPath('installer.ini.php')) && !is_writable(App::configPath('installer.ini.php'))) { $this->error('path.installer.writable'); $ok = false; } } if (!file_exists(App::wwwPath())) { $this->error('path.www'); $ok = false; } foreach ($this->otherPaths as $path) { $realPath = \jFile::parseJelixPath($path); if (!file_exists($realPath)) { $this->error('path.custom.not.exists', array($path)); $ok = false; } else { if (!is_writable($realPath)) { $this->error('path.custom.writable', array($path)); $ok = false; } else { $this->ok('path.custom.ok', array($path)); } } } if ($ok) { $this->ok('paths.ok'); } else { throw new \Exception($this->messages->get('too.critical.error')); } return $ok; }
protected function _execute(InputInterface $input, OutputInterface $output) { $module = $input->getArgument('module'); $initialVersion = $input->getOption('ver'); if (!$initialVersion) { $initialVersion = '0.1pre'; } // note: since module name are used for name of generated name, // only this characters are allowed if ($module == null || preg_match('/([^a-zA-Z_0-9])/', $module)) { throw new \Exception("'" . $module . "' is not a valid name for a module"); } // check if the module already exist or not $path = ''; try { $path = $this->getModulePath($module); } catch (\Exception $e) { } if ($path != '') { throw new \Exception("module '" . $module . "' already exists"); } // verify the given repository $repository = $input->getArgument('repository'); if (substr($repository, -1) != '/') { $repository .= '/'; } $repositoryPath = \jFile::parseJelixPath($repository); if (!$input->getOption('noregistration')) { $this->registerModulesDir($repository, $repositoryPath); } $path = $repositoryPath . $module . '/'; $this->createDir($path); App::setConfig(null); $noSubDir = $input->getOption('nosubdir'); $addInstallZone = $input->getOption('addinstallzone'); $isdefault = $input->getOption('defaultmodule'); if ($input->getOption('admin')) { $noSubDir = false; $addInstallZone = false; } $param = array(); $param['module'] = $module; $param['version'] = $initialVersion; $this->createFile($path . 'jelix-module.json', 'module/jelix-module.json.tpl', $param); // create all sub directories of a module if (!$noSubDir) { $this->createDir($path . 'classes/'); $this->createDir($path . 'zones/'); $this->createDir($path . 'controllers/'); $this->createDir($path . 'templates/'); $this->createDir($path . 'classes/'); $this->createDir($path . 'daos/'); $this->createDir($path . 'forms/'); $this->createDir($path . 'locales/'); $this->createDir($path . 'locales/en_US/'); $this->createDir($path . 'locales/fr_FR/'); $this->createDir($path . 'install/'); if ($this->verbose()) { $output->writeln("Sub directories have been created in the new module {$module}."); } $this->createFile($path . 'install/install.php', 'module/install.tpl', $param); $this->createFile($path . 'urls.xml', 'module/urls.xml.tpl', array()); } $iniDefault = new \Jelix\IniFile\IniModifier(App::mainConfigFile()); $urlsFile = App::appConfigPath($iniDefault->getValue('significantFile', 'urlengine')); $xmlMap = new \Jelix\Routing\UrlMapping\XmlMapModifier($urlsFile, true); // activate the module in the application if ($isdefault) { if ($this->allEntryPoint) { $xmlEp = $xmlMap->getDefaultEntryPoint($type); } else { $xmlEp = $xmlMap->getEntryPoint($this->entryPointId); } if ($xmlEp) { $xmlEp->addUrlAction('/', $module, 'default:index', null, null, array('default' => true)); $xmlEp->addUrlModule('', $module); if ($this->verbose()) { $output->writeln("The new module {$module} becomes the default module"); } } else { if ($this->verbose()) { $output->writeln("No default entry point found: the new module cannot be the default module"); } } } $xmlMap->save(); $iniDefault->setValue($module . '.access', $this->allEntryPoint ? 2 : 1, 'modules'); $iniDefault->save(); $list = $this->getEntryPointsList(); $install = new \Jelix\IniFile\IniModifier(App::configPath('installer.ini.php')); // install the module for all needed entry points foreach ($list as $entryPoint) { $configFile = App::appConfigPath($entryPoint['config']); $epconfig = new \Jelix\IniFile\IniModifier($configFile); if ($this->allEntryPoint) { $access = 2; } else { $access = $entryPoint['file'] == $this->entryPointName ? 2 : 0; } $epconfig->setValue($module . '.access', $access, 'modules'); $epconfig->save(); if ($this->allEntryPoint || $entryPoint['file'] == $this->entryPointName) { $install->setValue($module . '.installed', 1, $entryPoint['id']); $install->setValue($module . '.version', $initialVersion, $entryPoint['id']); } if ($this->verbose()) { $output->writeln("The module is initialized for the entry point " . $entryPoint['file']); } } $install->save(); App::declareModule($path); // create a default controller if (!$input->getOption('nocontroller')) { $arguments = array('module' => $module, 'controller' => 'default', 'method' => 'index'); if ($input->getOption('entry-point')) { $arguments['--entry-point'] = $input->getOption('entry-point'); } if ($input->getOption('cmdline')) { $arguments['--cmdline'] = true; } if ($addInstallZone) { $arguments['--addinstallzone'] = true; } if ($output->isVerbose()) { $arguments['-v'] = true; } $this->executeSubCommand('module:create-ctrl', $arguments, $output); } if ($input->getOption('admin')) { $this->createFile($path . 'classes/admin' . $module . '.listener.php', 'module/admin.listener.php.tpl', $param, "Listener"); $this->createFile($path . 'events.xml', 'module/events.xml.tpl', $param); file_put_contents($path . 'locales/en_US/interface.UTF-8.properties', 'menu.item=' . $module); file_put_contents($path . 'locales/fr_FR/interface.UTF-8.properties', 'menu.item=' . $module); } }
/** * initialize the installation * * it reads configurations files of all entry points, and prepare object for * each module, needed to install/upgrade modules. * @param ReporterInterface $reporter object which is responsible to process messages (display, storage or other..) * @param string $lang the language code for messages */ function __construct(ReporterInterface $reporter, $lang = '') { $this->reporter = $reporter; $this->messages = new Checker\Messages($lang); $localConfig = App::configPath('localconfig.ini.php'); if (!file_exists($localConfig)) { $localConfigDist = App::configPath('localconfig.ini.php.dist'); if (file_exists($localConfigDist)) { copy($localConfigDist, $localConfig); } else { file_put_contents($localConfig, ';<' . '?php die(\'\');?' . '>'); } } $this->mainConfig = new \Jelix\IniFile\MultiIniModifier(\Jelix\Core\Config::getDefaultConfigFile(), App::mainConfigFile()); $this->localConfig = new \Jelix\IniFile\MultiIniModifier($this->mainConfig, $localConfig); $this->installerIni = $this->getInstallerIni(); $urlfile = App::appConfigPath($this->localConfig->getValue('significantFile', 'urlengine')); $this->xmlMapFile = new \Jelix\Routing\UrlMapping\XmlMapModifier($urlfile, true); $appInfos = new \Jelix\Core\Infos\AppInfos(); $this->readEntryPointsData($appInfos); $this->installerIni->save(); // be sure temp path is ready $chmod = $this->mainConfig->getValue('chmodDir'); \jFile::createDir(App::tempPath(), intval($chmod, 8)); }
function __construct($sel) { $this->_basePath = \Jelix\Core\App::appConfigPath(); parent::__construct($sel); }
protected function execute(InputInterface $input, OutputInterface $output) { // retrieve the type of entry point we want to create $type = $input->getOption('type'); if (!in_array($type, array('classic', 'jsonrpc', 'xmlrpc', 'soap', 'cmdline'))) { throw new \Exception("invalid type"); } // retrieve the name of the entry point $name = $input->getArgument('entrypoint'); if (preg_match('/(.*)\\.php$/', $name, $m)) { $name = $m[1]; } // the full path of the entry point if ($type == 'cmdline') { $entryPointFullPath = App::scriptsPath($name . '.php'); $entryPointTemplate = 'scripts/cmdline.php.tpl'; } else { $entryPointFullPath = App::wwwPath($name . '.php'); $entryPointTemplate = 'www/' . ($type == 'classic' ? 'index' : $type) . '.php.tpl'; } if (file_exists($entryPointFullPath)) { throw new \Exception("the entry point already exists"); } $entryPointDir = dirname($entryPointFullPath) . '/'; $this->loadAppInfos(); // retrieve the config file name $configFile = $input->getArgument('config'); if ($configFile == null) { if ($type == 'cmdline') { $configFile = 'cmdline/' . $name . '.ini.php'; } else { $configFile = $name . '/config.ini.php'; } } // let's create the config file if needed $configFilePath = App::appConfigPath($configFile); if (!file_exists($configFilePath)) { $this->createDir(dirname($configFilePath)); // the file doesn't exists // if there is a -copy-config parameter, we copy this file $originalConfig = $input->getOption('copy-config'); if ($originalConfig) { if (!file_exists(App::appConfigPath($originalConfig))) { throw new \Exception("unknown original configuration file"); } file_put_contents($configFilePath, file_get_contents(App::appConfigPath($originalConfig))); if ($this->verbose()) { $output->writeln("Configuration file {$configFile} has been created from the config file {$originalConfig}."); } } else { // else we create a new config file $param = array(); $this->createFile($configFilePath, 'app/config/index/config.ini.php.tpl', $param, "Configuration file"); } } $inifile = new \Jelix\IniFile\MultiIniModifier(App::mainConfigFile(), $configFilePath); $urlsFile = App::appConfigPath($inifile->getValue('significantFile', 'urlengine')); $xmlMap = new \Jelix\Routing\UrlMapping\XmlMapModifier($urlsFile, true); $param = array(); // creation of the entry point $this->createDir($entryPointDir); $param['rp_app'] = Path::shortestPath($entryPointDir, App::appPath()); $param['config_file'] = $configFile; $this->createFile($entryPointFullPath, $entryPointTemplate, $param, "Entry point"); if ($type != 'cmdline') { $xmlEp = $xmlMap->addEntryPoint($name, $type); /*if ($type == 'classic') { $xmlEp->addUrlAction('/', $module, $action); }*/ $xmlMap->save(); } $this->appInfos->addEntryPointInfo($name . ".php", $configFile, $type); if ($this->verbose()) { $output->writeln($this->appInfos->getFile() . " has been updated."); } $installer = new \Jelix\Installer\Installer(new \Jelix\Installer\Reporter\Console('warning')); $installer->installEntryPoint($name . ".php"); if ($this->verbose()) { $output->writeln("All modules have been initialized for the new entry point."); } }
protected function _createSkeleton($appPath, $appName, $wwwpath, InputInterface $input) { $this->createDir($appPath); $this->createDir(App::tempBasePath()); $this->createDir($wwwpath); $varPath = App::varPath(); $configPath = App::configPath(); $this->createDir($varPath); $this->createDir(App::logPath()); $this->createDir(App::appConfigPath()); $this->createDir($configPath); $this->createDir(App::appConfigPath('index/')); $this->createDir(App::appPath('app/overloads/')); $this->createDir(App::appPath('app/themes')); $this->createDir(App::appPath('app/themes/default/')); $this->createDir($varPath . 'uploads/'); $this->createDir($varPath . 'sessions/'); $this->createDir($varPath . 'mails/'); $this->createDir($appPath . 'install'); $this->createDir($appPath . 'modules'); $this->createDir($appPath . 'plugins'); $this->createDir(App::appPath('app/responses')); $this->createDir($appPath . 'tests'); $this->createDir(App::scriptsPath()); $param = array(); if ($input->getOption('nodefaultmodule')) { $param['tplname'] = 'jelix~defaultmain'; $param['modulename'] = 'jelix'; } else { $moduleName = $input->getOption('modulename'); if (!$moduleName) { // note: since module name are used for name of generated name, // only this characters are allowed $moduleName = preg_replace('/([^a-zA-Z_0-9])/', '_', $appName); } $param['modulename'] = $moduleName; $param['tplname'] = $moduleName . '~main'; } $param['config_file'] = 'index/config.ini.php'; $param['rp_temp'] = Path::shortestPath($appPath, App::tempBasePath()) . '/'; $param['rp_var'] = Path::shortestPath($appPath, App::varPath()) . '/'; $param['rp_log'] = Path::shortestPath($appPath, App::logPath()) . '/'; $param['rp_conf'] = Path::shortestPath($appPath, $configPath) . '/'; $param['rp_www'] = Path::shortestPath($appPath, $wwwpath) . '/'; $param['rp_cmd'] = Path::shortestPath($appPath, App::scriptsPath()) . '/'; $param['rp_jelix'] = Path::shortestPath($appPath, JELIX_LIB_PATH) . '/'; $param['rp_lib'] = Path::shortestPath($appPath, LIB_PATH) . '/'; $param['rp_vendor'] = ''; foreach (array(LIB_PATH . 'vendor/', LIB_PATH . '../vendor/', LIB_PATH . '../../../') as $path) { if (file_exists($path)) { $param['rp_vendor'] = Path::shortestPath($appPath, realpath($path) . '/') . '/'; break; } } $param['rp_app'] = Path::shortestPath($wwwpath, $appPath) . '/'; $this->createFile(App::logPath() . '.dummy', 'dummy.tpl', array()); $this->createFile(App::varPath() . 'mails/.dummy', 'dummy.tpl', array()); $this->createFile(App::varPath() . 'sessions/.dummy', 'dummy.tpl', array()); $this->createFile(App::appPath() . 'app/overloads/.dummy', 'dummy.tpl', array()); $this->createFile(App::appPath() . 'app/themes/default/.dummy', 'dummy.tpl', array()); $this->createFile(App::varPath() . 'uploads/.dummy', 'dummy.tpl', array()); $this->createFile($appPath . 'plugins/.dummy', 'dummy.tpl', array()); $this->createFile(App::scriptsPath() . '.dummy', 'dummy.tpl', array()); $this->createFile(App::tempBasePath() . '.dummy', 'dummy.tpl', array()); $this->createFile($appPath . '.htaccess', 'htaccess_deny', $param, "Configuration file for Apache"); $this->createFile($appPath . '.gitignore', 'git_ignore.tpl', $param, ".gitignore"); $this->createFile($appPath . 'jelix-app.json', 'jelix-app.json.tpl', $param, "Project description file"); $this->createFile($appPath . 'composer.json', 'composer.json.tpl', $param, "Composer file"); $this->createFile($appPath . 'cmd.php', 'cmd.php.tpl', $param, "Script for developer commands"); $this->createFile(App::appConfigPath('mainconfig.ini.php'), 'app/config/mainconfig.ini.php.tpl', $param, "Main configuration file"); $this->createFile($configPath . 'localconfig.ini.php.dist', 'var/config/localconfig.ini.php.tpl', $param, "Configuration file for specific environment"); $this->createFile($configPath . 'profiles.ini.php', 'var/config/profiles.ini.php.tpl', $param, "Profiles file"); $this->createFile($configPath . 'profiles.ini.php.dist', 'var/config/profiles.ini.php.tpl', $param, "Profiles file for your repository"); $this->createFile($configPath . 'preferences.ini.php', 'var/config/preferences.ini.php.tpl', $param, "Preferences file"); $this->createFile(App::appConfigPath('urls.xml'), 'app/config/urls.xml.tpl', $param, "URLs mapping file"); $this->createFile(App::appConfigPath('index/config.ini.php'), 'app/config/index/config.ini.php.tpl', $param, "Entry point configuration file"); $this->createFile($appPath . 'app/responses/myHtmlResponse.class.php', 'app/responses/myHtmlResponse.class.php.tpl', $param, "Main response class"); $this->createFile($appPath . 'install/installer.php', 'installer/installer.php.tpl', $param, "Installer script"); $this->createFile($appPath . 'tests/runtests.php', 'tests/runtests.php', $param, "Tests script"); $temp = dirname(rtrim(App::tempBasePath(), '/')); if ($temp != rtrim($appPath, '/')) { if (file_exists($temp . '/.gitignore')) { $gitignore = file_get_contents($temp . '/.gitignore') . "\n" . $appName . "/*\n"; file_put_contents($temp . '/.gitignore', $gitignore); } else { file_put_contents($temp . '/.gitignore', $appName . "/*\n"); } } else { $gitignore = file_get_contents($appPath . '.gitignore') . "\n" . basename(rtrim(App::tempBasePath(), '/')) . "/*\n"; file_put_contents($appPath . '.gitignore', $gitignore); } $this->createFile($wwwpath . 'index.php', 'www/index.php.tpl', $param, "Main entry point"); $this->createFile($wwwpath . '.htaccess', 'htaccess_allow', $param, "Configuration file for Apache"); $param['php_rp_temp'] = $this->convertRp($param['rp_temp']); $param['php_rp_var'] = $this->convertRp($param['rp_var']); $param['php_rp_log'] = $this->convertRp($param['rp_log']); $param['php_rp_conf'] = $this->convertRp($param['rp_conf']); $param['php_rp_www'] = $this->convertRp($param['rp_www']); $param['php_rp_cmd'] = $this->convertRp($param['rp_cmd']); $param['php_rp_jelix'] = $this->convertRp($param['rp_jelix']); if ($param['rp_vendor']) { $param['php_rp_vendor'] = $this->convertRp($param['rp_vendor']); $this->createFile($appPath . 'application.init.php', 'application2.init.php.tpl', $param, "Bootstrap file"); } else { $this->createFile($appPath . 'application.init.php', 'application.init.php.tpl', $param, "Bootstrap file"); } return $param; }
/** * @param \Jelix\IniFile\MultiIniModifier $mainConfig the mainconfig.ini.php file combined with defaultconfig.ini.php * @param \Jelix\IniFile\MultiIniModifier $localConfig the localconfig.ini.php file combined with $mainConfig * @param string $configFile the path of the configuration file, relative * to the app/config directory * @param string $file the filename of the entry point * @param string $type type of the entry point ('classic', 'cli', 'xmlrpc'....) */ function __construct(\Jelix\IniFile\MultiIniModifier $mainConfig, \Jelix\IniFile\MultiIniModifier $localConfig, $configFile, $file, $type) { $this->type = $type; $this->isCliScript = $type == 'cmdline'; $this->configFile = $configFile; $this->scriptName = $this->isCliScript ? $file : '/' . $file; $this->file = $file; $this->mainConfigIni = $mainConfig; $this->localConfigIni = $localConfig; $this->epConfigIni = new \Jelix\IniFile\IniModifier(\Jelix\Core\App::appConfigPath($configFile)); $this->configIni = new \Jelix\IniFile\MultiIniModifier($localConfig, $this->epConfigIni); $compiler = new \Jelix\Core\Config\Compiler($configFile, $this->scriptName, $this->isCliScript); $this->config = $compiler->read(true); $this->modulesInfos = $compiler->getModulesInfos(); }
protected function migrate_1_7_0() { $this->reporter->message('Start migration to 1.7.0', 'notice'); $newConfigPath = App::appConfigPath(); if (!file_exists($newConfigPath)) { $this->reporter->message('Create app/config/', 'notice'); \jFile::createDir($newConfigPath); } // move mainconfig.php to app/config/ if (!file_exists($newConfigPath . 'mainconfig.ini.php')) { if (!file_exists(App::configPath('mainconfig.ini.php'))) { if (!file_exists(App::configPath('defaultconfig.ini.php'))) { throw new \Exception("Migration to Jelix 1.7.0 canceled: where is your mainconfig.ini.php?"); } $this->reporter->message('Move var/config/defaultconfig.ini.php to app/config/mainconfig.ini.php', 'notice'); rename(App::configPath('defaultconfig.ini.php'), $newConfigPath . 'mainconfig.ini.php'); } else { $this->reporter->message('Move var/config/mainconfig.ini.php to app/config/', 'notice'); rename(App::configPath('mainconfig.ini.php'), $newConfigPath . 'mainconfig.ini.php'); } } // move entrypoint configs to app/config $projectxml = simplexml_load_file(App::appPath('project.xml')); // read all entry points data foreach ($projectxml->entrypoints->entry as $entrypoint) { $configFile = (string) $entrypoint['config']; $dest = App::appConfigPath($configFile); if (!file_exists($dest)) { if (!file_exists(App::configPath($configFile))) { $this->reporter->message("Config file var/config/{$configFile} indicated in project.xml, does not exist", 'warning'); continue; } $this->reporter->message("Move var/config/{$configFile} to app/config/", 'notice'); \jFile::createDir(dirname($dest)); rename(App::configPath($configFile), $dest); } $config = parse_ini_file(App::appConfigPath($configFile), true); if (isset($config['urlengine']['significantFile'])) { $urlFile = $config['urlengine']['significantFile']; if (!file_exists(App::appConfigPath($urlFile)) && file_exists(App::configPath($urlFile))) { $this->reporter->message("Move var/config/{$urlFile} to app/config/", 'notice'); rename(App::configPath($urlFile), App::appConfigPath($urlFile)); } } } // move urls.xml to app/config $mainconfig = parse_ini_file(App::appConfigPath('mainconfig.ini.php'), true); if (isset($mainconfig['urlengine']['significantFile'])) { $urlFile = $mainconfig['urlengine']['significantFile']; } else { $urlFile = 'urls.xml'; } if (!file_exists(App::appConfigPath($urlFile)) && file_exists(App::configPath($urlFile))) { $this->reporter->message("Move var/config/{$urlFile} to app/config/", 'notice'); rename(App::configPath($urlFile), App::appConfigPath($urlFile)); } $this->reporter->message('Migration to 1.7.0 is done', 'notice'); if (!file_exists(App::appPath('app/responses'))) { $this->reporter->message("Move responses/ to app/responses/", 'notice'); rename(App::appPath('responses'), App::appPath('app/responses')); } }
protected function _execute(InputInterface $input, OutputInterface $output) { $entrypoint = $input->getArgument('entrypoint'); if (($p = strpos($entrypoint, '.php')) !== false) { $entrypoint = substr($entrypoint, 0, $p); } $ep = $this->getEntryPointInfo($entrypoint); if ($ep == null) { try { $options = array('entrypoint' => $entrypoint); $this->executeSubCommand('app:createentrypoint', $options, $output); $this->appInfos = null; $ep = $this->getEntryPointInfo($entrypoint); } catch (\Exception $e) { throw new \Exception("The entrypoint has not been created because of this error: " . $e->getMessage() . ". No other files have been created.\n"); } } $installConfig = new \Jelix\IniFile\IniModifier(App::configPath('installer.ini.php')); $inifile = new \Jelix\IniFile\MultiIniModifier(App::mainConfigFile(), App::appConfigPath($ep['config'])); $params = array(); $this->createFile(App::appPath('app/responses/adminHtmlResponse.class.php'), 'app/responses/adminHtmlResponse.class.php.tpl', $params, "Response for admin interface"); $this->createFile(App::appPath('app/responses/adminLoginHtmlResponse.class.php'), 'app/responses/adminLoginHtmlResponse.class.php.tpl', $params, "Response for login page"); $inifile->setValue('html', 'adminHtmlResponse', 'responses'); $inifile->setValue('htmlauth', 'adminLoginHtmlResponse', 'responses'); $repositoryPath = \jFile::parseJelixPath('lib:jelix-admin-modules'); $this->registerModulesDir('lib:jelix-admin-modules', $repositoryPath); $installConfig->setValue('jacl.installed', '0', $entrypoint); $inifile->setValue('jacl.access', '0', 'modules'); $installConfig->setValue('jacldb.installed', '0', $entrypoint); $inifile->setValue('jacldb.access', '0', 'modules'); $inifile->save(); $urlsFile = jApp::appConfigPath($inifile->getValue('significantFile', 'urlengine')); $xmlMap = new \Jelix\Routing\UrlMapping\XmlMapModifier($urlsFile, true); $xmlEp = $xmlMap->getEntryPoint($entrypoint); $xmlEp->addUrlAction('/', 'master_admin', 'default:index', null, null, array('default' => true)); $xmlEp->addUrlModule('', 'master_admin'); $xmlEp->addUrlInclude('/admin/acl', 'jacl2db_admin', 'urls.xml'); $xmlEp->addUrlInclude('/admin/auth', 'jauthdb_admin', 'urls.xml'); $xmlEp->addUrlInclude('/admin/pref', 'jpref_admin', 'urls.xml'); $xmlEp->addUrlInclude('/auth', 'jauth', 'urls.xml'); $xmlMap->save(); $reporter = new \Jelix\Installer\Reporter\Console($output->isVerbose() ? 'notice' : 'warning'); $installer = new \Jelix\Installer\Installer($reporter); $installer->installModules(array('jauth', 'master_admin'), $entrypoint . '.php'); $authini = new \Jelix\IniFile\IniModifier(App::configPath($entrypoint . '/auth.coord.ini.php')); $authini->setValue('after_login', 'master_admin~default:index'); $authini->setValue('timeout', '30'); $authini->save(); $profile = $input->getOption('profile'); if (!$input->getOption('noauthdb')) { if ($profile != '') { $authini->setValue('profile', $profile, 'Db'); } $authini->save(); $installer->setModuleParameters('jauthdb', array('defaultuser' => true)); $installer->installModules(array('jauthdb', 'jauthdb_admin'), $entrypoint . '.php'); } else { $installConfig->setValue('jauthdb_admin.installed', '0', $entrypoint); $installConfig->save(); $inifile->setValue('jauthdb_admin.access', '0', 'modules'); $inifile->save(); } if (!$input->getOption('noacl2db')) { if ($profile != '') { $dbini = new \Jelix\IniFile\IniModifier(App::configPath('profiles.ini.php')); $dbini->setValue('jacl2_profile', $profile, 'jdb'); $dbini->save(); } $installer = new \Jelix\Installer\Installer($reporter); $installer->setModuleParameters('jacl2db', array('defaultuser' => true)); $installer->installModules(array('jacl2db', 'jacl2db_admin'), $entrypoint . '.php'); } else { $installConfig->setValue('jacl2db_admin.installed', '0', $entrypoint); $installConfig->save(); $inifile->setValue('jacl2db_admin.access', '0', 'modules'); $inifile->save(); } $installer->installModules(array('jpref_admin'), $entrypoint . '.php'); }
public static function appConfigPath($file = '') { return \Jelix\Core\App::appConfigPath($file); }