1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2009 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 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
---|
25 | |
---|
26 | /** |
---|
27 | * プラグインのアンインストールのページクラス |
---|
28 | * |
---|
29 | * FIXME インストール直後のレンダリング時点では、上部ナビに反映されない |
---|
30 | * TODO Transaction Token を使用する |
---|
31 | * |
---|
32 | * @package Page |
---|
33 | * @author Seasoft 塚田将久 |
---|
34 | * @version $Id:$ |
---|
35 | */ |
---|
36 | class LC_Page_Admin_Plugin_Uninstall extends LC_Page { |
---|
37 | |
---|
38 | /** |
---|
39 | * Page を初期化する. |
---|
40 | * |
---|
41 | * @return void |
---|
42 | */ |
---|
43 | function init() { |
---|
44 | if (DEBUG_LOAD_PLUGIN !== true) SC_Utils_Ex::sfDispException('プラグインは有効化されていない'); // XXX 開発途上対応 |
---|
45 | parent::init(); |
---|
46 | |
---|
47 | $this->tpl_mainpage = 'plugin/uninstall.tpl'; |
---|
48 | $this->tpl_mainno = 'plugin'; |
---|
49 | $this->tpl_subno = 'uninstall'; |
---|
50 | $this->tpl_subtitle = 'プラグインのアンインストール'; |
---|
51 | } |
---|
52 | |
---|
53 | /** |
---|
54 | * Page のプロセス. |
---|
55 | * |
---|
56 | * @return void |
---|
57 | */ |
---|
58 | function process() { |
---|
59 | $objView = new SC_AdminView(); |
---|
60 | $objSess = new SC_Session(); |
---|
61 | |
---|
62 | // 認証可否の判定 |
---|
63 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
64 | |
---|
65 | // パラメータ管理クラス |
---|
66 | $this->objFormParam = new SC_FormParam(); |
---|
67 | // パラメータ情報の初期化 |
---|
68 | $this->lfInitParam(); |
---|
69 | // POST値の取得 |
---|
70 | $this->objFormParam->setParam($_REQUEST); |
---|
71 | // 入力情報を渡す |
---|
72 | $this->arrForm = $this->objFormParam->getHashArray(); |
---|
73 | $this->arrErr = $this->objFormParam->checkError(); |
---|
74 | if (count($this->arrErr) == 0) { |
---|
75 | // アンインストール |
---|
76 | $this->lfUninstall($this->arrForm['path']); |
---|
77 | $this->tpl_result = '完了しました。'; |
---|
78 | } else { |
---|
79 | SC_Utils_Ex::sfDispException(); |
---|
80 | } |
---|
81 | |
---|
82 | $objView->assignobj($this); |
---|
83 | $objView->display(MAIN_FRAME); |
---|
84 | } |
---|
85 | |
---|
86 | /** |
---|
87 | * デストラクタ. |
---|
88 | * |
---|
89 | * @return void |
---|
90 | */ |
---|
91 | function destroy() { |
---|
92 | parent::destroy(); |
---|
93 | } |
---|
94 | |
---|
95 | /** |
---|
96 | * アンインストール |
---|
97 | * |
---|
98 | * @return void |
---|
99 | */ |
---|
100 | function lfUninstall($path) { |
---|
101 | $objQuery = new SC_Query(); |
---|
102 | |
---|
103 | // プラグインにて指定された SQL を実行 |
---|
104 | $sqlPath = PLUGIN_PATH . "$path/" . 'sql/uninstall.sql'; |
---|
105 | if (file_exists($sqlPath)) { |
---|
106 | $sql = file_get_contents($sqlPath); |
---|
107 | if ($sql === false) SC_Utils_Ex::sfDispException('ファイルは存在するが読み込めない'); |
---|
108 | $objQuery->query($sql); |
---|
109 | } |
---|
110 | |
---|
111 | // プラグイン XML から削除 |
---|
112 | $this->lfRemoveFromPluginsXml($path); |
---|
113 | } |
---|
114 | |
---|
115 | /** |
---|
116 | * プラグイン XML から削除 |
---|
117 | * |
---|
118 | * @return void |
---|
119 | */ |
---|
120 | function lfRemoveFromPluginsXml($path) { |
---|
121 | $pluginsXml = SC_Utils_Ex::sfGetPluginsXml(); |
---|
122 | for ($i = 0; $i <= count($pluginsXml->plugin) - 1; $i++) { |
---|
123 | if ((string)$pluginsXml->plugin[$i]->path == $path) { |
---|
124 | unset($pluginsXml->plugin[$i]); |
---|
125 | } |
---|
126 | } |
---|
127 | SC_Utils_Ex::sfPutPluginsXml($pluginsXml); |
---|
128 | } |
---|
129 | |
---|
130 | /** |
---|
131 | * パラメータ情報の初期化 |
---|
132 | * |
---|
133 | * @return void |
---|
134 | */ |
---|
135 | function lfInitParam() { |
---|
136 | $this->objFormParam->addParam('プラグインのパス', 'path', STEXT_LEN, '', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
137 | } |
---|
138 | } |
---|
139 | ?> |
---|