Source for file Ethna_Plugin_Generator_Plugin.php

Documentation is available at Ethna_Plugin_Generator_Plugin.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Ethna_Plugin_Generator_Plugin.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$
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Generator_Plugin
  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  $type       プラグインの$type
  26.      *  @param  string  $name       プラグインの$name
  27.      *  @param  bool    $overwrite  上書きオプション
  28.      *  @return bool    true:成功 false:失敗
  29.      */
  30.     function generate($type$name$overwrite false)
  31.     {
  32.         $appid $this->ctl->getAppId();
  33.         $plugin =$this->ctl->getPlugin();
  34.  
  35.         list($class$plugin_dir$plugin_path$plugin->getPluginNaming($type$name$appid);
  36.  
  37.         $macro array();
  38.         $macro['project_id'$appid;
  39.         $macro['application_id'$appid;
  40.         $user_macro $this->_getUserMacro();
  41.         $macro array_merge($macro$user_macro);
  42.  
  43.         Ethna_Util::mkdir(dirname("$plugin_dir/$plugin_path")0755);
  44.  
  45.         if ($this->_generateFile("skel.plugin.{$type}_{$name}.php""$plugin_dir/$plugin_path"$macro$overwrite== false{
  46.             printf("[warning] file creation failed [%s]\n""$plugin_dir/$plugin_path");
  47.         else {
  48.             printf("plugin script(s) successfully created [%s]\n""$plugin_dir/$plugin_path");
  49.         }
  50.     }
  51.  
  52.     /**
  53.      *  プラグインを消す
  54.      *
  55.      *  @access public
  56.      *  @param  string  $type       プラグインの$type
  57.      *  @param  string  $name       プラグインの$name
  58.      *  @return bool    true:成功 false:失敗
  59.      */
  60.     function remove($type$name)
  61.     {
  62.         $appid $this->ctl->getAppId();
  63.         $plugin =$this->ctl->getPlugin();
  64.  
  65.         list($class$plugin_dir$plugin_path$plugin->getPluginNaming($type$name$appid);
  66.  
  67.         $macro array();
  68.         $macro['project_id'$appid;
  69.         $user_macro $this->_getUserMacro();
  70.         $macro array_merge($macro$user_macro);
  71.  
  72.         if (file_exists("$plugin_dir/$plugin_path")) {
  73.             unlink("$plugin_dir/$plugin_path");
  74.             printf("file [%s] successfully unlinked\n""$plugin_dir/$plugin_path");
  75.         else {
  76.             printf("file [%s] not found\n""$plugin_dir/$plugin_path");
  77.         }
  78.     }
  79. }
  80. // }}}
  81. ?>

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