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 =& SC_Query_Ex::getSingletonInstance(); |
---|
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 | |
---|
42 | // プラグインフックポイントを取得. |
---|
43 | $max = count($arrRet); |
---|
44 | for ($i = 0; $i < $max; $i++) { |
---|
45 | $plugin_id = $arrRet[$i]['plugin_id']; |
---|
46 | $arrHookPoint = SC_Plugin_Util::getPluginHookPoint($plugin_id); |
---|
47 | $arrRet[$i]['plugin_hook_point'] = $arrHookPoint; |
---|
48 | } |
---|
49 | return $arrRet; |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * インストールされているプラグインを取得する。 |
---|
54 | * |
---|
55 | * @return array $arrRet インストールされているプラグイン. |
---|
56 | */ |
---|
57 | function getAllPlugin() { |
---|
58 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
59 | $col = '*'; |
---|
60 | $table = 'dtb_plugin'; |
---|
61 | // XXX 2.11.0 互換のため |
---|
62 | $arrCols = $objQuery->listTableFields($table); |
---|
63 | if (in_array('priority', $arrCols)) { |
---|
64 | $objQuery->setOrder('plugin_id ASC'); |
---|
65 | } |
---|
66 | $arrRet = $objQuery->select($col,$table); |
---|
67 | return $arrRet; |
---|
68 | } |
---|
69 | |
---|
70 | /** |
---|
71 | * プラグインIDをキーにプラグインを取得する。 |
---|
72 | * |
---|
73 | * @param int $plugin_id プラグインID. |
---|
74 | * @return array プラグインの基本情報. |
---|
75 | */ |
---|
76 | function getPluginByPluginId($plugin_id) { |
---|
77 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
78 | $col = '*'; |
---|
79 | $table = 'dtb_plugin'; |
---|
80 | $where = 'plugin_id = ?'; |
---|
81 | $plugin = $objQuery->getRow($col, $table, $where, array($plugin_id)); |
---|
82 | return $plugin; |
---|
83 | } |
---|
84 | |
---|
85 | |
---|
86 | /** |
---|
87 | * プラグインコードをキーにプラグインを取得する。 |
---|
88 | * |
---|
89 | * @param string $plugin_code プラグインコード. |
---|
90 | * @return array プラグインの基本情報. |
---|
91 | */ |
---|
92 | function getPluginByPluginCode($plugin_code) { |
---|
93 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
94 | $col = '*'; |
---|
95 | $table = 'dtb_plugin'; |
---|
96 | $where = 'plugin_code = ?'; |
---|
97 | $plugin = $objQuery->getRow($col, $table, $where, array($plugin_code)); |
---|
98 | return $plugin; |
---|
99 | } |
---|
100 | |
---|
101 | /** |
---|
102 | * プラグインIDをキーにプラグインを削除する。 |
---|
103 | * |
---|
104 | * @param string $plugin_id プラグインID. |
---|
105 | * @return array プラグインの基本情報. |
---|
106 | */ |
---|
107 | function deletePluginByPluginId($plugin_id) { |
---|
108 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
109 | $where = 'plugin_id = ?'; |
---|
110 | $objQuery->delete('dtb_plugin', $where, array($plugin_id)); |
---|
111 | $objQuery->delete('dtb_plugin_hookpoint', $where, array($plugin_id)); |
---|
112 | } |
---|
113 | |
---|
114 | /** |
---|
115 | * プラグインディレクトリの取得 |
---|
116 | * |
---|
117 | * @return array $arrPluginDirectory |
---|
118 | */ |
---|
119 | function getPluginDirectory() { |
---|
120 | $arrPluginDirectory = array(); |
---|
121 | if (is_dir(PLUGIN_UPLOAD_REALDIR)) { |
---|
122 | if ($dh = opendir(PLUGIN_UPLOAD_REALDIR)) { |
---|
123 | while (($pluginDirectory = readdir($dh)) !== false) { |
---|
124 | $arrPluginDirectory[] = $pluginDirectory; |
---|
125 | } |
---|
126 | closedir($dh); |
---|
127 | } |
---|
128 | } |
---|
129 | return $arrPluginDirectory; |
---|
130 | } |
---|
131 | |
---|
132 | /** |
---|
133 | * プラグインIDをキーに, プラグインフックポイントを取得する. |
---|
134 | * |
---|
135 | * @param integer $plugin_id |
---|
136 | * @return array フックポイントの一覧 |
---|
137 | */ |
---|
138 | function getPluginHookPoint($plugin_id) { |
---|
139 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
140 | $cols = '*'; |
---|
141 | $from = 'dtb_plugin_hookpoint'; |
---|
142 | $where = 'plugin_id = ?'; |
---|
143 | return $objQuery->select($cols, $from, $where, array($plugin_id)); |
---|
144 | } |
---|
145 | } |
---|