/** * @param \Jelix\IniFile\IniModifier $mainConfig the mainconfig.ini.php file * @param string $configFile the path of the configuration file, relative * to the var/config directory * @param string $file the filename of the entry point * @param string $type type of the entry point ('classic', 'cli', 'xmlrpc'....) */ function __construct(\Jelix\IniFile\IniModifier $mainConfig, $configFile, $file, $type) { $this->type = $type; $this->isCliScript = $type == 'cmdline'; $this->configFile = $configFile; $this->scriptName = $this->isCliScript ? $file : '/' . $file; $this->file = $file; $this->configIni = new \Jelix\IniFile\MultiIniModifier($mainConfig, \Jelix\Core\App::configPath($configFile)); $compiler = new \Jelix\Core\Config\Compiler($configFile, $this->scriptName, $this->isCliScript); $this->config = $compiler->read(true); $this->modulesInfos = $compiler->getModulesInfos(); }
protected function _execute(InputInterface $input, OutputInterface $output) { $module = $input->getArgument('module'); $initialVersion = $input->getOption('ver'); if (!$initialVersion) { $initialVersion = '0.1pre'; } // note: since module name are used for name of generated name, // only this characters are allowed if ($module == null || preg_match('/([^a-zA-Z_0-9])/', $module)) { throw new \Exception("'" . $module . "' is not a valid name for a module"); } // check if the module already exist or not $path = ''; try { $path = $this->getModulePath($module); } catch (\Exception $e) { } if ($path != '') { throw new \Exception("module '" . $module . "' already exists"); } // verify the given repository $repository = $input->getArgument('repository'); if (substr($repository, -1) != '/') { $repository .= '/'; } $repositoryPath = \jFile::parseJelixPath($repository); if (!$input->getOption('noregistration')) { $this->registerModulesDir($repository, $repositoryPath); } $path = $repositoryPath . $module . '/'; $this->createDir($path); App::setConfig(null); $noSubDir = $input->getOption('nosubdir'); $addInstallZone = $input->getOption('addinstallzone'); $isdefault = $input->getOption('defaultmodule'); if ($input->getOption('admin')) { $noSubDir = false; $addInstallZone = false; } $param = array(); $param['module'] = $module; $param['version'] = $initialVersion; $this->createFile($path . 'jelix-module.json', 'module/jelix-module.json.tpl', $param); // create all sub directories of a module if (!$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_US/'); $this->createDir($path . 'locales/fr_FR/'); $this->createDir($path . 'install/'); if ($this->verbose()) { $output->writeln("Sub directories have been created in the new module {$module}."); } $this->createFile($path . 'install/install.php', 'module/install.tpl', $param); $this->createFile($path . 'urls.xml', 'module/urls.xml.tpl', array()); } $iniDefault = new \Jelix\IniFile\IniModifier(App::mainConfigFile()); $urlsFile = App::appConfigPath($iniDefault->getValue('significantFile', 'urlengine')); $xmlMap = new \Jelix\Routing\UrlMapping\XmlMapModifier($urlsFile, true); // activate the module in the application if ($isdefault) { if ($this->allEntryPoint) { $xmlEp = $xmlMap->getDefaultEntryPoint($type); } else { $xmlEp = $xmlMap->getEntryPoint($this->entryPointId); } if ($xmlEp) { $xmlEp->addUrlAction('/', $module, 'default:index', null, null, array('default' => true)); $xmlEp->addUrlModule('', $module); if ($this->verbose()) { $output->writeln("The new module {$module} becomes the default module"); } } else { if ($this->verbose()) { $output->writeln("No default entry point found: the new module cannot be the default module"); } } } $xmlMap->save(); $iniDefault->setValue($module . '.access', $this->allEntryPoint ? 2 : 1, 'modules'); $iniDefault->save(); $list = $this->getEntryPointsList(); $install = new \Jelix\IniFile\IniModifier(App::configPath('installer.ini.php')); // install the module for all needed entry points foreach ($list as $entryPoint) { $configFile = App::appConfigPath($entryPoint['config']); $epconfig = new \Jelix\IniFile\IniModifier($configFile); if ($this->allEntryPoint) { $access = 2; } else { $access = $entryPoint['file'] == $this->entryPointName ? 2 : 0; } $epconfig->setValue($module . '.access', $access, 'modules'); $epconfig->save(); if ($this->allEntryPoint || $entryPoint['file'] == $this->entryPointName) { $install->setValue($module . '.installed', 1, $entryPoint['id']); $install->setValue($module . '.version', $initialVersion, $entryPoint['id']); } if ($this->verbose()) { $output->writeln("The module is initialized for the entry point " . $entryPoint['file']); } } $install->save(); App::declareModule($path); // create a default controller if (!$input->getOption('nocontroller')) { $arguments = array('module' => $module, 'controller' => 'default', 'method' => 'index'); if ($input->getOption('entry-point')) { $arguments['--entry-point'] = $input->getOption('entry-point'); } if ($input->getOption('cmdline')) { $arguments['--cmdline'] = true; } if ($addInstallZone) { $arguments['--addinstallzone'] = true; } if ($output->isVerbose()) { $arguments['-v'] = true; } $this->executeSubCommand('module:create-ctrl', $arguments, $output); } if ($input->getOption('admin')) { $this->createFile($path . 'classes/admin' . $module . '.listener.php', 'module/admin.listener.php.tpl', $param, "Listener"); $this->createFile($path . 'events.xml', 'module/events.xml.tpl', $param); file_put_contents($path . 'locales/en_US/interface.UTF-8.properties', 'menu.item=' . $module); file_put_contents($path . 'locales/fr_FR/interface.UTF-8.properties', 'menu.item=' . $module); } }
public static function configPath($file = '') { return \Jelix\Core\App::configPath($file); }
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'); }
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"; } }
/** * load the plugins and their configuration file */ private function _loadPlugins() { $config = App::config(); foreach ($config->coordplugins as $name => $conf) { if (strpos($name, '.') !== false) { continue; } // the config compiler has removed all deactivated plugins // so we don't have to check if the value $conf is empty or not if ($conf == '1') { $confname = 'coordplugin_' . $name; if (isset($config->{$confname})) { $conf = $config->{$confname}; } else { $conf = array(); } } else { $conff = App::configPath($conf); if (false === ($conf = parse_ini_file($conff, true))) { throw new Exception("Error in a plugin configuration file -- plugin: {$name} file: {$conff}", 13); } } include_once $config->_pluginsPathList_coord[$name] . $name . '.coord.php'; $class = $name . 'CoordPlugin'; if (isset($config->coordplugins[$name . '.name'])) { $name = $config->coordplugins[$name . '.name']; } $class = '\\' . $class; $this->plugins[strtolower($name)] = new $class($conf); } }
function __construct($sel) { $this->_basePath = \Jelix\Core\App::configPath(); parent::__construct($sel); }
public function run() { $this->loadAppConfig(); $module = $this->getParam('module'); $initialVersion = $this->getOption('-ver'); if ($initialVersion === false) { $initialVersion = '0.1pre'; } // note: since module name are used for name of generated name, // only this characters are allowed if ($module == null || preg_match('/([^a-zA-Z_0-9])/', $module)) { throw new Exception("'" . $module . "' is not a valid name for a module"); } // check if the module already exist or not $path = ''; try { $path = $this->getModulePath($module); } catch (Exception $e) { } if ($path != '') { throw new Exception("module '" . $module . "' already exists"); } // verify the given repository $repository = $this->getParam('repository', 'app:modules/'); if (substr($repository, -1) != '/') { $repository .= '/'; } $repositoryPath = jFile::parseJelixPath($repository); if (!$this->getOption('-noregistration')) { $this->registerModulesDir($repository, $repositoryPath); } $path = $repositoryPath . $module . '/'; $this->createDir($path); App::setConfig(null); if ($this->getOption('-admin')) { $this->removeOption('-nosubdir'); $this->removeOption('-addinstallzone'); } $param = array(); $param['module'] = $module; $param['version'] = $initialVersion; $this->createFile($path . 'jelix-module.json', 'module/jelix-module.json.tpl', $param); // create all sub directories of a module 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_US/'); $this->createDir($path . 'locales/fr_FR/'); $this->createDir($path . 'install/'); if ($this->verbose()) { echo "Sub directories have been created in the new module {$module}.\n"; } $this->createFile($path . 'install/install.php', 'module/install.tpl', $param); $this->createFile($path . 'urls.xml', 'module/urls.xml.tpl', array()); } $isdefault = $this->getOption('-defaultmodule'); $iniDefault = new \Jelix\IniFile\IniModifier(App::mainConfigFile()); // activate the module in the application if ($isdefault) { $iniDefault->setValue('startModule', $module); $iniDefault->setValue('startAction', 'default:index'); if ($this->verbose()) { echo "The new module {$module} becomes the default module\n"; } } $iniDefault->setValue($module . '.access', $this->allEntryPoint ? 2 : 1, 'modules'); $iniDefault->save(); $list = $this->getEntryPointsList(); $install = new \Jelix\IniFile\IniModifier(App::configPath('installer.ini.php')); // install the module for all needed entry points foreach ($list as $entryPoint) { $configFile = App::configPath($entryPoint['config']); $epconfig = new \Jelix\IniFile\IniModifier($configFile); if ($this->allEntryPoint) { $access = 2; } else { $access = $entryPoint['file'] == $this->entryPointName ? 2 : 0; } $epconfig->setValue($module . '.access', $access, 'modules'); $epconfig->save(); if ($this->allEntryPoint || $entryPoint['file'] == $this->entryPointName) { $install->setValue($module . '.installed', 1, $entryPoint['id']); $install->setValue($module . '.version', $initialVersion, $entryPoint['id']); } if ($isdefault) { // we set the module as default module for one or all entry points. // we set the startModule option for all entry points except // if an entry point is indicated on the command line if ($this->allEntryPoint || $entryPoint['file'] == $this->entryPointName) { if ($epconfig->getValue('startModule') != '') { $epconfig->setValue('startModule', $module); $epconfig->setValue('startAction', 'default:index'); $epconfig->save(); } } } if ($this->verbose()) { echo "The module is initialized for the entry point " . $entryPoint['file'] . ".\n"; } } $install->save(); // create a default controller if (!$this->getOption('-nocontroller')) { $agcommand = JelixScript::getCommand('createctrl', $this->config); $options = $this->getCommonActiveOption(); if ($this->getOption('-cmdline')) { $options['-cmdline'] = true; } if ($this->getOption('-addinstallzone')) { $options['-addinstallzone'] = true; } $agcommand->initOptParam($options, array('module' => $module, 'name' => 'default', 'method' => 'index')); $agcommand->run(); } if ($this->getOption('-admin')) { $this->createFile($path . 'classes/admin' . $module . '.listener.php', 'module/admin.listener.php.tpl', $param, "Listener"); $this->createFile($path . 'events.xml', 'module/events.xml.tpl', $param); file_put_contents($path . 'locales/en_US/interface.UTF-8.properties', 'menu.item=' . $module); file_put_contents($path . 'locales/fr_FR/interface.UTF-8.properties', 'menu.item=' . $module); } }
/** * @internal mainly for tests * @return \Jelix\IniFile\IniModifier the modifier for the installer.ini.php file */ protected function getInstallerIni() { if (!file_exists(App::configPath('installer.ini.php'))) { if (false === @file_put_contents(App::configPath('installer.ini.php'), ";<?php die(''); ?>\n; for security reasons , don't remove or modify the first line\n; don't modify this file if you don't know what you do. it is generated automatically by jInstaller\n\n")) { throw new \Exception('impossible to create var/config/installer.ini.php'); } } else { copy(App::configPath('installer.ini.php'), App::configPath('installer.bak.ini.php')); } return new \Jelix\IniFile\IniModifier(App::configPath('installer.ini.php')); }
protected function _createSkeleton($appPath, $appName, $wwwpath, InputInterface $input) { $this->createDir($appPath); $this->createDir(App::tempBasePath()); $this->createDir($wwwpath); $varPath = App::varPath(); $configPath = App::configPath(); $this->createDir($varPath); $this->createDir(App::logPath()); $this->createDir(App::appConfigPath()); $this->createDir($configPath); $this->createDir(App::appConfigPath('index/')); $this->createDir(App::appPath('app/overloads/')); $this->createDir(App::appPath('app/themes')); $this->createDir(App::appPath('app/themes/default/')); $this->createDir($varPath . 'uploads/'); $this->createDir($varPath . 'sessions/'); $this->createDir($varPath . 'mails/'); $this->createDir($appPath . 'install'); $this->createDir($appPath . 'modules'); $this->createDir($appPath . 'plugins'); $this->createDir(App::appPath('app/responses')); $this->createDir($appPath . 'tests'); $this->createDir(App::scriptsPath()); $param = array(); if ($input->getOption('nodefaultmodule')) { $param['tplname'] = 'jelix~defaultmain'; $param['modulename'] = 'jelix'; } else { $moduleName = $input->getOption('modulename'); if (!$moduleName) { // note: since module name are used for name of generated name, // only this characters are allowed $moduleName = preg_replace('/([^a-zA-Z_0-9])/', '_', $appName); } $param['modulename'] = $moduleName; $param['tplname'] = $moduleName . '~main'; } $param['config_file'] = 'index/config.ini.php'; $param['rp_temp'] = Path::shortestPath($appPath, App::tempBasePath()) . '/'; $param['rp_var'] = Path::shortestPath($appPath, App::varPath()) . '/'; $param['rp_log'] = Path::shortestPath($appPath, App::logPath()) . '/'; $param['rp_conf'] = Path::shortestPath($appPath, $configPath) . '/'; $param['rp_www'] = Path::shortestPath($appPath, $wwwpath) . '/'; $param['rp_cmd'] = Path::shortestPath($appPath, App::scriptsPath()) . '/'; $param['rp_jelix'] = Path::shortestPath($appPath, JELIX_LIB_PATH) . '/'; $param['rp_lib'] = Path::shortestPath($appPath, LIB_PATH) . '/'; $param['rp_vendor'] = ''; foreach (array(LIB_PATH . 'vendor/', LIB_PATH . '../vendor/', LIB_PATH . '../../../') as $path) { if (file_exists($path)) { $param['rp_vendor'] = Path::shortestPath($appPath, realpath($path) . '/') . '/'; break; } } $param['rp_app'] = Path::shortestPath($wwwpath, $appPath) . '/'; $this->createFile(App::logPath() . '.dummy', 'dummy.tpl', array()); $this->createFile(App::varPath() . 'mails/.dummy', 'dummy.tpl', array()); $this->createFile(App::varPath() . 'sessions/.dummy', 'dummy.tpl', array()); $this->createFile(App::appPath() . 'app/overloads/.dummy', 'dummy.tpl', array()); $this->createFile(App::appPath() . 'app/themes/default/.dummy', 'dummy.tpl', array()); $this->createFile(App::varPath() . 'uploads/.dummy', 'dummy.tpl', array()); $this->createFile($appPath . 'plugins/.dummy', 'dummy.tpl', array()); $this->createFile(App::scriptsPath() . '.dummy', 'dummy.tpl', array()); $this->createFile(App::tempBasePath() . '.dummy', 'dummy.tpl', array()); $this->createFile($appPath . '.htaccess', 'htaccess_deny', $param, "Configuration file for Apache"); $this->createFile($appPath . '.gitignore', 'git_ignore.tpl', $param, ".gitignore"); $this->createFile($appPath . 'jelix-app.json', 'jelix-app.json.tpl', $param, "Project description file"); $this->createFile($appPath . 'composer.json', 'composer.json.tpl', $param, "Composer file"); $this->createFile($appPath . 'cmd.php', 'cmd.php.tpl', $param, "Script for developer commands"); $this->createFile(App::appConfigPath('mainconfig.ini.php'), 'app/config/mainconfig.ini.php.tpl', $param, "Main configuration file"); $this->createFile($configPath . 'localconfig.ini.php.dist', 'var/config/localconfig.ini.php.tpl', $param, "Configuration file for specific environment"); $this->createFile($configPath . 'profiles.ini.php', 'var/config/profiles.ini.php.tpl', $param, "Profiles file"); $this->createFile($configPath . 'profiles.ini.php.dist', 'var/config/profiles.ini.php.tpl', $param, "Profiles file for your repository"); $this->createFile($configPath . 'preferences.ini.php', 'var/config/preferences.ini.php.tpl', $param, "Preferences file"); $this->createFile(App::appConfigPath('urls.xml'), 'app/config/urls.xml.tpl', $param, "URLs mapping file"); $this->createFile(App::appConfigPath('index/config.ini.php'), 'app/config/index/config.ini.php.tpl', $param, "Entry point configuration file"); $this->createFile($appPath . 'app/responses/myHtmlResponse.class.php', 'app/responses/myHtmlResponse.class.php.tpl', $param, "Main response class"); $this->createFile($appPath . 'install/installer.php', 'installer/installer.php.tpl', $param, "Installer script"); $this->createFile($appPath . 'tests/runtests.php', 'tests/runtests.php', $param, "Tests script"); $temp = dirname(rtrim(App::tempBasePath(), '/')); if ($temp != rtrim($appPath, '/')) { if (file_exists($temp . '/.gitignore')) { $gitignore = file_get_contents($temp . '/.gitignore') . "\n" . $appName . "/*\n"; file_put_contents($temp . '/.gitignore', $gitignore); } else { file_put_contents($temp . '/.gitignore', $appName . "/*\n"); } } else { $gitignore = file_get_contents($appPath . '.gitignore') . "\n" . basename(rtrim(App::tempBasePath(), '/')) . "/*\n"; file_put_contents($appPath . '.gitignore', $gitignore); } $this->createFile($wwwpath . 'index.php', 'www/index.php.tpl', $param, "Main entry point"); $this->createFile($wwwpath . '.htaccess', 'htaccess_allow', $param, "Configuration file for Apache"); $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']); $param['php_rp_jelix'] = $this->convertRp($param['rp_jelix']); if ($param['rp_vendor']) { $param['php_rp_vendor'] = $this->convertRp($param['rp_vendor']); $this->createFile($appPath . 'application.init.php', 'application2.init.php.tpl', $param, "Bootstrap file"); } else { $this->createFile($appPath . 'application.init.php', 'application.init.php.tpl', $param, "Bootstrap file"); } return $param; }
protected function migrate_1_7_0() { $this->reporter->message('Start migration to 1.7.0', 'notice'); $newConfigPath = App::appConfigPath(); if (!file_exists($newConfigPath)) { $this->reporter->message('Create app/config/', 'notice'); \jFile::createDir($newConfigPath); } // move mainconfig.php to app/config/ if (!file_exists($newConfigPath . 'mainconfig.ini.php')) { if (!file_exists(App::configPath('mainconfig.ini.php'))) { if (!file_exists(App::configPath('defaultconfig.ini.php'))) { throw new \Exception("Migration to Jelix 1.7.0 canceled: where is your mainconfig.ini.php?"); } $this->reporter->message('Move var/config/defaultconfig.ini.php to app/config/mainconfig.ini.php', 'notice'); rename(App::configPath('defaultconfig.ini.php'), $newConfigPath . 'mainconfig.ini.php'); } else { $this->reporter->message('Move var/config/mainconfig.ini.php to app/config/', 'notice'); rename(App::configPath('mainconfig.ini.php'), $newConfigPath . 'mainconfig.ini.php'); } } // move entrypoint configs to app/config $projectxml = simplexml_load_file(App::appPath('project.xml')); // read all entry points data foreach ($projectxml->entrypoints->entry as $entrypoint) { $configFile = (string) $entrypoint['config']; $dest = App::appConfigPath($configFile); if (!file_exists($dest)) { if (!file_exists(App::configPath($configFile))) { $this->reporter->message("Config file var/config/{$configFile} indicated in project.xml, does not exist", 'warning'); continue; } $this->reporter->message("Move var/config/{$configFile} to app/config/", 'notice'); \jFile::createDir(dirname($dest)); rename(App::configPath($configFile), $dest); } $config = parse_ini_file(App::appConfigPath($configFile), true); if (isset($config['urlengine']['significantFile'])) { $urlFile = $config['urlengine']['significantFile']; if (!file_exists(App::appConfigPath($urlFile)) && file_exists(App::configPath($urlFile))) { $this->reporter->message("Move var/config/{$urlFile} to app/config/", 'notice'); rename(App::configPath($urlFile), App::appConfigPath($urlFile)); } } } // move urls.xml to app/config $mainconfig = parse_ini_file(App::appConfigPath('mainconfig.ini.php'), true); if (isset($mainconfig['urlengine']['significantFile'])) { $urlFile = $mainconfig['urlengine']['significantFile']; } else { $urlFile = 'urls.xml'; } if (!file_exists(App::appConfigPath($urlFile)) && file_exists(App::configPath($urlFile))) { $this->reporter->message("Move var/config/{$urlFile} to app/config/", 'notice'); rename(App::configPath($urlFile), App::appConfigPath($urlFile)); } $this->reporter->message('Migration to 1.7.0 is done', 'notice'); if (!file_exists(App::appPath('app/responses'))) { $this->reporter->message("Move responses/ to app/responses/", 'notice'); rename(App::appPath('responses'), App::appPath('app/responses')); } }
/** * Find all activated modules and check their status * @param object $config the config object * @param boolean $allModuleInfo may be true for the installer, which needs all informations * else should be false, these extra informations are * not needed to run the application * @return \Jelix\Core\Infos\ModuleInfos[] */ protected function _loadModulesInfo($config, $allModuleInfo) { $installerFile = App::configPath('installer.ini.php'); if ($config->disableInstallers) { $installation = array(); } else { if (file_exists($installerFile)) { $installation = parse_ini_file($installerFile, true); } else { if ($allModuleInfo) { $installation = array(); } else { throw new Exception("The application is not installed -- installer.ini.php doesn't exist!\n", 9); } } } $section = $config->urlengine['urlScriptId']; if (!isset($installation[$section])) { $installation[$section] = array(); } if ($config->compilation['checkCacheFiletime']) { $config->_allBasePath = App::getDeclaredModulesDir(); } else { $config->_allBasePath = array(); } $modules = array(); $list = App::getAllModulesPath(); foreach ($list as $k => $path) { $module = $this->_readModuleInfo($config, $allModuleInfo, $path, $installation, $section); if ($module !== null) { $modules[$module->name] = $module; } } return $modules; }
/** * @param \Jelix\IniFile\MultiIniModifier $mainConfig the mainconfig.ini.php file combined with defaultconfig.ini.php * @param \Jelix\IniFile\MultiIniModifier $localConfig the localconfig.ini.php file combined with $mainConfig * @param string $configFile the path of the configuration file, relative * to the app/config directory * @param string $file the filename of the entry point * @param string $type type of the entry point ('classic', 'cli', 'xmlrpc'....) */ function __construct(\Jelix\IniFile\MultiIniModifier $mainConfig, \Jelix\IniFile\MultiIniModifier $localConfig, $configFile, $file, $type) { $this->type = $type; $this->isCliScript = $type == 'cmdline'; $this->configFile = $configFile; $this->scriptName = $this->isCliScript ? $file : '/' . $file; $this->file = $file; $this->mainConfigIni = $mainConfig; $this->localConfigIni = $localConfig; $appConfigPath = \Jelix\Core\App::appConfigPath($configFile); if (!file_exists($appConfigPath)) { \jFile::createDir(dirname($appConfigPath)); file_put_contents($appConfigPath, ';<' . '?php die(\'\');?' . '>'); } $this->epConfigIni = new \Jelix\IniFile\IniModifier($appConfigPath); $varConfigPath = \Jelix\Core\App::configPath($configFile); if (!file_exists($varConfigPath)) { \jFile::createDir(dirname($varConfigPath)); file_put_contents($varConfigPath, ';<' . '?php die(\'\');?' . '>'); } $this->localEpConfigIni = new \Jelix\IniFile\IniModifier($varConfigPath); $this->fullConfigIni = new \Jelix\IniFile\MultiIniModifier($localConfig, $this->epConfigIni); $this->fullConfigIni = new \Jelix\IniFile\MultiIniModifier($this->fullConfigIni, $this->localEpConfigIni); $compiler = new \Jelix\Core\Config\Compiler($configFile, $this->scriptName, $this->isCliScript); $this->config = $compiler->read(true); $this->modulesInfos = $compiler->getModulesInfos(); }
/** * read the list of entrypoint from the project.xml file * and read all modules data used by each entry point * @param \Jelix\Core\Infos\AppInfos $appInfos */ protected function readEntryPointsData(\Jelix\Core\Infos\AppInfos $appInfos) { $configFileList = array(); $installerIni = $this->installerIni; $allModules =& $this->allModules; $that = $this; // read all entry points data foreach ($appInfos->entrypoints as $file => $entrypoint) { $configFile = $entrypoint['config']; if (isset($entrypoint['type'])) { $type = $entrypoint['type']; } else { $type = "classic"; } // we create an object corresponding to the entry point $ep = $this->getEntryPointObject($configFile, $file, $type); // not to the constructor, to no break API. FIXME $ep->localConfigIni = new \Jelix\IniFile\MultiIniModifier($this->localConfig, App::configPath($configFile)); $epId = $ep->getEpId(); $this->epId[$file] = $epId; $this->entryPoints[$epId] = $ep; // ignore entry point which have the same config file of an other one if (isset($configFileList[$configFile])) { $ep->sameConfigAs = $configFileList[$configFile]; continue; } $configFileList[$configFile] = $epId; $ep->createInstallLaunchers(function ($moduleStatus, $moduleInfos) use($that, $epId) { $name = $moduleInfos->name; $path = $moduleInfos->getPath(); $that->installerIni->setValue($name . '.installed', $moduleStatus->isInstalled, $epId); $that->installerIni->setValue($name . '.version', $moduleStatus->version, $epId); if (!isset($that->allModules[$path])) { $that->allModules[$path] = new ModuleInstallLauncher($moduleInfos, $that); } return $that->allModules[$path]; }); } }
/** * declare a new db profile. if the content of the section is not given, * it will declare an alias to the default profile * @param string $name the name of the new section/alias * @param null|string|array $sectionContent the content of the new section, or null * to create an alias. * @param boolean $force true:erase the existing profile * @return boolean true if the ini file has been changed */ protected function declareDbProfile($name, $sectionContent = null, $force = true) { $profiles = new \Jelix\IniFile\IniModifier(App::configPath('profiles.ini.php')); if ($sectionContent == null) { if (!$profiles->isSection('jdb:' . $name)) { // no section if ($profiles->getValue($name, 'jdb') && !$force) { // already a name return false; } } else { if ($force) { // existing section, and no content provided : we erase the section // and add an alias $profiles->removeValue('', 'jdb:' . $name); } else { return false; } } $default = $profiles->getValue('default', 'jdb'); if ($default) { $profiles->setValue($name, $default, 'jdb'); } else { // default is a section $profiles->setValue($name, 'default', 'jdb'); } } else { if ($profiles->getValue($name, 'jdb') !== null) { if (!$force) { return false; } $profiles->removeValue($name, 'jdb'); } if (is_array($sectionContent)) { foreach ($sectionContent as $k => $v) { $profiles->setValue($k, $v, 'jdb:' . $name); } } else { $profile = $profiles->getValue($sectionContent, 'jdb'); if ($profile !== null) { $profiles->setValue($name, $profile, 'jdb'); } else { $profiles->setValue($name, $sectionContent, 'jdb'); } } } $profiles->save(); \Jelix\Core\Profiles::clear(); return true; }
function checkAppPaths() { $ok = true; if (!defined('JELIX_LIB_PATH') || !App::isInit()) { throw new \Exception($this->messages->get('path.core')); } if (!file_exists(App::tempBasePath()) || !is_writable(App::tempBasePath())) { $this->error('path.temp'); $ok = false; } if (!file_exists(App::logPath()) || !is_writable(App::logPath())) { $this->error('path.log'); $ok = false; } if (!file_exists(App::varPath())) { $this->error('path.var'); $ok = false; } if (!file_exists(App::appConfigPath())) { $this->error('path.config'); $ok = false; } if (!file_exists(App::configPath())) { $this->error('path.config'); $ok = false; } elseif ($this->checkForInstallation) { if (!is_writable(App::configPath())) { $this->error('path.config.writable'); $ok = false; } if (file_exists(App::configPath('profiles.ini.php')) && !is_writable(App::configPath('profiles.ini.php'))) { $this->error('path.profiles.writable'); $ok = false; } if (file_exists(App::configPath('installer.ini.php')) && !is_writable(App::configPath('installer.ini.php'))) { $this->error('path.installer.writable'); $ok = false; } } if (!file_exists(App::wwwPath())) { $this->error('path.www'); $ok = false; } foreach ($this->otherPaths as $path) { $realPath = \jFile::parseJelixPath($path); if (!file_exists($realPath)) { $this->error('path.custom.not.exists', array($path)); $ok = false; } else { if (!is_writable($realPath)) { $this->error('path.custom.writable', array($path)); $ok = false; } else { $this->ok('path.custom.ok', array($path)); } } } if ($ok) { $this->ok('paths.ok'); } else { throw new \Exception($this->messages->get('too.critical.error')); } return $ok; }
protected function checkPhpSettings() { if (file_exists(App::configPath("mainconfig.ini.php"))) { $defaultconfig = parse_ini_file(App::configPath("mainconfig.ini.php"), true); } else { $defaultconfig = array(); } if (file_exists(App::configPath("index/config.ini.php"))) { $indexconfig = parse_ini_file(App::configPath("index/config.ini.php"), true); } else { $indexconfig = array(); } return parent::checkPhpSettings(); }
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'); }
public function run() { $appPath = $this->getParam('path'); $appPath = $this->getRealPath($appPath); $appName = basename($appPath); $appPath .= '/'; if (file_exists($appPath . '/jelix-app.json') || file_exists($appPath . '/project.xml')) { throw new Exception("this application is already created"); } $this->config = JelixScript::loadConfig($appName); $this->config->infoWebsite = $this->config->newAppInfoWebsite; $this->config->infoLicence = $this->config->newAppInfoLicence; $this->config->infoLicenceUrl = $this->config->newAppInfoLicenceUrl; $this->config->infoLocale = $this->config->newAppInfoLocale; $this->config->infoCopyright = $this->config->newAppInfoCopyright; $this->config->initAppPaths($appPath); App::setEnv('jelix-scripts'); JelixScript::checkTempPath(); if ($p = $this->getOption('-wwwpath')) { $wwwpath = path::real($appPath . $p, false) . '/'; } else { $wwwpath = App::wwwPath(); } $this->createDir($appPath); $this->createDir(App::tempBasePath()); $this->createDir($wwwpath); $varPath = App::varPath(); $configPath = App::configPath(); $this->createDir($varPath); $this->createDir(App::logPath()); $this->createDir($configPath); $this->createDir($configPath . 'index/'); $this->createDir($varPath . 'overloads/'); $this->createDir($varPath . 'themes/'); $this->createDir($varPath . 'themes/default/'); $this->createDir($varPath . 'uploads/'); $this->createDir($varPath . 'sessions/'); $this->createDir($varPath . 'mails/'); $this->createDir($appPath . 'install'); $this->createDir($appPath . 'modules'); $this->createDir($appPath . 'plugins'); $this->createDir($appPath . 'responses'); $this->createDir($appPath . 'tests'); $this->createDir(App::scriptsPath()); $param = array(); if ($this->getOption('-nodefaultmodule')) { $param['tplname'] = 'jelix~defaultmain'; $param['modulename'] = 'jelix'; } else { $moduleName = $this->getOption('-modulename'); if (!$moduleName) { // note: since module name are used for name of generated name, // only this characters are allowed $moduleName = preg_replace('/([^a-zA-Z_0-9])/', '_', $appName); } $param['modulename'] = $moduleName; $param['tplname'] = $moduleName . '~main'; } $param['config_file'] = 'index/config.ini.php'; $param['rp_temp'] = $this->getRelativePath($appPath, App::tempBasePath()); $param['rp_var'] = $this->getRelativePath($appPath, App::varPath()); $param['rp_log'] = $this->getRelativePath($appPath, App::logPath()); $param['rp_conf'] = $this->getRelativePath($appPath, $configPath); $param['rp_www'] = $this->getRelativePath($appPath, $wwwpath); $param['rp_cmd'] = $this->getRelativePath($appPath, App::scriptsPath()); $param['rp_jelix'] = $this->getRelativePath($appPath, JELIX_LIB_PATH); $param['rp_vendor'] = ''; foreach (array(LIB_PATH . 'vendor/', LIB_PATH . '../vendor/', LIB_PATH . '../../../') as $path) { if (file_exists($path)) { $param['rp_vendor'] = $this->getRelativePath($appPath, realpath($path) . '/'); break; } } $param['rp_app'] = $this->getRelativePath($wwwpath, $appPath); $this->createFile(App::logPath() . '.dummy', 'dummy.tpl', array()); $this->createFile(App::varPath() . 'mails/.dummy', 'dummy.tpl', array()); $this->createFile(App::varPath() . 'sessions/.dummy', 'dummy.tpl', array()); $this->createFile(App::varPath() . 'overloads/.dummy', 'dummy.tpl', array()); $this->createFile(App::varPath() . 'themes/default/.dummy', 'dummy.tpl', array()); $this->createFile(App::varPath() . 'uploads/.dummy', 'dummy.tpl', array()); $this->createFile($appPath . 'plugins/.dummy', 'dummy.tpl', array()); $this->createFile(App::scriptsPath() . '.dummy', 'dummy.tpl', array()); $this->createFile(App::tempBasePath() . '.dummy', 'dummy.tpl', array()); $this->createFile($appPath . '.htaccess', 'htaccess_deny', $param, "Configuration file for Apache"); $this->createFile($appPath . '.gitignore', 'git_ignore.tpl', $param, ".gitignore"); $this->createFile($appPath . 'jelix-app.json', 'jelix-app.json.tpl', $param, "Project description file"); $this->createFile($appPath . 'composer.json', 'composer.json.tpl', $param, "Composer file"); $this->createFile($appPath . 'cmd.php', 'cmd.php.tpl', $param, "Script for developer commands"); $this->createFile($configPath . 'mainconfig.ini.php', 'var/config/mainconfig.ini.php.tpl', $param, "Main configuration file"); $this->createFile($configPath . 'localconfig.ini.php.dist', 'var/config/localconfig.ini.php.tpl', $param, "Configuration file for specific environment"); $this->createFile($configPath . 'profiles.ini.php', 'var/config/profiles.ini.php.tpl', $param, "Profiles file"); $this->createFile($configPath . 'profiles.ini.php.dist', 'var/config/profiles.ini.php.tpl', $param, "Profiles file for your repository"); $this->createFile($configPath . 'preferences.ini.php', 'var/config/preferences.ini.php.tpl', $param, "Preferences file"); $this->createFile($configPath . 'urls.xml', 'var/config/urls.xml.tpl', $param, "URLs mapping file"); $this->createFile($configPath . 'index/config.ini.php', 'var/config/index/config.ini.php.tpl', $param, "Entry point configuration file"); $this->createFile($appPath . 'responses/myHtmlResponse.class.php', 'responses/myHtmlResponse.class.php.tpl', $param, "Main response class"); $this->createFile($appPath . 'install/installer.php', 'installer/installer.php.tpl', $param, "Installer script"); $this->createFile($appPath . 'tests/runtests.php', 'tests/runtests.php', $param, "Tests script"); $temp = dirname(rtrim(App::tempBasePath(), '/')); if ($temp != rtrim($appPath, '/')) { if (file_exists($temp . '/.gitignore')) { $gitignore = file_get_contents($temp . '/.gitignore') . "\n" . $appName . "/*\n"; file_put_contents($temp . '/.gitignore', $gitignore); } else { file_put_contents($temp . '/.gitignore', $appName . "/*\n"); } } else { $gitignore = file_get_contents($appPath . '.gitignore') . "\n" . basename(rtrim(App::tempBasePath(), '/')) . "/*\n"; file_put_contents($appPath . '.gitignore', $gitignore); } $this->createFile($wwwpath . 'index.php', 'www/index.php.tpl', $param, "Main entry point"); $this->createFile($wwwpath . '.htaccess', 'htaccess_allow', $param, "Configuration file for Apache"); $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']); $param['php_rp_jelix'] = $this->convertRp($param['rp_jelix']); if ($param['rp_vendor']) { $param['php_rp_vendor'] = $this->convertRp($param['rp_vendor']); $this->createFile($appPath . 'application.init.php', 'application2.init.php.tpl', $param, "Bootstrap file"); } else { $this->createFile($appPath . 'application.init.php', 'application.init.php.tpl', $param, "Bootstrap file"); } $installer = new \Jelix\Installer\Installer(new \Jelix\Installer\Reporter\Console('warning')); $installer->installApplication(); $moduleok = true; if (!$this->getOption('-nodefaultmodule')) { try { $cmd = JelixScript::getCommand('createmodule', $this->config); $options = $this->getCommonActiveOption(); $options['-addinstallzone'] = true; $options['-noregistration'] = true; $cmd->initOptParam($options, array('module' => $param['modulename'])); $cmd->run(); $this->createFile($appPath . 'modules/' . $param['modulename'] . '/templates/main.tpl', 'module/main.tpl.tpl', $param, "Main template"); } 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 = JelixScript::getCommand('createctrl', $this->config); $options = $this->getCommonActiveOption(); $options['-cmdline'] = true; $agcommand->initOptParam($options, array('module' => $param['modulename'], 'name' => 'default', 'method' => 'index')); $agcommand->run(); } $agcommand = JelixScript::getCommand('createentrypoint', $this->config); $options = $this->getCommonActiveOption(); $options['-type'] = 'cmdline'; $parameters = array('name' => $param['modulename']); $agcommand->initOptParam($options, $parameters); $agcommand->run(); } }