/**
  *  テンプレートのスケルトンを生成する
  *
  *  @access public
  *  @param  string  $forward_name   テンプレート名
  *  @param  string  $skelton        スケルトンファイル名
  *  @return true|Ethna_Error        true:成功 Ethna_Error:失敗
  */
 function &generate($forward_name, $skelton = null)
 {
     $tpl_dir = $this->ctl->getTemplatedir();
     if ($tpl_dir[strlen($tpl_dir) - 1] != '/') {
         $tpl_dir .= '/';
     }
     $tpl_path = $this->ctl->getDefaultForwardPath($forward_name);
     // entity
     $entity = $tpl_dir . $tpl_path;
     Ethna_Util::mkdir(dirname($entity), 0755);
     // skelton
     if ($skelton === null) {
         $skelton = 'skel.template.tpl';
     }
     // macro
     $macro = array();
     // add '_' for tpl and no user macro for tpl
     $macro['_project_id'] = $this->ctl->getAppId();
     // generate
     if (file_exists($entity)) {
         printf("file [%s] already exists -> skip\n", $entity);
     } else {
         if ($this->_generateFile($skelton, $entity, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $entity);
         } else {
             printf("template file(s) successfully created [%s]\n", $entity);
         }
     }
     $true = true;
     return $true;
 }
Example #2
0
 /**
  *  Ethna_Renderer_Smartyクラスのコンストラクタ
  *
  *  @access public
  */
 public function __construct($controller)
 {
     parent::__construct($controller);
     // get renderer config
     $smarty_config = $this->config;
     // load template engine
     $this->loadEngine($smarty_config);
     $this->engine = new Smarty();
     // ディレクトリ関連は Controllerによって実行時に設定
     $template_dir = $controller->getTemplatedir();
     $compile_dir = $controller->getDirectory('template_c');
     $this->setTemplateDir($template_dir);
     $this->compile_dir = $compile_dir;
     $this->engine->template_dir = $this->template_dir;
     $this->engine->compile_dir = $this->compile_dir;
     $this->engine->compile_id = md5($this->template_dir);
     // delimiter setting
     $this->engine->left_delimiter = $smarty_config['left_delimiter'];
     $this->engine->right_delimiter = $smarty_config['right_delimiter'];
     // コンパイルディレクトリは必須なので一応がんばってみる
     if (is_dir($this->engine->compile_dir) === false) {
         Ethna_Util::mkdir($this->engine->compile_dir, 0755);
     }
     $this->engine->plugins_dir = array_merge($controller->getDirectory('plugins'), array(ETHNA_BASE . '/class/Plugin/Smarty', SMARTY_DIR . 'plugins'));
 }
 /**
  * ScaffoldSmartyPlugin を生成する
  * 
  * @access public
  */
 function &generate()
 {
     $app_dir = $this->ctl->getDirectory('app');
     $app_path = ucfirst($this->ctl->getAppId()) . '_ScaffoldSmartyPlugin.php';
     $macro = array();
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['file_path'] = $app_path;
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     // ファイル生成
     $filePath = "{$app_dir}/{$app_path}";
     Ethna_Util::mkdir(dirname($filePath), 0755);
     $skelton = "skel.scaffold-smartyPlugin.php";
     if (file_exists($filePath)) {
         printf("file [%s] already exists -> skip\n", $filePath);
     } else {
         if ($this->_generateFile($skelton, $filePath, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $filePath);
         } else {
             printf("action script(s) successfully created [%s]\n", $filePath);
         }
     }
     $true = true;
     return $true;
 }
 /**
  * ScaffoldAppObject を生成する
  * 
  * @access public
  * @param $table_name string テーブル名
  */
 function &generate($table_name)
 {
     $table_id = $this->_getTableId($table_name);
     $app_dir = $this->ctl->getDirectory('app');
     $app_path = ucfirst($this->ctl->getAppId()) . '_' . $table_id . '.php';
     $baseClass_path = ucfirst($this->ctl->getAppId()) . '_AppBase_AppObject.php';
     // マクロ
     $macro = array();
     $macro['model'] = $table_name;
     $macro['modelName'] = $table_id;
     $macro['modelUName'] = strtoupper($table_id);
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['app_path'] = $app_path;
     $macro['app_object'] = ucfirst($this->ctl->getAppId()) . '_' . $table_id;
     $macro['column_name_file'] = $this->_getColumnNamePath($table_id);
     $macro['base_class_file'] = $baseClass_path;
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     // ファイル生成
     $path = "{$app_dir}/{$app_path}";
     Ethna_Util::mkdir(dirname($path), 0755);
     if (file_exists($path)) {
         printf("file [%s] already exists -> skip\n", $path);
     } else {
         if ($this->_generateFile("skel.scaffold-appobject.php", $path, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $path);
         } else {
             printf("app-object script(s) successfully created [%s]\n", $path);
         }
     }
     $true = true;
     return $true;
 }
Example #5
0
 /**
  *  Constructor for Ethna_Renderer_Smarty3
  *
  *  @access public
  */
 public function __construct($controller)
 {
     parent::__construct($controller);
     // get renderer config
     $smarty_config = isset($this->config['smarty3']) ? $this->config['smarty3'] : array();
     $this->loadEngine($smarty_config);
     $this->engine = new Smarty();
     // Configurerd by controller
     $template_dir = $controller->getTemplatedir();
     $compile_dir = $controller->getDirectory('template_c');
     $this->setTemplateDir($template_dir);
     $this->compile_dir = $compile_dir;
     $this->engine->template_dir = $template_dir;
     $this->engine->compile_dir = $compile_dir;
     $this->engine->compile_id = md5($this->template_dir);
     if (isset($smarty_config['left_delimiter'])) {
         $this->engine->left_delimiter = $smarty_config['left_delimiter'];
     }
     if (isset($smarty_config['right_delimiter'])) {
         $this->engine->right_delimiter = $smarty_config['right_delimiter'];
     }
     // make compile dir
     if (is_dir($this->engine->compile_dir) === false) {
         Ethna_Util::mkdir($this->engine->compile_dir, 0755);
     }
     $this->engine->inheritance = true;
     $this->engine->plugins_dir = array_merge($controller->getDirectory('plugins'), array(ETHNA_BASE . '/class/Plugin/Smarty', SMARTY_DIR . 'plugins'));
 }
