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