public function run() { $this->loadStep(); $this->loadProjectXml(); // verify version $this->checkVersion(); // update configuration file of entry points $this->updateConfig(); // update project.xml $this->updateProjectXml(); // launch jInstaller if ($this->checkStep("Install virtually all modules")) { require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php'; $reporter = new textInstallReporter(); $install = new jInstaller($reporter); $install->forceModuleVersion('jacl2db', '1.1'); $install->forceModuleVersion('jauthdb', '1.1'); $result = $install->installApplication(jInstaller::FLAG_MIGRATION_11X); if (!$result) { throw new Exception("Installation of modules failed. Fix and retry."); } } if ($this->checkStep("Create the install/installer.php script")) { if (!file_exists(jApp::appPath('install/installer.php'))) { $this->createDir(jApp::appPath('install/')); $this->createFile(jApp::appPath('install/installer.php'), 'installer/installer.php.tpl', array()); } } $this->finalStep("Migration done"); }
public function run() { require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php'; jAppManager::close(); if ($this->verbose()) { $reporter = new textInstallReporter(); } else { $reporter = new textInstallReporter('error'); } $installer = new jInstaller($reporter); $installer->installApplication(); try { jAppManager::clearTemp(jApp::tempBasePath()); } catch (Exception $e) { if ($e->getCode() == 2) { echo "Error: bad path in jApp::tempBasePath(), it is equals to '" . jApp::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(); } } jAppManager::open(); }
protected function _execute(InputInterface $input, OutputInterface $output) { require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php'; \jAppManager::close(); $module = $input->getArgument('module'); if ($this->verbose()) { $reporter = new \textInstallReporter(); } else { $reporter = new \textInstallReporter('error'); } $installer = new \jInstaller($reporter); if ($this->allEntryPoint) { $installer->uninstallModules(array($module)); } else { $installer->uninstallModules(array($module), $this->entryPointName); } try { \jAppManager::clearTemp(\jApp::tempBasePath()); } catch (\Exception $e) { if ($e->getCode() == 2) { $output->writeln("Error: bad path in jApp::tempBasePath(), it is equals to '" . jApp::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>"); } } \jAppManager::open(); }
public function run() { require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php'; jAppManager::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 textInstallReporter(); } else { $reporter = new textInstallReporter('error'); } $installer = new jInstaller($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 { jAppManager::clearTemp(jApp::tempBasePath()); } catch (Exception $e) { if ($e->getCode() == 2) { echo "Error: bad path in jApp::tempBasePath(), it is equals to '" . jApp::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(); } } jAppManager::open(); }
function show($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 jInstaller($reporter); $ok = $installer->installApplication(); $tpl->assign('messages', $reporter->messages); $tpl->assign('installok', $ok); return $ok; }
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->projectXml = 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 jIniFileModifier(jApp::configPath('installer.ini.php')); $inifile = new jIniMultiFilesModifier(jApp::configPath('defaultconfig.ini.php'), jApp::configPath($ep['config'])); $params = array(); $this->createFile(jApp::appPath('responses/adminHtmlResponse.class.php'), 'responses/adminHtmlResponse.class.php.tpl', $params); $this->createFile(jApp::appPath('responses/adminLoginHtmlResponse.class.php'), 'responses/adminLoginHtmlResponse.class.php.tpl', $params); $inifile->setValue('html', 'adminHtmlResponse', 'responses'); $inifile->setValue('htmlauth', 'adminLoginHtmlResponse', 'responses'); $inifile->setValue('startModule', 'master_admin'); $inifile->setValue('startAction', 'default:index'); $modulePath = $inifile->getValue("modulesPath", 0, null, true); if (strpos($modulePath, 'lib:jelix-admin-modules') === false) { // we set it on defaultconfig.ini.php, so if the url engine is "significant" // it could know the admin modules during the parsing of modules $inifile->setValue('modulesPath', 'lib:jelix-admin-modules/,' . $modulePath, 0, null, true); } $installConfig->setValue('jacldb.installed', '0', $entrypoint); $inifile->setValue('jacldb.access', '0', 'modules'); $installConfig->setValue('junittests.installed', '0', $entrypoint); $inifile->setValue('junittests.access', '0', 'modules'); $installConfig->setValue('jWSDL.installed', '0', $entrypoint); $inifile->setValue('jWSDL.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', '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', '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'; } $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(); require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php'; $verbose = $this->getOption("-v"); $reporter = new textInstallReporter($verbose ? 'notice' : 'warning'); $installer = new jInstaller($reporter); $installer->installModules(array('master_admin'), $entrypoint . '.php'); $authini = new jIniFileModifier(jApp::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 jIniFileModifier(jApp::configPath('profiles.ini.php')); $dbini->setValue('jacl2_profile', $profile, 'jdb'); $dbini->save(); } $installer = new jInstaller($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(); } }
<?php /** * @package jelix * @subpackage testapp * @author Laurent Jouanneau * @contributor Rahal Aboulfeth * @copyright 2009-2010 Laurent Jouanneau, 2011 Rahal Aboulfeth * @link http://jelix.org * @licence http://www.gnu.org/licenses/gpl.html GNU General Public Licence, see LICENCE file */ require_once dirname(__FILE__) . '/../application.init.php'; jApp::setEnv('install'); jAppManager::close(); $installer = new jInstaller(new textInstallReporter()); $installer->installApplication(); jAppManager::clearTemp(); jAppManager::open();
public function run() { require_once LIB_PATH . 'clearbricks/jelix.inc.php'; require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php'; $appPath = $this->getParam('path'); $appPath = $this->getRealPath($appPath); $appName = basename($appPath); $appPath .= '/'; if (file_exists($appPath)) { throw new Exception("this application is already created"); } $this->config = JelixScript::loadConfig($appName); $this->config->infoIDSuffix = $this->config->newAppInfoIDSuffix; $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); jApp::setEnv('jelix-scripts'); jApp::initLegacy(); JelixScript::checkTempPath(); if ($p = $this->getOption('-wwwpath')) { $wwwpath = path::real($appPath . $p, false) . '/'; } else { $wwwpath = jApp::wwwPath(); } $this->createDir($appPath); $this->createDir(jApp::tempBasePath()); $this->createDir($wwwpath); $varPath = jApp::varPath(); $configPath = jApp::configPath(); $this->createDir($varPath); $this->createDir(jApp::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 . 'plugins/coord/'); $this->createDir($appPath . 'plugins/tpl/'); $this->createDir($appPath . 'plugins/tpl/common'); $this->createDir($appPath . 'plugins/tpl/html'); $this->createDir($appPath . 'plugins/tpl/text'); $this->createDir($appPath . 'plugins/db/'); $this->createDir($appPath . 'plugins/auth/'); $this->createDir($appPath . 'responses'); $this->createDir($appPath . 'tests'); $this->createDir(jApp::scriptsPath()); $param = array(); $param['default_id'] = $appName . $this->config->infoIDSuffix; if ($this->getOption('-nodefaultmodule')) { $param['tplname'] = 'jelix~defaultmain'; $param['modulename'] = 'jelix'; } else { // note: since module name are used for name of generated name, // only this characters are allowed $param['modulename'] = preg_replace('/([^a-zA-Z_0-9])/', '_', $appName); $param['tplname'] = $param['modulename'] . '~main'; } $param['config_file'] = 'index/config.ini.php'; $param['rp_temp'] = $this->getRelativePath($appPath, jApp::tempBasePath()); $param['rp_var'] = $this->getRelativePath($appPath, jApp::varPath()); $param['rp_log'] = $this->getRelativePath($appPath, jApp::logPath()); $param['rp_conf'] = $this->getRelativePath($appPath, $configPath); $param['rp_www'] = $this->getRelativePath($appPath, $wwwpath); $param['rp_cmd'] = $this->getRelativePath($appPath, jApp::scriptsPath()); $param['rp_jelix'] = $this->getRelativePath($appPath, JELIX_LIB_PATH); $param['rp_app'] = $this->getRelativePath($wwwpath, $appPath); $this->createFile(jApp::logPath() . '.dummy', 'dummy.tpl', array()); $this->createFile(jApp::varPath() . 'mails/.dummy', 'dummy.tpl', array()); $this->createFile(jApp::varPath() . 'sessions/.dummy', 'dummy.tpl', array()); $this->createFile(jApp::varPath() . 'overloads/.dummy', 'dummy.tpl', array()); $this->createFile(jApp::varPath() . 'themes/default/.dummy', 'dummy.tpl', array()); $this->createFile($appPath . 'plugins/.dummy', 'dummy.tpl', array()); $this->createFile(jApp::scriptsPath() . '.dummy', 'dummy.tpl', array()); $this->createFile(jApp::tempBasePath() . '.dummy', 'dummy.tpl', array()); $this->createFile($appPath . '.htaccess', 'htaccess_deny', $param, "Configuration file for Apache"); $this->createFile($appPath . 'project.xml', 'project.xml.tpl', $param, "Project description file"); $this->createFile($appPath . 'cmd.php', 'cmd.php.tpl', $param, "Script for developer commands"); $this->createFile($configPath . 'defaultconfig.ini.php', 'var/config/defaultconfig.ini.php.tpl', $param, "Main configuration file"); $this->createFile($configPath . 'defaultconfig.ini.php.dist', 'var/config/defaultconfig.ini.php.tpl', $param, "Main configuration file for your repository"); $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(JELIX_APP_CONFIG_PATH.'installer.ini.php', 'var/config/installer.ini.php.tpl', $param); $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(jApp::tempBasePath()); 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"); } $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']); $this->createFile($appPath . 'application.init.php', 'application.init.php.tpl', $param, "Bootstrap file"); $installer = new jInstaller(new textInstallReporter('warning')); $installer->installApplication(); $moduleok = true; if (!$this->getOption('-nodefaultmodule')) { try { $cmd = JelixScript::getCommand('createmodule', $this->config); $options = $this->getCommonActiveOption(); $options['-addinstallzone'] = 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(); } }
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', 'rdf', '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 = jApp::scriptsPath($name . '.php'); $entryPointTemplate = 'scripts/cmdline.php.tpl'; } else { $entryPointFullPath = jApp::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->loadProjectXml(); // 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 = jApp::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(jApp::configPath($originalConfig))) { throw new Exception("unknown original configuration file"); } file_put_contents($configFilePath, file_get_contents(jApp::configPath($originalConfig))); } else { // else we create a new config file, with the startmodule of the default // config as a module name. $defaultConfig = parse_ini_file(jApp::configPath('defaultconfig.ini.php'), true); $param = array(); if (isset($defaultConfig['startModule'])) { $param['modulename'] = $defaultConfig['startModule']; } else { $param['modulename'] = 'jelix'; } $this->createFile($configFilePath, 'var/config/index/config.ini.php.tpl', $param); } } require_once JELIX_LIB_PATH . 'utils/jIniMultiFilesModifier.class.php'; $inifile = new jIniMultiFilesModifier(jApp::configPath('defaultconfig.ini.php'), $configFilePath); $param = array(); $param['modulename'] = $inifile->getValue('startModule'); // creation of the entry point $this->createDir($entryPointDir); $param['rp_app'] = $this->getRelativePath($entryPointDir, jApp::appPath()); $param['config_file'] = $configFile; $this->createFile($entryPointFullPath, $entryPointTemplate, $param); 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->updateProjectXml($name . ".php", $configFile, $type); require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php'; $installer = new jInstaller(new textInstallReporter('warning')); $installer->installEntryPoint($name . ".php"); }