Source for file Ethna_Plugin_Generator_Template.php

Documentation is available at Ethna_Plugin_Generator_Template.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Ethna_Plugin_Generator_Template.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_Generator_Template.php 411 2006-11-17 02:32:32Z ichii386 $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Generator_Template
  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)
  30.     {
  31.         $tpl_dir $this->ctl->getTemplatedir();
  32.         if ($tpl_dir{strlen($tpl_dir)-1!= '/'{
  33.             $tpl_dir .= '/';
  34.         }
  35.         $tpl_path $this->ctl->getDefaultForwardPath($forward_name);
  36.  
  37.         // entity
  38.         $entity $tpl_dir $tpl_path;
  39.         Ethna_Util::mkdir(dirname($entity)0755);
  40.  
  41.         // skelton
  42.         if ($skelton === null{
  43.             $skelton 'skel.template.tpl';
  44.         }
  45.  
  46.         // macro
  47.         $macro array();
  48.         // add '_' for tpl and no user macro for tpl
  49.         $macro['_project_id'$this->ctl->getAppId();
  50.  
  51.  
  52.         // generate
  53.         if (file_exists($entity)) {
  54.             printf("file [%s] already exists -> skip\n"$entity);
  55.         else if ($this->_generateFile($skelton$entity$macro== false{
  56.             printf("[warning] file creation failed [%s]\n"$entity);
  57.         else {
  58.             printf("template file(s) successfully created [%s]\n"$entity);
  59.         }
  60.  
  61.         $true true;
  62.         return $true;
  63.     }
  64. }
  65. // }}}
  66. ?>

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