| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * @package Dolphin Core |
|---|
| 4 | * @copyright Copyright (c) BoonEx Pty Limited - http://www.boonex.com/ |
|---|
| 5 | * @license CC-BY - http://creativecommons.org/licenses/by/3.0/ |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | // TODO: move to separate module |
|---|
| 9 | |
|---|
| 10 | require_once('./inc/header.inc.php'); |
|---|
| 11 | require_once(BX_DIRECTORY_PATH_INC . "params.inc.php"); |
|---|
| 12 | require_once(BX_DIRECTORY_PATH_INC . "design.inc.php"); |
|---|
| 13 | |
|---|
| 14 | bx_import('BxDolLanguages'); |
|---|
| 15 | bx_import('BxDolMenu'); |
|---|
| 16 | bx_import('BxDolTemplate'); |
|---|
| 17 | |
|---|
| 18 | BxDolMenu::setSelected ('system', 'contact'); |
|---|
| 19 | |
|---|
| 20 | $oTemplate = BxDolTemplate::getInstance(); |
|---|
| 21 | $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT); |
|---|
| 22 | $oTemplate->setPageHeader (_t("_CONTACT_H")); |
|---|
| 23 | $oTemplate->setPageContent ('page_main_code', PageCompPageMainCodeWithForm()); |
|---|
| 24 | $oTemplate->getPageCode(); |
|---|
| 25 | |
|---|
| 26 | /** |
|---|
| 27 | * page code function with contact form |
|---|
| 28 | */ |
|---|
| 29 | function PageCompPageMainCodeWithForm() { |
|---|
| 30 | |
|---|
| 31 | $sActionText = ''; |
|---|
| 32 | |
|---|
| 33 | $aFormNested = array( |
|---|
| 34 | |
|---|
| 35 | 'inputs' => array( |
|---|
| 36 | 'file_name' => array( |
|---|
| 37 | 'type' => 'text', |
|---|
| 38 | 'name' => 'file_name[]', |
|---|
| 39 | 'value' => '{file_title}', |
|---|
| 40 | 'caption' => _t('Caption'), |
|---|
| 41 | 'required' => true, |
|---|
| 42 | 'checker' => array( |
|---|
| 43 | 'func' => 'length', |
|---|
| 44 | 'params' => array(1, 150), |
|---|
| 45 | 'error' => _t( 'Caption name is required' ) |
|---|
| 46 | ), |
|---|
| 47 | ), |
|---|
| 48 | |
|---|
| 49 | 'file_desc' => array( |
|---|
| 50 | 'type' => 'textarea', |
|---|
| 51 | 'name' => 'file_desc[]', |
|---|
| 52 | 'caption' => _t('Description'), |
|---|
| 53 | 'required' => true, |
|---|
| 54 | 'checker' => array( |
|---|
| 55 | 'func' => 'length', |
|---|
| 56 | 'params' => array(10, 5000), |
|---|
| 57 | 'error' => _t( '_ps_ferr_incorrect_length' ) |
|---|
| 58 | ), |
|---|
| 59 | ), |
|---|
| 60 | |
|---|
| 61 | ), |
|---|
| 62 | ); |
|---|
| 63 | |
|---|
| 64 | bx_import('BxDolFormNested'); |
|---|
| 65 | $oFormNested = new BxDolFormNested('attachment', $aFormNested, 'do_submit'); |
|---|
| 66 | |
|---|
| 67 | $aForm = array( |
|---|
| 68 | 'form_attrs' => array( |
|---|
| 69 | 'id' => 'post_us_form', |
|---|
| 70 | 'action' => BX_DOL_URL_ROOT . 'contact.php', |
|---|
| 71 | 'method' => 'post', |
|---|
| 72 | ), |
|---|
| 73 | 'params' => array ( |
|---|
| 74 | 'db' => array( |
|---|
| 75 | 'submit_name' => 'do_submit', |
|---|
| 76 | ), |
|---|
| 77 | ), |
|---|
| 78 | 'inputs' => array( |
|---|
| 79 | 'name' => array( |
|---|
| 80 | 'type' => 'text', |
|---|
| 81 | 'name' => 'name', |
|---|
| 82 | 'caption' => _t('_Your name'), |
|---|
| 83 | 'required' => true, |
|---|
| 84 | 'checker' => array( |
|---|
| 85 | 'func' => 'length', |
|---|
| 86 | 'params' => array(1, 150), |
|---|
| 87 | 'error' => _t( '_Name is required' ) |
|---|
| 88 | ), |
|---|
| 89 | ), |
|---|
| 90 | 'email' => array( |
|---|
| 91 | 'type' => 'text', |
|---|
| 92 | 'name' => 'email', |
|---|
| 93 | 'caption' => _t('_Your email'), |
|---|
| 94 | 'required' => true, |
|---|
| 95 | 'checker' => array( |
|---|
| 96 | 'func' => 'email', |
|---|
| 97 | 'error' => _t( '_Incorrect Email' ) |
|---|
| 98 | ), |
|---|
| 99 | ), |
|---|
| 100 | 'message_subject' => array( |
|---|
| 101 | 'type' => 'text', |
|---|
| 102 | 'name' => 'subject', |
|---|
| 103 | 'caption' => _t('_message_subject'), |
|---|
| 104 | 'required' => true, |
|---|
| 105 | 'checker' => array( |
|---|
| 106 | 'func' => 'length', |
|---|
| 107 | 'params' => array(5, 300), |
|---|
| 108 | 'error' => _t( '_ps_ferr_incorrect_length' ) |
|---|
| 109 | ), |
|---|
| 110 | ), |
|---|
| 111 | 'message_text' => array( |
|---|
| 112 | 'type' => 'textarea', |
|---|
| 113 | 'name' => 'body', |
|---|
| 114 | 'caption' => _t('_Message text'), |
|---|
| 115 | 'required' => true, |
|---|
| 116 | 'checker' => array( |
|---|
| 117 | 'func' => 'length', |
|---|
| 118 | 'params' => array(10, 5000), |
|---|
| 119 | 'error' => _t( '_ps_ferr_incorrect_length' ) |
|---|
| 120 | ), |
|---|
| 121 | ), |
|---|
| 122 | |
|---|
| 123 | 'attachment' => array( |
|---|
| 124 | 'type' => 'files', |
|---|
| 125 | 'storage_object' => 'sample2', |
|---|
| 126 | 'uploaders' => array ('Simple', 'HTML5'), |
|---|
| 127 | 'images_transcoder' => 'sample2', |
|---|
| 128 | 'multiple' => true, |
|---|
| 129 | 'content_id' => 0, |
|---|
| 130 | 'ghost_template' => |
|---|
| 131 | $oFormNested, |
|---|
| 132 | // $aFormNested, |
|---|
| 133 | /* |
|---|
| 134 | '<div id="bx-uploader-file-{file_id}" class="bx-uploader-ghost"> |
|---|
| 135 | <div style="border:2px dotted green; padding:10px; margin-bottom:10px;"> |
|---|
| 136 | <input type="hidden" name="f[]" value="{file_id}" /> |
|---|
| 137 | {file_name} <br /> |
|---|
| 138 | <a href="javascript:void(0);" onclick="{js_instance_name}.deleteGhost(\'{file_id}\')">delete</a> |
|---|
| 139 | </div> |
|---|
| 140 | </div>', |
|---|
| 141 | */ |
|---|
| 142 | 'name' => 'attachment', |
|---|
| 143 | 'caption' => _t('Attachments'), |
|---|
| 144 | // 'required' => true, // TODO: |
|---|
| 145 | ), |
|---|
| 146 | /* |
|---|
| 147 | 'captcha' => array( |
|---|
| 148 | 'type' => 'captcha', |
|---|
| 149 | 'caption' => _t('_Enter what you see:'), |
|---|
| 150 | 'name' => 'securityImageValue', |
|---|
| 151 | 'required' => true, |
|---|
| 152 | 'checker' => array( |
|---|
| 153 | 'func' => 'captcha', |
|---|
| 154 | 'error' => _t( '_Incorrect Captcha' ), |
|---|
| 155 | ), |
|---|
| 156 | ), |
|---|
| 157 | */ |
|---|
| 158 | 'submit' => array( |
|---|
| 159 | 'type' => 'input_set', |
|---|
| 160 | 0 => array ( |
|---|
| 161 | 'type' => 'submit', |
|---|
| 162 | 'name' => 'do_submit', |
|---|
| 163 | 'value' => _t('_Submit'), |
|---|
| 164 | ), |
|---|
| 165 | 1 => array ( |
|---|
| 166 | 'type' => 'reset', |
|---|
| 167 | 'name' => 'close', |
|---|
| 168 | 'value' => _t('_Reset'), |
|---|
| 169 | 'attrs' => array('class' => 'bx-def-margin-sec-left'), |
|---|
| 170 | ), |
|---|
| 171 | ), |
|---|
| 172 | |
|---|
| 173 | ), |
|---|
| 174 | ); |
|---|
| 175 | |
|---|
| 176 | bx_import('BxTemplFormView'); |
|---|
| 177 | $oForm = new BxTemplFormView($aForm); |
|---|
| 178 | $oForm->initChecker(); |
|---|
| 179 | if ( $oForm->isSubmittedAndValid() ) { |
|---|
| 180 | $sSenderName = bx_process_output(bx_process_input($_POST['name'], BX_DATA_TEXT_MULTILINE), BX_DATA_TEXT_MULTILINE); |
|---|
| 181 | $sSenderEmail = bx_process_output(bx_process_input($_POST['email'], BX_DATA_TEXT_MULTILINE), BX_DATA_TEXT_MULTILINE); |
|---|
| 182 | $sLetterSubject = bx_process_output(bx_process_input($_POST['subject'], BX_DATA_TEXT_MULTILINE), BX_DATA_TEXT_MULTILINE); |
|---|
| 183 | $sLetterBody = bx_process_output(bx_process_input($_POST['body'], BX_DATA_TEXT_MULTILINE), BX_DATA_TEXT_MULTILINE); |
|---|
| 184 | |
|---|
| 185 | $sLetterBody = $sLetterBody . "\r\n" . '============' . "\r\n" . _t('_from') . ' ' . $sSenderName . "\r\n" . 'with email ' . $sSenderEmail; |
|---|
| 186 | |
|---|
| 187 | if (sendMail(getParam('site_email'), $sLetterSubject, $sLetterBody, 0, array(), BX_EMAIL_SYSTEM)) { |
|---|
| 188 | $sActionKey = '_ADM_PROFILE_SEND_MSG'; |
|---|
| 189 | } else { |
|---|
| 190 | $sActionKey = '_Email sent failed'; |
|---|
| 191 | } |
|---|
| 192 | $sActionText = MsgBox(_t($sActionKey)); |
|---|
| 193 | } |
|---|
| 194 | |
|---|
| 195 | $sForm = $sActionText . $oForm->getCode(); |
|---|
| 196 | return DesignBoxContent(_t('_CONTACT_H1'), $sForm, BX_DB_PADDING_DEF); |
|---|
| 197 | } |
|---|
| 198 | |
|---|