/**
  *  @access protected
  */
 function &_perform($target, $target_name, $opt_list)
 {
     // basedir
     if (isset($opt_list['basedir'])) {
         $basedir = realpath(end($opt_list['basedir']));
     } else {
         $basedir = getcwd();
     }
     // skelfile
     if (isset($opt_list['skelfile'])) {
         $skelfile = end($opt_list['skelfile']);
     } else {
         $skelfile = null;
     }
     // gateway
     if (isset($opt_list['gateway'])) {
         $gateway = 'GATEWAY_' . strtoupper(end($opt_list['gateway']));
         if (defined($gateway)) {
             $gateway = constant($gateway);
         } else {
             return Ethna::raiseError('unknown gateway', 'usage');
         }
     } else {
         $gateway = GATEWAY_WWW;
     }
     $r =& Ethna_Generator::generate($target, $basedir, $target_name, $skelfile, $gateway);
     if (Ethna::isError($r)) {
         printf("error occurred while generating skelton. please see also following error message(s)\n\n");
         return $r;
     }
     $true = true;
     return $true;
 }
 /**
  *  @access protected
  */
 function _perform($target)
 {
     $r =& $this->_getopt(array('basedir='));
     if (Ethna::isError($r)) {
         return $r;
     }
     list($opt_list, $arg_list) = $r;
     // table_name
     $table_name = array_shift($arg_list);
     if ($table_name == null) {
         return Ethna::raiseError('table name isn\'t set.', 'usage');
     }
     // basedir
     if (isset($opt_list['basedir'])) {
         $basedir = realpath(end($opt_list['basedir']));
     } else {
         $basedir = getcwd();
     }
     $r =& Ethna_Generator::generate($target, $basedir, $table_name);
     if (Ethna::isError($r)) {
         printf("error occurred while generating skelton. please see also following error message(s)\n\n");
         return $r;
     }
     return true;
 }
 /**
  *  add project:)
  *
  *  @access public
  */
 function perform()
 {
     $r = $this->_getopt(array('basedir='));
     if (Ethna::isError($r)) {
         return $r;
     }
     list($opt_list, $arg_list) = $r;
     // app_id
     $app_id = array_shift($arg_list);
     if ($app_id == null) {
         return Ethna::raiseError('project id isn\'t set.', 'usage');
     }
     $r = Ethna_Controller::checkAppId($app_id);
     if (Ethna::isError($r)) {
         return $r;
     }
     // basedir
     if (isset($opt_list['basedir'])) {
         $basedir = realpath(end($opt_list['basedir']));
     } else {
         $basedir = getcwd();
     }
     $r = Ethna_Generator::generate('Project', null, $app_id, $basedir);
     if (Ethna::isError($r)) {
         printf("error occurred while generating skelton. please see also error messages given above\n\n");
         return $r;
     }
     printf("\nproject skelton for [%s] is successfully generated at [%s]\n\n", $app_id, $basedir);
     return true;
 }
