Esempio n. 1
0
 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();
 }
Esempio n. 2
0
 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();
 }
Esempio n. 3
0
 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');
 }
Esempio n. 4
0
 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');
 }