contact.php 6.9 KB

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