Example #6
0
 /**
  *  Ethna_Renderer_Smartyクラスのコンストラクタ
  *
  *  @access public
  */
 public function __construct($controller)
 {
     parent::__construct($controller);
     $this->engine = new Smarty();
     // ディレクトリ関連は Controllerによって実行時に設定
     // TODO: iniファイルによって上書き可にするかは要検討
     $template_dir = $controller->getTemplatedir();
     $compile_dir = $controller->getDirectory('template_c');
     $this->setTemplateDir($template_dir);
     $this->compile_dir = $compile_dir;
     $this->engine->template_dir = $this->template_dir;
     $this->engine->compile_dir = $this->compile_dir;
     $this->engine->compile_id = md5($this->template_dir);
     //  デリミタは Ethna_Config を見る
     $smarty_config = isset($this->config['smarty']) ? $this->config['smarty'] : array();
     if (array_key_exists('left_delimiter', $smarty_config)) {
         $this->engine->left_delimiter = $smarty_config['left_delimiter'];
     }
     if (array_key_exists('right_delimiter', $smarty_config)) {
         $this->engine->right_delimiter = $smarty_config['right_delimiter'];
     }
     // コンパイルディレクトリは必須なので一応がんばってみる
     if (is_dir($this->engine->compile_dir) === false) {
         Ethna_Util::mkdir($this->engine->compile_dir, 0755);
     }
     $this->engine->plugins_dir = array_merge($controller->getDirectory('plugins'), array(ETHNA_BASE . '/class/Plugin/Smarty', SMARTY_DIR . 'plugins'));
 }
Example #7
0
 /**
  *  アプリケーションオブジェクトのスケルトンを生成する
  *
  *  @access public
  *  @param  string  $table_name     テーブル名
  *  @return bool    true:成功 false:失敗
  */
 function generate($table_name)
 {
     $table_id = preg_replace_callback('/_(.)/', function (array $matches) {
         return strtoupper($matches[1]);
     }, ucfirst($table_name));
     $app_dir = $this->ctl->getDirectory('app');
     $app_path = ucfirst($this->ctl->getAppId()) . '_' . $table_id . '.php';
     $macro = array();
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['app_path'] = $app_path;
     $macro['app_object'] = ucfirst($this->ctl->getAppId()) . '_' . $table_id;
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     $path = "{$app_dir}/{$app_path}";
     Ethna_Util::mkdir(dirname($path), 0755);
     if (file_exists($path)) {
         printf("file [%s] already exists -> skip\n", $path);
     } else {
         if ($this->_generateFile("skel.app_object.php", $path, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $path);
         } else {
             printf("app-object script(s) successfully created [%s]\n", $path);
         }
     }
 }
 /**
  * ScaffoldActionForm を生成する
  * 
  * @access public
  * @param $model string テーブル名
  * @param $modelDefine array モデル定義
  * @param $formDef array フォーム定義
  */
 function &generate($model, $modelDefine, $formDef)
 {
     $table_id = $this->_getTableId($model);
     $project_id = $this->ctl->getAppId();
     $dir = $this->ctl->getDirectory('action_form');
     if ($dir == null) {
         $dir = $this->ctl->getDirectory('app') . "/action_form/";
     }
     $file = "{$project_id}_{$table_id}_ActionForm.php";
     // Macro
     $macro = array();
     $macro['model'] = $model;
     $macro['modelName'] = $table_id;
     $macro['modelUName'] = strtoupper($table_id);
     $macro['project_id'] = $project_id;
     $macro['column_name_file'] = $this->_getColumnNamePath($table_id);
     $macro['form_define'] = $this->_getActionFormDefine($formDef);
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     $skelton = "skel.scaffold-actionform.php";
     // ファイル生成
     $path = "{$dir}{$file}";
     Ethna_Util::mkdir(dirname($path), 0755);
     if (file_exists($path)) {
         printf("file [%s] already exists -> skip\n", $path);
     } else {
         if ($this->_generateFile($skelton, $path, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $path);
         } else {
             printf("action script(s) successfully created [%s]\n", $path);
         }
     }
     $true = true;
     return $true;
 }
 /**
  *  ビューのスケルトンを生成する
  *
  *  @access public
  *  @param  string  $forward_name   ビュー名
  *  @param  string  $skelton        スケルトンファイル名
  *  @return true|Ethna_Error        true:成功 Ethna_Error:失敗
  */
 function &generate($forward_name, $skelton = null, $gateway = GATEWAY_WWW)
 {
     $view_dir = $this->ctl->getViewdir();
     $view_class = $this->ctl->getDefaultViewClass($forward_name, $gateway);
     $view_path = $this->ctl->getDefaultViewPath($forward_name);
     // entity
     $entity = $view_dir . $view_path;
     Ethna_Util::mkdir(dirname($entity), 0755);
     // skelton
     if ($skelton === null) {
         $skelton = 'skel.view.php';
     }
     // macro
     $macro = array();
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['forward_name'] = $forward_name;
     $macro['view_class'] = $view_class;
     $macro['view_path'] = $view_path;
     // user macro
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     // generate
     if (file_exists($entity)) {
         printf("file [%s] already exists -> skip\n", $entity);
     } else {
         if ($this->_generateFile($skelton, $entity, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $entity);
         } else {
             printf("view script(s) successfully created [%s]\n", $entity);
         }
     }
     $true = true;
     return $true;
 }
