1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2007 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 '../../require.php'; |
---|
26 | require_once DATA_PATH . 'module/Services/JSON.php'; |
---|
27 | |
---|
28 | /** |
---|
29 | * モジュール一覧を出力するテストスクリプト |
---|
30 | * |
---|
31 | * 新しいモジュールを管理画面に表示する場合は、下の配列の値を書き換える. |
---|
32 | * 追加する際には、新しく配列を追加すればよい. |
---|
33 | * |
---|
34 | * installed_flgとdownload_flgを1にすると「設定」ボタンが出るので、 |
---|
35 | * data/downloads/module/mdl_***にモジュールが設置してあれば、 |
---|
36 | * ダウンロードしなくてもすぐに使用可能な状態となります. |
---|
37 | * (codeがモジュールファイル設定先になります) |
---|
38 | * |
---|
39 | * product_idは重複しない値を設定してください. |
---|
40 | * 本番商品との重複を避けるためにも大きめの値を設定しておくとよいかもしれません. |
---|
41 | */ |
---|
42 | $arrProductsList = array( |
---|
43 | // サンプルモジュール |
---|
44 | array( |
---|
45 | 'name' => 'サンプルモジュール', |
---|
46 | 'code' => 'mdl_sample', |
---|
47 | 'main_list_comment' => 'モジュール開発テスト用です。', |
---|
48 | 'main_list_image' => 'no_image.jpg', |
---|
49 | 'version' => '開発版', |
---|
50 | 'last_update_date' => '9999/99/99 00:00:00', |
---|
51 | 'product_id' => '100', |
---|
52 | 'status' => '使用可能です', |
---|
53 | 'installed_flg' => '1', |
---|
54 | 'installed_version' => '開発版', |
---|
55 | 'download_flg' => '1', |
---|
56 | 'version_up_flg' => '0' |
---|
57 | ), |
---|
58 | ); |
---|
59 | |
---|
60 | switch(getMode()) { |
---|
61 | |
---|
62 | case 'products_list': |
---|
63 | displayProductsList(); |
---|
64 | break; |
---|
65 | |
---|
66 | default: |
---|
67 | displayProductsList(); |
---|
68 | break; |
---|
69 | } |
---|
70 | |
---|
71 | /** |
---|
72 | * モード取得. |
---|
73 | * |
---|
74 | * @return string |
---|
75 | */ |
---|
76 | function getMode() { |
---|
77 | if (isset($_GET['mode'])) { |
---|
78 | return $_GET['mode']; |
---|
79 | } elseif (isset($_POST['mode'])) { |
---|
80 | return $_POST['mode']; |
---|
81 | } |
---|
82 | return ''; |
---|
83 | } |
---|
84 | |
---|
85 | /** |
---|
86 | * モジュールリスト一覧をjson出力する |
---|
87 | * |
---|
88 | */ |
---|
89 | function displayProductsList() { |
---|
90 | global $arrProductsList; |
---|
91 | $arrRet = array( |
---|
92 | 'status' => 'SUCCESS', |
---|
93 | 'data' => $arrProductsList |
---|
94 | ); |
---|
95 | |
---|
96 | // FIXME 一覧を取得するたびに更新されるのは微妙かも.. |
---|
97 | updateModuleTable($arrProductsList); |
---|
98 | |
---|
99 | $objJson = new Services_JSON(); |
---|
100 | echo $objJson->encode($arrRet); |
---|
101 | } |
---|
102 | |
---|
103 | /** |
---|
104 | * dtb_moduleを更新する. |
---|
105 | * |
---|
106 | * @param array $arrProductsList |
---|
107 | */ |
---|
108 | function updateModuleTable($arrProductsList) { |
---|
109 | $table = 'dtb_module'; |
---|
110 | $where = 'module_id = ?'; |
---|
111 | $objQuery = new SC_Query; |
---|
112 | |
---|
113 | foreach ($arrProductsList as $arrProduct) { |
---|
114 | $count = $objQuery->count($table, $where, array($arrProduct['product_id'])); |
---|
115 | if ($count) { |
---|
116 | $arrUpdate = array( |
---|
117 | 'module_code' => $arrProduct['code'], |
---|
118 | 'module_name' => $arrProduct['name'], |
---|
119 | 'auto_update_flg' => '0', |
---|
120 | 'del_flg' => '0,', |
---|
121 | 'update_date' => 'NOW()', |
---|
122 | ); |
---|
123 | $objQuery->update($table, $arrUpdate, $where, array($arrProduct['product_id'])); |
---|
124 | } else { |
---|
125 | $arrInsert = array( |
---|
126 | 'module_id' => $arrProduct['product_id'], |
---|
127 | 'module_code' => $arrProduct['code'], |
---|
128 | 'module_name' => $arrProduct['name'], |
---|
129 | 'auto_update_flg' => '0', |
---|
130 | 'del_flg' => '0,', |
---|
131 | 'update_date' => 'NOW()', |
---|
132 | 'create_date' => 'NOW()', |
---|
133 | ); |
---|
134 | $objQuery->insert($table, $arrInsert); |
---|
135 | } |
---|
136 | } |
---|
137 | } |
---|
138 | ?> |
---|