Exemple #1
0
 /**
  * 
  * @param string $psModuleName
  */
 public function newModuleAction($psModuleName = null)
 {
     if ($psModuleName == null) {
         $this->setClientFolder($this->getRequestArg('folder', "onionapp.com"));
         $this->setModuleName($this->getRequestArg('module', null, true));
     } else {
         $this->setModuleName($psModuleName);
     }
     if ($this->_sModuleName == null) {
         System::echoError("The param module is required! Please, use --help for further information.");
         return;
     }
     $lsPathClient = $this->_sClientPath;
     $lsPathModules = $lsPathClient . DS . 'module';
     $lsPathConfig = $lsPathClient . DS . 'config';
     if (file_exists($lsPathModules)) {
         $lsPathModule = $lsPathModules . DS . $this->_sModuleName;
         $this->createDir($lsPathModule);
         if (file_exists($lsPathModule)) {
             $lsFileLicense = $this->getLicense($this->_sModuleName);
             $this->saveFile($lsPathModule, 'Module', $lsFileLicense);
             $lsPathModuleConfig = $lsPathModule . DS . 'config';
             $this->createDir($lsPathModuleConfig);
             if ($this->_sModuleName == "Backend") {
                 $this->saveFile($lsPathModuleConfig, 'dashboard.config', $lsFileLicense);
             } elseif ($this->_sModuleName == "Frontend") {
                 $this->saveFile($lsPathModuleConfig, 'site.config', $lsFileLicense);
             } else {
                 $this->saveFile($lsPathModuleConfig, 'module.config', $lsFileLicense);
             }
             $lsModuleRoute = String::slugfy($this->_sModuleName);
             $lsPathView = $lsPathModule . DS . 'view';
             $this->createDir($lsPathView);
             $lsPathViewModule = $lsPathView . DS . $lsModuleRoute;
             $this->createDir($lsPathViewModule);
             $lsPathViewController = $lsPathViewModule . DS . $lsModuleRoute;
             $this->createDir($lsPathViewController);
             $this->saveFile($lsPathViewController, 'message', $lsFileLicense, 'phtml');
             if ($this->_sModuleName == "Backend") {
                 $this->saveFile($lsPathViewController, 'dashboard', $lsFileLicense, 'phtml');
             } elseif ($this->_sModuleName == "Frontend") {
                 $this->saveFile($lsPathViewController, 'site', $lsFileLicense, 'phtml');
             } else {
                 $this->saveFile($lsPathViewController, 'actionIndex', $lsFileLicense);
                 $this->saveFile($lsPathViewController, 'add', $lsFileLicense, 'phtml');
                 $this->saveFile($lsPathViewController, 'edit', $lsFileLicense, 'phtml');
                 $this->saveFile($lsPathViewController, 'trash', $lsFileLicense, 'phtml');
                 $this->saveFile($lsPathViewController, 'view', $lsFileLicense, 'phtml');
             }
             $lsPathSrc = $lsPathModule . DS . 'src';
             $this->createDir($lsPathSrc);
             if (file_exists($lsPathSrc)) {
                 $lsPathSrcModule = $lsPathSrc . DS . $this->_sModuleName;
                 $this->createDir($lsPathSrcModule);
                 if (file_exists($lsPathSrcModule)) {
                     $lsPathController = $lsPathSrcModule . DS . 'Controller';
                     $this->createDir($lsPathController);
                     if ($this->_sModuleName == "Backend") {
                         $this->saveFile($lsPathController, '_Dashboard', $lsFileLicense);
                     } elseif ($this->_sModuleName == "Frontend") {
                         $this->saveFile($lsPathController, '_Site', $lsFileLicense);
                     } else {
                         $this->saveFile($lsPathController, '_Controller', $lsFileLicense);
                     }
                     if ($this->_sModuleName != "Backend" && $this->_sModuleName != "Frontend") {
                         $lsPathEntity = $lsPathSrcModule . DS . 'Entity';
                         $this->createDir($lsPathEntity);
                         $this->saveFile($lsPathEntity, 'Entity', $lsFileLicense);
                         $this->saveFile($lsPathEntity, '_Basic', $lsFileLicense);
                         $this->saveFile($lsPathEntity, '_Extended', $lsFileLicense);
                         $this->saveFile($lsPathEntity, '_Repository', $lsFileLicense);
                         $lsPathForm = $lsPathSrcModule . DS . 'Form';
                         $this->createDir($lsPathForm);
                         $this->saveFile($lsPathForm, '_Form', $lsFileLicense);
                         //$lsPathGrid = $lsPathSrcModule . DS . 'Grid';
                         //$this->createDir($lsPathGrid);
                         //$this->saveFile($lsPathGrid, 'Grid', $lsFileLicense);
                         $this->setModuleAutoload($lsPathConfig);
                     }
                 }
             }
         }
     } else {
         System::echoError("Client folder do not exist! You need to create a new client first. Please, use --help for further information.");
     }
 }
Exemple #2
0
 /**
  * 
  * @param string $psModule
  * @param string $psController
  * @param string $psAction
  * @param string $psParam
  */
 public function getParamHelp($psModule, $psController, $psAction, $psParam)
 {
     $psModule = String::lcfirst($psModule);
     $psController = String::lcfirst($psController);
     if (isset($this->_aModuleHelp[$psModule][$psController][$psAction]["params"][$psParam])) {
         return $this->_aModuleHelp[$psModule][$psController][$psAction]["params"][$psParam];
     }
     return null;
 }
Exemple #3
0
 /**
  * 
  * @param string $psPath
  * @param string $psFile
  * @param string $psFileLicense
  * @param string $psFileType
  */
 public function saveFile($psPath, $psFile, $psFileLicense = "", $psFileType = "php")
 {
     switch ($psFile) {
         case 'htaccess':
             $lsFileName = ".{$psFile}";
             break;
         case 'Entity':
         case 'EntityEmpty':
             $lsFileName = "{$this->_sModuleName}.php";
             break;
         case 'actionIndex':
             $lsFileName = "index.phtml";
             break;
         case '_Dashboard':
         case '_Site':
             $lsFileName = "{$this->_sModuleName}Controller.php";
             break;
         case 'dashboard.config':
         case 'site.config':
             $lsFileName = "module.config.php";
             break;
         default:
             $lsFileName = "{$psFile}.{$psFileType}";
             $lsFileName = preg_replace("/_/", $this->_sModuleName, $lsFileName);
     }
     $lsFilePath = $psPath . DS . $lsFileName;
     if (!file_exists($lsFilePath)) {
         $lsFileContent = System::localRequest($this->_sModelPath . DS . "{$psFile}.model");
         Util::parse($lsFileContent, "#%LICENSE%#", $psFileLicense);
         Util::parse($lsFileContent, "#%MODULE%#", $this->_sModuleName);
         Util::parse($lsFileContent, "#%TABLE%#", $this->_sModuleName);
         Util::parse($lsFileContent, "#%ACTION%#", String::lcfirst($this->_sModuleName));
         Util::parse($lsFileContent, "#%ROUTE%#", String::slugfy($this->_sModuleName));
         Util::parse($lsFileContent, "#%PACKAGE%#", $this->_sClientFolder);
         Util::parse($lsFileContent, "#%CLIENT-NAME%#", $this->_sClientName);
         Util::parse($lsFileContent, "#%DATE%#", date('Y-m-d'));
         Util::parse($lsFileContent, "#%DOMAIN%#", $this->_sClientDomain);
         System::saveFile($lsFilePath, $lsFileContent);
     }
 }