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

Revision 22856, 7.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$
32 */
33class LC_Page_Contact extends LC_Page_Ex
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    function init()
41    {
42        parent::init();
43        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
44            $this->tpl_title = 'お問い合わせ';
45        } else {
46            $this->tpl_title = 'お問い合わせ(入力ページ)';
47        }
48        $this->tpl_page_category = 'contact';
49        $this->httpCacheControl('nocache');
50
51        $masterData = new SC_DB_MasterData_Ex();
52        $this->arrPref = $masterData->getMasterData('mtb_pref');
53
54        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
55            // @deprecated EC-CUBE 2.11 テンプレート互換用
56            $this->CONF = SC_Helper_DB_Ex::sfGetBasisData();
57        }
58    }
59
60    /**
61     * Page のプロセス.
62     *
63     * @return void
64     */
65    function process()
66    {
67        parent::process();
68        $this->action();
69        $this->sendResponse();
70    }
71
72    /**
73     * Page のアクション.
74     *
75     * @return void
76     */
77    function action()
78    {
79        $objDb = new SC_Helper_DB_Ex();
80        $objFormParam = new SC_FormParam_Ex();
81
82        $this->arrData = isset($_SESSION['customer']) ? $_SESSION['customer'] : '';
83
84        switch ($this->getMode()) {
85            case 'confirm':
86                // エラーチェック
87                $this->lfInitParam($objFormParam);
88                $objFormParam->setParam($_POST);
89                $objFormParam->convParam();
90                $objFormParam->toLower('email');
91                $objFormParam->toLower('email02');
92                $this->arrErr = $this->lfCheckError($objFormParam);
93                // 入力値の取得
94                $this->arrForm = $objFormParam->getFormParamList();
95
96                if (SC_Utils_Ex::isBlank($this->arrErr)) {
97                    // エラー無しで完了画面
98                    $this->tpl_mainpage = 'contact/confirm.tpl';
99                    $this->tpl_title = 'お問い合わせ(確認ページ)';
100                }
101
102                break;
103
104            case 'return':
105                $this->lfInitParam($objFormParam);
106                $objFormParam->setParam($_POST);
107                $this->arrForm = $objFormParam->getFormParamList();
108
109                break;
110
111            case 'complete':
112                $this->lfInitParam($objFormParam);
113                $objFormParam->setParam($_POST);
114                $this->arrErr = $objFormParam->checkError();
115                $this->arrForm = $objFormParam->getFormParamList();
116                if (SC_Utils_Ex::isBlank($this->arrErr)) {
117                    $this->lfSendMail($this);
118
119
120                    // 完了ページへ移動する
121                    SC_Response_Ex::sendRedirect('complete.php');
122                    SC_Response_Ex::actionExit();
123                } else {
124                    SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
125                    SC_Response_Ex::actionExit();
126                }
127                break;
128
129            default:
130                break;
131        }
132
133    }
134
135    /**
136     * デストラクタ.
137     *
138     * @return void
139     */
140    function destroy()
141    {
142        parent::destroy();
143    }
144
145    /**
146     * お問い合わせ入力時のパラメーター情報の初期化を行う.
147     *
148     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
149     * @return void
150     */
151    function lfInitParam(&$objFormParam)
152    {
153        $objFormParam->addParam('お名前(姓)', 'name01', STEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
154        $objFormParam->addParam('お名前(名)', 'name02', STEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
155        $objFormParam->addParam('お名前(フリガナ・姓)', 'kana01', STEXT_LEN, 'KVCa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK', 'KANA_CHECK'));
156        $objFormParam->addParam('お名前(フリガナ・名)', 'kana02', STEXT_LEN, 'KVCa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK', 'KANA_CHECK'));
157        $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n',array('SPTAB_CHECK' ,'NUM_CHECK', 'NUM_COUNT_CHECK'));
158        $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n',array('SPTAB_CHECK' ,'NUM_CHECK', 'NUM_COUNT_CHECK'));
159        $objFormParam->addParam('都道府県', 'pref', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
160        $objFormParam->addParam('住所1', 'addr01', MTEXT_LEN, 'KVa', array('SPTAB_CHECK' ,'MAX_LENGTH_CHECK'));
161        $objFormParam->addParam('住所2', 'addr02', MTEXT_LEN, 'KVa', array('SPTAB_CHECK' ,'MAX_LENGTH_CHECK'));
162        $objFormParam->addParam('お問い合わせ内容', 'contents', MLTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
163        $objFormParam->addParam('メールアドレス', 'email', null, 'KVa',array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK'));
164        $objFormParam->addParam('メールアドレス(確認)', 'email02', null, 'KVa',array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK'));
165        $objFormParam->addParam('お電話番号1', 'tel01', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
166        $objFormParam->addParam('お電話番号2', 'tel02', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
167        $objFormParam->addParam('お電話番号3', 'tel03', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
168    }
169
170    /**
171     * 入力内容のチェックを行なう.
172     *
173     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
174     * @return array 入力チェック結果の配列
175     */
176    function lfCheckError(&$objFormParam)
177    {
178        // 入力データを渡す。
179        $arrForm =  $objFormParam->getHashArray();
180        $objErr = new SC_CheckError_Ex($arrForm);
181        $objErr->arrErr = $objFormParam->checkError();
182        $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', 'email', 'email02') ,array('EQUAL_CHECK'));
183
184        return $objErr->arrErr;
185    }
186
187    /**
188     * メールの送信を行う。
189     *
190     * @return void
191     */
192    function lfSendMail(&$objPage)
193    {
194        $CONF = SC_Helper_DB_Ex::sfGetBasisData();
195        $objPage->tpl_shopname = $CONF['shop_name'];
196        $objPage->tpl_infoemail = $CONF['email02'];
197        $helperMail = new SC_Helper_Mail_Ex();
198        $helperMail->setPage($this);
199        $helperMail->sfSendTemplateMail(
200            $objPage->arrForm['email']['value'],            // to
201            $objPage->arrForm['name01']['value'] .' 様',    // to_name
202            5,                                              // template_id
203            $objPage,                                       // objPage
204            $CONF['email03'],                               // from_address
205            $CONF['shop_name'],                             // from_name
206            $CONF['email02'],                               // reply_to
207            $CONF['email02']                                // bcc
208        );
209    }
210}
Note: See TracBrowser for help on using the repository browser.