Source for file CreatePlugin.php

Documentation is available at CreatePlugin.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  CreatePlugin.php
  5.  *
  6.  *  please go to http://ethna.jp/ethna-document-dev_guide-pearchannel.html
  7.  *  for more info.
  8.  *
  9.  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
  10.  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
  11.  *  @package    Ethna
  12.  *  @version    $Id: c3b3b8c67188ac0ca4f43ff86b02d34c9536aa6b $
  13.  */
  14.  
  15. // {{{ Ethna_Plugin_Handle_CreatePlugin
  16. /**
  17.  *  create Ethna Plugin Skelton handler.
  18.  *
  19.  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
  20.  *  @access     public
  21.  *  @package    Ethna
  22.  */
  23. {
  24.     // {{{ perform()
  25.     /**
  26.      * @access public
  27.      */
  28.     function perform()
  29.     {
  30.         $r $this->_getopt(
  31.             array(
  32.                 'basedir=',
  33.                 'type=',
  34.                 'plugin-package',
  35.             )
  36.         )
  37.         if (Ethna::isError($r)) {
  38.             return $r;
  39.         }
  40.         list($opt_list$arg_list$r;
  41.  
  42.         //  plugin name
  43.         $plugin_name array_shift($arg_list);
  44.         if (empty($plugin_name)) {
  45.             return Ethna::raiseError('Please specify plugin Name.''usage');
  46.         }
  47.  
  48.         //  plugin types
  49.         $type end($opt_list['type']);
  50.         $types explode(','$type);
  51.         if (empty($type)) {
  52.             $types array('v''f''sm')// Validator, Filter, Smarty modifier.
  53.         
  54.  
  55.         //  basedir
  56.         if (isset($opt_list['basedir'])) {
  57.             $basedir realpath(end($opt_list['basedir']));
  58.         else {
  59.             $basedir getcwd();
  60.         }
  61.  
  62.         //  no-ini file flag.
  63.         $forpackage (isset($opt_list['plugin-package'])) true false
  64.  
  65.         $r Ethna_Generator::generate('CreatePlugin'NULL$basedir$types$forpackage$plugin_name);
  66.         if (Ethna::isError($r)) {
  67.             printf("error occurred while generating plugin skelton. please see also error messages given above\n\n");
  68.             return $r;
  69.         }
  70.         printf("\nplugin skelton for [%s] is successfully generated.\n\n"$plugin_name);
  71.         return true;
  72.     }
  73.     // }}}
  74.  
  75.     // {{{ getDescription()
  76.     /**
  77.      *  @access public
  78.      */
  79.     function getUsage()
  80.     {
  81.         return <<<EOS
  82. ethna {$this->id} [-b|--basedir=dir] [-t|--type=f,v,sb,sf,sm...] [-p|--plugin-package] plugin-name
  83.     -t: type is as follows (separated by comma):
  84.         f = Filter (default),
  85.         v = Validator (default),
  86.         sm = Smarty modifier (default)
  87.         sb = Smarty block,
  88.         sf = Smarty function,
  89.     -p: if you want to make plugin package, set this option.
  90. EOS;
  91.     }
  92.     // }}}
  93.  
  94.     // {{{ getDescription()
  95.     /**
  96.      *  @access public
  97.      */
  98.     function getDescription()
  99.     {
  100.         return <<<EOS
  101. make plugin package:
  102.     {$this->id} [-b|--basedir=dir] [-t|--type=f,v,sb,sf,sm...] [-p|--plugin-package] plugin-name
  103. EOS;
  104.     }
  105.     // }}}
  106. }
  107. // }}}

Documentation generated on Fri, 11 Nov 2011 03:57:55 +0900 by phpDocumentor 1.4.3