Source for file Ethna_Plugin_Handle_InfoPlugin.php

Documentation is available at Ethna_Plugin_Handle_InfoPlugin.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Ethna_Plugin_Handle_InfoPlugin.php
  5.  *
  6.  *  @author     ICHII Takashi <ichii386@schweetheart.jp>
  7.  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
  8.  *  @package    Ethna
  9.  *  @version    $Id$
  10.  */
  11.  
  12. require_once ETHNA_BASE '/class/Ethna_PearWrapper.php';
  13.  
  14. // {{{ Ethna_Plugin_Handle_InfoPlugin
  15. /**
  16.  *  info-plugin handler
  17.  *
  18.  *  @author     ICHII Takashi <ichii386@schweetheart.jp>
  19.  *  @access     public
  20.  *  @package    Ethna
  21.  */
  22. {
  23.     // {{{ _parseArgList()
  24.     /**
  25.      * @access private
  26.      */
  27.     function &_parseArgList()
  28.     {
  29.         $r =$this->_getopt(array('local''master',
  30.                                    'basedir=''channel=''pearopt='));
  31.         if (Ethna::isError($r)) {
  32.             return $r;
  33.         }
  34.         list($opt_list$arg_list$r;
  35.         $ret array();
  36.  
  37.         // options
  38.         $ret['target'= isset($opt_list['master']'master' 'local';
  39.         if (isset($opt_list['basedir'])) {
  40.             $ret['basedir'end($opt_list['basedir']);
  41.         }
  42.         if (isset($opt_list['channel'])) {
  43.             $ret['channel'end($opt_list['channel']);
  44.         }
  45.  
  46.         // arguments
  47.         if (count($arg_list== 2{
  48.             $ret['type'$arg_list[0];
  49.             $ret['name'$arg_list[1];
  50.         }
  51.  
  52.         return $ret;
  53.     }
  54.     // }}}
  55.  
  56.     // {{{ perform()
  57.     /**
  58.      *  @access public
  59.      */
  60.     function perform()
  61.     {
  62.         $args =$this->_parseArgList();
  63.         if (Ethna::isError($args)) {
  64.             return $args;
  65.         }
  66.  
  67.         $pear =new Ethna_PearWrapper();
  68.         if (isset($args['pearopt'])) {
  69.             $pear->setPearOpt($args['pearopt']);
  70.         }
  71.  
  72.         if (isset($args['type']&& isset($args['name'])) {
  73.             $target = isset($args['target']$args['target'null;
  74.             $channel = isset($args['channel']$args['channel'null;
  75.             $basedir = isset($args['basedir']realpath($args['basedir']getcwd();
  76.             if ($target == 'master'{
  77.                 $pkg_name sprintf('Ethna_Plugin_%s_%s'$args['type']$args['name']);
  78.             else {
  79.                 $pkg_name sprintf('App_Plugin_%s_%s'$args['type']$args['name']);
  80.             }
  81.  
  82.             $r =$pear->init($target$basedir$channel);
  83.             if (Ethna::isError($r)) {
  84.                 return $r;
  85.             }
  86.             $r =$pear->doInfo($pkg_name);
  87.             if (Ethna::isError($r)) {
  88.                 return $r;
  89.             }
  90.  
  91.         else {
  92.             return Ethna::raiseError('invalid arguments''usage');
  93.         }
  94.  
  95.         return true;
  96.     }
  97.     // }}}
  98.  
  99.     // {{{ getDescription()
  100.     /**
  101.      *  @access public
  102.      */
  103.     function getDescription()
  104.     {
  105.         return <<<EOS
  106. show plugin information:
  107.     {$this->id} [-c|--channel=channel] [-b|--basedir=dir] [-l|--local] [-m|--master] [type name]
  108.  
  109. EOS;
  110.     }
  111.     // }}}
  112.  
  113.     // {{{ getUsage()
  114.     /**
  115.      *  @access public
  116.      */
  117.     function getUsage()
  118.     {
  119.         return <<<EOS
  120. ethna {$this->id} [-c|--channel=channel] [-b|--basedir=dir] [-l|--local] [-m|--master] [type name]
  121. EOS;
  122.     }
  123.     // }}}
  124. }
  125. // }}}
  126. ?>

Documentation generated on Fri, 11 Nov 2011 04:00:27 +0900 by phpDocumentor 1.4.3