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

Revision 22567, 7.0 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

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