Example #10
0
 /**
  *  テンプレートのスケルトンを生成する
  *
  *  @access public
  *  @param  string  $forward_name   テンプレート名
  *  @param  string  $skelton        スケルトンファイル名
  *  @param  string  $locale         ロケール名
  *  @param  string  $encoding       エンコーディング
  *  @return true|Ethna_Error        true:成功 Ethna_Error:失敗
  */
 function generate($forward_name, $skelton = null, $locale, $encoding)
 {
     //  ロケールが指定された場合は、それを優先する
     if (!empty($locale)) {
         $this->ctl->setLocale($locale);
     }
     //  ロケール名がディレクトリに含まれていない場合は、
     //  ディレクトリがないためなのでそれを補正
     $tpl_dir = $this->ctl->getTemplatedir();
     $tpl_path = $this->ctl->getDefaultForwardPath($forward_name);
     // entity
     $entity = $tpl_dir . '/' . $tpl_path;
     Ethna_Util::mkdir(dirname($entity), 0755);
     // skelton
     if ($skelton === null) {
         $skelton = 'skel.template.tpl';
     }
     // macro
     $macro = array();
     // add '_' for tpl and no user macro for tpl
     $macro['_project_id'] = $this->ctl->getAppId();
     $macro['client_enc'] = $encoding;
     // generate
     if (file_exists($entity)) {
         printf("file [%s] already exists -> skip\n", $entity);
     } else {
         if ($this->_generateFile($skelton, $entity, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $entity);
         } else {
             printf("template file(s) successfully created [%s]\n", $entity);
         }
     }
     $true = true;
     return $true;
 }
 function testCachemanagerLocalfile()
 {
     $ctl =& Ethna_Controller::getInstance();
     $plugin =& $ctl->getPlugin();
     $cm = $plugin->getPlugin('Cachemanager', 'Localfile');
     // 文字列のキャッシュ
     $string_key = 'string_key';
     $string_value = "cache\ncontent";
     $cm->set($string_key, $string_value, mktime(0, 0, 0, 7, 1, 2000));
     $cache_string = $cm->get($string_key);
     $this->assertTrue($cm->isCached($string_key));
     $this->assertEqual(mktime(0, 0, 0, 7, 1, 2000), $cm->getLastModified($string_key));
     $this->assertTrue($string_value, $cache_string);
     // 整数のキャッシュ + namespace
     $int_key = 'int_key';
     $int_value = 777;
     $namespace = 'test';
     $cm->set($int_key, $int_value, mktime(0, 0, 0, 7, 1, 2000), $namespace);
     $cache_int = $cm->get($int_key, mktime(0, 0, 0, 7, 1, 2000), $namespace);
     $this->assertTrue($cm->isCached($int_key, mktime(0, 0, 0, 7, 1, 2000), $namespace));
     $this->assertTrue($int_value, $cache_int);
     // オブジェクトのキャッシュ
     $object_key = 'object_key';
     $object_value =& $cm;
     $cm->set($object_key, $object_value);
     $this->assertTrue($cm->isCached($object_key));
     // キャッシュされたインスタンス
     $cache_object = $cm->get($object_key);
     $this->assertTrue($string_value, $cache_object->get($string_key));
     // キャッシュのクリアをテスト
     $cm->clear($object_key);
     $this->assertFalse($cm->isCached($object_key));
     // キャッシュされていないのに呼び出そうとした場合
     $nocache_key = 'nocache_key';
     $cm->clear($nocache_key);
     $pear_error = $cm->get($nocache_key);
     $this->assertEqual(E_CACHE_NO_VALUE, $pear_error->getCode());
     $this->assertEqual('fopen failed', $pear_error->getMessage());
     // ファイルに読み込み権限がない場合
     Ethna_Util::chmod($cm->_getCacheFile(null, $string_key), 0222);
     $pear_error = $cm->get($string_key);
     $this->assertEqual(E_CACHE_NO_VALUE, $pear_error->getCode());
     $this->assertEqual('fopen failed', $pear_error->getMessage());
     Ethna_Util::chmod($cm->_getCacheFile(null, $string_key), 0666);
     // lifetime切れの場合
     $pear_error = $cm->get($string_key, 1);
     $this->assertEqual(E_CACHE_EXPIRED, $pear_error->getCode());
     $this->assertEqual('fopen failed', $pear_error->getMessage());
     // ディレクトリ名と同じファイルがあってディレクトリが作成できない場合
     $tmp_key = 'tmpkey';
     $tmp_dirname = $cm->_getCacheDir(null, $tmp_key);
     Ethna_Util::mkdir(dirname($tmp_dirname), 0777);
     $tmp_file = fopen($tmp_dirname, 'w');
     fclose($tmp_file);
     $pear_error = $cm->set($tmp_key, $string_value);
     $this->assertEqual(E_USER_WARNING, $pear_error->getCode());
     $this->assertEqual("mkdir({$tmp_dirname}) failed", $pear_error->getMessage());
     $this->rm($cm->backend->getTmpdir());
 }
 /**
  * ScaffoldTemplates を生成する
  * 
  * @access public
  * @param string $baseAction ベースのアクション名
  * @param string  $model モデル名
  * @param array $modelDefine モデル定義
  * @param string $idDefine 主キー名
  * @param array $formDef フォーム定義
  */
 function &generate($baseAction, $model, $modelDefine, $idDefine, $formDef)
 {
     // Template Directory
     $tpl_dir = $this->ctl->getTemplatedir();
     if ($tpl_dir[strlen($tpl_dir) - 1] != '/') {
         $tpl_dir .= '/';
     }
     $table_id = $this->_getTableId($model);
     // Generating Templates
     $templates = array('list' => array('title' => sprintf("Listing {model_name model='%s'}", $table_id), 'template' => 'list', 'headerTag' => $this->_getListHeaderTags($modelDefine, $table_id), 'mainTag' => $this->_getListMainTags($modelDefine, $table_id)), 'read' => array('title' => sprintf("Show {model_name model='%s'}", $table_id), 'template' => 'item', 'itemTag' => $this->_getItemMainTag($modelDefine, $table_id)), 'form_create' => array('title' => sprintf("New {model_name model='%s'}", $table_id), 'template' => 'form', 'formTag' => $this->_getFormMainTag($formDef, null, array($idDefine)), 'action' => $this->_getFullAction($baseAction, 'create_do')), 'form_update' => array('title' => sprintf("Editing {model_name model='%s'}", $table_id), 'template' => 'form', 'formTag' => $this->_getFormMainTag($formDef, null, array($idDefine)), 'action' => $this->_getFullAction($baseAction, 'update_do')), 'delete' => array('title' => sprintf("Are you sure?", $model), 'template' => 'delete', 'itemTag' => $this->_getItemMainTag($modelDefine, $table_id)), '_errorbox' => array('_fileName' => '_errorMessages.tpl.html', 'template' => 'errorMessages'), '_noticebox' => array('_fileName' => '_noticeMessages.tpl.html', 'template' => 'noticeMessages'));
     // Create BoxFilePath
     foreach ($templates as $name => $value) {
         if ($name[0] == '_') {
             $tpl_path = $this->ctl->getDefaultForwardPath($this->_getFullAction($baseAction, 'test'));
             $path = explode("/", $tpl_path);
             $path[count($path) - 1] = $value['_fileName'];
             $templates[$name]['path'] = implode("/", $path);
         }
     }
     // Project OverAll Macro
     $projMacro = array();
     $projMacro['listAction'] = $this->_getFullAction($baseAction, 'index');
     $projMacro['readAction'] = $this->_getFullAction($baseAction, 'read');
     $projMacro['createAction'] = $this->_getFullAction($baseAction, 'create');
     $projMacro['createDoAction'] = $this->_getFullAction($baseAction, 'create_do');
     $projMacro['updateAction'] = $this->_getFullAction($baseAction, 'update');
     $projMacro['updateDoAction'] = $this->_getFullAction($baseAction, 'update_do');
     $projMacro['deleteAction'] = $this->_getFullAction($baseAction, 'delete');
     $projMacro['deleteDoAction'] = $this->_getFullAction($baseAction, 'delete_do');
     $projMacro['errorBoxFile'] = $templates['_errorbox']['path'];
     $projMacro['noticeBoxFile'] = $templates['_noticebox']['path'];
     $projMacro['model'] = $model;
     $projMacro['modelName'] = ucfirst($table_id);
     $projMacro['modelPK'] = $idDefine;
     $projMacro['project_id'] = $this->ctl->getAppId();
     foreach ($templates as $name => $value) {
         $tpl_path = $this->ctl->getDefaultForwardPath($this->_getFullAction($baseAction, $name));
         // FormBox TemplateFile.
         if (isset($value['path'])) {
             $tpl_path = $value['path'];
         }
         $macro = array_merge($value, $projMacro);
         // ファイル生成
         Ethna_Util::mkdir(dirname("{$tpl_dir}/{$tpl_path}"), 0755);
         $skel = "skel.scaffold-template-{$value['template']}.tpl";
         if (file_exists("{$tpl_dir}{$tpl_path}")) {
             printf("file [%s] already exists -> skip\n", "{$tpl_dir}{$tpl_path}");
         } else {
             if ($this->_generateFile($skel, "{$tpl_dir}{$tpl_path}", $macro) == false) {
                 printf("[warning] file creation failed [%s]\n", "{$tpl_dir}{$tpl_path}");
             } else {
                 printf("template file(s) successfully created [%s]\n", "{$tpl_dir}{$tpl_path}");
             }
         }
     }
     $true = true;
     return $true;
 }
 /**
  * ScaffoldViews を生成する
  * 
  * @access public
  * @param $baseAction string ベースのアクション名
  * @param $model string モデル名
  * @param $modelDefine array モデル定義
  * @param $formDef array フォーム定義
  */
 function &generate($baseAction, $model, $modelDefine, $idDefine, $formDef)
 {
     $table_id = $this->_getTableId($model);
     $columnName_path = $this->_getColumnNamePath($table_id);
     // Viewを生成
     $views = array("list" => array('helper' => $this->_getFullAction($baseAction, 'create_do')), "read" => array('helper' => $this->_getFullAction($baseAction, 'create_do')), "form_create" => array('helper' => $this->_getFullAction($baseAction, 'create_do')), "form_update" => array('helper' => $this->_getFullAction($baseAction, 'update_do')), "delete" => array('helper' => $this->_getFullAction($baseAction, 'create_do')));
     foreach ($views as $name => $value) {
         $forward_name = $this->_getFullAction($baseAction, $name);
         $view_dir = $this->ctl->getViewdir();
         $view_class = $this->ctl->getDefaultViewClass($forward_name, false);
         $view_path = $this->ctl->getDefaultViewPath($forward_name, false);
         $macro = $value;
         $macro['model'] = $model;
         $macro['modelName'] = ucfirst($table_id);
         $macro['modelUName'] = strtoupper($table_id);
         $macro['modelPK'] = $idDefine;
         $macro['project_id'] = $this->ctl->getAppId();
         $macro['forward_name'] = $forward_name;
         $macro['view_class'] = $view_class;
         $macro['view_path'] = $view_path;
         $macro['column_name_file'] = $columnName_path;
         $user_macro = $this->_getUserMacro();
         $macro = array_merge($macro, $user_macro);
         Ethna_Util::mkdir(dirname("{$view_dir}/{$view_path}"), 0755);
         if ($name == 'list') {
             $skelton = 'skel.scaffold-view-list.php';
         } else {
             if ($name == 'delete') {
                 $skelton = 'skel.scaffold-view-delete.php';
             } else {
                 if ($name == 'read') {
                     $skelton = 'skel.scaffold-view-item.php';
                 } else {
                     if ($name == 'form_create') {
                         $skelton = 'skel.scaffold-view-formCreate.php';
                     } else {
                         if ($name == 'form_update') {
                             $skelton = 'skel.scaffold-view-formUpdate.php';
                         }
                     }
                 }
             }
         }
         if (file_exists("{$view_dir}{$view_path}")) {
             printf("file [%s] already exists -> skip\n", "{$view_dir}{$view_path}");
         } else {
             if ($this->_generateFile($skelton, "{$view_dir}{$view_path}", $macro) == false) {
                 printf("[warning] file creation failed [%s]\n", "{$view_dir}{$view_path}");
             } else {
                 printf("view script(s) successfully created [%s]\n", "{$view_dir}{$view_path}");
             }
         }
     }
     $true = true;
     return $true;
 }
