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() { $installFile = JELIX_APP_PATH . 'install/installer.php'; echo "EXPERIMENTAL ! Still in development !\n"; if (!file_exists($installFile)) { echo "No install script.\nDone.\n"; return; } jxs_init_jelix_env(); include $installFile; if (!class_exists('appInstaller', true)) { echo "No appInstaller class in install script.\nDone.\n"; return; } //@TODO: show information found in project.xml //@TODO: check the jelix version according to project.xml //@TODO: put rights on temp directory (and create directory ?) $reporter = new installappReporter(); $installer = new appInstaller($reporter, JELIX_APP_PATH . 'install/'); $installer->install(); if ($reporter->hasError) { echo "\nEnded with errors.\n"; } else { if ($reporter->hasWarning) { echo "\nEnded with warning.\n"; } else { echo "\nSuccessful install.\n"; } } }
public function run() { jxs_init_jelix_env(); $action = $this->getParam('action'); if (!in_array($action, array('list', 'add', 'remove', 'subject_create', 'subject_delete', 'subject_list'))) { throw new Exception("unknown subcommand"); } $meth = 'cmd_' . $action; echo "----", $this->titles[MESSAGE_LANG][$action], "\n\n"; $this->{$meth}(); }
public function run() { jxs_init_jelix_env(); $action = $this->getParam('action'); if (!in_array($action, array('list', 'create', 'setdefault', 'changename', 'delete', 'userslist', 'alluserslist', 'adduser', 'removeuser', 'createuser', 'destroyuser'))) { throw new Exception("unknown subcommand"); } $meth = 'cmd_' . $action; echo "----", $this->titles[MESSAGE_LANG][$action], "\n\n"; $this->{$meth}(); }
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(); }
public function run() { jxs_init_jelix_env(); $path = $this->getModulePath($this->_parameters['module']); $filename = $path . 'forms/'; $this->createDir($filename); $filename .= strtolower($this->_parameters['form']) . '.form.xml'; $submit = "\n\n<submit ref=\"_submit\">\n\t<label>ok</label>\n</submit>"; if (($dao = $this->getParam('dao')) === null) { $this->createFile($filename, 'form.xml.tpl', array('content' => '<!-- add control declaration here -->' . $submit)); return; } global $gJConfig; $gJConfig->startModule = $this->_parameters['module']; jContext::push($this->_parameters['module']); // we're going to parse the dao $selector = new jSelectorDao($dao, '', false); jDaoCompiler::$daoId = $selector->toString(); jDaoCompiler::$daoPath = $selector->getPath(); jDaoCompiler::$dbType = $selector->driver; $doc = new DOMDocument(); if (!$doc->load(jDaoCompiler::$daoPath)) { throw new jException('jelix~daoxml.file.unknow', jDaoCompiler::$daoPath); } if ($doc->documentElement->namespaceURI != JELIX_NAMESPACE_BASE . 'dao/1.0') { throw new jException('jelix~daoxml.namespace.wrong', array(jDaoCompiler::$daoPath, $doc->namespaceURI)); } $parser = new jDaoParser(); $parser->parse(simplexml_import_dom($doc)); // know we generate the form file $properties = $parser->GetProperties(); $table = $parser->GetPrimaryTable(); $content = ''; foreach ($properties as $name => $property) { if (!$property->ofPrimaryTable) { continue; } if ($property->isPK && ($property->datatype == 'autoincrement' || $property->datatype == 'bigautoincrement')) { continue; } $attr = ''; if ($property->required) { $attr .= ' required="true"'; } if ($property->defaultValue !== null) { $attr .= ' defaultvalue="' . htmlspecialchars($property->defaultValue) . '"'; } if ($property->maxlength !== null) { $attr .= ' maxlength="' . $property->maxlength . '"'; } if ($property->minlength !== null) { $attr .= ' minlength="' . $property->minlength . '"'; } //if(false) // $attr.=' defaultvalue=""'; $datatype = ''; $tag = 'input'; switch ($property->datatype) { case 'autoincrement': case 'bigautoincrement': case 'int': case 'integer': case 'numeric': $datatype = 'integer'; break; case 'datetime': $datatype = 'datetime'; break; case 'time': $datatype = 'time'; break; case 'date': $datatype = 'date'; break; case 'double': case 'float': $datatype = 'decimal'; break; case 'text': $tag = 'textarea'; break; case 'boolean': $tag = 'checkbox'; break; } if ($datatype != '') { $attr .= ' type="' . $datatype . '"'; } $content .= "\n\n<{$tag} ref=\"{$name}\"{$attr}>\n\t<label>{$name}</label>\n</{$tag}>"; } $this->createFile($filename, 'form.xml.tpl', array('content' => $content . $submit)); }
public function run() { jxs_init_jelix_env(); $type = $this->getOption('-type'); if (!$type) { $type = 'classic'; } if (!in_array($type, array('classic', 'jsonrpc', 'xmlrpc', 'rdf', 'soap', 'cmdline'))) { throw new Exception("invalid type"); } if ($type == 'classic') { $type = 'index'; } $name = $this->getParam('name'); $inifile = new jIniMultiFilesModifier(JELIX_APP_CONFIG_PATH . 'defaultconfig.ini.php', JELIX_APP_CONFIG_PATH . 'index/config.ini.php'); $param = array(); $param['modulename'] = $inifile->getValue('startModule'); if ($type == 'cmdline') { if (file_exists(JELIX_APP_CMD_PATH . $name . '.php')) { throw new Exception("the entry point already exists"); } if (!file_exists(JELIX_APP_PATH . 'application-cli.init.php')) { $this->createDir(substr(JELIX_APP_TEMP_PATH, -1) . '-cli'); $param2['rp_temp'] = jxs_getRelativePath(JELIX_APP_PATH, substr(JELIX_APP_TEMP_PATH, 0, -1) . '-cli', true); $param2['rp_var'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_VAR_PATH, true); $param2['rp_log'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_LOG_PATH, true); $param2['rp_conf'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CONFIG_PATH, true); $param2['rp_www'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_WWW_PATH, true); $param2['rp_cmd'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CMD_PATH, true); $param2['rp_jelix'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_LIB_PATH, true); $param2['rp_app'] = jxs_getRelativePath(JELIX_APP_WWW_PATH, JELIX_APP_PATH, true); $param2['php_rp_temp'] = $this->convertRp($param2['rp_temp']); $param2['php_rp_var'] = $this->convertRp($param2['rp_var']); $param2['php_rp_log'] = $this->convertRp($param2['rp_log']); $param2['php_rp_conf'] = $this->convertRp($param2['rp_conf']); $param2['php_rp_www'] = $this->convertRp($param2['rp_www']); $param2['php_rp_cmd'] = $this->convertRp($param2['rp_cmd']); $this->createFile(JELIX_APP_PATH . 'application-cli.init.php', 'application.init.php.tpl', $param2); } $this->createDir(JELIX_APP_CONFIG_PATH . 'cmdline'); $this->createDir(JELIX_APP_CMD_PATH); $this->createFile(JELIX_APP_CONFIG_PATH . 'cmdline/' . $name . '.ini.php', 'var/config/cmdline/config.ini.php.tpl', $param); $param['rp_cmd'] = jxs_getRelativePath(JELIX_APP_CMD_PATH, JELIX_APP_PATH, true); $param['config_file'] = 'cmdline/' . $name . '.ini.php'; $this->createFile(JELIX_APP_CMD_PATH . $name . '.php', 'scripts/cmdline.php.tpl', $param); return; } if (file_exists(JELIX_APP_WWW_PATH . $name . '.php')) { throw new Exception("the entry point already exists"); } $param['rp_app'] = jxs_getRelativePath(JELIX_APP_WWW_PATH, JELIX_APP_PATH, true); $param['config_file'] = $name . '/config.ini.php'; $this->createDir(JELIX_APP_CONFIG_PATH . $name); $this->createFile(JELIX_APP_CONFIG_PATH . $name . '/config.ini.php', 'var/config/index/config.ini.php.tpl', $param); $this->createFile(JELIX_APP_WWW_PATH . $name . '.php', 'www/' . $type . '.php.tpl', $param); $inifile = new jIniFileModifier(JELIX_APP_CONFIG_PATH . 'defaultconfig.ini.php'); if (null === $inifile->getValue($name, 'simple_urlengine_entrypoints')) { $inifile->setValue($name, '', 'simple_urlengine_entrypoints'); } if (null === $inifile->getValue($name, 'basic_significant_urlengine_entrypoints')) { $inifile->setValue($name, '1', 'basic_significant_urlengine_entrypoints'); } $doc = new DOMDocument(); if (!$doc->load(JELIX_APP_PATH . 'project.xml')) { throw new Exception("cannot load project.xml"); } if ($doc->documentElement->namespaceURI != JELIX_NAMESPACE_BASE . 'project/1.0') { throw new Exception("bad namespace in project.xml"); } $elem = $doc->createElementNS(JELIX_NAMESPACE_BASE . 'project/1.0', 'entry'); $elem->setAttribute("file", $name . ".php"); $elem->setAttribute("config", $name . "/config.ini.php"); $ep = $doc->documentElement->getElementsByTagName("entrypoints"); if (!$ep->length) { $ep = $doc->createElementNS(JELIX_NAMESPACE_BASE . 'project/1.0', 'entrypoints'); $doc->documentElement->appendChild($ep); $ep->appendChild($elem); } else { $ep->item(0)->appendChild($elem); } $doc->save(JELIX_APP_PATH . 'project.xml'); }
public function run() { jxs_init_jelix_env(); $path = $this->getModulePath($this->_parameters['module']); $filename = $path . 'daos/'; $this->createDir($filename); $filename .= strtolower($this->_parameters['name']) . '.dao.xml'; $profile = $this->getOption('-profile'); $param = array('name' => $this->_parameters['name'], 'table' => $this->getParam('table')); if ($param['table'] == null) { $param['table'] = $param['name']; } if ($this->getOption('-empty')) { $this->createFile($filename, 'dao_empty.xml.tpl', $param); } else { $tools = jDb::getTools($profile); $fields = $tools->getFieldList($param['table']); $properties = ''; $primarykeys = ''; foreach ($fields as $fieldname => $prop) { switch (strtolower($prop->type)) { case 'clob': case 'text': case 'mediumtext': case 'longtext': case 'tinytext': $type = 'text'; break; case 'varchar2': case 'varchar': case 'char': case 'enum': case 'bpchar': case 'set': $type = 'string'; break; case 'number': case 'tinyint': case 'numeric': case 'int': case 'integer': case 'smallint': case 'year': if ($prop->autoIncrement) { $type = 'autoincrement'; } else { $type = 'int'; } break; case 'mediumint': case 'bigint': if ($prop->autoIncrement) { $type = 'bigautoincrement'; } else { $type = 'numeric'; } break; case 'float': case 'double': case 'decimal': $type = 'float'; break; case 'date': $type = 'date'; break; case 'timestamp': case 'datetime': $type = 'datetime'; break; case 'time': $type = 'time'; break; case 'bool': case 'boolean': $type = 'boolean'; break; default: $type = ''; } if ($type != '') { $properties .= "\n <property name=\"{$fieldname}\" fieldname=\"{$fieldname}\""; $properties .= ' datatype="' . $type . '"'; if ($prop->primary) { if ($primarykeys != '') { $primarykeys .= ',' . $fieldname; } else { $primarykeys .= $fieldname; } } if ($prop->notNull && !$prop->autoIncrement) { $properties .= ' required="true"'; } if ($prop->hasDefault) { $properties .= ' default="' . htmlspecialchars($prop->default) . '"'; } if ($prop->length) { $properties .= ' maxlength="' . $prop->length . '"'; } if ($prop->sequence) { $properties .= ' sequence="' . $prop->sequence . '"'; } $properties .= '/>'; } } if ($primarykeys == '') { throw new Exception("The table has no primary keys. A dao needs a primary key on the table to be defined."); } $param['properties'] = $properties; $param['primarykeys'] = $primarykeys; $this->createFile($filename, 'dao.xml.tpl', $param); } }
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"; } } }