id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	modified_flg
2181	開発合宿：プラグインのインストーラ	adachi	somebody	"以下は、現状プラグイン任せなので、エラーがおきやすい

・インストール
・アンインストール
・有効
・無効

インストール用ユーティリティを用意し、プラグイン作成者に使ってもらう

※テーブル作成、ファイルコピー、ブロック追加など

仕様
{{{
* フロー

LC_Page_Admin_OwnersStore::installPlugin
  - トランザクション開始 (SC_QUery::begin())
  - プラグインアーカイブの一時ディレクトリを初期化
  - 必須拡張モジュールのチェック
  - アーカイブを一時ディレクトリに解凍
  - plugin_info.phpを読み込み
  - plugin_info.phpの内容チェック
  - プラグインコードから、既にプラグインがインストールされているかチェック
  - dtb_pluginへレコードを登録
  - 一時ディレクトリから, プラグイン保存ディレクトリへコピー
  - プラグインメインクラスをロード
  - プラグインHTMLディレクトリを作成
  - プラグインインストーラを生成
  - プラグインのinstallメソッドを実行 PLUGIN::install($arrPlugin, $objInstaller);
  - ★インストーラがインストール処理を実行 (SC_Plugin_Installer::execPlugin())
  - トランザクション終了(SC_Query::commit())
  - 一時ディレクトリ削除

* インストール処理のフロー

* インストーラで利用できるメソッド

- sql($sql, $params)
  SQLを実行
- sqlInsert($table, $entity);
  INSERT
- sqlUpdate($table, $entity, $where, $params)
  UPDATE
- sqlAterTableAddColumn($table_name, $col_name, $col_type)
  カラム追加
- sqlAterTableDropColumn($table_name, $col_name)
  カラム削除
- copyFile($src, $dist)
  html/plugin_code以下にコピー
- copyDirectory($src, $dist)
  html/plugin_code以下にコピー

* プラグイン側の利用イメージ
install($arrPlugin, $objPluginInstaller) {
    // カラム追加
    $objPluginInstaller->sql(""alter table dtb_products add column plg_plugin_code_hoge text"");

    // テーブル追加
    $objPluginInstaller->sql(
        ""create table plg_plugin_code_hogehugatable (
             hoge_id int not null primary key
             hoge_name text)"");

    // data/downloads/plugin/plugin_code/media/hoge.cssをhtml/plugin/plugin_code/media/huga.cssへコピー
    $objPluginInstaller->copyFile(""media/hoge.css"", ""media/huga.css"");

    // data/downloads/plugin/plugin_code/js/以下をhtml/plugin/plugin_code/js/へコピー
    $objPluginInstaller->copyDirectory(""js"", ""js"");
}

uninstall($arrPlugin, $objPluginInstaller) {
    // カラム追加
    $objPluginInstaller->sql(""alter table dtb_products drop column plg_plugin_code_hoge"");

    // テーブル削除
    $objPluginInstaller->sql(""drop table plg_plugin_code_hoge"");

    // ファイル削除
    html以下はアンインストール時にまるっと削除される
}
  

}}}"	改善提案	new	中	EC-CUBE2.13.0	フロント	2.12.3				0