Example #14
0
 /**
  *  アクションのスケルトンを生成する
  *
  *  @access public
  *  @param  string  $action_name    アクション名
  *  @param  string  $skelton        スケルトンファイル名
  *  @param  int     $gateway        ゲートウェイ
  *  @return true|Ethna_Error        true:成功 Ethna_Error:失敗
  */
 function generate($action_name, $skelton = null, $gateway = GATEWAY_WWW)
 {
     $action_dir = $this->ctl->getActiondir($gateway);
     $action_class = $this->ctl->getDefaultActionClass($action_name, $gateway);
     $action_form = $this->ctl->getDefaultFormClass($action_name, $gateway);
     $action_path = $this->ctl->getDefaultActionPath($action_name);
     // entity
     $entity = $action_dir . $action_path;
     Ethna_Util::mkdir(dirname($entity), 0755);
     // skelton
     if ($skelton === null) {
         switch ($gateway) {
             case GATEWAY_WWW:
                 $skelton = "skel.action.php";
                 break;
             case GATEWAY_CLI:
                 $skelton = "skel.action_cli.php";
                 break;
             case GATEWAY_XMLRPC:
                 $skelton = "skel.action_xmlrpc.php";
                 break;
             default:
                 $err = Ethna::raiseError('unknown gateway.');
                 return $err;
         }
     }
     // macro
     $macro = array();
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['action_name'] = $action_name;
     $macro['action_class'] = $action_class;
     $macro['action_form'] = $action_form;
     $macro['action_path'] = $action_path;
     // user macro
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     // generate
     if (file_exists($entity)) {
         printf("file [%s] already exists -> skip\n", $entity);
     } else {
         if ($this->_generateFile($skelton, $entity, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $entity);
         } else {
             printf("action script(s) successfully created [%s]\n", $entity);
         }
     }
     $true = true;
     return $true;
 }
