コード例 #1
0
 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();
 }
コード例 #2
0
ファイル: initadmin.cmd.php プロジェクト: hadrienl/jelix
 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();
     }
 }