source: branches/version-2_5-dev/data/class/pages/admin/products/LC_Page_Admin_Products_Review.php @ 19807

Revision 19807, 11.3 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to "Id Revision Date"
  • 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-2010 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(CLASS_REALDIR . "pages/admin/LC_Page_Admin.php");
26require_once(CLASS_EX_REALDIR . "helper_extends/SC_Helper_CSV_Ex.php");
27
28/**
29 * レビュー管理 のページクラス.
30 *
31 * @package Page
32 * @author LOCKON CO.,LTD.
33 * @version $Id$
34 */
35class LC_Page_Admin_Products_Review extends LC_Page_Admin {
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * Page を初期化する.
42     *
43     * @return void
44     */
45    function init() {
46        parent::init();
47        $this->tpl_mainpage = 'products/review.tpl';
48        $this->tpl_subnavi = 'products/subnavi.tpl';
49        $this->tpl_mainno = 'products';
50        $this->tpl_subno = 'review';
51        $this->tpl_pager = TEMPLATE_REALDIR . 'admin/pager.tpl';
52        $this->tpl_subtitle = 'レビュー管理';
53
54        $masterData = new SC_DB_MasterData_Ex();
55        $this->arrPageMax = $masterData->getMasterData("mtb_page_max");
56        $this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend");
57        $this->arrSex = $masterData->getMasterData("mtb_sex");
58    }
59
60    /**
61     * Page のプロセス.
62     *
63     * @return void
64     */
65    function process() {
66        $this->action();
67        $this->sendResponse();
68    }
69
70    /**
71     * Page のアクション.
72     *
73     * @return void
74     */
75    function action() {
76        $objSess = new SC_Session();
77        $objDate = new SC_Date();
78        $objQuery = new SC_Query();
79
80        // 登録・更新検索開始年
81        $objDate->setStartYear(RELEASE_YEAR);
82        $objDate->setEndYear(DATE("Y"));
83        $this->arrStartYear = $objDate->getYear();
84        $this->arrStartMonth = $objDate->getMonth();
85        $this->arrStartDay = $objDate->getDay();
86        // 登録・更新検索終了年
87        $objDate->setStartYear(RELEASE_YEAR);
88        $objDate->setEndYear(DATE("Y"));
89        $this->arrEndYear = $objDate->getYear();
90        $this->arrEndMonth = $objDate->getMonth();
91        $this->arrEndDay = $objDate->getDay();
92
93        // 認証可否の判定
94        SC_Utils_Ex::sfIsSuccess($objSess);
95
96        //レビュー情報のカラムの取得
97        $select="review_id, A.product_id, reviewer_name, sex, recommend_level, ";
98        $select.="reviewer_url, title, comment, A.status, A.create_date, A.update_date, name";
99        $from = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ";
100
101        // 検索ワードの引き継ぎ
102        foreach ($_POST as $key => $val) {
103            if (ereg("^search_", $key)) {
104                switch ($key){
105                case 'search_sex':
106                    $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
107                    if(!is_array($val)) {
108                        $this->arrForm[$key] = split("-", $val);
109                    }
110                    break;
111
112                default:
113                    $this->arrHidden[$key] = $val;
114                    break;
115                }
116            }
117        }
118
119        if (!isset($_POST['mode'])) $_POST['mode'] = "";
120
121        if ($_POST['mode'] == "delete"){
122            //レビューの削除
123            $objQuery->exec("UPDATE dtb_review SET del_flg=1 WHERE review_id=?", array($_POST['review_id']));
124        }
125
126        if ($_POST['mode'] == 'search' || $_POST['mode'] == 'csv' || $_POST['mode'] == 'delete'){
127
128            //削除されていない商品を検索
129            $where="A.del_flg = 0 AND B.del_flg = 0";
130            $this->arrForm = $_POST;
131            if (isset($_POST['search_sex']) && !is_array($_POST['search_sex'])){
132                $this->arrForm['search_sex'] = split("-", $_POST['search_sex']);
133            }
134            //エラーチェック
135            $this->arrErr = $this->lfCheckError();
136
137            if (!$this->arrErr){
138                foreach ($_POST as $key => $val){
139
140                    if($val == "") {
141                        continue;
142                    }
143
144                    switch ($key){
145                    case 'search_reviewer_name':
146                        $val = ereg_replace(" ", "%", $val);
147                        $val = ereg_replace(" ", "%", $val);
148                        $where.= " AND reviewer_name ILIKE ? ";
149                        $arrval[] = "%$val%";
150                        break;
151
152                    case 'search_reviewer_url':
153                        $val = ereg_replace(" ", "%", $val);
154                        $val = ereg_replace(" ", "%", $val);
155                        $where.= " AND reviewer_url ILIKE ? ";
156                        $arrval[] = "%$val%";
157                        break;
158
159                    case 'search_name':
160                        $val = ereg_replace(" ", "%", $val);
161                        $val = ereg_replace(" ", "%", $val);
162                        $where.= " AND name ILIKE ? ";
163                        $arrval[] = "%$val%";
164                        break;
165
166                    case 'search_product_code':
167                        $val = ereg_replace(" ", "%", $val);
168                        $val = ereg_replace(" ", "%", $val);
169                        $where.= " AND A.product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? )";
170                        $arrval[] = "%$val%";
171                        break;
172
173                    case 'search_sex':
174                        $tmp_where = "";
175                        //$val=配列の中身,$element=各キーの値(1,2)
176                        if (is_array($val)){
177                            foreach($val as $element) {
178                                if($element != "") {
179                                    if($tmp_where == "") {
180                                        $tmp_where .= " AND (sex = ?";
181                                    } else {
182                                        $tmp_where .= " OR sex = ?";
183                                    }
184                                    $arrval[] = $element;
185                                }
186                            }
187                            if($tmp_where != "") {
188                                $tmp_where .= ")";
189                                $where .= " $tmp_where ";
190                            }
191                        }
192
193                        break;
194
195                    case 'search_recommend_level':
196                        $where.= " AND recommend_level = ? ";
197                        $arrval[] = $val;
198                        break;
199
200                    case 'search_startyear':
201                        if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])){
202                            $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']);
203                            $where.= " AND A.create_date >= ? ";
204                            $arrval[] = $date;
205                        }
206                        break;
207
208                    case 'search_endyear':
209                        if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])){
210                            $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']);
211
212                            $end_date = date("Y/m/d",strtotime("1 day" ,strtotime($date)));
213
214                            $where.= " AND A.create_date <= cast('$end_date' as date) ";
215                        }
216                        break;
217                    }
218
219                }
220
221            }
222
223            $order = "A.create_date DESC";
224
225            // ページ送りの処理
226            if(is_numeric($_POST['search_page_max'])) {
227                $page_max = $_POST['search_page_max'];
228            } else {
229                $page_max = SEARCH_PMAX;
230            }
231
232            if (!isset($arrval)) $arrval = array();
233
234            $linemax = $objQuery->count($from, $where, $arrval);
235            $this->tpl_linemax = $linemax;
236
237            $this->tpl_pageno =
238                isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
239
240            // ページ送りの取得
241            $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $page_max,
242                                       "fnNaviSearchPage", NAVI_PMAX);
243            $this->arrPagenavi = $objNavi->arrPagenavi;
244            $startno = $objNavi->start_row;
245
246
247
248            // 取得範囲の指定(開始行番号、行数のセット)
249            $objQuery->setLimitOffset($page_max, $startno);
250
251            // 表示順序
252            $objQuery->setOrder($order);
253
254            //検索結果の取得
255            $this->arrReview = $objQuery->select($select, $from, $where, $arrval);
256
257            //CSVダウンロード
258            if ($_POST['mode'] == 'csv'){
259
260                $objCSV = new SC_Helper_CSV_Ex();
261                // オプションの指定
262                $option = "ORDER BY review_id";
263                // CSV出力タイトル行の作成
264                $head = SC_Utils_Ex::sfGetCSVList($objCSV->arrREVIEW_CVSTITLE);
265                $data = $objCSV->lfGetReviewCSV($where, '', $arrval);
266                // CSVを送信する。
267                SC_Utils_Ex::sfCSVDownload($head.$data);
268                exit;
269            }
270        }
271    }
272
273    /**
274     * デストラクタ.
275     *
276     * @return void
277     */
278    function destroy() {
279        parent::destroy();
280    }
281
282    // 入力エラーチェック
283    function lfCheckError() {
284        $objErr = new SC_CheckError();
285
286        if (!isset($_POST['mode'])) $_POST['mode'] = "";
287
288        switch ($_POST['mode']){
289        case 'search':
290            $objErr->doFunc(array("投稿者", "search_startyear", "search_startmonth", "search_startday"), array("CHECK_DATE"));
291            $objErr->doFunc(array("開始日", "search_startyear", "search_startmonth", "search_startday"), array("CHECK_DATE"));
292            $objErr->doFunc(array("終了日", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_DATE"));
293            $objErr->doFunc(array("開始日", "終了日", "search_startyear", "search_startmonth", "search_startday", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_SET_TERM"));
294            break;
295
296        case 'complete':
297            $objErr->doFunc(array("おすすめレベル", "recommend_level"), array("SELECT_CHECK"));
298            $objErr->doFunc(array("タイトル", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
299            $objErr->doFunc(array("コメント", "comment", LTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
300            break;
301        }
302        return $objErr->arrErr;
303    }
304}
305?>
Note: See TracBrowser for help on using the repository browser.