[22629] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
| 5 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
| 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
| 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License |
---|
| 11 | * as published by the Free Software Foundation; either version 2 |
---|
| 12 | * of the License, or (at your option) any later version. |
---|
| 13 | * |
---|
| 14 | * This program is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this program; if not, write to the Free Software |
---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
| 25 | require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * オーナーズストア:プラグイン管理 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id: LC_Page_Admin_OwnersStore.php 22567 2013-02-18 10:09:54Z shutta $ |
---|
| 33 | */ |
---|
| 34 | class LC_Page_Admin_OwnersStore_PluginHookPointList extends LC_Page_Admin_Ex |
---|
| 35 | { |
---|
| 36 | |
---|
| 37 | // }}} |
---|
| 38 | // {{{ functions |
---|
| 39 | |
---|
| 40 | /** |
---|
| 41 | * Page を初期化する. |
---|
| 42 | * |
---|
| 43 | * @return void |
---|
| 44 | */ |
---|
| 45 | function init() |
---|
| 46 | { |
---|
| 47 | parent::init(); |
---|
| 48 | $this->tpl_mainpage = 'ownersstore/plugin_hookpoint_list.tpl'; |
---|
| 49 | $this->tpl_subno = 'index'; |
---|
| 50 | $this->tpl_mainno = 'ownersstore'; |
---|
| 51 | $this->tpl_maintitle = 'オーナーズストア'; |
---|
| 52 | $this->tpl_subtitle = 'プラグインフックポイント管理'; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | /** |
---|
| 56 | * Page のプロセス. |
---|
| 57 | * |
---|
| 58 | * @return void |
---|
| 59 | */ |
---|
| 60 | function process() |
---|
| 61 | { |
---|
| 62 | $this->action(); |
---|
| 63 | $this->sendResponse(); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /** |
---|
| 67 | * Page のアクション. |
---|
| 68 | * |
---|
| 69 | * @return void |
---|
| 70 | */ |
---|
| 71 | function action() |
---|
| 72 | { |
---|
| 73 | // パラメーター管理クラス |
---|
| 74 | $objFormParam = new SC_FormParam_Ex(); |
---|
| 75 | $this->initParam($objFormParam, $mode); |
---|
| 76 | $objFormParam->setParam($_POST); |
---|
| 77 | |
---|
| 78 | $mode = $this->getMode(); |
---|
| 79 | switch ($mode) { |
---|
| 80 | // 削除 |
---|
| 81 | case 'uninstall': |
---|
| 82 | // エラーチェック |
---|
| 83 | $this->arrErr = $objFormParam->checkError(); |
---|
| 84 | if ($this->isError($this->arrErr) === false) { |
---|
| 85 | $plugin_id = $objFormParam->getValue('plugin_id'); |
---|
| 86 | $plugin = SC_Plugin_Util_Ex::getPluginByPluginId($plugin_id); |
---|
| 87 | $this->arrErr = $this->uninstallPlugin($plugin); |
---|
| 88 | if ($this->isError($this->arrErr) === false) { |
---|
| 89 | // TODO 全プラグインのインスタンスを保持したまま後続処理が実行されるので、全てのインスタンスを解放する。 |
---|
| 90 | unset($GLOBALS['_SC_Helper_Plugin_instance']); |
---|
| 91 | // コンパイルファイルのクリア処理 |
---|
| 92 | SC_Utils_Ex::clearCompliedTemplate(); |
---|
| 93 | $this->tpl_onload = "alert('" . $plugin['plugin_name'] ."を削除しました。');"; |
---|
| 94 | } |
---|
| 95 | } |
---|
| 96 | break; |
---|
| 97 | // 有効化 |
---|
| 98 | case 'enable': |
---|
| 99 | // エラーチェック |
---|
| 100 | $this->arrErr = $objFormParam->checkError(); |
---|
| 101 | if ($this->isError($this->arrErr) === false) { |
---|
| 102 | $plugin_id = $objFormParam->getValue('plugin_id'); |
---|
| 103 | // プラグイン取得. |
---|
| 104 | $plugin = SC_Plugin_Util_Ex::getPluginByPluginId($plugin_id); |
---|
| 105 | $this->arrErr = $this->enablePlugin($plugin); |
---|
| 106 | if ($this->isError($this->arrErr) === false) { |
---|
| 107 | // TODO 全プラグインのインスタンスを保持したまま後続処理が実行されるので、全てのインスタンスを解放する。 |
---|
| 108 | unset($GLOBALS['_SC_Helper_Plugin_instance']); |
---|
| 109 | // コンパイルファイルのクリア処理 |
---|
| 110 | SC_Utils_Ex::clearCompliedTemplate(); |
---|
| 111 | $this->tpl_onload = "alert('" . $plugin['plugin_name'] . "を有効にしました。');"; |
---|
| 112 | } |
---|
| 113 | } |
---|
| 114 | break; |
---|
| 115 | // 無効化 |
---|
| 116 | case 'disable': |
---|
| 117 | // エラーチェック |
---|
| 118 | $this->arrErr = $objFormParam->checkError(); |
---|
| 119 | if ($this->isError($this->arrErr) === false) { |
---|
| 120 | $plugin_id = $objFormParam->getValue('plugin_id'); |
---|
| 121 | // プラグイン取得. |
---|
| 122 | $plugin = SC_Plugin_Util_Ex::getPluginByPluginId($plugin_id); |
---|
| 123 | $this->arrErr = $this->disablePlugin($plugin); |
---|
| 124 | if ($this->isError($this->arrErr) === false) { |
---|
| 125 | // TODO 全プラグインのインスタンスを保持したまま後続処理が実行されるので、全てのインスタンスを解放する。 |
---|
| 126 | unset($GLOBALS['_SC_Helper_Plugin_instance']); |
---|
| 127 | // コンパイルファイルのクリア処理 |
---|
| 128 | SC_Utils_Ex::clearCompliedTemplate(); |
---|
| 129 | $this->tpl_onload = "alert('" . $plugin['plugin_name'] . "を無効にしました。');"; |
---|
| 130 | } |
---|
| 131 | } |
---|
| 132 | break; |
---|
| 133 | default: |
---|
| 134 | break; |
---|
| 135 | } |
---|
| 136 | // DBからプラグイン情報を取得 |
---|
| 137 | $arrHookPoint = SC_Plugin_Util_Ex::getPluginHookPointList(); |
---|
| 138 | |
---|
| 139 | $this->arrHookPoint = $arrHookPoint; |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | /** |
---|
| 143 | * デストラクタ. |
---|
| 144 | * |
---|
| 145 | * @return void |
---|
| 146 | */ |
---|
| 147 | function destroy() |
---|
| 148 | { |
---|
| 149 | parent::destroy(); |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | /** |
---|
| 153 | * パラメーター初期化. |
---|
| 154 | * |
---|
| 155 | * @param SC_FormParam_Ex $objFormParam |
---|
| 156 | * @param string $mode モード |
---|
| 157 | * @return void |
---|
| 158 | */ |
---|
| 159 | function initParam(&$objFormParam, $mode) |
---|
| 160 | { |
---|
| 161 | $objFormParam->addParam('mode', 'mode', INT_LEN, '', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 162 | $objFormParam->addParam('plugin_id', 'plugin_id', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 163 | if ($mode === 'priority') { |
---|
| 164 | $objFormParam->addParam('優先度', 'priority', INT_LEN, '', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 165 | } |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | } |
---|