1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2012 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 CLASS_REALDIR . 'pages/admin/products/LC_Page_Admin_Products_Review.php'; |
---|
26 | |
---|
27 | /** |
---|
28 | * レビュー編集 のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Admin_Products_ReviewEdit extends LC_Page_Admin_Products_Review { |
---|
35 | |
---|
36 | // }}} |
---|
37 | // {{{ functions |
---|
38 | |
---|
39 | /** |
---|
40 | * Page を初期化する. |
---|
41 | * |
---|
42 | * @return void |
---|
43 | */ |
---|
44 | function init() { |
---|
45 | parent::init(); |
---|
46 | $this->tpl_mainpage = 'products/review_edit.tpl'; |
---|
47 | $this->tpl_mainno = 'products'; |
---|
48 | $this->tpl_subno = 'review'; |
---|
49 | // 両方選択可能 |
---|
50 | $this->tpl_status_change = true; |
---|
51 | |
---|
52 | $masterData = new SC_DB_MasterData_Ex(); |
---|
53 | $this->arrRECOMMEND = $masterData->getMasterData('mtb_recommend'); |
---|
54 | $this->tpl_maintitle = t('TPL_MAINTITLE_007'); |
---|
55 | $this->tpl_subtitle = t('LC_Page_Admin_Products_ReviewEdit_001'); |
---|
56 | $this->arrSex = $masterData->getMasterData('mtb_sex'); |
---|
57 | } |
---|
58 | |
---|
59 | /** |
---|
60 | * Page のプロセス. |
---|
61 | * |
---|
62 | * @return void |
---|
63 | */ |
---|
64 | function process() { |
---|
65 | $this->action(); |
---|
66 | $this->sendResponse(); |
---|
67 | } |
---|
68 | |
---|
69 | /** |
---|
70 | * Page のアクション. |
---|
71 | * |
---|
72 | * @return void |
---|
73 | */ |
---|
74 | function action() { |
---|
75 | |
---|
76 | // パラメーター情報の初期化 |
---|
77 | $objFormParam = new SC_FormParam_Ex(); |
---|
78 | $this->lfInitParam($objFormParam); |
---|
79 | $objFormParam->setParam($_POST); |
---|
80 | $objFormParam->convParam(); |
---|
81 | // 検索ワードの引き継ぎ |
---|
82 | $this->arrSearchHidden = $objFormParam->getSearchArray(); |
---|
83 | $this->arrForm = $objFormParam->getHashArray(); |
---|
84 | |
---|
85 | switch ($this->getMode()) { |
---|
86 | // 登録 |
---|
87 | case 'complete': |
---|
88 | $this->arrErr = $objFormParam->checkError(); |
---|
89 | // エラー無し |
---|
90 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
91 | // レビュー情報の更新 |
---|
92 | $this->lfRegistReviewData($this->arrForm['review_id'], $objFormParam); |
---|
93 | // レビュー情報のDB取得 |
---|
94 | $this->arrForm = $this->lfGetReviewData($this->arrForm['review_id']); |
---|
95 | $this->tpl_onload = "alert('" . t('ALERT_004') . "');"; |
---|
96 | } |
---|
97 | break; |
---|
98 | default: |
---|
99 | // レビュー情報のDB取得 |
---|
100 | $this->arrForm = $this->lfGetReviewData($this->arrForm['review_id']); |
---|
101 | break; |
---|
102 | } |
---|
103 | |
---|
104 | } |
---|
105 | |
---|
106 | /** |
---|
107 | * デストラクタ. |
---|
108 | * |
---|
109 | * @return void |
---|
110 | */ |
---|
111 | function destroy() { |
---|
112 | parent::destroy(); |
---|
113 | } |
---|
114 | |
---|
115 | /** |
---|
116 | * パラメーター情報の初期化を行う. |
---|
117 | * |
---|
118 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
119 | * @return void |
---|
120 | */ |
---|
121 | function lfInitParam(&$objFormParam) { |
---|
122 | // 検索条件のパラメーターを初期化 |
---|
123 | parent::lfInitParam($objFormParam); |
---|
124 | $objFormParam->addParam(t('PARAM_LABEL_REVIEW_ID'), 'review_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
125 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_NAME'), 'name', '', '', array(), '', false); |
---|
126 | $objFormParam->addParam(t('PARAM_LABEL_POST_DATE'), 'create_date', '', '', array(), '', false); |
---|
127 | |
---|
128 | // 登録情報 |
---|
129 | $objFormParam->addParam(t('PARAM_LABEL_DISP_REVIEWE'), 'status', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
130 | $objFormParam->addParam(t('PARAM_LABEL_REVIEWER_NAME'), 'reviewer_name', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
131 | $objFormParam->addParam(t('PARAM_LABEL_REVIEWER_URL'), 'reviewer_url', URL_LEN, 'KVCa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
132 | $objFormParam->addParam(t('c_Gender_01'), 'sex', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
133 | $objFormParam->addParam(t('PARAM_LABEL_RECOMMEND_LEVEL'), 'recommend_level', INT_LEN, 'n', array('SELECT_CHECK')); |
---|
134 | $objFormParam->addParam(t('PARAM_LABEL_TITLE'), 'title', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
135 | $objFormParam->addParam(t('PARAM_LABEL_COMMENT'), 'comment', LTEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
136 | } |
---|
137 | |
---|
138 | /** |
---|
139 | * レビュー情報のDB取得 |
---|
140 | * |
---|
141 | * @param integer $review_id レビューID |
---|
142 | * @return array レビュー情報 |
---|
143 | */ |
---|
144 | function lfGetReviewData($review_id) { |
---|
145 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
146 | $select='review_id, A.product_id, reviewer_name, sex, recommend_level, '; |
---|
147 | $select.='reviewer_url, title, comment, A.status, A.create_date, A.update_date, name'; |
---|
148 | $from = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id '; |
---|
149 | $where = 'A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? '; |
---|
150 | $arrReview = $objQuery->select($select, $from, $where, array($review_id)); |
---|
151 | if (empty($arrReview)) { |
---|
152 | SC_Utils_Ex::sfDispError(''); |
---|
153 | } |
---|
154 | return $arrReview[0]; |
---|
155 | } |
---|
156 | |
---|
157 | /** |
---|
158 | * レビュー情報の更新 |
---|
159 | * |
---|
160 | * @param integer $review_id レビューID |
---|
161 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
162 | * @return void |
---|
163 | */ |
---|
164 | function lfRegistReviewData($review_id, &$objFormParam) { |
---|
165 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
166 | $arrValues = $objFormParam->getDbArray(); |
---|
167 | $arrValues['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
168 | $objQuery->update('dtb_review', $arrValues, 'review_id = ?', array($review_id)); |
---|
169 | } |
---|
170 | } |
---|