Source for file View.php

Documentation is available at View.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  View.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: e8b2ccbcec5f22c5c856cae96c9567485bbe59cb $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Generator_View
  13. /**
  14.  *  スケルトン生成クラス
  15.  *
  16.  *  @author     Masaki Fujimoto <fujimoto@php.net>
  17.  *  @access     public
  18.  *  @package    Ethna
  19.  */
  20. {
  21.     /**
  22.      *  ビューのスケルトンを生成する
  23.      *
  24.      *  @access public
  25.      *  @param  string  $forward_name   ビュー名
  26.      *  @param  string  $skelton        スケルトンファイル名
  27.      *  @return true|Ethna_Error       true:成功 Ethna_Error:失敗
  28.      */
  29.     function generate($forward_name, $skelton = null, $gateway = GATEWAY_WWW)
  30.     {
  31.         $view_dir = $this->ctl->getViewdir();
  32.         $view_class = $this->ctl->getDefaultViewClass($forward_name, $gateway);
  33.         $view_path = $this->ctl->getDefaultViewPath($forward_name);
  34.  
  35.         // entity
  36.         $entity = $view_dir . $view_path;
  37.         Ethna_Util::mkdir(dirname($entity), 0755);
  38.  
  39.         // skelton
  40.         if ($skelton === null) {
  41.             $skelton = 'skel.view.php';
  42.         }
  43.  
  44.         // macro
  45.         $macro = array();
  46.         $macro['project_id'] = $this->ctl->getAppId();
  47.         $macro['forward_name'] = $forward_name;
  48.         $macro['view_class'] = $view_class;
  49.         $macro['view_path'] = $view_path;
  50.  
  51.         // user macro
  52.         $user_macro = $this->_getUserMacro();
  53.         $macro = array_merge($macro, $user_macro);
  54.  
  55.  
  56.         // generate
  57.         if (file_exists($entity)) {
  58.             printf("file [%s] already exists -> skip\n", $entity);
  59.         } else if ($this->_generateFile($skelton, $entity, $macro) == false) {
  60.             printf("[warning] file creation failed [%s]\n", $entity);
  61.         } else {
  62.             printf("view script(s) successfully created [%s]\n", $entity);
  63.         }
  64.  
  65.         $true = true;
  66.         return $true;
  67.     }
  68. }
  69. // }}}

Documentation generated on Fri, 11 Nov 2011 03:59:21 +0900 by phpDocumentor 1.4.3