Skip to content

Instantly share code, notes, and snippets.

@nanasess
Created June 10, 2013 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanasess/5747139 to your computer and use it in GitHub Desktop.
Save nanasess/5747139 to your computer and use it in GitHub Desktop.
EC-CUBE のプラグイン本体のプログラムを消さずにリロードするパッチ。 開発時に便利
diff --git a/data/Smarty/templates/admin/ownersstore/plugin.tpl b/data/Smarty/templates/admin/ownersstore/plugin.tpl
index 14f9be6c09839a0ea1f93341d770254e94abedfe 100644
--- a/data/Smarty/templates/admin/ownersstore/plugin.tpl
+++ b/data/Smarty/templates/admin/ownersstore/plugin.tpl
@@ -115,6 +115,11 @@
fnModeSubmit('priority','plugin_id',plugin_id);
}
+ function reload(plugin_id, plugin_code) {
+ fnSetFormValue('plugin_id', plugin_id);
+ fnModeSubmit('reload','plugin_code', plugin_code);
+ }
+
//]]></script>
<!--<form name="form1" id="form1" method="post" action="?">-->
@@ -206,7 +211,7 @@
<!--{else}-->
<label><input id="plugin_enable" type="checkbox" name="enable" value="<!--{$plugin.plugin_id}-->" id="login_memory">有効にする</input></label><br/>
<!--{/if}-->
-
+ <a href="javascript:;" name="reload" onclick="reload(<!--{$plugin.plugin_id}-->, '<!--{$plugin.plugin_code}-->'); return false;">リロード</a>&nbsp;|&nbsp;
<!-- アップデートリンク押下時に表示する. -->
<div id="plugin_update_<!--{$plugin.plugin_id}-->" style="display: none">
<input id="update_file_<!--{$plugin.plugin_id}-->" name="<!--{$plugin.plugin_code}-->" type="file" style="<!--{$arrErr[$key]|sfGetErrorColor}-->" class="box30" size="30" <!--{if $arrErr[$key]}-->style="background-color:<!--{$smarty.const.ERR_COLOR|h}-->"<!--{/if}--> />
diff --git a/data/class/pages/admin/ownersstore/LC_Page_Admin_OwnersStore.php b/data/class/pages/admin/ownersstore/LC_Page_Admin_OwnersStore.php
index f74dde4de66ac46bc9f0a2117ddac6185df7d759 100644
--- a/data/class/pages/admin/ownersstore/LC_Page_Admin_OwnersStore.php
+++ b/data/class/pages/admin/ownersstore/LC_Page_Admin_OwnersStore.php
@@ -183,6 +183,22 @@
}
break;
+
+ case 'reload':
+ $arrErr = $objFormParam->checkError();
+ $plugin_id = $objFormParam->getValue('plugin_id');
+ if ($this->isError($arrErr) === false) {
+ // 優先度の更新
+ $plugin = SC_Plugin_Util_Ex::getPluginByPluginId($plugin_id);
+ $this->reload($plugin);
+ // コンパイルファイルのクリア処理
+ SC_Utils_Ex::clearCompliedTemplate();
+ } else {
+ // エラーメッセージを詰め直す.
+ $this->tpl_onload = "array('error!');";
+ }
+
+ break;
default:
break;
}
@@ -1015,4 +1031,42 @@
$where = 'plugin_id = ?';
return $objQuery->select('*', $table, $where, array($plugin_id));
}
+
+ function reload($plugin) {
+ $arrErr = $this->requirePluginFile(PLUGIN_UPLOAD_REALDIR . $plugin['plugin_code'] . '/plugin_info.php', $key);
+ // プラグインが有効な場合に無効化処理を実行
+ if ($plugin['enable'] == PLUGIN_ENABLE_TRUE){
+ // 無効化処理を実行します.
+ $arrErr = $this->execPlugin($plugin, $plugin['class_name'], 'disable');
+ if ($this->isError($arrErr) === true) {
+ return $arrErr;
+ }
+ // プラグインを無効にします.
+ $this->updatePluginEnable($plugin['plugin_id'], PLUGIN_ENABLE_FALSE);
+ }
+
+ // アンインストール処理を実行します.
+ $arrErr = $this->execPlugin($plugin, $plugin['class_name'], 'uninstall');
+ SC_Plugin_Util_Ex::deletePluginByPluginId($plugin['plugin_id']);
+
+
+
+ // リフレクションオブジェクトを生成.
+ $objReflection = new ReflectionClass('plugin_info');
+ $arrPluginInfo = $this->getPluginInfo($objReflection);
+
+ // プラグイン情報をDB登録
+ $this->registerData($arrPluginInfo);
+
+ // プラグイン情報を取得
+ $plugin = SC_Plugin_Util_Ex::getPluginByPluginCode($arrPluginInfo['PLUGIN_CODE']);
+
+ // クラスファイルを読み込み.
+ $plugin_class_file_path = $this->getPluginFilePath($plugin['plugin_code'], $plugin['class_name']);
+ $arrErr = $this->requirePluginFile($plugin_class_file_path, $key);
+ $arrErr = $this->execPlugin($plugin, $plugin['class_name'], 'install');
+ $this->updatePluginEnable($plugin['plugin_id'], PLUGIN_ENABLE_TRUE);
+ $this->tpl_onload = "alert('プラグインをリロードしました。');";
+ return $arrErr;
+ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment