Skip to content

Commit

Permalink
#1737 アップデート処理を修正。全ての画面でプラグインが実行される仕様に変更。
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.ec-cube.net/open/branches/version-2_12-dev@21712 1e3b908f-19a9-db11-a64c-001125224ba8
  • Loading branch information
h_yoshimoto committed Apr 5, 2012
1 parent 1368985 commit 75f3226
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 41 deletions.
6 changes: 0 additions & 6 deletions data/class/pages/LC_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ function init() {
$layout->sfGetPageLayout($this, false, $_SERVER['SCRIPT_NAME'],
$this->objDisplay->detectDevice());

// プラグインを実行するかを判定します.
// プラグイン管理ではプラグインが実行されません
if ($_SERVER['SCRIPT_NAME'] === ROOT_URLPATH . ADMIN_DIR . 'system/plugin.php') {
$this->plugin_activate_flg = false;
}

// スーパーフックポイントを実行.
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
$objPlugin->doAction('LC_Page_preProcess', array($this));
Expand Down
6 changes: 0 additions & 6 deletions data/class/pages/admin/LC_Page_Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ function init() {
// ディスプレイクラス生成
$this->objDisplay = new SC_Display_Ex();

// プラグインを実行するかを判定します.
// プラグイン管理ではプラグインが実行されません
if ($_SERVER['SCRIPT_NAME'] === ROOT_URLPATH . ADMIN_DIR . 'system/plugin.php') {
$this->plugin_activate_flg = false;
}

// スーパーフックポイントを実行.
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);

Expand Down
38 changes: 9 additions & 29 deletions data/class/pages/admin/system/LC_Page_Admin_System_Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,41 +489,21 @@ function checkPluginConstants(ReflectionClass $objReflection, $unpack_dir) {
*/
function updatePlugin($target_plugin, $upload_file_name) {
$arrErr = array();

// ファイルをチェックし展開します.
$arrErr = $this->unpackPluginFile($upload_file_name, DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR, $target_plugin['plugin_code']);
if ($this->isError($arrErr) === true) {
return $arrErr;
}

// plugin_infoを読み込み.
$arrErr = $this->requirePluginFile(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . 'plugin_info.php', $target_plugin['plugin_code']);
if ($this->isError($arrErr) === true) {
$this->rollBack(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR);
return $arrErr;
}

// リフレクションオブジェクトを生成.
$objReflection = new ReflectionClass('plugin_info');
// プラグインクラスに必須となるパラメータが正常に定義されているかチェックします.
$arrErr = $this->checkPluginConstants($objReflection, DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR);
if ($this->isError($arrErr) === true) {
$this->rollBack(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR);
return $arrErr;
}

// プラグインのクラス名を取得;
$class_name = $objReflection->getConstant('CLASS_NAME');

// 展開されたディレクトリからプラグインクラスファイルを読み込みます.
$update_plugin_class_path = DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . $class_name . '.php';
$arrErr = $this->requirePluginFile($update_plugin_class_path, $target_plugin['plugin_code']);
// plugin_update.phpを読み込み.
$arrErr = $this->requirePluginFile(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . 'plugin_update.php', $target_plugin['plugin_code']);
if ($this->isError($arrErr) === true) {
$this->rollBack(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR);
return $arrErr;
}
// プラグインクラスファイルのUPDATE処理を実行.
$arrErr = $this->execPlugin($target_plugin, $class_name, 'update');
$objPluginUpdate = new plugin_update;
$arrErr = $this->execPlugin($objPluginUpdate, 'plugin_update', 'update');

// 保存ディレクトリの削除.
SC_Utils_Ex::deleteFile(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR, false);
Expand Down Expand Up @@ -733,16 +713,16 @@ function requirePluginFile($file_path, $key) {
/**
* インスタンスを生成し、指定のメソッドを実行する.
*
* @param integer $plugin プラグイン情報
* @param string $plugin_code プラグインコード
* @param object $obj インスタンス
* @param string $class_name クラス名
* @param string $exec_func 実行するメソッド名.
* @return array $arrErr エラー情報を格納した連想配列.
*
*/
function execPlugin($plugin, $class_name, $exec_func) {
function execPlugin($obj, $class_name, $exec_func) {
$arrErr = array();
if (method_exists($class_name, $exec_func) === true) {
call_user_func(array($class_name, $exec_func), $plugin);
call_user_func(array($class_name, $exec_func), $obj);
} else {
$arrErr['plugin_error'] = '※ ' . $class_name . '.php に' . $exec_func . 'が見つかりません。<br/>';
}
Expand Down

0 comments on commit 75f3226

Please sign in to comment.