Example #15
0
 /**
  *  Ethna_Renderer_Smartyクラスのコンストラクタ
  *
  *  @access public
  */
 function Ethna_Renderer_Smarty(&$controller)
 {
     parent::Ethna_Renderer($controller);
     $this->engine =& new Smarty();
     $template_dir = $controller->getTemplatedir();
     $compile_dir = $controller->getDirectory('template_c');
     $this->setTemplateDir($template_dir);
     $this->compile_dir = $compile_dir;
     $this->engine->template_dir = $this->template_dir;
     $this->engine->compile_dir = $this->compile_dir;
     $this->engine->compile_id = md5($this->template_dir);
     // 一応がんばってみる
     if (is_dir($this->engine->compile_dir) === false) {
         Ethna_Util::mkdir($this->engine->compile_dir, 0755);
     }
     $this->engine->plugins_dir = array_merge($controller->getDirectory('plugins'), array(ETHNA_BASE . '/class/Plugin/Smarty', SMARTY_DIR . 'plugins'));
 }
 /**
  *  プラグインを生成する
  *
  *  @access public
  *  @param  string  $type       プラグインの$type
  *  @param  string  $name       プラグインの$name
  *  @param  bool    $overwrite  上書きオプション
  *  @return bool    true:成功 false:失敗
  */
 function generate($type, $name, $overwrite = false)
 {
     $appid = $this->ctl->getAppId();
     $plugin =& $this->ctl->getPlugin();
     list($class, $plugin_dir, $plugin_path) = $plugin->getPluginNaming($type, $name, $appid);
     $macro = array();
     $macro['project_id'] = $appid;
     $macro['application_id'] = $appid;
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     Ethna_Util::mkdir(dirname("{$plugin_dir}/{$plugin_path}"), 0755);
     if ($this->_generateFile("skel.plugin.{$type}_{$name}.php", "{$plugin_dir}/{$plugin_path}", $macro, $overwrite) == false) {
         printf("[warning] file creation failed [%s]\n", "{$plugin_dir}/{$plugin_path}");
     } else {
         printf("plugin script(s) successfully created [%s]\n", "{$plugin_dir}/{$plugin_path}");
     }
 }
Example #17
0
 /**
  *  アクション用テストのスケルトンを生成する
  *  (現在のところ GATEWAY_WWW のみ対応)
  *
  *  @access public
  *  @param  string  $action_name    アクション名
  *  @param  string  $skelton        スケルトンファイル名
  *  @param  int     $gateway        ゲートウェイ
  *  @return true|Ethna_Error        true:成功 Ethna_Error:失敗
  */
 function &generate($action_name, $skelton = null, $gateway = GATEWAY_WWW)
 {
     $action_dir = $this->ctl->getActiondir($gateway);
     $action_class = $this->ctl->getDefaultActionClass($action_name, $gateway);
     $action_form = $this->ctl->getDefaultFormClass($action_name, $gateway);
     $action_path = $this->ctl->getDefaultActionPath($action_name . 'Test');
     // entity
     $entity = $action_dir . $action_path;
     Ethna_Util::mkdir(dirname($entity), 0755);
     // skelton
     if ($skelton === null) {
         $skelton = 'skel.action_test.php';
     }
     // macro
     $macro = array();
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['action_name'] = $action_name;
     $macro['action_class'] = $action_class;
     $macro['action_form'] = $action_form;
     $macro['action_path'] = $action_path;
     // user macro
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     // original action script existence check.
     $original_action_path = $this->ctl->getDefaultActionPath($action_name);
     $original_action_entity = $action_dir . $original_action_path;
     if (!file_exists($original_action_entity)) {
         printf("\n");
         printf("[!!!!warning!!!!] original action script was not found.\n");
         printf("[!!!!warning!!!!] You must generate it by the following command :\n");
         printf("[!!!!warning!!!!] ethna add-action %s\n\n", $action_name);
     }
     // generate
     if (file_exists($entity)) {
         printf("file [%s] already exists -> skip\n", $entity);
     } else {
         if ($this->_generateFile($skelton, $entity, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $entity);
         } else {
             printf("action test(s) successfully created [%s]\n", $entity);
         }
     }
     $true = true;
     return $true;
 }
Example #18
0
 function create()
 {
     $this->is_created = true;
     if (!is_dir($this->proj_basedir)) {
         do {
             sleep(0.1);
             $r = Ethna_Util::mkdir($this->proj_basedir, 0775);
         } while ($r == false || is_dir($this->proj_basedir) == false);
     }
     //  fire ethna add-project command
     $id = 'add-project';
     $options = array('-b', $this->basedir . '/' . $this->project_name, '-s', $this->skel_dir, $this->project_name);
     $r = $this->runCmd($id, $options);
     if (Ethna::isError($r)) {
         return $r;
     }
     return true;
 }
Example #19
0
 /**
  *  Ethna_Renderer_Smartyクラスのコンストラクタ
  *
  *  @access public
  */
 public function __construct(string $template_dir, array $option)
 {
     parent::__construct($template_dir, $option);
     $this->engine = new Smarty();
     // ディレクトリ関連は Kernelによって実行時に設定
     $compile_dir = $option['template_c'];
     $this->compile_dir = $compile_dir;
     $this->engine->template_dir = $this->template_dir;
     $this->engine->compile_dir = $this->compile_dir;
     $this->engine->compile_id = md5($this->template_dir);
     // delimiter setting
     $this->engine->left_delimiter = $this->config['left_delimiter'];
     $this->engine->right_delimiter = $this->config['right_delimiter'];
     // コンパイルディレクトリは必須なので一応がんばってみる
     if (is_dir($this->engine->compile_dir) === false) {
         Ethna_Util::mkdir($this->engine->compile_dir, 0755);
     }
     $this->engine->plugins_dir = array_merge($option['plugins'], array(ETHNA_BASE . '/src/Plugin/Smarty', SMARTY_DIR . 'plugins'));
 }
 /**
  * ScaffoldColumnDefine を生成する
  * 
  * @access public
  * @param string $model モデル名
  * @param array $modelDefine モデル定義
  */
 function &generate($model, $modelDefine)
 {
     $table_id = $this->_getTableId($model);
     $file = ucfirst($this->ctl->getAppId()) . '_' . $table_id . '_ColumnName.php';
     // Directory
     $dir = $this->ctl->getDirectory('column_name');
     if ($dir == null) {
         $dir = $this->ctl->getDirectory('app') . "/column_name/";
     }
     // ModelName
     $modelUName = strtoupper($table_id);
     $modelName = ucfirst(strtolower($table_id));
     // ColumnName
     foreach ($modelDefine as $name => $def) {
         $columnUName = strtoupper($name);
         $columnName = ucfirst(strtolower($name));
         $columnDefine[] = "define('SCAFFOLD_COLUMN_NAME_{$modelUName}_{$columnUName}', \"{$columnName}\");";
     }
     // Macro Setting
     $macro = array();
     $macro['modelNameDefine'] = "define('SCAFFOLD_MODEL_NAME_{$modelUName}', \"{$modelName}\");";
     $macro['columnNameDefine'] = implode("\n", $columnDefine);
     $macro['model'] = $model;
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['app_path'] = $file;
     $macro = array_merge($macro, $this->_getUserMacro());
     // Creating File
     $skelton = "skel.scaffold-ColumnNameDefine.php";
     $path = "{$dir}{$file}";
     Ethna_Util::mkdir(dirname($path), 0755);
     if (file_exists($path)) {
         printf("file [%s] already exists -> skip\n", $path);
     } else {
         if ($this->_generateFile($skelton, $path, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $path);
         } else {
             printf("ColumnName script(s) successfully created [%s]\n", $path);
         }
     }
     $true = true;
     return $true;
 }
Example #21
0
File: Rhaco.php Project: riaf/ethna
 /**
  *  Ethna_Renderer_Rhacoクラスのコンストラクタ
  *
  *  @access public
  */
 public function __construct($controller)
 {
     parent::__construct($controller);
     $this->template_dir = $controller->getTemplatedir() . '/';
     $this->compile_dir = $controller->getDirectory('template_c');
     Rhaco::constant('TEMPLATE_PATH', $this->template_dir);
     $this->engine = new TemplateParser_Ethna();
     /*
             $this->setTemplateDir($template_dir);
             $this->compile_dir = $compile_dir;
     */
     $this->engine->template_dir = $this->template_dir;
     $this->engine->compile_dir = $this->compile_dir;
     $this->engine->compile_id = md5($this->template_dir);
     // 一応がんばってみる
     if (is_dir($this->engine->compile_dir) === false) {
         Ethna_Util::mkdir($this->engine->compile_dir, 0755);
     }
     $this->_setDefaultPlugin();
 }
