source: branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Review.php @ 22856

Revision 22856, 6.9 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 主に空白・空白行の調整。もう少し整えたいが、一旦現状コミット。
  • 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
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26/**
27 * お客様の声投稿のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id:LC_Page_Products_Review.php 15532 2007-08-31 14:39:46Z nanasess $
32 */
33class LC_Page_Products_Review extends LC_Page_Ex
34{
35    /** おすすめレベル */
36    var $arrRECOMMEND;
37
38    /** 性別 */
39    var $arrSex;
40
41    /** 入力禁止URL */
42    var $arrReviewDenyURL;
43
44
45    /**
46     * Page を初期化する.
47     *
48     * @return void
49     */
50    function init()
51    {
52        parent::init();
53
54        $masterData = new SC_DB_MasterData_Ex();
55        $this->arrRECOMMEND = $masterData->getMasterData('mtb_recommend');
56        $this->arrSex = $masterData->getMasterData('mtb_sex');
57        $this->arrReviewDenyURL = $masterData->getMasterData('mtb_review_deny_url');
58        $this->tpl_mainpage = 'products/review.tpl';
59        $this->httpCacheControl('nocache');
60    }
61
62    /**
63     * Page のプロセス.
64     */
65    function process()
66    {
67        parent::process();
68        $this->action();
69        $this->sendResponse();
70    }
71
72    /**
73     * Page のAction.
74     *
75     * @return void
76     */
77    function action()
78    {
79        $objFormParam = new SC_FormParam_Ex();
80        $this->lfInitParam($objFormParam);
81        $objFormParam->setParam($_POST);
82        $objFormParam->convParam();
83
84        switch ($this->getMode()) {
85            case 'confirm':
86                $this->arrErr = $this->lfCheckError($objFormParam);
87
88                //エラーチェック
89                if (empty($this->arrErr)) {
90                    //重複タイトルでない
91                    $this->tpl_mainpage = 'products/review_confirm.tpl';
92                }
93                break;
94
95            case 'return':
96                break;
97
98            case 'complete':
99                $this->arrErr = $this->lfCheckError($objFormParam);
100                //エラーチェック
101                if (empty($this->arrErr)) {
102                    //登録実行
103                    $this->lfRegistRecommendData($objFormParam);
104
105
106                    //レビュー書き込み完了ページへ
107                    SC_Response_Ex::sendRedirect('review_complete.php');
108                    SC_Response_Ex::actionExit();
109                }
110                break;
111
112            default:
113                // 最初のproduct_idは、$_GETで渡ってくる。
114                $objFormParam->setParam($_GET);
115                break;
116        }
117
118        $this->arrForm = $objFormParam->getHashArray();
119
120        //商品名の取得
121        $this->arrForm['name'] = $this->lfGetProductName($this->arrForm['product_id']);
122        if (empty($this->arrForm['name'])) {
123            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
124        }
125
126        $this->setTemplate($this->tpl_mainpage);
127
128
129    }
130
131    /**
132     * デストラクタ.
133     *
134     * @return void
135     */
136    function destroy()
137    {
138        parent::destroy();
139    }
140
141    /**
142     * パラメーター情報の初期化を行う.
143     *
144     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
145     * @return void
146     */
147    function lfInitParam(&$objFormParam)
148    {
149        $objFormParam->addParam('レビューID', 'review_id', INT_LEN, 'aKV');
150        $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('NUM_CHECK','EXIST_CHECK', 'MAX_LENGTH_CHECK'));
151        $objFormParam->addParam('投稿者名', 'reviewer_name', STEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
152        $objFormParam->addParam('投稿者URL', 'reviewer_url', MTEXT_LEN, 'a', array('NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'URL_CHECK'));
153        $objFormParam->addParam('性別', 'sex', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
154        $objFormParam->addParam('おすすめレベル', 'recommend_level', INT_LEN, 'n', array('EXIST_CHECK', 'SELECT_CHECK'));
155        $objFormParam->addParam('タイトル', 'title', STEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
156        $objFormParam->addParam('コメント', 'comment', LTEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
157    }
158
159    /**
160     * 入力内容のチェックを行う.
161     *
162     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
163     * @return array エラーメッセージの配列
164     */
165    function lfCheckError(&$objFormParam)
166    {
167        $arrErr = $objFormParam->checkError();
168
169        $arrForm = $objFormParam->getHashArray();
170
171        // 重複メッセージの判定
172        $objQuery =& SC_Query_Ex::getSingletonInstance();
173        $exists = $objQuery->exists('dtb_review','product_id = ? AND title = ? ', array($arrForm['product_id'], $arrForm['title']));
174        if ($exists) {
175            $arrErr['title'] .= '重複したタイトルは登録できません。';
176        }
177
178        if (REVIEW_ALLOW_URL == false) {
179            $objErr = new SC_CheckError_Ex($objFormParam->getHashArray());
180            // コメント欄へのURLの入力を禁止
181            $objErr->doFunc(array('URL', 'comment', $this->arrReviewDenyURL), array('PROHIBITED_STR_CHECK'));
182            $arrErr += $objErr->arrErr;
183        }
184
185        return $arrErr;
186    }
187
188    /**
189     * 商品名を取得
190     *
191     * @param integer $product_id 商品ID
192     * @return string $product_name 商品名
193     */
194    function lfGetProductName($product_id)
195    {
196        $objQuery =& SC_Query_Ex::getSingletonInstance();
197
198        return $objQuery->get('name', 'dtb_products', 'product_id = ? AND ' . SC_Product_Ex::getProductDispConditions(), array($product_id));
199    }
200
201    //登録実行
202    function lfRegistRecommendData(&$objFormParam)
203    {
204        $objQuery =& SC_Query_Ex::getSingletonInstance();
205        $arrRegist = $objFormParam->getDbArray();
206
207        $arrRegist['create_date'] = 'CURRENT_TIMESTAMP';
208        $arrRegist['update_date'] = 'CURRENT_TIMESTAMP';
209        $arrRegist['creator_id'] = '0';
210
211        //-- 登録実行
212        $objQuery->begin();
213        $arrRegist['review_id'] = $objQuery->nextVal('dtb_review_review_id');
214        $objQuery->insert('dtb_review', $arrRegist);
215        $objQuery->commit();
216    }
217}
Note: See TracBrowser for help on using the repository browser.