1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2011 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 = '商品管理'; |
---|
55 | $this->tpl_subtitle = 'レビュー管理'; |
---|
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 | $objFormParam = new SC_FormParam_Ex(); |
---|
77 | $this->lfInitParam($objFormParam); |
---|
78 | $objFormParam->setParam($_POST); |
---|
79 | $objFormParam->convParam(); |
---|
80 | // 検索ワードの引き継ぎ |
---|
81 | $this->arrSearchHidden = $objFormParam->getSearchArray(); |
---|
82 | $this->arrForm = $objFormParam->getHashArray(); |
---|
83 | |
---|
84 | switch ($this->getMode()) { |
---|
85 | // 登録 |
---|
86 | case 'complete': |
---|
87 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
88 | // エラー無し |
---|
89 | if (!$this->arrErr) { |
---|
90 | // レビュー情報の更新 |
---|
91 | $this->lfRegistReviewData($this->arrForm['review_id'], $objFormParam); |
---|
92 | // レビュー情報のDB取得 |
---|
93 | $this->arrForm = $this->lfGetReviewData($this->arrForm['review_id']); |
---|
94 | $this->tpl_onload = "alert('登録が完了しました。');"; |
---|
95 | } |
---|
96 | break; |
---|
97 | default: |
---|
98 | // レビュー情報のDB取得 |
---|
99 | $this->arrForm = $this->lfGetReviewData($this->arrForm['review_id']); |
---|
100 | break; |
---|
101 | } |
---|
102 | } |
---|
103 | |
---|
104 | /** |
---|
105 | * デストラクタ. |
---|
106 | * |
---|
107 | * @return void |
---|
108 | */ |
---|
109 | function destroy() { |
---|
110 | parent::destroy(); |
---|
111 | } |
---|
112 | |
---|
113 | /** |
---|
114 | * パラメータ情報の初期化を行う. |
---|
115 | * |
---|
116 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
117 | * @return void |
---|
118 | */ |
---|
119 | function lfInitParam(&$objFormParam) { |
---|
120 | // 検索条件のパラメータを初期化 |
---|
121 | parent::lfInitParam($objFormParam); |
---|
122 | $objFormParam->addParam("レビューID", "review_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
123 | $objFormParam->addParam("商品名", 'name', "", "", array(), "", false); |
---|
124 | $objFormParam->addParam("投稿日", "create_date", "", "", array(), "", false); |
---|
125 | |
---|
126 | // 登録情報 |
---|
127 | $objFormParam->addParam("レビュー表示", 'status', INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
128 | $objFormParam->addParam("投稿者名", "reviewer_name", STEXT_LEN, 'KVa', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
129 | $objFormParam->addParam("投稿者URL", "reviewer_url", URL_LEN, 'KVCa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
130 | $objFormParam->addParam("性別", 'sex', INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
131 | $objFormParam->addParam("おすすめレベル", "recommend_level", INT_LEN, 'n', array("SELECT_CHECK")); |
---|
132 | $objFormParam->addParam("タイトル", 'title', STEXT_LEN, 'KVa', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
133 | $objFormParam->addParam("コメント", 'comment', LTEXT_LEN, 'KVa', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
134 | } |
---|
135 | |
---|
136 | /** |
---|
137 | * フォーム入力パラメーターエラーチェック |
---|
138 | * |
---|
139 | * @param array $objFormParam フォームパラメータークラス |
---|
140 | * @return array エラー配列 |
---|
141 | */ |
---|
142 | function lfCheckError(&$objFormParam) { |
---|
143 | $arrErr = $objFormParam->checkError(); |
---|
144 | if (!SC_Utils_Ex::isBlank($arrErr)) { |
---|
145 | return $arrErr; |
---|
146 | } |
---|
147 | } |
---|
148 | |
---|
149 | /** |
---|
150 | * レビュー情報のDB取得 |
---|
151 | * |
---|
152 | * @param integer $review_id レビューID |
---|
153 | * @return array レビュー情報 |
---|
154 | */ |
---|
155 | function lfGetReviewData($review_id){ |
---|
156 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
157 | $select="review_id, A.product_id, reviewer_name, sex, recommend_level, "; |
---|
158 | $select.="reviewer_url, title, comment, A.status, A.create_date, A.update_date, name"; |
---|
159 | $from = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id "; |
---|
160 | $where = "A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? "; |
---|
161 | $arrReview = $objQuery->select($select, $from, $where, array($review_id)); |
---|
162 | if (empty($arrReview)) { |
---|
163 | SC_Utils_Ex::sfDispError(""); |
---|
164 | } |
---|
165 | return $arrReview[0]; |
---|
166 | } |
---|
167 | |
---|
168 | /** |
---|
169 | * レビュー情報の更新 |
---|
170 | * |
---|
171 | * @param integer $review_id レビューID |
---|
172 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
173 | * @return void |
---|
174 | */ |
---|
175 | function lfRegistReviewData($review_id, &$objFormParam){ |
---|
176 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
177 | $arrValues = $objFormParam->getDbArray(); |
---|
178 | $arrValues['update_date'] = 'now()'; |
---|
179 | $objQuery->update("dtb_review", $arrValues, "review_id = ?", array($review_id)); |
---|
180 | } |
---|
181 | } |
---|
182 | ?> |
---|