Esempio n. 4
0
 /**
  * @access public
  */
 function perform()
 {
     $r = $this->_getopt(array('basedir=', 'type=', 'plugin-package'));
     if (Ethna::isError($r)) {
         return $r;
     }
     list($opt_list, $arg_list) = $r;
     //  plugin name
     $plugin_name = array_shift($arg_list);
     if (empty($plugin_name)) {
         return Ethna::raiseError('Please specify plugin Name.', 'usage');
     }
     //  plugin types
     $type = end($opt_list['type']);
     $types = explode(',', $type);
     if (empty($type)) {
         $types = array('v', 'f', 'sm');
         // Validator, Filter, Smarty modifier.
     }
     //  basedir
     if (isset($opt_list['basedir'])) {
         $basedir = realpath(end($opt_list['basedir']));
     } else {
         $basedir = getcwd();
     }
     //  no-ini file flag.
     $forpackage = isset($opt_list['plugin-package']) ? true : false;
     $r = Ethna_Generator::generate('CreatePlugin', NULL, $basedir, $types, $forpackage, $plugin_name);
     if (Ethna::isError($r)) {
         printf("error occurred while generating plugin skelton. please see also error messages given above\n\n");
         return $r;
     }
     printf("\nplugin skelton for [%s] is successfully generated.\n\n", $plugin_name);
     return true;
 }
 /**
  * コマンドの実装部分
  * 
  * テストケースファイル生成を行う
  * 
  * @access protected
  * @return mixed 実行結果: TRUE: 成功
  *                         Ethna_Error: エラー
  */
 function &perform()
 {
     // get args.
     $r = $this->_getopt(array('basedir=', 'skelfile='));
     if (Ethna::isError($r)) {
         return $r;
     }
     list($optlist, $arglist) = $r;
     $num = count($arglist);
     if ($num < 1 || $num > 3) {
         return Ethna::raiseError("Invalid Arguments.", 'usage');
     }
     if (isset($optlist['skelfile'])) {
         $skelfile = end($optlist['skelfile']);
     } else {
         $skelfile = null;
     }
     $baseDir = isset($optlist['basedir']) ? $optlist['basedir'] : getcwd();
     $name = $arglist[0];
     $r =& Ethna_Generator::generate('Test', $baseDir, $skelfile, $name);
     if (Ethna::isError($r)) {
         return $r;
     }
     $true = true;
     return $true;
 }
 /**
  *  generate message catalog.
  *
  *  @access public
  */
 function perform()
 {
     $r = $this->_getopt(array('basedir=', 'locale=', 'gettext'));
     if (Ethna::isError($r)) {
         return $r;
     }
     list($opt_list, $arg_list) = $r;
     // basedir
     if (isset($opt_list['basedir'])) {
         $basedir = realpath(end($opt_list['basedir']));
     } else {
         $basedir = getcwd();
     }
     // locale
     if (isset($opt_list['locale'])) {
         $locale = end($opt_list['locale']);
         if (!preg_match('/^[A-Za-z_]+$/', $locale)) {
             return Ethna::raiseError("You specified locale, but invalid : {$locale}", 'usage');
         }
     } else {
         $locale = 'ja_JP';
         //  default locale.
     }
     //  use gettext ?
     $use_gettext = isset($opt_list['gettext']) ? true : false;
     //  generate message catalog.
     $ret =& Ethna_Generator::generate('I18n', $basedir, $locale, $use_gettext, $arg_list);
     if (Ethna::isError($ret)) {
         printf("error occurred while generating skelton. please see also following error message(s)\n\n");
         return $ret;
     }
     return $ret;
 }
 /**
  *  add project:)
  *
  *  @access public
  */
 function perform()
 {
     $r = $this->_getopt(array('basedir=', 'skeldir=', 'locale=', 'encoding='));
     if (Ethna::isError($r)) {
         return $r;
     }
     list($opt_list, $arg_list) = $r;
     // app_id
     $app_id = array_shift($arg_list);
     if ($app_id == null) {
         return Ethna::raiseError('Application id isn\'t set.', 'usage');
     }
     $r = Ethna_Controller::checkAppId($app_id);
     if (Ethna::isError($r)) {
         return $r;
     }
     // basedir
     if (isset($opt_list['basedir'])) {
         $dir = end($opt_list['basedir']);
         $basedir = realpath($dir);
         if ($basedir === false) {
             //  e.x file does not exist
             $basedir = $dir;
         }
     } else {
         $basedir = sprintf("%s/%s", getcwd(), strtolower($app_id));
     }
     // skeldir
     if (isset($opt_list['skeldir'])) {
         $selected_dir = end($opt_list['skeldir']);
         $skeldir = realpath($selected_dir);
         if ($skeldir == false || is_dir($skeldir) == false || file_exists($skeldir) == false) {
             return Ethna::raiseError("You specified skeldir, but invalid : {$selected_dir}", 'usage');
         }
     } else {
         $skeldir = null;
     }
     // locale
     if (isset($opt_list['locale'])) {
         $locale = end($opt_list['locale']);
         if (!preg_match('/^[A-Za-z_]+$/', $locale)) {
             return Ethna::raiseError("You specified locale, but invalid : {$locale}", 'usage');
         }
     } else {
         $locale = 'ja_JP';
         //  default locale.
     }
     // encoding
     if (isset($opt_list['encoding'])) {
         $encoding = end($opt_list['encoding']);
         if (function_exists('mb_list_encodings')) {
             $supported_enc = mb_list_encodings();
             if (!in_array($encoding, $supported_enc)) {
                 return Ethna::raiseError("Unknown Encoding : {$encoding}", 'usage');
             }
         }
     } else {
         $encoding = 'UTF-8';
         //  default encoding.
     }
     $r = Ethna_Generator::generate('Project', null, $app_id, $basedir, $skeldir, $locale, $encoding);
     if (Ethna::isError($r)) {
         printf("error occurred while generating skelton. please see also error messages given above\n\n");
         return $r;
     }
     printf("\nproject skelton for [%s] is successfully generated at [%s]\n\n", $app_id, $basedir);
     return true;
 }
 /**
  *  @access public
  *  @todo   deal with the package including some plugins.
  */
 function perform()
 {
     $args =& $this->_parseArgList();
     if (Ethna::isError($args)) {
         return $args;
     }
     $pear =& new Ethna_PearWrapper();
     if (isset($args['pearopt'])) {
         $pear->setPearOpt($args['pearopt']);
     }
     if (isset($args['pkg_file_or_url'])) {
         // install from local tgz.
         $pkg_file_or_url = $args['pkg_file_or_url'];
         $pkg_name =& Ethna_PearWrapper::getPackageNameFromTgz($pkg_file_or_url);
         if (Ethna::isError($pkg_name)) {
             return $pkg_name;
         }
         list($appid, , $ctype, $cname) = explode('_', $pkg_name, 4);
         $target = isset($args['target']) ? $args['target'] : null;
         if ($target == 'master') {
             if ($appid != 'Ethna') {
                 return Ethna::raiseError("this package is not for master.");
             }
         } else {
             if ($appid == 'Ethna') {
                 return Ethna::raiseError("this package is not for local.");
             }
         }
         $channel = isset($args['channel']) ? $args['channel'] : null;
         $basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd();
         $r =& $pear->init($target, $basedir, $channel);
         if (Ethna::isError($r)) {
             return $r;
         }
         $r =& $pear->doInstallFromTgz($pkg_file_or_url, $pkg_name);
         if (Ethna::isError($r)) {
             return $r;
         }
     } else {
         if (isset($args['type']) && isset($args['name'])) {
             // install from repository.
             $target = isset($args['target']) ? $args['target'] : null;
             $channel = isset($args['channel']) ? $args['channel'] : null;
             $basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd();
             $state = isset($args['state']) ? $args['state'] : null;
             if ($target == 'master') {
                 $pkg_name = sprintf('Ethna_Plugin_%s_%s', $args['type'], $args['name']);
             } else {
                 $pkg_name = sprintf('App_Plugin_%s_%s', $args['type'], $args['name']);
             }
             $r =& $pear->init($target, $basedir, $channel);
             if (Ethna::isError($r)) {
                 return $r;
             }
             $r =& $pear->doInstall($pkg_name, $state);
             if (Ethna::isError($r)) {
                 return $r;
             }
             $pkg_name = $pear->getCanonicalPackageName($pkg_name);
             if (Ethna::isError($pkg_name)) {
                 return $pkg_name;
             }
         } else {
             return Ethna::raiseError('invalid number of arguments', 'usage');
         }
     }
     if ($target != 'master') {
         list(, , $ctype, $cname) = explode('_', $pkg_name, 4);
         $r = Ethna_Generator::generate('Plugin', $basedir, $ctype, $cname, true);
         if (Ethna::isError($r)) {
             return $r;
         }
     }
     return true;
 }
