public function run() { \Jelix\Core\AppManager::close(); $module = $this->getParam('module'); $modulesList = $this->getParam('...', array()); array_unshift($modulesList, $module); $parameters = $this->getOption('-p'); if ($parameters && count($modulesList) > 1) { throw new Exception('Parameters are for only one module'); } if ($parameters) { $params = explode(';', $parameters); $parameters = array(); foreach ($params as $param) { $kp = explode("=", $param); if (count($kp) > 1) { $parameters[$kp[0]] = $kp[1]; } else { $parameters[$kp[0]] = true; } } } if ($this->verbose()) { $reporter = new \Jelix\Installer\Reporter\Console(); } else { $reporter = new \Jelix\Installer\Reporter\Console('error'); } $installer = new \Jelix\Installer\Installer($reporter); if ($this->allEntryPoint) { if ($parameters) { $installer->setModuleParameters($modulesList[0], $parameters); } $installer->installModules($modulesList); } else { if ($parameters) { $installer->setModuleParameters($modulesList[0], $parameters, $this->entryPointName); } $installer->installModules($modulesList, $this->entryPointName); } try { \Jelix\Core\AppManager::clearTemp(\Jelix\Core\App::tempBasePath()); } catch (Exception $e) { if ($e->getCode() == 2) { echo "Error: bad path in \\Jelix\\Core\\App::tempBasePath(), it is equals to '" . \Jelix\Core\App::tempBasePath() . "' !!\n"; echo " Jelix cannot clear the content of the temp directory.\n"; echo " you must clear it your self.\n"; echo " Correct the path in application.init.php or create the directory\n"; } else { echo "Error: " . $e->getMessage(); } } \Jelix\Core\AppManager::open(); }
protected function _execute(InputInterface $input, OutputInterface $output) { require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php'; \Jelix\Core\AppManager::close(); $module = $input->getArgument('module'); $parameters = $input->getOption('parameters'); if ($parameters) { $params = explode(';', $parameters); $parameters = array(); foreach ($params as $param) { $kp = explode("=", $param); if (count($kp) > 1) { $parameters[$kp[0]] = $kp[1]; } else { $parameters[$kp[0]] = true; } } } if ($this->verbose()) { $reporter = new \Jelix\Installer\Reporter\Console(); } else { $reporter = new \Jelix\Installer\Reporter\Console('error'); } $installer = new \Jelix\Installer\Installer($reporter); if ($this->allEntryPoint) { if ($parameters) { $installer->setModuleParameters($module, $parameters); } $installer->installModules(array($module)); } else { if ($parameters) { $installer->setModuleParameters($module, $parameters, $this->entryPointName); } $installer->installModules(array($module), $this->entryPointName); } try { \Jelix\Core\AppManager::clearTemp(\jApp::tempBasePath()); } catch (\Exception $e) { if ($e->getCode() == 2) { $output->writeln("Error: bad path in \\Jelix\\Core\\App::tempBasePath(), it is equals to '" . App::tempBasePath() . "' !!"); $output->writeln(" Jelix cannot clear the content of the temp directory."); $output->writeln(" you must clear it your self."); $output->writeln(" Correct the path in application.init.php or create the directory"); } else { $output->writeln("<error>Error: " . $e->getMessage() . "</error>"); } } \Jelix\Core\AppManager::open(); }
/** * action to display the page * @param \Jelix\Castor\Castor $tpl the template container */ function show(\Jelix\Castor\Castor $tpl) { if (isset($this->config['level'])) { $level = $this->config['level']; if (!in_array($level, array('error', 'notice', 'warning'))) { $level = 'warning'; } } else { $level = 'warning'; } $reporter = new wizInstallReporter($level, $this); $installer = new \Jelix\Installer\Installer($reporter); $ok = $installer->installApplication(); $tpl->assign('messages', $reporter->messages); $tpl->assign('installok', $ok); return $ok; }
protected function _execute(InputInterface $input, OutputInterface $output) { \Jelix\Core\AppManager::close(); if ($this->verbose()) { $reporter = new \Jelix\Installer\Reporter\Console('notice', 'Low-level migration'); } else { $reporter = new \Jelix\Installer\Reporter\Console('error', 'Low-level migration'); } // launch the low-level migration $migrator = new \Jelix\Installer\Migration($reporter); $migrator->migrate(); // we can now launch the installer/updater if ($this->verbose()) { $reporter = new \Jelix\Installer\Reporter\Console(); } else { $reporter = new \Jelix\Installer\Reporter\Console('error'); } $installer = new \Jelix\Installer\Installer($reporter); if ($input->getOption('entry-point')) { $installer->installEntryPoint($this->entryPointId); } else { $installer->installApplication(); } try { \Jelix\Core\AppManager::clearTemp(\Jelix\Core\App::tempBasePath()); } catch (\Exception $e) { if ($e->getCode() == 2) { $output->writeln("<error>Error: bad path in jApp::tempBasePath(), it is equals to '" . jApp::tempBasePath() . "' !!</error>"); $output->writeln(" Jelix cannot clear the content of the temp directory."); $output->writeln(" you must clear it your self."); $output->writeln(" Correct the path in the application.init.php or create the directory"); } else { $output->writeln("<error>Error: " . $e->getMessage() . "</error>"); } } \Jelix\Core\AppManager::open(); }
public function run() { \Jelix\Core\AppManager::close(); if ($this->verbose()) { $reporter = new \Jelix\Installer\Reporter\Console(); } else { $reporter = new \Jelix\Installer\Reporter\Console('error'); } $installer = new \Jelix\Installer\Installer($reporter); $installer->installApplication(); try { \Jelix\Core\AppManager::clearTemp(\Jelix\Core\App::tempBasePath()); } catch (Exception $e) { if ($e->getCode() == 2) { echo "Error: bad path in use \\Jelix\\Core\\App::tempBasePath(), it is equals to '" . \Jelix\Core\App::tempBasePath() . "' !!\n"; echo " Jelix cannot clear the content of the temp directory.\n"; echo " you must clear it your self.\n"; echo " Correct the path in the application.init.php or create the directory\n"; } else { echo "Error: " . $e->getMessage(); } } \Jelix\Core\AppManager::open(); }
public function run() { $this->loadAppConfig(); $entrypoint = $this->getParam('entrypoint'); if (($p = strpos($entrypoint, '.php')) !== false) { $entrypoint = substr($entrypoint, 0, $p); } $ep = $this->getEntryPointInfo($entrypoint); if ($ep == null) { try { $cmd = JelixScript::getCommand('createentrypoint', $this->config); $cmd->initOptParam(array(), array('name' => $entrypoint)); $cmd->run(); $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::configPath($ep['config'])); $params = array(); $this->createFile(App::appPath('responses/adminHtmlResponse.class.php'), 'responses/adminHtmlResponse.class.php.tpl', $params, "Response for admin interface"); $this->createFile(App::appPath('responses/adminLoginHtmlResponse.class.php'), 'responses/adminLoginHtmlResponse.class.php.tpl', $params, "Response for login page"); $inifile->setValue('html', 'adminHtmlResponse', 'responses'); $inifile->setValue('htmlauth', 'adminLoginHtmlResponse', 'responses'); $inifile->setValue('startModule', 'master_admin'); $inifile->setValue('startAction', 'default:index'); $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'); $urlconf = $inifile->getValue($entrypoint, 'simple_urlengine_entrypoints', null, true); if ($urlconf === null || $urlconf == '') { // in defaultconfig $inifile->setValue($entrypoint, 'jacl2db_admin~*@classic, jauthdb_admin~*@classic, master_admin~*@classic, jpref_admin~*@classic', 'simple_urlengine_entrypoints', null, true); // in the config of the entry point $inifile->setValue($entrypoint, 'jacl2db~*@classic, jauth~*@classic, jacl2db_admin~*@classic, jauthdb_admin~*@classic, master_admin~*@classic, jpref_admin~*@classic', 'simple_urlengine_entrypoints'); } else { $urlconf2 = $inifile->getValue($entrypoint, 'simple_urlengine_entrypoints'); if (strpos($urlconf, 'jacl2db_admin~*@classic') === false) { $urlconf .= ',jacl2db_admin~*@classic'; } if (strpos($urlconf, 'jauthdb_admin~*@classic') === false) { $urlconf .= ',jauthdb_admin~*@classic'; } if (strpos($urlconf, 'master_admin~*@classic') === false) { $urlconf .= ',master_admin~*@classic'; } if (strpos($urlconf2, 'jacl2db_admin~*@classic') === false) { $urlconf2 .= ',jacl2db_admin~*@classic'; } if (strpos($urlconf2, 'jauthdb_admin~*@classic') === false) { $urlconf2 .= ',jauthdb_admin~*@classic'; } if (strpos($urlconf2, 'master_admin~*@classic') === false) { $urlconf2 .= ',master_admin~*@classic'; } if (strpos($urlconf2, 'jacl2db~*@classic') === false) { $urlconf2 .= ',jacl2db~*@classic'; } if (strpos($urlconf2, 'jauth~*@classic') === false) { $urlconf2 .= ',jauth~*@classic'; } if (strpos($urlconf2, 'jpref_admin~*@classic') === false) { $urlconf2 .= ',jpref_admin~*@classic'; } $inifile->setValue($entrypoint, $urlconf, 'simple_urlengine_entrypoints', null, true); $inifile->setValue($entrypoint, $urlconf2, 'simple_urlengine_entrypoints'); } if (null == $inifile->getValue($entrypoint, 'basic_significant_urlengine_entrypoints', null, true)) { $inifile->setValue($entrypoint, '1', 'basic_significant_urlengine_entrypoints', null, true); } $inifile->save(); $verbose = $this->verbose(); $reporter = new \Jelix\Installer\Reporter\Console($verbose ? 'notice' : 'warning'); $installer = new \Jelix\Installer\Installer($reporter); $installer->installModules(array('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 = $this->getOption('-profile'); if (!$this->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 (!$this->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 function run() { // retrieve the type of entry point we want to create $type = $this->getOption('-type'); if (!$type) { $type = 'classic'; } else { if (!in_array($type, array('classic', 'jsonrpc', 'xmlrpc', 'soap', 'cmdline'))) { throw new Exception("invalid type"); } } // retrieve the name of the entry point $name = $this->getParam('name'); 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 = $this->getParam('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::configPath($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 = $this->getOption('-copy-config'); if ($originalConfig) { if (!file_exists(App::configPath($originalConfig))) { throw new Exception("unknown original configuration file"); } file_put_contents($configFilePath, file_get_contents(App::configPath($originalConfig))); if ($this->verbose()) { echo "Configuration file {$configFile} has been created from the config file {$originalConfig}.\n"; } } else { // else we create a new config file, with the startmodule of the default // config as a module name. $mainConfig = parse_ini_file(App::mainConfigFile(), true); $param = array(); if (isset($mainConfig['startModule'])) { $param['modulename'] = $mainConfig['startModule']; } else { $param['modulename'] = 'jelix'; } $this->createFile($configFilePath, 'var/config/index/config.ini.php.tpl', $param, "Configuration file"); } } $inifile = new \Jelix\IniFile\MultiIniModifier(App::mainConfigFile(), $configFilePath); $param = array(); $param['modulename'] = $inifile->getValue('startModule'); // creation of the entry point $this->createDir($entryPointDir); $param['rp_app'] = $this->getRelativePath($entryPointDir, App::appPath()); $param['config_file'] = $configFile; $this->createFile($entryPointFullPath, $entryPointTemplate, $param, "Entry point"); if ($type != 'cmdline') { if (null === $inifile->getValue($name, 'simple_urlengine_entrypoints', null, true)) { $inifile->setValue($name, '', 'simple_urlengine_entrypoints', null, true); } if (null === $inifile->getValue($name, 'basic_significant_urlengine_entrypoints', null, true)) { $inifile->setValue($name, '1', 'basic_significant_urlengine_entrypoints', null, true); } $inifile->save(); } $this->appInfos->addEntryPointInfo($name . ".php", $configFile, $type); if ($this->verbose()) { echo $this->appInfos->getFile() . " has been updated.\n"; } $installer = new \Jelix\Installer\Installer(new \Jelix\Installer\Reporter\Console('warning')); $installer->installEntryPoint($name . ".php"); if ($this->verbose()) { echo "All modules have been initialized for the new entry point.\n"; } }
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 execute(InputInterface $input, OutputInterface $output) { $appPath = $input->getArgument('path'); $appPath = Path::normalizePath($appPath, 0, getcwd()); $appName = basename($appPath); $appPath .= '/'; if (file_exists($appPath . '/jelix-app.json') || file_exists($appPath . '/project.xml')) { throw new \Exception("this application is already created"); } $this->prepareSubCommandApp($appName, $appPath); App::setEnv('jelix-scripts'); \Jelix\DevHelper\JelixScript::checkTempPath(); if ($p = $input->getOption('wwwpath')) { $wwwpath = Path::shortestPath($appPath, $p) . '/'; } else { $wwwpath = App::wwwPath(); } if ($output->isVerbose()) { $output->writeln("Create directories and files at {$appPath}"); } $param = $this->_createSkeleton($appPath, $appName, $wwwpath, $input); App::declareModulesDir(array($appPath . '/modules/')); $installer = new \Jelix\Installer\Installer(new \Jelix\Installer\Reporter\Console($output->isVerbose() ? 'notice' : 'warning')); $installer->installApplication(); $moduleok = true; if (!$input->getOption('nodefaultmodule')) { try { if ($output->isVerbose()) { $output->writeln("Create default module " . $param['modulename']); } $options = array('module' => $param['modulename'], '--addinstallzone' => true, '--noregistration' => true); if ($output->isVerbose()) { $options['-v'] = true; } $this->executeSubCommand('module:create', $options, $output); if ($output->isVerbose()) { $output->writeln("Create main template"); } $this->createFile($appPath . 'modules/' . $param['modulename'] . '/templates/main.tpl', 'module/main.tpl.tpl', $param, "Main template"); } catch (\Exception $e) { $moduleok = false; $output->writeln("<error>The module has not been created because of this error: " . $e->getMessage() . "</error>"); $output->writeln("However the application has been created"); } } if ($input->getOption('withcmdline')) { if (!$input->getOption('nodefaultmodule') && $moduleok) { if ($output->isVerbose()) { $output->writeln("Create a controller in the default module for the cli script"); } $options = array('module' => $param['modulename'], 'controller' => 'default', 'method' => 'index', '--cmdline' => true); if ($output->isVerbose()) { $options['-v'] = true; } $this->executeSubCommand('module:createctrl', $options, $output); } if ($output->isVerbose()) { $output->writeln("Create the cli script"); } $options = array('entrypoint' => $param['modulename'], '--type' => 'cmdline'); if ($output->isVerbose()) { $options['-v'] = true; } $this->executeSubCommand('app:createentrypoint', $options, $output); } }
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 function run() { $appPath = $this->getParam('path'); $appPath = $this->getRealPath($appPath); $appName = basename($appPath); $appPath .= '/'; if (file_exists($appPath . '/jelix-app.json') || file_exists($appPath . '/project.xml')) { throw new Exception("this application is already created"); } $this->config = JelixScript::loadConfig($appName); $this->config->infoWebsite = $this->config->newAppInfoWebsite; $this->config->infoLicence = $this->config->newAppInfoLicence; $this->config->infoLicenceUrl = $this->config->newAppInfoLicenceUrl; $this->config->infoLocale = $this->config->newAppInfoLocale; $this->config->infoCopyright = $this->config->newAppInfoCopyright; $this->config->initAppPaths($appPath); App::setEnv('jelix-scripts'); JelixScript::checkTempPath(); if ($p = $this->getOption('-wwwpath')) { $wwwpath = path::real($appPath . $p, false) . '/'; } else { $wwwpath = App::wwwPath(); } $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($configPath); $this->createDir($configPath . 'index/'); $this->createDir($varPath . 'overloads/'); $this->createDir($varPath . 'themes/'); $this->createDir($varPath . '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($appPath . 'responses'); $this->createDir($appPath . 'tests'); $this->createDir(App::scriptsPath()); $param = array(); if ($this->getOption('-nodefaultmodule')) { $param['tplname'] = 'jelix~defaultmain'; $param['modulename'] = 'jelix'; } else { $moduleName = $this->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'] = $this->getRelativePath($appPath, App::tempBasePath()); $param['rp_var'] = $this->getRelativePath($appPath, App::varPath()); $param['rp_log'] = $this->getRelativePath($appPath, App::logPath()); $param['rp_conf'] = $this->getRelativePath($appPath, $configPath); $param['rp_www'] = $this->getRelativePath($appPath, $wwwpath); $param['rp_cmd'] = $this->getRelativePath($appPath, App::scriptsPath()); $param['rp_jelix'] = $this->getRelativePath($appPath, JELIX_LIB_PATH); $param['rp_vendor'] = ''; foreach (array(LIB_PATH . 'vendor/', LIB_PATH . '../vendor/', LIB_PATH . '../../../') as $path) { if (file_exists($path)) { $param['rp_vendor'] = $this->getRelativePath($appPath, realpath($path) . '/'); break; } } $param['rp_app'] = $this->getRelativePath($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::varPath() . 'overloads/.dummy', 'dummy.tpl', array()); $this->createFile(App::varPath() . '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($configPath . 'mainconfig.ini.php', 'var/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($configPath . 'urls.xml', 'var/config/urls.xml.tpl', $param, "URLs mapping file"); $this->createFile($configPath . 'index/config.ini.php', 'var/config/index/config.ini.php.tpl', $param, "Entry point configuration file"); $this->createFile($appPath . 'responses/myHtmlResponse.class.php', '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"); } $installer = new \Jelix\Installer\Installer(new \Jelix\Installer\Reporter\Console('warning')); $installer->installApplication(); $moduleok = true; if (!$this->getOption('-nodefaultmodule')) { try { $cmd = JelixScript::getCommand('createmodule', $this->config); $options = $this->getCommonActiveOption(); $options['-addinstallzone'] = true; $options['-noregistration'] = true; $cmd->initOptParam($options, array('module' => $param['modulename'])); $cmd->run(); $this->createFile($appPath . 'modules/' . $param['modulename'] . '/templates/main.tpl', 'module/main.tpl.tpl', $param, "Main template"); } catch (Exception $e) { $moduleok = false; echo "The module has not been created because of this error: " . $e->getMessage() . "\nHowever the application has been created\n"; } } if ($this->getOption('-withcmdline')) { if (!$this->getOption('-nodefaultmodule') && $moduleok) { $agcommand = JelixScript::getCommand('createctrl', $this->config); $options = $this->getCommonActiveOption(); $options['-cmdline'] = true; $agcommand->initOptParam($options, array('module' => $param['modulename'], 'name' => 'default', 'method' => 'index')); $agcommand->run(); } $agcommand = JelixScript::getCommand('createentrypoint', $this->config); $options = $this->getCommonActiveOption(); $options['-type'] = 'cmdline'; $parameters = array('name' => $param['modulename']); $agcommand->initOptParam($options, $parameters); $agcommand->run(); } }