source: branches/feature-module-update/html/admin/products/index_csv.php @ 15080

Revision 15080, 4.5 KB checked in by nanasess, 17 years ago (diff)

svn properties 設定

  • svn:mime-type - application/x-httpd-php; charset=UTF-8
  • svn:keywords - Id
  • Property svn:keywords set to Id
  • Property svn:mime-type set to application/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once(DATA_PATH . "include/csv_output.inc");
8
9$arrREVIEW_CVSCOL = array(
10                        'B.name',
11                        'A.status',
12                        'A.create_date',
13                        'A.reviewer_name',
14                        'A.sex',
15                        'A.recommend_level',
16                        'A.title',
17                        'A.comment'
18                        );
19                       
20$arrREVIEW_CVSTITLE = array(
21                        '商品名',
22                        'レビュー表示',
23                        '投稿日',
24                        '投稿者名',
25                        '性別',
26                        'おすすめレベル',
27                        'タイトル',
28                        'コメント'
29                        );
30
31$arrTRACKBACK_CVSTITLE = array(
32                        '商品名',
33                        'ブログ名',
34                        'ブログ記事タイトル',
35                        'ブログ記事内容',
36                        '状態',
37                        '投稿日'
38                        );
39
40$arrTRACKBACK_CVSCOL = array(
41                        'B.name',
42                        'A.blog_name',
43                        'A.title',
44                        'A.excerpt',
45                        'A.status',
46                        'A.create_date'
47                        );
48
49// CSV出力データを作成する。(商品)
50function lfGetProductsCSV($where, $option, $arrval, $arrOutputCols) {
51    global $arrPRODUCTS_CVSCOL;
52
53    $from = "vw_product_class AS prdcls";
54    $cols = sfGetCommaList($arrOutputCols);
55   
56    $objQuery = new SC_Query();
57    $objQuery->setoption($option);
58   
59    $list_data = $objQuery->select($cols, $from, $where, $arrval);
60    $max = count($list_data);
61   
62    // 規格分類名一覧
63    $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
64   
65    for($i = 0; $i < $max; $i++) {
66        // 関連商品情報の付与
67        $list_data[$i]['classcategory_id1'] = $arrClassCatName[$list_data[$i]['classcategory_id1']];
68        $list_data[$i]['classcategory_id2'] = $arrClassCatName[$list_data[$i]['classcategory_id2']];
69       
70        // 各項目をCSV出力用に変換する。
71        $data .= lfMakeProductsCSV($list_data[$i]);
72    }
73    return $data;
74}
75
76// CSV出力データを作成する。(レビュー)
77function lfGetReviewCSV($where, $option, $arrval) {
78    global $arrREVIEW_CVSCOL;
79
80    $from = "dtb_review AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id ";
81    $cols = sfGetCommaList($arrREVIEW_CVSCOL);
82   
83    $objQuery = new SC_Query();
84    $objQuery->setoption($option);
85   
86    $list_data = $objQuery->select($cols, $from, $where, $arrval); 
87
88    $max = count($list_data);
89    for($i = 0; $i < $max; $i++) {
90        // 各項目をCSV出力用に変換する。
91        $data .= lfMakeReviewCSV($list_data[$i]);
92    }
93    return $data;
94}
95
96// CSV出力データを作成する。(トラックバック)
97function lfGetTrackbackCSV($where, $option, $arrval) {
98    global $arrTRACKBACK_CVSCOL;
99
100    $from = "dtb_trackback AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id ";
101    $cols = sfGetCommaList($arrTRACKBACK_CVSCOL);
102   
103    $objQuery = new SC_Query();
104    $objQuery->setoption($option);
105   
106    $list_data = $objQuery->select($cols, $from, $where, $arrval); 
107
108    $max = count($list_data);
109    for($i = 0; $i < $max; $i++) {
110        // 各項目をCSV出力用に変換する。
111        $data .= lfMakeTrackbackCSV($list_data[$i]);
112    }
113    return $data;
114}
115
116// 各項目をCSV出力用に変換する。(商品)
117function lfMakeProductsCSV($list) {
118    global $arrDISP;
119    $line = "";
120    if(is_array($list)) {
121        foreach($list as $key => $val) {
122            $tmp = "";
123            switch($key) {
124            case 'point_rate':
125                if($val == "") {
126                    $tmp = '0';
127                } else {
128                    $tmp = $val;
129                }
130                break;
131            default:
132                $tmp = $val;
133                break;
134            }
135   
136            $tmp = str_replace("\"", "\\\"", $tmp);
137            $line .= "\"".$tmp."\",";
138        }
139        // 文末の","を変換
140        $line = ereg_replace(",$", "\n", $line);
141    }
142    return $line;
143}
144
145
146// 各項目をCSV出力用に変換する。(レビュー)
147function lfMakeReviewCSV($list) {
148    global $arrSex;
149    global $arrRECOMMEND;
150    global $arrDISP;
151   
152    $line = "";
153   
154    foreach($list as $key => $val) {
155        $tmp = "";
156        switch($key) {
157        case 'sex':
158            $tmp = $arrSex[$val];
159            break;
160        case 'recommend_level':
161            $tmp = $arrRECOMMEND[$val];
162            break;
163        case 'status':
164            $tmp = $arrDISP[$val];
165            break;
166        default:
167            $tmp = $val;
168            break;
169        }
170
171        $tmp = ereg_replace("[\",]", " ", $tmp);
172        $line .= "\"".$tmp."\",";
173    }
174    // 文末の","を変換
175    $line = ereg_replace(",$", "\n", $line);
176    return $line;
177}
178
179// 各項目をCSV出力用に変換する。(トラックバック)
180function lfMakeTrackbackCSV($list) {
181    global $arrTrackBackStatus;
182    global $arrDISP;
183   
184    $line = "";
185   
186    foreach($list as $key => $val) {
187        $tmp = "";
188        switch($key) {
189            case 'status':
190                $tmp = $arrTrackBackStatus[$val];
191                break;
192            default:
193                $tmp = $val;
194                break;
195        }
196
197        $tmp = ereg_replace("[\",]", " ", $tmp);
198        $line .= "\"".$tmp."\",";
199    }
200    // 文末の","を変換
201    $line = ereg_replace(",$", "\n", $line);
202    return $line;
203}
204
205?>
Note: See TracBrowser for help on using the repository browser.