Source for file Ethna_Plugin_Handle_AddView.php

Documentation is available at Ethna_Plugin_Handle_AddView.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Ethna_Plugin_Handle_AddView.php
  5.  *
  6.  *  @author     Masaki Fujimoto <fujimoto@php.net>
  7.  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
  8.  *  @package    Ethna
  9.  *  @version    $Id: Ethna_Plugin_Handle_AddView.php 507 2008-04-26 19:50:45Z mumumu-org $
  10.  */
  11.  
  12. require_once ETHNA_BASE '/class/Plugin/Handle/Ethna_Plugin_Handle_AddAction.php';
  13.  
  14. // {{{ Ethna_Plugin_Handle_AddView
  15. /**
  16.  *  add-view handler
  17.  *
  18.  *  @author     Masaki Fujimoto <fujimoto@php.net>
  19.  *  @access     public
  20.  *  @package    Ethna
  21.  */
  22. {
  23.     /**
  24.      *  add view
  25.      *
  26.      *  @access public
  27.      */
  28.     function perform()
  29.     {
  30.         //
  31.         //  '-w[with-unittest]' and '-u[unittestskel]' option
  32.         //  are not intuisive, but I dare to define them because
  33.         //  -t and -s option are reserved by add-[action|view] handle
  34.         //  and Console_Getopt cannot interpret two-character option.
  35.         //
  36.         $r =$this->_getopt(
  37.                   array('basedir=',
  38.                         'skelfile=',
  39.                         'template',
  40.                         'with-unittest',
  41.                         'unittestskel=',
  42.                   )
  43.               );
  44.         if (Ethna::isError($r)) {
  45.             return $r;
  46.         }
  47.         list($opt_list$arg_list$r;
  48.  
  49.         // view_name
  50.         $view_name array_shift($arg_list);
  51.         if ($view_name == null{
  52.             return Ethna::raiseError('view name isn\'t set.''usage');
  53.         }
  54.         $r =Ethna_Controller::checkViewName($view_name);
  55.         if (Ethna::isError($r)) {
  56.             return $r;
  57.         }
  58.  
  59.         // add view
  60.         $ret =$this->_perform('View'$view_name$opt_list);
  61.         if (Ethna::isError($ret|| $ret === false
  62.             return $ret;
  63.         }
  64.  
  65.         // add template
  66.         if (isset($opt_list['template'])) {
  67.             $ret =$this->_perform('Template'$view_name$opt_list);
  68.             if (Ethna::isError($ret|| $ret === false
  69.                 return $ret;
  70.             }
  71.         }
  72.  
  73.         return true;
  74.     }
  75.  
  76.     /**
  77.      *  get handler's description
  78.      *
  79.      *  @access public
  80.      */
  81.     function getDescription()
  82.     {
  83.         return <<<EOS
  84. add new view to project:
  85.     {$this->id} [-b|--basedir=dir] [-s|--skelfile=file] [-t|--template] [-w|--with-unittest] [-u|--unittestskel=file] [view]
  86.     NOTICE: "-w" and "-u" options are ignored when you specify -t option.
  87.  
  88. EOS;
  89.     }
  90.  
  91.     /**
  92.      *  @access public
  93.      */
  94.     function getUsage()
  95.     {
  96.         return <<<EOS
  97. ethna {$this->id} [-b|--basedir=dir] [-s|--skelfile=file] [-t|--template] [-w|--with-unittest] [-u|--unittestskel=file] [view]
  98.     NOTICE: "-w" and "-u" options are ignored when you specify -t option.
  99. EOS;
  100.     }
  101. }
  102. // }}}
  103. ?>

Documentation generated on Thu, 08 May 2008 00:15:13 +0900 by phpDocumentor 1.4.2