1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2011 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 | // プラグインのユーティリティクラス. |
---|
25 | class SC_Plugin_Util { |
---|
26 | |
---|
27 | /** |
---|
28 | * 稼働中のプラグインを取得する。 |
---|
29 | */ |
---|
30 | function getEnablePlugin() { |
---|
31 | $objQuery = new SC_Query_Ex(); |
---|
32 | $col = '*'; |
---|
33 | $table = 'dtb_plugin'; |
---|
34 | $where = 'enable = 1'; |
---|
35 | // XXX 2.11.0 互換のため |
---|
36 | $arrCols = $objQuery->listTableFields($table); |
---|
37 | if (in_array('priority', $arrCols)) { |
---|
38 | $objQuery->setOrder('priority DESC, plugin_id ASC'); |
---|
39 | } |
---|
40 | $arrRet = $objQuery->select($col,$table,$where); |
---|
41 | return $arrRet; |
---|
42 | } |
---|
43 | |
---|
44 | /** |
---|
45 | * インストールされているプラグインを取得する。 |
---|
46 | * |
---|
47 | * @return array $arrRet インストールされているプラグイン. |
---|
48 | */ |
---|
49 | function getAllPlugin() { |
---|
50 | $objQuery = new SC_Query_Ex(); |
---|
51 | $col = '*'; |
---|
52 | $table = 'dtb_plugin'; |
---|
53 | // XXX 2.11.0 互換のため |
---|
54 | $arrCols = $objQuery->listTableFields($table); |
---|
55 | if (in_array('priority', $arrCols)) { |
---|
56 | $objQuery->setOrder('plugin_id ASC'); |
---|
57 | } |
---|
58 | $arrRet = $objQuery->select($col,$table); |
---|
59 | return $arrRet; |
---|
60 | } |
---|
61 | |
---|
62 | /** |
---|
63 | * プラグインIDをキーにプラグインを取得する。 |
---|
64 | * |
---|
65 | * @param int $plugin_id プラグインID. |
---|
66 | * @return array プラグインの基本情報. |
---|
67 | */ |
---|
68 | function getPluginByPluginId($plugin_id) { |
---|
69 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
70 | $col = '*'; |
---|
71 | $table = 'dtb_plugin'; |
---|
72 | $where = 'plugin_id = ?'; |
---|
73 | $plugin = $objQuery->getRow($col, $table, $where, array($plugin_id)); |
---|
74 | return $plugin; |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | /** |
---|
79 | * プラグインコードをキーにプラグインを取得する。 |
---|
80 | * |
---|
81 | * @param string $plugin_code プラグインコード. |
---|
82 | * @return array プラグインの基本情報. |
---|
83 | */ |
---|
84 | function getPluginByPluginCode($plugin_code) { |
---|
85 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
86 | $col = '*'; |
---|
87 | $table = 'dtb_plugin'; |
---|
88 | $where = 'plugin_code = ?'; |
---|
89 | $plugin = $objQuery->getRow($col, $table, $where, array($plugin_code)); |
---|
90 | return $plugin; |
---|
91 | } |
---|
92 | |
---|
93 | /** |
---|
94 | * プラグインIDをキーにプラグインを削除する。 |
---|
95 | * |
---|
96 | * @param string $plugin_id プラグインID. |
---|
97 | * @return array プラグインの基本情報. |
---|
98 | */ |
---|
99 | function deletePluginByPluginId($plugin_id) { |
---|
100 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
101 | $where = 'plugin_id = ?'; |
---|
102 | $objQuery->delete('dtb_plugin', $where, array($plugin_id)); |
---|
103 | $objQuery->delete('dtb_plugin_hookpoint', $where, array($plugin_id)); |
---|
104 | } |
---|
105 | |
---|
106 | /** |
---|
107 | * プラグインディレクトリの取得 |
---|
108 | * |
---|
109 | * @return array $arrPluginDirectory |
---|
110 | */ |
---|
111 | function getPluginDirectory() { |
---|
112 | $arrPluginDirectory = array(); |
---|
113 | if (is_dir(PLUGIN_UPLOAD_REALDIR)) { |
---|
114 | if ($dh = opendir(PLUGIN_UPLOAD_REALDIR)) { |
---|
115 | while (($pluginDirectory = readdir($dh)) !== false) { |
---|
116 | $arrPluginDirectory[] = $pluginDirectory; |
---|
117 | } |
---|
118 | closedir($dh); |
---|
119 | } |
---|
120 | } |
---|
121 | return $arrPluginDirectory; |
---|
122 | } |
---|
123 | } |
---|