Example #22
0
 /**
  * ファイル生成を行う
  * 
  * @access public
  * @param string $skelfile スケルトンファイル名
  * @param string $name     テストケース名
  * @return mixed TRUE; OK
  *               Ethna_Error: エラー発生
  */
 function generate($skelfile, $name)
 {
     // Controllerを取得
     $ctl = $this->ctl;
     // テストを生成するディレクトリがあるか?
     // なければ app/test がデフォルト。
     $dir = $ctl->getDirectory('test');
     if ($dir === null) {
         $dir = $ctl->getDirectory('app') . "/" . "test";
     }
     // ファイル名生成
     $file = preg_replace_callback('/_(.)/', function (array $matches) {
         return '/' . strtoupper($matches[1]);
     }, ucfirst($name)) . "Test.php";
     $generatePath = "{$dir}/{$file}";
     // スケルトン決定
     $skelton = !empty($skelfile) ? $skelfile : "skel.test.php";
     // マクロ生成
     $macro = array();
     $macro['project_id'] = ucfirst($ctl->getAppId());
     $macro['file_path'] = $file;
     $macro['name'] = preg_replace_callback('/_(.)/', function (array $matches) {
         return strtoupper($matches[1]);
     }, ucfirst($name));
     $userMacro = $this->_getUserMacro();
     $macro = array_merge($macro, $userMacro);
     // 生成
     Ethna_Util::mkdir(dirname($generatePath), 0755);
     if (file_exists($generatePath)) {
         printf("file [%s] already exists -> skip\n", $generatePath);
     } else {
         if ($this->_generateFile($skelton, $generatePath, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $generatePath);
         } else {
             printf("test script(s) successfully created [%s]\n", $generatePath);
         }
     }
     $true = true;
     return $true;
 }
 /**
  * ScaffoldAppObject を生成する
  * 
  * @access public
  */
 function &generate()
 {
     $app_dir = $this->ctl->getDirectory('app');
     $app_path = ucfirst($this->ctl->getAppId()) . '_AppBase_AppObject.php';
     $macro = array();
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['app_path'] = $app_path;
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     $path = "{$app_dir}/{$app_path}";
     Ethna_Util::mkdir(dirname($path), 0755);
     if (file_exists($path)) {
         printf("file [%s] already exists -> skip\n", $path);
     } else {
         if ($this->_generateFile("skel.scaffold-template-appobject.php", $path, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $path);
         } else {
             printf("app-object script(s) successfully created [%s]\n", $path);
         }
     }
     $true = true;
     return $true;
 }
 /**
  *  アプリケーションマネージャのスケルトンを生成する
  *
  *  @access public
  *  @param  string  $manager_name    アプリケーションマネージ名
  *  @return bool    true:成功 false:失敗
  */
 function generate($manager_name)
 {
     $class_name = $this->ctl->getManagerClassName($manager_name);
     $app_dir = $this->ctl->getDirectory('app');
     $app_path = "{$class_name}.php";
     $macro = array();
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['app_path'] = $app_path;
     $macro['app_manager'] = $class_name;
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     $path = "{$app_dir}/{$app_path}";
     Ethna_Util::mkdir(dirname($path), 0755);
     if (file_exists($path)) {
         printf("file [%s] already exists -> skip\n", $path);
     } else {
         if ($this->_generateFile("skel.app_manager.php", $path, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $path);
         } else {
             printf("app-manager script(s) successfully created [%s]\n", $path);
         }
     }
 }
 /**
  *  アプリケーションマネージャのスケルトンを生成する
  *
  *  @access public
  *  @param  string  $manager_name    アプリケーションマネージ名
  *  @return bool    true:成功 false:失敗
  */
 function generate($manager_name)
 {
     $manager_id = preg_replace('/_(.)/e', "strtoupper('\$1')", ucfirst($manager_name));
     $app_dir = $this->ctl->getDirectory('app');
     $app_path = ucfirst($this->ctl->getAppId()) . '_' . $manager_id . 'Manager.php';
     $macro = array();
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['app_path'] = $app_path;
     $macro['app_manager'] = ucfirst($this->ctl->getAppId()) . '_' . $manager_id;
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     $path = "{$app_dir}/{$app_path}";
     Ethna_Util::mkdir(dirname($path), 0755);
     if (file_exists($path)) {
         printf("file [%s] already exists -> skip\n", $path);
     } else {
         if ($this->_generateFile("skel.app_manager.php", $path, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $path);
         } else {
             printf("app-manager script(s) successfully created [%s]\n", $path);
         }
     }
 }
 /**
  *  アクション用テストのスケルトンを生成する
  *  (現在のところ GATEWAY_WWW のみ対応)
  *
  *  @access public
  *  @param  string  $action_name    アクション名
  *  @param  string  $skelton        スケルトンファイル名
  *  @param  int     $gateway        ゲートウェイ
  *  @return true|Ethna_Error        true:成功 Ethna_Error:失敗
  */
 function &generate($action_name, $skelton = null, $gateway = GATEWAY_WWW)
 {
     $action_dir = $this->ctl->getActiondir($gateway);
     $action_class = $this->ctl->getDefaultActionClass($action_name, $gateway);
     $action_form = $this->ctl->getDefaultFormClass($action_name, $gateway);
     $action_path = $this->ctl->getDefaultActionPath($action_name . 'Test');
     // entity
     $entity = $action_dir . $action_path;
     Ethna_Util::mkdir(dirname($entity), 0755);
     // skelton
     if ($skelton === null) {
         $skelton = 'skel.action_test.php';
     }
     // macro
     $macro = array();
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['action_name'] = $action_name;
     $macro['action_class'] = $action_class;
     $macro['action_form'] = $action_form;
     $macro['action_path'] = $action_path;
     // user macro
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     // generate
     if (file_exists($entity)) {
         printf("file [%s] already exists -> skip\n", $entity);
     } else {
         if ($this->_generateFile($skelton, $entity, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $entity);
         } else {
             printf("action test(s) successfully created [%s]\n", $entity);
         }
     }
     $true = true;
     return $true;
 }
 /**
  * @access private
  */
 function &_makePackage($skelfile, $setting, $workdir)
 {
     if (Ethna_Util::mkdir($workdir, 0755) === false) {
         return Ethna::raiseError("failed making working dir: {$workdir}.");
     }
     // プラグインの元ファイルを作成
     $rfp = fopen($skelfile, "r");
     if ($rfp == false) {
         return Ethna::raiseError("failed open skelton file: {$skelfile}.");
     }
     $outputfile = $setting['filename'];
     $wfp = fopen("{$workdir}/{$outputfile}", "w");
     if ($rfp == false) {
         fclose($rfp);
         return Ethna::raiseError("failed creating working file: {$outputfile}.");
     }
     for (;;) {
         $s = fread($rfp, 4096);
         if (strlen($s) == 0) {
             break;
         }
         foreach ($setting['macro'] as $k => $v) {
             $s = preg_replace("/{\\\${$k}}/", $v, $s);
         }
         fwrite($wfp, $s);
     }
     fclose($wfp);
     fclose($rfp);
     // package.xml を作る
     $pkgconfig = array('packagedirectory' => $workdir, 'outputdirectory' => $workdir, 'ignore' => array('CVS/', '.cvsignore', '.svn/', 'package.xml', 'package.ini', $setting['pkgname'] . '-*.tgz'), 'filelistgenerator' => 'file', 'changelogoldtonew' => false);
     $packagexml =& new PEAR_PackageFileManager2();
     $pkgconfig = array_merge($pkgconfig, $setting['config']);
     $packagexml->setOptions($pkgconfig);
     $packagexml->setPackage($setting['pkgname']);
     $packagexml->setSummary($setting['summary']);
     $packagexml->setNotes($setting['notes']);
     $packagexml->setDescription($setting['description']);
     $packagexml->setChannel($setting['channel']);
     $packagexml->setAPIVersion($setting['version']);
     $packagexml->setReleaseVersion($setting['version']);
     $packagexml->setReleaseStability($setting['state']);
     $packagexml->setAPIStability($setting['state']);
     $packagexml->setPackageType('php');
     foreach ($setting['maintainers'] as $m) {
         $packagexml->addMaintainer($m['role'], $m['user'], $m['name'], $m['email'], $m['active']);
     }
     $packagexml->setLicense($setting['license']['name'], $setting['license']['uri']);
     $packagexml->addRole('css', 'php');
     $packagexml->addRole('tpl', 'php');
     $packagexml->addRole('ethna', 'php');
     $packagexml->addRole('sh', 'script');
     $packagexml->addRole('bat', 'script');
     $packagexml->setPhpDep('4.1.0');
     $packagexml->setPearinstallerDep('1.3.5');
     $packagexml->generateContents();
     foreach ($setting['callback'] as $method => $params) {
         $r = call_user_func_array(array(&$packagexml, $method), $params);
     }
     $r = $packagexml->writePackageFile();
     if (PEAR::isError($r)) {
         return Ethna::raiseError($r->getMessage, $r->getCode());
     }
     // package を作る
     $r = $this->pear->_run('package', array(), array("{$workdir}/package.xml"));
     if (PEAR::isError($r)) {
         return Ethna::raiseError($r->getMessage, $r->getCode());
     }
     if (Ethna_Util::purgeDir($workdir) === false) {
         return Ethna::raiseError("failed cleaning up working dir: {$workdir}.");
     }
 }
 /**
  *  解析済みのメッセージ処理関数の情報を元に、カタログファイ
  *  ルを生成します。 生成先は以下のパスになる。
  *  [appid]/[locale_dir]/[locale_name]/LC_MESSAGES/[locale_name].[ini|po]
  *
  *  @access protected 
  *  @param  string  $locale         生成するカタログのロケール
  *  @param  int     $use_gettext    gettext 使用フラグ
  *                                  true ならgettext のカタログ生成
  *                                  false ならEthna組み込みのカタログ生成
  *  @return true|Ethna_Error true:成功 Ethna_Error:失敗
  */
 function _generateFile()
 {
     $outfile_path = $this->_get_output_file();
     $skel = $this->use_gettext ? 'locale/skel.msg.po' : 'locale/skel.msg.ini';
     $resolved = $this->_resolveSkelfile($skel);
     if ($resolved === false) {
         return Ethna::raiseError("skelton file [%s] not found.\n", $skel);
     } else {
         $skel = $resolved;
     }
     $contents = file_get_contents($skel);
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['locale_name'] = $this->locale;
     $macro['now_date'] = strftime('%Y-%m-%d %H:%M%z');
     foreach ($macro as $k => $v) {
         $contents = preg_replace("/{\\\${$k}}/", $v, $contents);
     }
     //  generate file contents
     foreach ($this->tokens as $file_path => $tokens) {
         $is_first_loop = false;
         foreach ($tokens as $token) {
             $token_str = $token['token_str'];
             $token_line = $token['linenum'];
             $token_line = $token_line !== false ? ":{$token_line}" : '';
             $translation = $token['translation'];
             if ($this->use_gettext) {
                 $contents .= "#: {$file_path}{$token_line}\n" . "msgid \"{$token_str}\"\n" . "msgstr \"{$translation}\"\n\n";
             } else {
                 if ($is_first_loop === false) {
                     $contents .= "\n; {$file_path}\n";
                     $is_first_loop = true;
                 }
                 $contents .= "\"{$token_str}\" = \"{$translation}\"\n";
             }
         }
     }
     //  finally write.
     $outfile_dir = dirname($outfile_path);
     if (!is_dir($outfile_dir)) {
         Ethna_Util::mkdir($outfile_dir, 0755);
     }
     $wfp = @fopen($outfile_path, "w");
     if ($wfp == null) {
         return Ethna::raiseError("unable to open file: {$outfile_path}");
     }
     if (fwrite($wfp, $contents) === false) {
         fclose($wfp);
         return Ethna::raiseError("unable to write contents to {$outfile_path}");
     }
     fclose($wfp);
     printf("Message catalog template successfully created [%s]\n", $outfile_path);
     return true;
 }
