source: branches/version-2_12-dev/html/test/upgrade/index.php @ 22567

Revision 22567, 4.2 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
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
25require_once '../../require.php';
26
27/**
28 * モジュール一覧を出力するテストスクリプト
29 *
30 * 新しいモジュールを管理画面に表示する場合は、下の配列の値を書き換える.
31 * 追加する際には、新しく配列を追加すればよい.
32 *
33 * installed_flgとdownload_flgを1にすると「設定」ボタンが出るので、
34 * data/downloads/module/mdl_***にモジュールが設置してあれば、
35 * ダウンロードしなくてもすぐに使用可能な状態となります.
36 * (codeがモジュールファイル設定先になります)
37 *
38 * product_idは重複しない値を設定してください.
39 * 本番商品との重複を避けるためにも大きめの値を設定しておくとよいかもしれません.
40 */
41$GLOBALS['productsList'] = array(
42    // サンプルモジュール
43    array(
44        'name' => 'サンプルモジュール',
45        'code' => 'mdl_sample',
46        'main_list_comment' => 'モジュール開発テスト用です。',
47        'main_list_image' => 'no_image.jpg',
48        'version' => '開発版',
49        'last_update_date' => '9999/99/99 00:00:00',
50        'product_id' => '100',
51        'status' => '使用可能です',
52        'installed_flg' => '1',
53        'installed_version' => '開発版',
54        'download_flg' => '1',
55        'version_up_flg' => '0'
56    ),
57);
58
59switch (getMode()) {
60
61case 'products_list':
62    displayProductsList();
63    break;
64
65default:
66    displayProductsList();
67    break;
68}
69
70/**
71 * モード取得.
72 *
73 * @return string
74 */
75function getMode()
76{
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 */
89function displayProductsList()
90{
91    $arrRet = array(
92        'status' => 'SUCCESS',
93        'data'   => $GLOBALS['productsList']
94    );
95
96    // FIXME 一覧を取得するたびに更新されるのは微妙かも..
97    updateModuleTable($GLOBALS['productsList']);
98
99    echo SC_Utils_Ex::jsonEncode($arrRet);
100}
101
102/**
103 * dtb_moduleを更新する.
104 *
105 * @param array $arrProductsList
106 */
107function updateModuleTable($arrProductsList)
108{
109    $table = 'dtb_module';
110    $where = 'module_id = ?';
111    $objQuery =& SC_Query_Ex::getSingletonInstance();
112
113    $objQuery->begin();
114    foreach ($arrProductsList as $arrProduct) {
115        $count = $objQuery->count($table, $where, array($arrProduct['product_id']));
116        if ($count) {
117            $arrUpdate = array(
118                'module_code' => $arrProduct['code'],
119                'module_name' => $arrProduct['name'],
120                'auto_update_flg' => '0',
121                'del_flg' => '0',
122                'update_date' => 'CURRENT_TIMESTAMP',
123            );
124            $objQuery->update($table, $arrUpdate, $where, array($arrProduct['product_id']));
125        } else {
126            $arrInsert = array(
127                'module_id'   => $arrProduct['product_id'],
128                'module_code' => $arrProduct['code'],
129                'module_name' => $arrProduct['name'],
130                'auto_update_flg' => '0',
131                'del_flg' => '0',
132                'update_date' => 'CURRENT_TIMESTAMP',
133                'create_date' => 'CURRENT_TIMESTAMP',
134            );
135            $objQuery->insert($table, $arrInsert);
136        }
137    }
138    $objQuery->commit();
139}
Note: See TracBrowser for help on using the repository browser.