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

Revision 22931, 7.7 KB checked in by Seasoft, 11 years ago (diff)

#2291 (利用ガイドブロック selected クラスの指定に誤り)
#2140 (標準テンプレートのカスタマイズ性を高める)
#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • html ヘッダーを「charset -> title -> meta -> link -> script」の順に整えた。ただし、スマートフォンは定義が複雑なので、link, script の混在は残した。

#2044 (無駄な処理を改善する for 2.13.0)

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