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