public function run() { jxs_init_jelix_env(); $path = $this->getModulePath($this->_parameters['module']); $table = $this->getParam('table'); $ctrlname = $this->getParam('ctrlname', $table); if (file_exists($path . 'controllers/' . $ctrlname . '.classic.php')) { throw new Exception("controller '" . $ctrlname . "' already exists"); } $agcommand = jxs_load_command('createdao'); $options = array(); $profile = ''; if ($this->getOption('-profile')) { $profile = $this->getOption('-profile'); $options = array('-profile' => $profile); } $agcommand->init($options, array('module' => $this->_parameters['module'], 'name' => $table, 'table' => $table)); $agcommand->run(); $agcommand = jxs_load_command('createform'); $agcommand->init(array(), array('module' => $this->_parameters['module'], 'form' => $table, 'dao' => $table)); $agcommand->run(); $this->createDir($path . 'controllers/'); $params = array('name' => $ctrlname, 'module' => $this->_parameters['module'], 'table' => $table, 'profile' => $profile); $this->createFile($path . 'controllers/' . $ctrlname . '.classic.php', 'controller.daocrud.tpl', $params); }
public function run() { if (isset($this->_parameters['command'])) { if ($this->_parameters['command'] == 'help') { $command = $this; } else { $command = jxs_load_command($this->_parameters['command']); } if (MESSAGE_LANG == 'fr') { $this->disp("\nUtilisation de la commande " . $this->_parameters['command'] . " :\n"); $this->disp("# " . $_SERVER['argv'][0] . " [--NOMAPP] " . $this->_parameters['command'] . " " . $command->syntaxhelp . "\n\n"); } else { $this->disp("\nUsage of " . $this->_parameters['command'] . ":\n"); $this->disp("# " . $_SERVER['argv'][0] . " [--APPNAME] " . $this->_parameters['command'] . " " . $command->syntaxhelp . "\n\n"); } if (is_array($command->help)) { if (isset($command->help[MESSAGE_LANG])) { $this->disp($command->help[MESSAGE_LANG] . "\n\n"); } elseif (isset($command->help['en'])) { $this->disp($command->help['en'] . "\n\n"); } else { $this->disp(array_shift($command->help) . "\n\n"); } } else { $this->disp($command->help . "\n\n"); } } else { if (isset($this->mainhelp[MESSAGE_LANG])) { $help = $this->mainhelp[MESSAGE_LANG]; } else { $help = $this->mainhelp['en']; } $help = str_replace('%SCRIPT%', $_SERVER['argv'][0], $help); $this->disp($help); $list = jxs_commandlist(); foreach ($list as $cmd) { $this->disp($cmd . ' '); } $this->disp("\n\n"); } }
public function run() { if (file_exists(JELIX_APP_PATH)) { throw new Exception("this application is already created"); } $this->createDir(JELIX_APP_PATH); if ($p = $this->getOption('-wwwpath')) { $wwwpath = path::real(JELIX_APP_PATH . $p, false) . '/'; } else { $wwwpath = JELIX_APP_WWW_PATH; } $this->createDir(JELIX_APP_REAL_TEMP_PATH); $this->createDir(JELIX_APP_CLI_TEMP_PATH); $this->createDir(JELIX_APP_TEMP_PATH); $this->createDir($wwwpath); $this->createDir(JELIX_APP_VAR_PATH); $this->createDir(JELIX_APP_LOG_PATH); $this->createDir(JELIX_APP_CONFIG_PATH); $this->createDir(JELIX_APP_CONFIG_PATH . 'index/'); $this->createDir(JELIX_APP_VAR_PATH . 'overloads/'); $this->createDir(JELIX_APP_VAR_PATH . 'themes/'); $this->createDir(JELIX_APP_VAR_PATH . 'themes/default/'); $this->createDir(JELIX_APP_VAR_PATH . 'uploads/'); $this->createDir(JELIX_APP_VAR_PATH . 'sessions/'); $this->createDir(JELIX_APP_PATH . 'modules'); $this->createDir(JELIX_APP_PATH . 'plugins'); $this->createDir(JELIX_APP_PATH . 'plugins/coord/'); $this->createDir(JELIX_APP_PATH . 'plugins/tpl/'); $this->createDir(JELIX_APP_PATH . 'plugins/tpl/common'); $this->createDir(JELIX_APP_PATH . 'plugins/tpl/html'); $this->createDir(JELIX_APP_PATH . 'plugins/tpl/text'); $this->createDir(JELIX_APP_PATH . 'plugins/db/'); $this->createDir(JELIX_APP_PATH . 'plugins/auth/'); $this->createDir(JELIX_APP_PATH . 'responses'); $this->createDir(JELIX_APP_PATH . 'scripts'); $param = array(); $param['default_id'] = $GLOBALS['APPNAME'] . JELIXS_INFO_DEFAULT_IDSUFFIX; 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])/', '_', $GLOBALS['APPNAME']); $param['tplname'] = $param['modulename'] . '~main'; } $param['config_file'] = 'index/config.ini.php'; $param['rp_temp'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_REAL_TEMP_PATH, true); $param['rp_var'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_VAR_PATH, true); $param['rp_log'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_LOG_PATH, true); $param['rp_conf'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CONFIG_PATH, true); $param['rp_www'] = jxs_getRelativePath(JELIX_APP_PATH, $wwwpath, true); $param['rp_cmd'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CMD_PATH, true); $param['rp_jelix'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_LIB_PATH, true); $param['rp_app'] = jxs_getRelativePath($wwwpath, JELIX_APP_PATH, true); $this->createFile(JELIX_APP_PATH . '.htaccess', 'htaccess_deny', $param); $this->createFile(JELIX_APP_PATH . 'project.xml', 'project.xml.tpl', $param); $this->createFile(JELIX_APP_CONFIG_PATH . 'defaultconfig.ini.php', 'var/config/defaultconfig.ini.php.tpl', $param); $this->createFile(JELIX_APP_CONFIG_PATH . 'dbprofils.ini.php', 'var/config/dbprofils.ini.php.tpl', $param); $this->createFile(JELIX_APP_CONFIG_PATH . 'index/config.ini.php', 'var/config/index/config.ini.php.tpl', $param); $this->createFile(JELIX_APP_PATH . 'responses/myHtmlResponse.class.php', 'myHtmlResponse.class.php.tpl', $param); $this->createFile($wwwpath . 'index.php', 'www/index.php.tpl', $param); $this->createFile($wwwpath . '.htaccess', 'htaccess_allow', $param); $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']); $this->createFile(JELIX_APP_PATH . 'application.init.php', 'application.init.php.tpl', $param); $param['rp_temp_app'] = $param['rp_temp']; $param['php_rp_temp_app'] = $param['php_rp_temp']; $param['rp_temp'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_TEMP_PATH, true); $param['rp_temp_cli'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CLI_TEMP_PATH, true); $param['php_rp_temp'] = $this->convertRp($param['rp_temp']); $param['php_rp_temp_cli'] = $this->convertRp($param['rp_temp_cli']); $this->createFile(JELIX_APP_PATH . 'jelix-scripts.init.php', 'jelix-scripts.init.php.tpl', $param); $param['rp_temp'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CLI_TEMP_PATH, true); $param['php_rp_temp'] = $this->convertRp($param['rp_temp']); $this->createFile(JELIX_APP_PATH . 'application-cli.init.php', 'application.init.php.tpl', $param); $moduleok = true; if (!$this->getOption('-nodefaultmodule')) { try { $cmd = jxs_load_command('createmodule'); $cmd->init(array('-addinstallzone' => true), array('module' => $param['modulename'])); $cmd->run(); $this->createFile(JELIX_APP_PATH . 'modules/' . $param['modulename'] . '/templates/main.tpl', 'main.tpl.tpl', $param); } 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 = jxs_load_command('createctrl'); $options = array('-cmdline' => true); $agcommand->init($options, array('module' => $GLOBALS['APPNAME'], 'name' => 'default', 'method' => 'index')); $agcommand->run(); } $agcommand = jxs_load_command('createentrypoint'); $options = array('-type' => 'cmdline'); $parameters = array('name' => $GLOBALS['APPNAME']); $agcommand->init($options, $parameters); $agcommand->run(); } }
public function run() { jxs_init_jelix_env(); $entrypoint = $this->getParam('entrypoint'); if (!file_exists(JELIX_APP_WWW_PATH . $entrypoint . '.php')) { try { $cmd = jxs_load_command('createentrypoint'); $cmd->init(array(), array('name' => $entrypoint)); $cmd->run(); } catch (Exception $e) { echo "The entrypoint has not been created because of this error: " . $e->getMessage() . ". No other files have been created.\n"; } } $inifile = new jIniMultiFilesModifier(JELIX_APP_CONFIG_PATH . 'defaultconfig.ini.php', JELIX_APP_CONFIG_PATH . $entrypoint . '/config.ini.php'); $inifile->setValue('html', 'adminHtmlResponse', 'responses'); $inifile->setValue('htmlauth', 'adminLoginHtmlResponse', 'responses'); $inifile->setValue('auth', $entrypoint . '/auth.coord.ini.php', 'coordplugins'); $inifile->setValue('jacl2', $entrypoint . '/jacl2.coord.ini.php', 'coordplugins'); $inifile->setValue('startModule', 'master_admin'); $inifile->setValue('startAction', 'default:index'); $modulePath = $inifile->getValue("modulesPath"); if (strpos($modulePath, 'lib:jelix-admin-modules') === false) { $inifile->setValue('modulesPath', 'lib:jelix-admin-modules/,' . $modulePath); } $inifile->setValue('driver', 'db', 'acl2'); $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); } $params = array(); $this->createFile(JELIX_APP_PATH . 'responses/adminHtmlResponse.class.php', 'responses/adminHtmlResponse.class.php.tpl', $params); $this->createFile(JELIX_APP_PATH . 'responses/adminLoginHtmlResponse.class.php', 'responses/adminLoginHtmlResponse.class.php.tpl', $params); $this->createFile(JELIX_APP_PATH . 'var/config/' . $entrypoint . '/auth.coord.ini.php', 'var/config/auth.coord.ini.php.tpl', $params); $this->createFile(JELIX_APP_PATH . 'var/config/' . $entrypoint . '/jacl2.coord.ini.php', 'var/config/jacl2.coord.ini.php.tpl', $params); $authini = new jIniFileModifier(JELIX_APP_CONFIG_PATH . $entrypoint . '/auth.coord.ini.php'); $authini->setValue('after_login', 'master_admin~default:index'); $authini->setValue('timeout', '30'); $profile = $this->getOption('-profile'); if (!$this->getOption('-noauthdb')) { $authini->setValue('dao', 'jauth~jelixuser', 'Db'); $authini->setValue('form', 'jauthdb_admin~jelixuser', 'Db'); if ($profile != '') { $authini->setValue('profile', $profile, 'Db'); } $tools = jDb::getTools($profile); $db = jDb::getConnection($profile); $path = JELIX_LIB_PATH . 'core-modules/jelix/install/sql/'; if (file_exists($path . 'install_jauth.schema.' . $db->dbms . '.sql')) { try { $tools->execSQLScript($path . 'install_jauth.schema.' . $db->dbms . '.sql'); $rs = $db->query("SELECT usr_login FROM jlx_user WHERE usr_login='******'"); if (!$rs || !$rs->fetch()) { $db->exec("INSERT INTO jlx_user (usr_login , usr_password , usr_email) VALUES ('admin', '" . md5('admin') . "', '*****@*****.**')"); } $rs = null; } catch (Exception $e) { echo "An error has occured during the execution of SQL script to install jAuth: " . $e->getMessage() . "\n"; } } else { echo "Tables and datas for jAuth.db couldn't be created because SQL scripts are not available for the database declared in the profile.\nYou should initialize the database by hand.\n"; } } else { $inifile->setValue('unusedModules', $inifile->getValue('unusedModules') . ', jauthdb_admin'); } if (!$this->getOption('-noacl2db')) { $tools = jDb::getTools($profile); $db = jDb::getConnection($profile); $path = JELIX_LIB_PATH . 'core-modules/jelix/install/sql/'; $tables = $tools->getTableList(); if (in_array('jacl2_rights', $tables)) { ob_start(); try { $cmd = jxs_load_command('acl2group'); $cmd->init(array(), array('action' => 'createuser', '...' => array('admin'))); $cmd->run(); } catch (Exception $e) { } try { $cmd = jxs_load_command('acl2group'); $cmd->init(array(), array('action' => 'adduser', '...' => array('admins', 'admin'))); $cmd->run(); } catch (Exception $e) { } $subjects = array('auth.users.list' => 'jelix~auth.acl.users.list', 'auth.users.view' => 'jelix~auth.acl.users.view', 'auth.users.modify' => 'jelix~auth.acl.users.modify', 'auth.users.create' => 'jelix~auth.acl.users.create', 'auth.users.delete' => 'jelix~auth.acl.users.delete', 'auth.users.change.password' => 'jelix~auth.acl.users.change.password', 'auth.user.view' => 'jelix~auth.acl.user.view', 'auth.user.modify' => 'jelix~auth.acl.user.modify', 'auth.user.change.password' => 'jelix~auth.acl.user.change.password'); foreach ($subjects as $subject => $label) { try { $cmd = jxs_load_command('acl2right'); $cmd->init(array(), array('action' => 'subject_create', '...' => array($subject, $label))); $cmd->run(); } catch (Exception $e) { } } $rights = array(array('auth.users.list', 'admins'), array('auth.users.view', 'admins'), array('auth.users.modify', 'admins'), array('auth.users.create', 'admins'), array('auth.users.delete', 'admins'), array('auth.users.change.password', 'admins'), array('auth.user.view', 'admins'), array('auth.user.modify', 'admins'), array('auth.user.change.password', 'admins'), array('auth.user.view', 'users'), array('auth.user.modify', 'users'), array('auth.user.change.password', 'users')); foreach ($rights as $right) { try { $cmd = jxs_load_command('acl2right'); $cmd->init(array(), array('action' => 'add', '...' => array($right[1], $right[0]))); $cmd->run(); } catch (Exception $e) { } } ob_end_clean(); } else { if (file_exists($path . 'install_jauth.schema.' . $db->dbms . '.sql')) { try { $tools->execSQLScript($path . 'install_jacl2.schema.' . $db->dbms . '.sql'); $tools->execSQLScript($path . 'install_jacl2.data.' . $db->dbms . '.sql'); } catch (Exception $e) { echo "An error has occured during the execution of SQL script to install jAcl2.db: " . $e->getMessage() . "\n"; } } else { echo "Tables and datas for jAcl2.db couldn't be created because SQL scripts are not available for the database declared in the profile.\nYou should initialize the database by hand.\n"; } } } else { $inifile->setValue('unusedModules', $inifile->getValue('unusedModules') . ', jacl2db_admin'); } $authini->save(); $inifile->save(); }
} include JELIXS_INIT_PATH; define('JELIX_APP_PATH', JELIXS_APPTPL_PATH); define('JELIX_APP_REAL_TEMP_PATH', JELIXS_APPTPL_TEMP_PATH); define('JELIX_APP_CLI_TEMP_PATH', substr(JELIXS_APPTPL_TEMP_PATH, 0, -1) . '-cli/'); define('JELIX_APP_TEMP_PATH', substr(JELIXS_APPTPL_TEMP_PATH, 0, -1) . '-jelix-scripts/'); define('JELIX_APP_VAR_PATH', JELIXS_APPTPL_VAR_PATH); define('JELIX_APP_LOG_PATH', JELIXS_APPTPL_LOG_PATH); define('JELIX_APP_CONFIG_PATH', JELIXS_APPTPL_CONFIG_PATH); define('JELIX_APP_WWW_PATH', JELIXS_APPTPL_WWW_PATH); define('JELIX_APP_CMD_PATH', JELIXS_APPTPL_CMD_PATH); } include 'includes/command.class.php'; include 'includes/utils.lib.php'; if (function_exists('date_default_timezone_set')) { date_default_timezone_set(JELIXS_INFO_DEFAULT_TIMEZONE); } /** * chargement de la commande */ $command = jxs_load_command($commandName); list($options, $parameters) = jxs_getOptionsAndParams($argv, $command->allowed_options, $command->allowed_parameters); //--------- launch the command now $command->init($options, $parameters); try { $command->run(); } catch (Exception $e) { echo "Error: " . $e->getMessage(), "\n"; exit(1); } exit(0);
public function run() { jxs_init_jelix_env(); // note: since module name are used for name of generated name, // only this characters are allowed if (preg_match('/([^a-zA-Z_0-9])/', $this->_parameters['module'])) { throw new Exception("the name '" . $this->_parameters['module'] . "' is not valid for a module"); } $path = $this->getModulePath($this->_parameters['module'], false); if (file_exists($path)) { throw new Exception("module '" . $this->_parameters['module'] . "' already exists"); } $this->createDir($path); $param = array(); $param['name'] = $this->_parameters['module']; $param['default_id'] = $this->_parameters['module'] . JELIXS_INFO_DEFAULT_IDSUFFIX; $this->createFile($path . 'module.xml', 'module.xml.tpl', $param); if (!$this->getOption('-nosubdir')) { $this->createDir($path . 'classes/'); $this->createDir($path . 'zones/'); $this->createDir($path . 'controllers/'); $this->createDir($path . 'templates/'); $this->createDir($path . 'classes/'); $this->createDir($path . 'daos/'); $this->createDir($path . 'forms/'); $this->createDir($path . 'locales/'); $this->createDir($path . 'locales/en_EN/'); $this->createDir($path . 'locales/fr_FR/'); } if (!$this->getOption('-nocontroller')) { $agcommand = jxs_load_command('createctrl'); $options = array(); if ($this->getOption('-cmdline')) { $options = array('-cmdline' => true); } if ($this->getOption('-addinstallzone')) { $options = array('-addinstallzone' => true); } $agcommand->init($options, array('module' => $this->_parameters['module'], 'name' => 'default', 'method' => 'index')); $agcommand->run(); } $inifiles = array(JELIX_APP_CONFIG_PATH . 'index/config.ini.php', JELIX_APP_CONFIG_PATH . 'cmdline/config.ini.php', JELIX_APP_CONFIG_PATH . 'jsonrpc/config.ini.php', JELIX_APP_CONFIG_PATH . 'xmlrpc/config.ini.php'); $isdefault = $this->getOption('-defaultmodule'); foreach ($inifiles as $k => $filename) { if (!file_exists($filename)) { continue; } try { $ini = new jIniFileModifier($filename); if ($isdefault && $k == 0) { $ini->setValue('startModule', $this->_parameters['module']); $ini->setValue('startAction', 'default:index'); } else { if ($ini->getValue('startModule') == '') { $ini->setValue('startModule', $this->_parameters['module']); } } $ini->save(); } catch (Exception $e) { echo "Error during the modification of an ini file: " . $e->getMessage() . "\n"; } } }