Esempio n. 9
0
 /**
  *  Special Function for generating template.
  *
  *  @param  string $target_name Template Name
  *  @param  array  $opt_list    Option List.
  *  @access protected
  */
 function _performTemplate($target_name, $opt_list)
 {
     // basedir
     if (isset($opt_list['basedir'])) {
         $basedir = realpath(end($opt_list['basedir']));
     } else {
         $basedir = getcwd();
     }
     // skelfile
     if (isset($opt_list['skelfile'])) {
         $skelfile = end($opt_list['skelfile']);
     } else {
         $skelfile = null;
     }
     // locale
     $ctl = Ethna_Handle::getAppController(getcwd());
     if (isset($opt_list['locale'])) {
         $locale = end($opt_list['locale']);
         if (!preg_match('/^[A-Za-z_]+$/', $locale)) {
             return Ethna::raiseError("You specified locale, but invalid : {$locale}", 'usage');
         }
     } else {
         if (Ethna::isError($ctl)) {
             $locale = 'ja_JP';
         } else {
             $locale = $ctl->getLocale();
         }
     }
     // encoding
     if (isset($opt_list['encoding'])) {
         $encoding = end($opt_list['encoding']);
         if (function_exists('mb_list_encodings')) {
             $supported_enc = mb_list_encodings();
             if (!in_array($encoding, $supported_enc)) {
                 return Ethna::raiseError("Unknown Encoding : {$encoding}", 'usage');
             }
         }
     } else {
         if (Ethna::isError($ctl)) {
             $encoding = 'UTF-8';
         } else {
             $encoding = $ctl->getClientEncoding();
         }
     }
     $r = Ethna_Generator::generate('Template', $basedir, $target_name, $skelfile, $locale, $encoding);
     if (Ethna::isError($r)) {
         printf("error occurred while generating skelton. please see also following error message(s)\n\n");
         return $r;
     }
     $true = true;
     return $true;
 }
 /**
  *  @access public
  *  @todo   deal with the package including some plugins.
  */
 function perform()
 {
     $args =& $this->_parseArgList();
     if (Ethna::isError($args)) {
         return $args;
     }
     $pear =& new Ethna_PearWrapper();
     if (isset($args['pearopt'])) {
         $pear->setPearOpt($args['pearopt']);
     }
     if (isset($args['type']) && isset($args['name'])) {
         // install from repository.
         $target = isset($args['target']) ? $args['target'] : null;
         $channel = isset($args['channel']) ? $args['channel'] : null;
         $basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd();
         if ($target == 'master') {
             $pkg_name = sprintf('Ethna_Plugin_%s_%s', $args['type'], $args['name']);
         } else {
             $pkg_name = sprintf('App_Plugin_%s_%s', $args['type'], $args['name']);
         }
         $r =& $pear->init($target, $basedir, $channel);
         if (Ethna::isError($r)) {
             return $r;
         }
         $pkg_name = $pear->getCanonicalPackageName($pkg_name);
         if (Ethna::isError($pkg_name)) {
             return $pkg_name;
         }
         $r =& $pear->doUninstall($pkg_name);
         if (Ethna::isError($r)) {
             return $r;
         }
     } else {
         return Ethna::raiseError('invalid number of arguments', 'usage');
     }
     if ($target != 'master') {
         list(, , $ctype, $cname) = explode('_', $pkg_name, 4);
         $r = Ethna_Generator::remove('Plugin', $basedir, $ctype, $cname);
         if (Ethna::isError($r)) {
             return $r;
         }
     }
     return true;
 }
 /**
  *  @access protected
  */
 function &_perform($target, $target_name, $opt_list)
 {
     // basedir
     if (isset($opt_list['basedir'])) {
         $basedir = realpath(end($opt_list['basedir']));
     } else {
         $basedir = getcwd();
     }
     // skelfile
     if (isset($opt_list['skelfile'])) {
         $skelfile = end($opt_list['skelfile']);
     } else {
         $skelfile = null;
     }
     // gateway
     if (isset($opt_list['gateway'])) {
         $gateway = 'GATEWAY_' . strtoupper(end($opt_list['gateway']));
         if (defined($gateway)) {
             $gateway = constant($gateway);
         } else {
             return Ethna::raiseError('unknown gateway', 'usage');
         }
     } else {
         $gateway = GATEWAY_WWW;
     }
     //  possible target is Action, View.
     $r =& Ethna_Generator::generate($target, $basedir, $target_name, $skelfile, $gateway);
     if (Ethna::isError($r)) {
         printf("error occurred while generating skelton. please see also following error message(s)\n\n");
         return $r;
     }
     //
     //  if specified, generate corresponding testcase,
     //  except for template.
     //
     if ($target != 'Template' && isset($opt_list['with-unittest'])) {
         $testskel = isset($opt_list['unittestskel']) ? end($opt_list['unittestskel']) : null;
         $r =& Ethna_Generator::generate("{$target}Test", $basedir, $target_name, $testskel, $gateway);
         if (Ethna::isError($r)) {
             printf("error occurred while generating action test skelton. please see also following error message(s)\n\n");
             return $r;
         }
     }
     $true = true;
     return $true;
 }