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

Revision 23082, 6.8 KB checked in by Seasoft, 11 years ago (diff)

#2327 (SC_Helper_PageLayout#sfGetPageLayout ページ情報が取得できない場合の動作が不定)

  • 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     * Page を初期化する.
46     *
47     * @return void
48     */
49    function init()
50    {
51        $this->skip_load_page_layout = true;
52
53        parent::init();
54
55        $masterData = new SC_DB_MasterData_Ex();
56        $this->arrRECOMMEND = $masterData->getMasterData('mtb_recommend');
57        $this->arrSex = $masterData->getMasterData('mtb_sex');
58        $this->arrReviewDenyURL = $masterData->getMasterData('mtb_review_deny_url');
59        $this->tpl_mainpage = 'products/review.tpl';
60        $this->httpCacheControl('nocache');
61    }
62
63    /**
64     * Page のプロセス.
65     */
66    function process()
67    {
68        parent::process();
69        $this->action();
70        $this->sendResponse();
71    }
72
73    /**
74     * Page のAction.
75     *
76     * @return void
77     */
78    function action()
79    {
80        $objFormParam = new SC_FormParam_Ex();
81        $this->lfInitParam($objFormParam);
82        $objFormParam->setParam($_POST);
83        $objFormParam->convParam();
84
85        switch ($this->getMode()) {
86            case 'confirm':
87                $this->arrErr = $this->lfCheckError($objFormParam);
88
89                //エラーチェック
90                if (empty($this->arrErr)) {
91                    //重複タイトルでない
92                    $this->tpl_mainpage = 'products/review_confirm.tpl';
93                }
94                break;
95
96            case 'return':
97                break;
98
99            case 'complete':
100                $this->arrErr = $this->lfCheckError($objFormParam);
101                //エラーチェック
102                if (empty($this->arrErr)) {
103                    //登録実行
104                    $this->lfRegistRecommendData($objFormParam);
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     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
133     * @return void
134     */
135    function lfInitParam(&$objFormParam)
136    {
137        $objFormParam->addParam('レビューID', 'review_id', INT_LEN, 'aKV');
138        $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('NUM_CHECK','EXIST_CHECK', 'MAX_LENGTH_CHECK'));
139        $objFormParam->addParam('投稿者名', 'reviewer_name', STEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
140        $objFormParam->addParam('投稿者URL', 'reviewer_url', MTEXT_LEN, 'a', array('NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'URL_CHECK'));
141        $objFormParam->addParam('性別', 'sex', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
142        $objFormParam->addParam('おすすめレベル', 'recommend_level', INT_LEN, 'n', array('EXIST_CHECK', 'SELECT_CHECK'));
143        $objFormParam->addParam('タイトル', 'title', STEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
144        $objFormParam->addParam('コメント', 'comment', LTEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
145    }
146
147    /**
148     * 入力内容のチェックを行う.
149     *
150     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
151     * @return array エラーメッセージの配列
152     */
153    function lfCheckError(&$objFormParam)
154    {
155        $arrErr = $objFormParam->checkError();
156
157        $arrForm = $objFormParam->getHashArray();
158
159        // 重複メッセージの判定
160        $objQuery =& SC_Query_Ex::getSingletonInstance();
161        $exists = $objQuery->exists('dtb_review','product_id = ? AND title = ? ', array($arrForm['product_id'], $arrForm['title']));
162        if ($exists) {
163            $arrErr['title'] .= '重複したタイトルは登録できません。';
164        }
165
166        if (REVIEW_ALLOW_URL == false) {
167            $objErr = new SC_CheckError_Ex($objFormParam->getHashArray());
168            // コメント欄へのURLの入力を禁止
169            $objErr->doFunc(array('URL', 'comment', $this->arrReviewDenyURL), array('PROHIBITED_STR_CHECK'));
170            $arrErr += $objErr->arrErr;
171        }
172
173        return $arrErr;
174    }
175
176    /**
177     * 商品名を取得
178     *
179     * @param integer $product_id 商品ID
180     * @return string $product_name 商品名
181     */
182    function lfGetProductName($product_id)
183    {
184        $objQuery =& SC_Query_Ex::getSingletonInstance();
185
186        return $objQuery->get('name', 'dtb_products', 'product_id = ? AND ' . SC_Product_Ex::getProductDispConditions(), array($product_id));
187    }
188
189    //登録実行
190    function lfRegistRecommendData(&$objFormParam)
191    {
192        $objQuery =& SC_Query_Ex::getSingletonInstance();
193        $arrRegist = $objFormParam->getDbArray();
194
195        $arrRegist['create_date'] = 'CURRENT_TIMESTAMP';
196        $arrRegist['update_date'] = 'CURRENT_TIMESTAMP';
197        $arrRegist['creator_id'] = '0';
198
199        //-- 登録実行
200        $objQuery->begin();
201        $arrRegist['review_id'] = $objQuery->nextVal('dtb_review_review_id');
202        $objQuery->insert('dtb_review', $arrRegist);
203        $objQuery->commit();
204    }
205}
Note: See TracBrowser for help on using the repository browser.