Example #29
0
 /**
  *  @access public
  *  @todo   deal with the package including some plugins.
  */
 public function perform()
 {
     $true = true;
     //   check arguments.
     $args = $this->_parseArgList();
     if (Ethna::isError($args)) {
         return Ethna::raiseError($args->getMessage(), 'usage');
     }
     $basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd();
     $channel = isset($args['channel']) ? $args['channel'] : 'dummy';
     $pear_local = new Ethna_PearConfig_Local();
     $r = $pear_local->init('local', $basedir, $channel);
     if (Ethna::isError($r)) {
         return $r;
     }
     //    build command string.
     $pear_cmds = $args['pear_args'];
     $pear_bin = ETHNA_OS_WINDOWS ? getenv('PHP_PEAR_BIN_DIR') . DIRECTORY_SEPARATOR . 'pear.bat' : PHP_BINDIR . DIRECTORY_SEPARATOR . 'pear';
     $local_conf_file = $pear_local->getConfFile();
     array_unshift($pear_cmds, $pear_bin, '-c', $local_conf_file);
     if (ETHNA_OS_WINDOWS) {
         foreach ($pear_cmds as $key => $value) {
             $pear_cmds[$key] = strpos($value, ' ') !== false ? '"' . $value . '"' : $value;
         }
     }
     $command_str = implode(' ', $pear_cmds);
     //   finally exec pear command.
     if (ETHNA_OS_WINDOWS) {
         $tmp_dir_name = "ethna_tmp_dir";
         Ethna_Util::mkdir($tmp_dir_name, 0777);
         $tmpnam = tempnam($tmp_dir_name, "temp") . '.bat';
         $fp = fopen($tmpnam, 'w');
         fwrite($fp, "@echo off\r\n");
         fwrite($fp, $command_str . " 2>&1");
         fclose($fp);
         system($tmpnam);
         Ethna_Util::purgeDir($tmp_dir_name);
     } else {
         system($command_str);
     }
     return $true;
 }
Example #30
0
 /**
  *  mkdir -p
  *
  *  @access public
  *  @param  string  $dir    作成するディレクトリ
  *  @param  int     $mode   パーミッション
  *  @return bool    true:成功 false:失敗
  *  @static
  */
 public static function mkdir($dir, $mode)
 {
     if (file_exists($dir)) {
         return is_dir($dir);
     }
     $parent = dirname($dir);
     if ($dir === $parent) {
         return true;
     }
     if (is_dir($parent) === false) {
         if (Ethna_Util::mkdir($parent, $mode) === false) {
             return false;
         }
     }
     return mkdir($dir, $mode) && Ethna_Util::chmod($dir, $mode);
 }