示例#1
0
 public function GenerateApp()
 {
     global $aParameter;
     $laResult['err'] = 1;
     if ($aParameter['app_name'] == '' or $aParameter['directory'] == '') {
         $laResult['msg'] = 'Invalid parameter !';
         return json_encode($laResult);
     }
     if (!is_dir($aParameter['directory'])) {
         $laResult['msg'] = 'Invalid Directory !';
         return json_encode($laResult);
     }
     $lsAppName = ucwords($aParameter['app_name']);
     //$lsAppName = str_replace( ' ', '', $lsAppName);
     $aParameter['app_name'] = $lsAppName;
     $aParameter['app_shortname'] = str_replace(' ', '', strtolower($lsAppName));
     $lsDir = $aParameter['directory'];
     $lsDirTarget = $lsDir . '/' . $aParameter['app_shortname'];
     _CreateDirectory($lsDirTarget, false);
     $lsDirSource = __DIR__ . '/templates/app/';
     _GeneratePluginFiles($lsAppName, $lsDirSource, $lsDirTarget);
     $laResult['err'] = 0;
     $lsMsg = "DONE !" . "\n\nApplication '" . $lsAppName . "' has been generated" . "\n\n";
     $laResult['msg'] = $lsMsg;
     //-- open index file
     $lsFileName = $lsDirTarget . "/index.php";
     //-- open project file
     $lsFileName = $lsDirTarget . "/{$lsAppName}.aprj";
     $laResult['command'] = 'fileopen';
     $laResult['parameter'] = $lsFileName;
     return json_encode($laResult);
 }
示例#2
0
 public function DBOjectGenerator()
 {
     global $aParameter;
     $laResult['err'] = 1;
     if ($aParameter['model_name'] == '' or $aParameter['table_name'] == '' or $aParameter['directory'] == '') {
         $laResult['msg'] = 'Invalid parameter !';
         return json_encode($laResult);
     }
     if (!is_dir($aParameter['directory'])) {
         $laResult['msg'] = 'Invalid Directory !';
         return json_encode($laResult);
     }
     $lsModelName = ucwords($aParameter['model_name']);
     $lsModelName = str_replace(' ', '', $lsModelName);
     $aParameter['model_name'] = $lsModelName;
     $lsDirSource = __DIR__ . '/templates/dbobject/';
     $lsTargetDir = $aParameter['directory'];
     _CreateDirectory($lsTargetDir);
     _GeneratePluginFiles($lsModelName, $lsDirSource, $lsTargetDir);
     $lsFileName = $lsTargetDir . '/' . "{$lsModelName}.php";
     $laResult['err'] = 0;
     $laResult['msg'] = "Model '{$lsModelName}' Created.";
     $laResult['command'] = 'fileopen';
     $laResult['parameter'] = $lsFileName;
     return json_encode($laResult);
 }
示例#3
0
 public function GeneratePlugin()
 {
     global $aParameter;
     $laResult['err'] = 1;
     if ($aParameter['pluginname'] == '' or $aParameter['directory'] == '') {
         $laResult['msg'] = 'Invalid parameter !';
         return json_encode($laResult);
     }
     if (!is_dir($aParameter['directory'])) {
         $laResult['msg'] = 'Invalid Directory !';
         return json_encode($laResult);
     }
     $lsPluginName = ucwords($aParameter['pluginname']);
     $lsPluginName = str_replace(' ', '', $lsPluginName);
     $aParameter['pluginname'] = $lsPluginName;
     $aParameter['pluginshortname'] = strtolower($lsPluginName);
     $lsDir = $aParameter['directory'];
     $lsDirTarget = $lsDir . '/' . $lsPluginName;
     _CreateDirectory($lsDirTarget);
     //chdir( $lsDirTarget);
     $lsDirSource = __DIR__ . '/templates/plugin/';
     _GeneratePluginFiles($lsPluginName, $lsDirSource, $lsDirTarget);
     $aParameter['pluginname'] = $lsPluginName;
     $aParameter['pluginname'] = str_replace(' ', '', $aParameter['pluginname']);
     $lsParameter = print_r($aParameter, true);
     $laResult['err'] = 0;
     $lsMsg = "DONE !" . "\n\nPlugin '" . $lsPluginName . "' has been generated" . "\n\nmake sure you add line to file 'app/Config/bootstrap.php' whith this code: " . "\n\n    CakePlugin::load('{$lsPluginName}', array('routes'=>true,'bootstrap'=>true));" . "\n\n";
     $lsFileName = "{$lsDirTarget}/Controller/" . $lsPluginName . "Controller.php";
     $lsFileName = "{$lsDirTarget}/" . $lsPluginName . "-plugin.aprj";
     $laResult['msg'] = $lsMsg;
     $laResult['command'] = 'fileopen';
     $laResult['parameter'] = $lsFileName;
     return json_encode($laResult);
 }
示例#4
0
/**
 * function _GeneratePluginFiles
 *
 * @params $psPluginName
 * @params $psDirSource
 * @params $psDirTarget
 * @return
 */
function _GeneratePluginFiles($psPluginName, $psDirSource, $psDirTarget)
{
    $lsPluginShortname = strtolower($psPluginName);
    $laFiles = scandir($psDirSource);
    foreach ($laFiles as $lsFileName) {
        if ($lsFileName == ".") {
            continue;
        }
        if ($lsFileName == "..") {
            continue;
        }
        $laTargetDir = explode("/", $psDirSource);
        $lsTargetDir = "";
        for ($liI = 1; $liI < count($laTargetDir); $liI++) {
            $lsTargetDir .= $laTargetDir[$liI] . "/";
        }
        $lsTargetDir = "{$psDirTarget}/{$lsFileName}";
        $lsType = filetype("{$psDirSource}/{$lsFileName}");
        if ($lsType == "dir") {
            //$lsTargetDir = str_replace("%plugin.name%", $psPluginName, $lsTargetDir);
            //$lsTargetDir = str_replace("%plugin.shortname%", $lsPluginShortname, $lsTargetDir);
            $lsTargetDir = _ConvertFileName($lsTargetDir);
            _CreateDirectory($lsTargetDir);
            $lsDir = $psDirSource . $lsFileName . '/';
            _GeneratePluginFiles($psPluginName, $lsDir, $lsTargetDir);
        } else {
            //-- copy dari templates
            $lsSourceFile = "{$psDirSource}/{$lsFileName}";
            $laSource = _ReadFile($lsSourceFile);
            $lsSource = $laSource['content'];
            $lsTargetFile = str_replace("_____", $lsPluginShortname, $lsTargetDir);
            $lsTargetFile = _ConvertFileName($lsTargetFile);
            $lsSource = _ConvertContent($lsSource, _ConvertFileName($lsFileName));
            _SaveFile($lsTargetFile, $lsSource);
        }
        //-- if ( $lsType == "dir")
    }
    //-- foreach ($laFiles as $lsFileName) {
}