/dottystyle/wp-content/plugins/si-contact-form/si-contact-form-ex-fields.php

https://github.com/dottystylecreative/Dottystyle-Style · PHP · 698 lines · 626 code · 37 blank · 35 comment · 263 complexity · 5af0522636f7a1403950f741f53f3834 MD5 · raw file

  1. <?php
  2. /*
  3. Fast Secure Contact Form
  4. Mike Challis
  5. http://www.642weather.com/weather/scripts.php
  6. */
  7. // display extra fields on the contact form
  8. $ex_fieldset = 0;
  9. $printed_tooltip_filetypes = 0;
  10. $ex_loop_cnt = 1;
  11. for ($i = 1; $i <= $si_contact_opt['max_fields']; $i++) {
  12. if ($si_contact_opt['ex_field'.$i.'_label'] != '' || $si_contact_opt['ex_field'.$i.'_type'] == 'fieldset-close') {
  13. $ex_req_field_ind = ($si_contact_opt['ex_field'.$i.'_req'] == 'true') ? $req_field_ind : '';
  14. $ex_req_field_aria = ($si_contact_opt['ex_field'.$i.'_req'] == 'true') ? $this->ctf_aria_required : '';
  15. if(!$si_contact_opt['ex_field'.$i.'_type'] ) $si_contact_opt['ex_field'.$i.'_type'] = 'text';
  16. if(!$si_contact_opt['ex_field'.$i.'_default'] ) $si_contact_opt['ex_field'.$i.'_default'] = '0';
  17. if(!$si_contact_opt['ex_field'.$i.'_default_text'] ) $si_contact_opt['ex_field'.$i.'_default_text'] = '';
  18. if(!$si_contact_opt['ex_field'.$i.'_max_len'] ) $si_contact_opt['ex_field'.$i.'_max_len'] = '';
  19. if(!$si_contact_opt['ex_field'.$i.'_label_css'] ) $si_contact_opt['ex_field'.$i.'_label_css'] = '';
  20. if(!$si_contact_opt['ex_field'.$i.'_input_css'] ) $si_contact_opt['ex_field'.$i.'_input_css'] = '';
  21. if(!$si_contact_opt['ex_field'.$i.'_attributes'] ) $si_contact_opt['ex_field'.$i.'_attributes'] = '';
  22. if(!$si_contact_opt['ex_field'.$i.'_regex'] ) $si_contact_opt['ex_field'.$i.'_regex'] = '';
  23. if(!$si_contact_opt['ex_field'.$i.'_regex_error'] ) $si_contact_opt['ex_field'.$i.'_regex_error'] = '';
  24. if(!$si_contact_opt['ex_field'.$i.'_notes'] ) $si_contact_opt['ex_field'.$i.'_notes'] = '';
  25. if(!$si_contact_opt['ex_field'.$i.'_notes_after'] ) $si_contact_opt['ex_field'.$i.'_notes_after'] = '';
  26. switch ($si_contact_opt['ex_field'.$i.'_type']) {
  27. case 'fieldset':
  28. if($ex_fieldset)
  29. $string .= "</fieldset>\n";
  30. if($si_contact_opt['ex_field'.$i.'_notes'] != '') {
  31. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes']);
  32. }
  33. $string .= '<fieldset '.$this->ctf_border_style.'>
  34. <legend>' . $si_contact_opt['ex_field'.$i.'_label'] ."</legend>\n";
  35. $ex_fieldset = 1;
  36. break;
  37. case 'fieldset-close':
  38. if($ex_fieldset)
  39. $string .= "</fieldset>\n";
  40. $ex_fieldset = 0;
  41. break;
  42. case 'hidden':
  43. $exf_opts_label = ''; $value = '';
  44. if(preg_match("/,/", $si_contact_opt['ex_field'.$i.'_label']) )
  45. list($exf_opts_label, $value) = explode(",",$si_contact_opt['ex_field'.$i.'_label']);
  46. $exf_opts_label = trim($exf_opts_label); $value = trim($value);
  47. if ($exf_opts_label == '' || $value == '') {
  48. // error
  49. $this->si_contact_error = 1;
  50. $string .= $this->ctf_echo_if_error(__('Error: A hidden field is not configured properly in settings.', 'si-contact-form'));
  51. }
  52. if (${'ex_field'.$i} != '') // guery string can overrride
  53. $value = ${'ex_field'.$i};
  54. $string .= '
  55. <input type="hidden" name="si_contact_ex_field'.$i.'" value="' . $this->ctf_output_string($value) . '" />
  56. ';
  57. break;
  58. case 'password':
  59. if($si_contact_opt['ex_field'.$i.'_notes'] != '') {
  60. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes']);
  61. }
  62. $string .= '
  63. <div ';
  64. $string .= ($si_contact_opt['ex_field'.$i.'_label_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_label_css']) : $this->ctf_title_style;
  65. $string .= '>
  66. <label for="si_contact_ex_field'.$form_id_num.'_'.$i.'">' . $si_contact_opt['ex_field'.$i.'_label'] . $ex_req_field_ind.'</label>
  67. </div>
  68. <div '.$this->ctf_field_div_style.'>'.$this->ctf_echo_if_error(${'si_contact_error_ex_field'.$i}).'
  69. <input '.$this->ctf_field_style.' type="password" id="si_contact_ex_field'.$form_id_num.'_'.$i.'" name="si_contact_ex_field'.$i.'" value="' . $this->ctf_output_string(${'ex_field'.$i}) . '" '.$ex_req_field_aria.' ';
  70. if($si_contact_opt['ex_field'.$i.'_max_len'] != '')
  71. $string .= ' maxlength="'.$si_contact_opt['ex_field'.$i.'_max_len'].'" ';
  72. $string .= 'size="'.$ctf_field_size.'"';
  73. if($si_contact_opt['ex_field'.$i.'_attributes'] != '')
  74. $string .= ' '.$si_contact_opt['ex_field'.$i.'_attributes'];
  75. $string .= ' />
  76. </div>
  77. ';
  78. if($si_contact_opt['ex_field'.$i.'_notes_after'] != '') {
  79. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes_after']);
  80. }
  81. break;
  82. case 'text':
  83. case 'email':
  84. case 'url':
  85. if($si_contact_opt['ex_field'.$i.'_notes'] != '') {
  86. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes']);
  87. }
  88. $string .= '
  89. <div ';
  90. $string .= ($si_contact_opt['ex_field'.$i.'_label_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_label_css']) : $this->ctf_title_style;
  91. $string .= '>
  92. <label for="si_contact_ex_field'.$form_id_num.'_'.$i.'">' . $si_contact_opt['ex_field'.$i.'_label'] . $ex_req_field_ind.'</label>
  93. </div>
  94. <div '.$this->ctf_field_div_style.'>'.$this->ctf_echo_if_error(${'si_contact_error_ex_field'.$i}).'
  95. <input ';
  96. $string .= ($si_contact_opt['ex_field'.$i.'_input_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_input_css']) : $this->ctf_field_style;
  97. $string .= ' type="'.$si_contact_opt['ex_field'.$i.'_type'].'" id="si_contact_ex_field'.$form_id_num.'_'.$i.'" name="si_contact_ex_field'.$i.'" value="';
  98. if($si_contact_opt['ex_field'.$i.'_default_text'] != '' && ${'ex_field'.$i} == '')
  99. $string .= $this->ctf_output_string($si_contact_opt['ex_field'.$i.'_default_text']);
  100. else
  101. $string .= $this->ctf_output_string(${'ex_field'.$i});
  102. $string .= '" '.$ex_req_field_aria.' ';
  103. if($si_contact_opt['ex_field'.$i.'_max_len'] != '')
  104. $string .= ' maxlength="'.$si_contact_opt['ex_field'.$i.'_max_len'].'" ';
  105. $string .= 'size="'.$ctf_field_size.'"';
  106. if($si_contact_opt['ex_field'.$i.'_attributes'] != '')
  107. $string .= ' '.$si_contact_opt['ex_field'.$i.'_attributes'];
  108. $string .= ' />
  109. </div>
  110. ';
  111. if($si_contact_opt['ex_field'.$i.'_notes_after'] != '') {
  112. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes_after']);
  113. }
  114. break;
  115. case 'textarea':
  116. if($si_contact_opt['ex_field'.$i.'_notes'] != '') {
  117. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes']);
  118. }
  119. $string .= '
  120. <div ';
  121. $string .= ($si_contact_opt['ex_field'.$i.'_label_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_label_css']) : $this->ctf_title_style;
  122. $string .= '>
  123. <label for="si_contact_ex_field'.$form_id_num.'_'.$i.'">' . $si_contact_opt['ex_field'.$i.'_label'] . $ex_req_field_ind.'</label>
  124. </div>
  125. <div '.$this->ctf_field_div_style.'>'.$this->ctf_echo_if_error(${'si_contact_error_ex_field'.$i}).'
  126. <textarea ';
  127. $string .= ($si_contact_opt['ex_field'.$i.'_input_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_input_css']) : $this->ctf_field_style;
  128. $string .= ' id="si_contact_ex_field'.$form_id_num.'_'.$i.'" name="si_contact_ex_field'.$i.'" '.$ex_req_field_aria.' cols="'.absint($si_contact_opt['text_cols']).'" rows="'.absint($si_contact_opt['text_rows']).'"';
  129. if($si_contact_opt['ex_field'.$i.'_attributes'] != '')
  130. $string .= ' '.$si_contact_opt['ex_field'.$i.'_attributes'];
  131. $string .= '>';
  132. if($si_contact_opt['ex_field'.$i.'_default_text'] != '' && ${'ex_field'.$i} == '')
  133. $string .= $this->ctf_output_string($si_contact_opt['ex_field'.$i.'_default_text']);
  134. else
  135. $string .= ($si_contact_opt['textarea_html_allow'] == 'true') ? $this->ctf_stripslashes(${'ex_field'.$i}) : $this->ctf_output_string(${'ex_field'.$i});
  136. $string .= '</textarea>
  137. </div>
  138. ';
  139. if($si_contact_opt['ex_field'.$i.'_notes_after'] != '') {
  140. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes_after']);
  141. }
  142. break;
  143. case 'select':
  144. // find the label and the options inside $si_contact_opt['ex_field'.$i.'_label']
  145. // the drop down list array will be made automatically by this code
  146. $exf_opts_array = array();
  147. $exf_opts_label = '';
  148. $exf_array_test = trim($si_contact_opt['ex_field'.$i.'_label'] );
  149. if(!preg_match('#(?<!\\\)\,#', $exf_array_test) ) {
  150. // error
  151. $this->si_contact_error = 1;
  152. $string .= $this->ctf_echo_if_error(__('Error: A select field is not configured properly in settings.', 'si-contact-form'));
  153. } else {
  154. list($exf_opts_label, $value) = preg_split('#(?<!\\\)\,#',$exf_array_test); //string will be split by "," but "\," will be ignored
  155. $exf_opts_label = trim(str_replace('\,',',',$exf_opts_label)); // "\," changes to ","
  156. $value = trim(str_replace('\,',',',$value)); // "\," changes to ","
  157. if ($exf_opts_label != '' && $value != '') {
  158. if(!preg_match("/;/", $value)) {
  159. // error
  160. $this->si_contact_error = 1;
  161. $string .= $this->ctf_echo_if_error(__('Error: A select field is not configured properly in settings.', 'si-contact-form'));
  162. } else {
  163. // multiple options
  164. $exf_opts_array = explode(";",$value);
  165. }
  166. }
  167. } // end else
  168. if($si_contact_opt['ex_field'.$i.'_notes'] != '') {
  169. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes']);
  170. }
  171. $string .= '
  172. <div ';
  173. $string .= ($si_contact_opt['ex_field'.$i.'_label_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_label_css']) : $this->ctf_title_style;
  174. $string .= '>
  175. <label for="si_contact_ex_field'.$form_id_num.'_'.$i.'">' . $exf_opts_label . $ex_req_field_ind.'</label>
  176. </div>
  177. <div '.$this->ctf_field_div_style.'>'.$this->ctf_echo_if_error(${'si_contact_error_ex_field'.$i}).'
  178. <select ';
  179. $string .= ($si_contact_opt['ex_field'.$i.'_input_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_input_css']) : $this->ctf_field_style;
  180. $string .= ' id="si_contact_ex_field'.$form_id_num.'_'.$i.'" name="si_contact_ex_field'.$i.'"';
  181. if($si_contact_opt['ex_field'.$i.'_attributes'] != '')
  182. $string .= ' '.$si_contact_opt['ex_field'.$i.'_attributes'];
  183. $string .= '>
  184. ';
  185. $exf_opts_ct = 1;
  186. $selected = '';
  187. foreach ($exf_opts_array as $k) {
  188. $k = trim($k);
  189. if (${'ex_field'.$i} != '') {
  190. if (${'ex_field'.$i} == "$k") {
  191. $selected = ' selected="selected"';
  192. }
  193. }else{
  194. if ($exf_opts_ct == $si_contact_opt['ex_field'.$i.'_default']) {
  195. $selected = ' selected="selected"';
  196. }
  197. }
  198. if ($exf_opts_ct == 1 && preg_match('/^\[(.*)]$/',$k, $matches)) // "[Please select]" becomes "Please select"
  199. $string .= ' <option value=""'.$selected.'>'.$this->ctf_output_string($matches[1]).'</option>'."\n";
  200. else
  201. $string .= ' <option value="'.$this->ctf_output_string($k).'"'.$selected.'>'.$this->ctf_output_string($k).'</option>'."\n";
  202. $exf_opts_ct++;
  203. $selected = '';
  204. }
  205. $string .= ' </select>
  206. </div>
  207. ';
  208. if($si_contact_opt['ex_field'.$i.'_notes_after'] != '') {
  209. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes_after']);
  210. }
  211. break;
  212. case 'select-multiple':
  213. // find the label and the options inside $si_contact_opt['ex_field'.$i.'_label']
  214. // the drop down list array will be made automatically by this code
  215. $exf_opts_array = array();
  216. $exf_opts_label = '';
  217. $exf_array_test = trim($si_contact_opt['ex_field'.$i.'_label'] );
  218. if(!preg_match('#(?<!\\\)\,#', $exf_array_test) ) {
  219. // error
  220. $this->si_contact_error = 1;
  221. $string .= $this->ctf_echo_if_error(__('Error: A select-multiple field is not configured properly in settings.', 'si-contact-form'));
  222. } else {
  223. list($exf_opts_label, $value) = preg_split('#(?<!\\\)\,#',$exf_array_test); //string will be split by "," but "\," will be ignored
  224. $exf_opts_label = trim(str_replace('\,',',',$exf_opts_label)); // "\," changes to ","
  225. $value = trim(str_replace('\,',',',$value)); // "\," changes to ","
  226. if ($exf_opts_label != '' && $value != '') {
  227. if(!preg_match("/;/", $value)) {
  228. echo $value;
  229. // error
  230. $this->si_contact_error = 1;
  231. $string .= $this->ctf_echo_if_error(__('Error: A select-multiple field is not configured properly in settings.', 'si-contact-form'));
  232. } else {
  233. // multiple options
  234. $exf_opts_array = explode(";",$value);
  235. }
  236. }
  237. } // end else
  238. if($si_contact_opt['ex_field'.$i.'_notes'] != '') {
  239. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes']);
  240. }
  241. $string .= '
  242. <div ';
  243. $string .= ($si_contact_opt['ex_field'.$i.'_label_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_label_css']) : $this->ctf_title_style;
  244. $string .= '>
  245. <label for="si_contact_ex_field'.$form_id_num.'_'.$i.'">' . $exf_opts_label . $ex_req_field_ind.'</label>
  246. </div>
  247. <div '.$this->ctf_field_div_style.'>'.$this->ctf_echo_if_error(${'si_contact_error_ex_field'.$i}).'
  248. <select ';
  249. $string .= ($si_contact_opt['ex_field'.$i.'_input_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_input_css']) : $this->ctf_field_style;
  250. $string .= ' id="si_contact_ex_field'.$form_id_num.'_'.$i.'" name="si_contact_ex_field'.$i.'[]" multiple="multiple"';
  251. if($si_contact_opt['ex_field'.$i.'_attributes'] != '')
  252. $string .= ' '.$si_contact_opt['ex_field'.$i.'_attributes'];
  253. $string .= '>
  254. ';
  255. $ex_get = 0;
  256. $ex_cnt = 1;
  257. // any thing already selected by GET method?
  258. foreach ($exf_opts_array as $k) {
  259. if(isset(${'ex_field'.$i.'_'.$ex_cnt}) && ${'ex_field'.$i.'_'.$ex_cnt} == 'selected' ){
  260. $ex_get =1;
  261. break;
  262. }
  263. $ex_cnt++;
  264. }
  265. $exf_opts_ct = 1;
  266. $selected = '';
  267. foreach ($exf_opts_array as $k) {
  268. $k = trim($k);
  269. if (is_array(${'ex_field'.$i}) && ${'ex_field'.$i} != '') {
  270. if (in_array($k, ${'ex_field'.$i} ) ) {
  271. $selected = ' selected="selected"';
  272. }
  273. }
  274. // selected by default
  275. if (!isset($_POST['si_contact_form_id']) && !$ex_get && $exf_opts_ct == $si_contact_opt['ex_field'.$i.'_default']) {
  276. $selected = ' selected="selected"';
  277. }
  278. // selected by get
  279. if ( $ex_get && isset(${'ex_field'.$i.'_'.$exf_opts_ct}) && ${'ex_field'.$i.'_'.$exf_opts_ct} == 'selected' )
  280. $selected = ' selected="selected"';
  281. $string .= ' <option value="'.$this->ctf_output_string($k).'"'.$selected.'>'.$this->ctf_output_string($k).'</option>'."\n";
  282. $exf_opts_ct++;
  283. $selected = '';
  284. }
  285. $string .= ' </select>
  286. </div>
  287. ';
  288. if($si_contact_opt['ex_field'.$i.'_notes_after'] != '') {
  289. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes_after']);
  290. }
  291. break;
  292. case 'checkbox':
  293. case 'checkbox-multiple':
  294. $exf_opts_array = array();
  295. $exf_opts_label = '';
  296. $exf_opts_inline = 0;
  297. $exf_array_test = trim($si_contact_opt['ex_field'.$i.'_label'] );
  298. if( preg_match('#(?<!\\\)\,#', $exf_array_test) && preg_match("/;/", $exf_array_test) ) {
  299. list($exf_opts_label, $value) = preg_split('#(?<!\\\)\,#',$exf_array_test); //string will be split by "," but "\," will be ignored
  300. $exf_opts_label = trim(str_replace('\,',',',$exf_opts_label)); // "\," changes to ","
  301. $value = trim(str_replace('\,',',',$value)); // "\," changes to ","
  302. if ($exf_opts_label != '' && $value != '') {
  303. if(!preg_match("/;/", $value)) {
  304. // error
  305. $this->si_contact_error = 1;
  306. $string .= $this->ctf_echo_if_error(__('Error: A checkbox field is not configured properly in settings.', 'si-contact-form'));
  307. } else {
  308. // multiple options
  309. $exf_opts_array = explode(";",$value);
  310. }
  311. }
  312. // checkbox children
  313. if(preg_match('/^{inline}/',$exf_opts_label)) {
  314. $exf_opts_label = str_replace('{inline}','',$exf_opts_label);
  315. $exf_opts_inline = 1;
  316. }
  317. if($si_contact_opt['ex_field'.$i.'_notes'] != '') {
  318. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes']);
  319. }
  320. $string .= '
  321. <div ';
  322. $string .= ($si_contact_opt['ex_field'.$i.'_label_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_label_css']) : $this->ctf_title_style;
  323. $string .= '>
  324. <label>' . $exf_opts_label . $ex_req_field_ind.'</label>
  325. </div>
  326. <div '.$this->ctf_field_div_style.'>'. $this->ctf_echo_if_error(${'si_contact_error_ex_field'.$i});
  327. $string .= "\n";
  328. $ex_get = 0;
  329. $ex_cnt = 1;
  330. // any thing already selected by GET method?
  331. foreach ($exf_opts_array as $k) {
  332. if(isset(${'ex_field'.$i.'_'.$ex_cnt}) && ${'ex_field'.$i.'_'.$ex_cnt} == 'selected' ){
  333. $ex_get =1;
  334. break;
  335. }
  336. $ex_cnt++;
  337. }
  338. $ex_cnt = 1;
  339. foreach ($exf_opts_array as $k) {
  340. $k = trim($k);
  341. if(!$exf_opts_inline && $ex_cnt > 1)
  342. $string .= " <br />\n";
  343. $string .= ' <span style="white-space:nowrap;"><input type="checkbox" style="width:13px;" id="si_contact_ex_field'.$form_id_num.'_'.$i.'_'.$ex_cnt.'" name="si_contact_ex_field'.$i.'_'.$ex_cnt.'" value="selected" ';
  344. if (!isset($_POST['si_contact_form_id']) && !$ex_get && $ex_cnt == $si_contact_opt['ex_field'.$i.'_default']) {
  345. $string .= ' checked="checked"';
  346. }
  347. if ( isset(${'ex_field'.$i.'_'.$ex_cnt}) && ${'ex_field'.$i.'_'.$ex_cnt} == 'selected' )
  348. $string .= ' checked="checked"';
  349. if($si_contact_opt['ex_field'.$i.'_attributes'] != '')
  350. $string .= ' '.$si_contact_opt['ex_field'.$i.'_attributes'];
  351. $string .= ' />
  352. <label style="display:inline;" for="si_contact_ex_field'.$form_id_num.'_'.$i.'_'.$ex_cnt.'">' . $k .'</label></span>'."\n";
  353. $ex_cnt++;
  354. }
  355. $string .= ' </div>'."\n";
  356. } else {
  357. // single
  358. if($si_contact_opt['ex_field'.$i.'_notes'] != '') {
  359. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes']);
  360. }
  361. $string .= '
  362. <div ';
  363. $string .= ($si_contact_opt['ex_field'.$i.'_label_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_label_css']) : $this->ctf_title_style;
  364. $string .= '>
  365. </div>
  366. <div '.$this->ctf_field_div_style.'>'.$this->ctf_echo_if_error(${'si_contact_error_ex_field'.$i}).'
  367. <input type="checkbox" style="width:13px;" id="si_contact_ex_field'.$form_id_num.'_'.$i.'" name="si_contact_ex_field'.$i.'" value="selected" ';
  368. if (${'ex_field'.$i} != '') {
  369. if (${'ex_field'.$i} == 'selected') {
  370. $string .= 'checked="checked"';
  371. }
  372. }else{
  373. if (!isset($_POST['si_contact_action']) && $si_contact_opt['ex_field'.$i.'_default'] == '1') {
  374. $string .= 'checked="checked"';
  375. }
  376. }
  377. $si_contact_opt['ex_field'.$i.'_label'] = trim(str_replace('\,',',',$si_contact_opt['ex_field'.$i.'_label'])); // "\," changes to ","
  378. if($si_contact_opt['ex_field'.$i.'_attributes'] != '')
  379. $string .= ' '.$si_contact_opt['ex_field'.$i.'_attributes'];
  380. $string .= ' />
  381. <label style="display:inline;" for="si_contact_ex_field'.$form_id_num.'_'.$i.'">' . $si_contact_opt['ex_field'.$i.'_label'] . $ex_req_field_ind.'</label>
  382. </div>
  383. ';
  384. } // end else
  385. if($si_contact_opt['ex_field'.$i.'_notes_after'] != '') {
  386. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes_after']);
  387. }
  388. break;
  389. case 'radio':
  390. // find the label and the options inside $si_contact_opt['ex_field'.$i.'_label']
  391. // the radio list array will be made automatically by this code
  392. $exf_opts_array = array();
  393. $exf_opts_label = '';
  394. $exf_opts_inline = 0;
  395. $exf_array_test = trim($si_contact_opt['ex_field'.$i.'_label'] );
  396. if(!preg_match('#(?<!\\\)\,#', $exf_array_test) ) {
  397. // error
  398. $this->si_contact_error = 1;
  399. $string .= $this->ctf_echo_if_error(__('Error: A radio field is not configured properly in settings.', 'si-contact-form'));
  400. } else {
  401. list($exf_opts_label, $value) = preg_split('#(?<!\\\)\,#',$exf_array_test); //string will be split by "," but "\," will be ignored
  402. $exf_opts_label = trim(str_replace('\,',',',$exf_opts_label)); // "\," changes to ","
  403. $value = trim(str_replace('\,',',',$value)); // "\," changes to ","
  404. if ($exf_opts_label != '' && $value != '') {
  405. if(!preg_match("/;/", $value)) {
  406. // error
  407. $this->si_contact_error = 1;
  408. $string .= $this->ctf_echo_if_error(__('Error: A radio field is not configured properly in settings.', 'si-contact-form'));
  409. } else {
  410. // multiple options
  411. $exf_opts_array = explode(";",$value);
  412. }
  413. }
  414. } // end else
  415. if(preg_match('/^{inline}/',$exf_opts_label)) {
  416. $exf_opts_label = str_replace('{inline}','',$exf_opts_label);
  417. $exf_opts_inline = 1;
  418. }
  419. if($si_contact_opt['ex_field'.$i.'_notes'] != '') {
  420. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes']);
  421. }
  422. $string .= '
  423. <div ';
  424. $string .= ($si_contact_opt['ex_field'.$i.'_label_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_label_css']) : $this->ctf_title_style;
  425. $string .= '>
  426. <label>' . $exf_opts_label . $ex_req_field_ind.'</label>
  427. </div>
  428. <div '.$this->ctf_field_div_style.'>'. $this->ctf_echo_if_error(${'si_contact_error_ex_field'.$i});
  429. $string .= "\n";
  430. $selected = '';
  431. $ex_cnt = 1;
  432. foreach ($exf_opts_array as $k) {
  433. $k = trim($k);
  434. if (${'ex_field'.$i} != '') {
  435. if (${'ex_field'.$i} == "$k") {
  436. $selected = ' checked="checked"';
  437. }
  438. }else{
  439. if ($ex_cnt == $si_contact_opt['ex_field'.$i.'_default']) {
  440. $selected = ' checked="checked"';
  441. }
  442. }
  443. if(!$exf_opts_inline && $ex_cnt > 1)
  444. $string .= " <br />\n";
  445. $string .= ' <span style="white-space:nowrap;"><input type="radio" style="width:13px;" id="si_contact_ex_field'.$form_id_num.'_'.$i.'_'.$ex_cnt.'" name="si_contact_ex_field'.$i.'" value="'.$this->ctf_output_string($k).'"'.$selected;
  446. if($si_contact_opt['ex_field'.$i.'_attributes'] != '')
  447. $string .= ' '.$si_contact_opt['ex_field'.$i.'_attributes'];
  448. $string .= ' />
  449. <label style="display:inline;" for="si_contact_ex_field'.$form_id_num.'_'.$i.'_'.$ex_cnt.'">' . $k .'</label></span>'."\n";
  450. $selected = '';
  451. $ex_cnt++;
  452. }
  453. $string .= '
  454. </div>
  455. ';
  456. if($si_contact_opt['ex_field'.$i.'_notes_after'] != '') {
  457. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes_after']);
  458. }
  459. break;
  460. case 'attachment':
  461. if ($si_contact_opt['php_mailer_enable'] != 'php') {
  462. if($si_contact_opt['ex_field'.$i.'_notes'] != '') {
  463. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes']);
  464. }
  465. $string .= '
  466. <div ';
  467. $string .= ($si_contact_opt['ex_field'.$i.'_label_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_label_css']) : $this->ctf_title_style;
  468. $string .= '>
  469. <label for="si_contact_ex_field'.$form_id_num.'_'.$i.'">' . $si_contact_opt['ex_field'.$i.'_label'] . $ex_req_field_ind.'</label>
  470. </div>
  471. <div '.$this->ctf_field_div_style.'>'.$this->ctf_echo_if_error(${'si_contact_error_ex_field'.$i}).'
  472. <input '.$this->ctf_field_style.' type="file" id="si_contact_ex_field'.$form_id_num.'_'.$i.'" name="si_contact_ex_field'.$i.'" value="' . $this->ctf_output_string(${'ex_field'.$i}) . '" '.$ex_req_field_aria.' size="20" ';
  473. if($si_contact_opt['ex_field'.$i.'_attributes'] != '')
  474. $string .= ' '.$si_contact_opt['ex_field'.$i.'_attributes'];
  475. $string .= ' />';
  476. if(!$printed_tooltip_filetypes || ($printed_tooltip_filetypes+1) != $ex_loop_cnt) {
  477. $string .= '<br /><span style="font-size:x-small;">';
  478. $string .= ($si_contact_opt['tooltip_filetypes'] != '') ? $si_contact_opt['tooltip_filetypes'] : __('Acceptable file types:', 'si-contact-form');
  479. $string .= ' '.$si_contact_opt['attach_types'] . '.<br />';
  480. $string .= ($si_contact_opt['tooltip_filesize'] != '') ? $si_contact_opt['tooltip_filesize'] : __('Maximum file size:', 'si-contact-form');
  481. $string .= ' '.$si_contact_opt['attach_size'].'.</span>';
  482. }
  483. $printed_tooltip_filetypes = $ex_loop_cnt;
  484. $string .= ' </div>
  485. ';
  486. if($si_contact_opt['ex_field'.$i.'_notes_after'] != '') {
  487. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes_after']);
  488. }
  489. }
  490. break;
  491. case 'date':
  492. $cal_date_array = array(
  493. 'mm/dd/yyyy' => $this->ctf_output_string(__('mm/dd/yyyy', 'si-contact-form')),
  494. 'dd/mm/yyyy' => $this->ctf_output_string(__('dd/mm/yyyy', 'si-contact-form')),
  495. 'mm-dd-yyyy' => $this->ctf_output_string(__('mm-dd-yyyy', 'si-contact-form')),
  496. 'dd-mm-yyyy' => $this->ctf_output_string(__('dd-mm-yyyy', 'si-contact-form')),
  497. 'mm.dd.yyyy' => $this->ctf_output_string(__('mm.dd.yyyy', 'si-contact-form')),
  498. 'dd.mm.yyyy' => $this->ctf_output_string(__('dd.mm.yyyy', 'si-contact-form')),
  499. 'yyyy/mm/dd' => $this->ctf_output_string(__('yyyy/mm/dd', 'si-contact-form')),
  500. 'yyyy-mm-dd' => $this->ctf_output_string(__('yyyy-mm-dd', 'si-contact-form')),
  501. 'yyyy.mm.dd' => $this->ctf_output_string(__('yyyy.mm.dd', 'si-contact-form')),
  502. );
  503. if($si_contact_opt['ex_field'.$i.'_notes'] != '') {
  504. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes']);
  505. }
  506. $string .= '
  507. <div ';
  508. $string .= ($si_contact_opt['ex_field'.$i.'_label_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_label_css']) : $this->ctf_title_style;
  509. $string .= '>
  510. <label for="si_contact_ex_field'.$form_id_num.'_'.$i.'">' .$si_contact_opt['ex_field'.$i.'_label'] . $ex_req_field_ind.'</label>
  511. </div>
  512. <div '.$this->ctf_field_div_style.'>'.$this->ctf_echo_if_error(${'si_contact_error_ex_field'.$i}).'
  513. <input ';
  514. $string .= ($si_contact_opt['ex_field'.$i.'_input_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_input_css']) : $this->ctf_field_style;
  515. $string .= ' type="text" id="si_contact_ex_field'.$form_id_num.'_'.$i.'" name="si_contact_ex_field'.$i.'" value="';
  516. $string .= ( isset(${'ex_field'.$i}) && ${'ex_field'.$i} != '') ? $this->ctf_output_string(${'ex_field'.$i}): $cal_date_array[$si_contact_opt['date_format']];
  517. $string .= '" '.$ex_req_field_aria.' size="15" ';
  518. if($si_contact_opt['ex_field'.$i.'_attributes'] != '')
  519. $string .= ' '.$si_contact_opt['ex_field'.$i.'_attributes'];
  520. $string .= ' />
  521. </div>
  522. ';
  523. if($si_contact_opt['ex_field'.$i.'_notes_after'] != '') {
  524. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes_after']);
  525. }
  526. break;
  527. case 'time':
  528. // the time drop down list array will be made automatically by this code
  529. $exf_opts_array = array();
  530. if($si_contact_opt['ex_field'.$i.'_notes'] != '') {
  531. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes']);
  532. }
  533. $string .= '
  534. <div ';
  535. $string .= ($si_contact_opt['ex_field'.$i.'_label_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_label_css']) : $this->ctf_title_style;
  536. $string .= '>
  537. <label for="si_contact_ex_field'.$form_id_num.'_'.$i.'">' . $si_contact_opt['ex_field'.$i.'_label'] . $ex_req_field_ind.'</label>
  538. </div>
  539. <div '.$this->ctf_field_div_style.'>'.$this->ctf_echo_if_error(${'si_contact_error_ex_field'.$i}).'
  540. <select ';
  541. $string .= ($si_contact_opt['ex_field'.$i.'_input_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_input_css']) : $this->ctf_field_style;
  542. $string .= ' id="si_contact_ex_field'.$form_id_num.'_'.$i.'" name="si_contact_ex_field'.$i.'h">
  543. ';
  544. $selected = '';
  545. // hours
  546. $tf_hours = ($si_contact_opt['time_format'] == '24') ? '23' : '12';
  547. for ($ii = ($si_contact_opt['time_format'] == '24') ? 0 : 1; $ii <= $tf_hours; $ii++) {
  548. $ii = sprintf("%02d",$ii);
  549. if (${'ex_field'.$i.'h'} != '') {
  550. if (${'ex_field'.$i.'h'} == "$ii") {
  551. $selected = ' selected="selected"';
  552. }
  553. }
  554. $string .= ' <option value="'.$this->ctf_output_string($ii).'"'.$selected.'>'.$this->ctf_output_string($ii).'</option>'."\n";
  555. $selected = '';
  556. }
  557. $string .= ' </select>:<select ';
  558. $string .= ($si_contact_opt['ex_field'.$i.'_input_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_input_css']) : $this->ctf_field_style;
  559. $string .= ' id="si_contact_ex_field'.$form_id_num.'_'.$i.'m" name="si_contact_ex_field'.$i.'m">
  560. ';
  561. $selected = '';
  562. // minutes
  563. for ($ii = 00; $ii <= 59; $ii++) {
  564. $ii = sprintf("%02d",$ii);
  565. if (${'ex_field'.$i.'m'} != '') {
  566. if (${'ex_field'.$i.'m'} == "$ii") {
  567. $selected = ' selected="selected"';
  568. }
  569. }
  570. $string .= ' <option value="'.$this->ctf_output_string($ii).'"'.$selected.'>'.$this->ctf_output_string($ii).'</option>'."\n";
  571. $selected = '';
  572. }
  573. $string .= ' </select>';
  574. if ($si_contact_opt['time_format'] == '12'){
  575. $string .= '<select ';
  576. $string .= ($si_contact_opt['ex_field'.$i.'_input_css'] != '') ? $this->si_contact_convert_css($si_contact_opt['ex_field'.$i.'_input_css']) : $this->ctf_field_style;
  577. $string .= ' id="si_contact_ex_field'.$form_id_num.'_'.$i.'ap" name="si_contact_ex_field'.$i.'ap">
  578. ';
  579. $selected = '';
  580. // am/pm
  581. foreach (array($this->ctf_output_string(__('AM', 'si-contact-form')), $this->ctf_output_string(__('PM', 'si-contact-form')) ) as $k) {
  582. if (${'ex_field'.$i.'ap'} != '') {
  583. if (${'ex_field'.$i.'ap'} == "$k") {
  584. $selected = ' selected="selected"';
  585. }
  586. }
  587. $string .= ' <option value="'.$this->ctf_output_string($k).'"'.$selected.'>'.$this->ctf_output_string($k).'</option>'."\n";
  588. $selected = '';
  589. }
  590. $string .= ' </select>';
  591. }
  592. $string .= '
  593. </div>
  594. ';
  595. if($si_contact_opt['ex_field'.$i.'_notes_after'] != '') {
  596. $string .= $this->ctf_notes($si_contact_opt['ex_field'.$i.'_notes_after']);
  597. }
  598. break;
  599. }
  600. } // end if label
  601. $ex_loop_cnt++;
  602. } // end foreach
  603. // how many extra fields are date fields?
  604. $ex_date_found = array();
  605. for ($i = 1; $i <= $si_contact_opt['max_fields']; $i++) {
  606. if ($si_contact_opt['ex_field'.$i.'_label'] != '' && $si_contact_opt['ex_field'.$i.'_type'] == 'date') {
  607. $ex_date_found[$i] = $i;
  608. }
  609. }
  610. if (isset($ex_date_found) && count($ex_date_found) > 0 ) {
  611. $string .= '
  612. <link rel="stylesheet" type="text/css" href="'.WP_PLUGIN_URL.'/si-contact-form/date/ctf_epoch_styles.css?'.time().'" />
  613. <script type="text/javascript">
  614. var ctf_daylist = new Array( \''.__('Su', 'si-contact-form').'\',\''.__('Mo', 'si-contact-form').'\',\''.__('Tu', 'si-contact-form').'\',\''.__('We', 'si-contact-form').'\',\''.__('Th', 'si-contact-form').'\',\''.__('Fr', 'si-contact-form').'\',\''.__('Sa', 'si-contact-form').'\',\''.__('Su', 'si-contact-form').'\',\''.__('Mo', 'si-contact-form').'\',\''.__('Tu', 'si-contact-form').'\',\''.__('We', 'si-contact-form').'\',\''.__('Th', 'si-contact-form').'\',\''.__('Fr', 'si-contact-form').'\',\''.__('Sa', 'si-contact-form').'\' );
  615. var ctf_months_sh = new Array( \''.__('Jan', 'si-contact-form').'\',\''.__('Feb', 'si-contact-form').'\',\''.__('Mar', 'si-contact-form').'\',\''.__('Apr', 'si-contact-form').'\',\''.__('May', 'si-contact-form').'\',\''.__('Jun', 'si-contact-form').'\',\''.__('Jul', 'si-contact-form').'\',\''.__('Aug', 'si-contact-form').'\',\''.__('Sep', 'si-contact-form').'\',\''.__('Oct', 'si-contact-form').'\',\''.__('Nov', 'si-contact-form').'\',\''.__('Dec', 'si-contact-form').'\' );
  616. var ctf_monthup_title = \''.__('Go to the next month', 'si-contact-form').'\';
  617. var ctf_monthdn_title = \''.__('Go to the previous month', 'si-contact-form').'\';
  618. var ctf_clearbtn_caption = \''.__('Clear', 'si-contact-form').'\';
  619. var ctf_clearbtn_title = \''.__('Clears any dates selected on the calendar', 'si-contact-form').'\';
  620. var ctf_maxrange_caption = \''.__('This is the maximum range', 'si-contact-form').'\';
  621. var ctf_cal_start_day = '.$si_contact_opt['cal_start_day'].';
  622. var ctf_date_format = \'';
  623. if($si_contact_opt['date_format'] == 'mm/dd/yyyy')
  624. $string .= 'm/d/Y';
  625. if($si_contact_opt['date_format'] == 'dd/mm/yyyy')
  626. $string .= 'd/m/Y';
  627. if($si_contact_opt['date_format'] == 'mm-dd-yyyy')
  628. $string .= 'm-d-Y';
  629. if($si_contact_opt['date_format'] == 'dd-mm-yyyy')
  630. $string .= 'd-m-Y';
  631. if($si_contact_opt['date_format'] == 'mm.dd.yyyy')
  632. $string .= 'm.d.Y';
  633. if($si_contact_opt['date_format'] == 'dd.mm.yyyy')
  634. $string .= 'd.m.Y';
  635. if($si_contact_opt['date_format'] == 'yyyy/mm/dd')
  636. $string .= 'Y/m/d';
  637. if($si_contact_opt['date_format'] == 'yyyy-mm-dd')
  638. $string .= 'Y-m-d';
  639. if($si_contact_opt['date_format'] == 'yyyy.mm.dd')
  640. $string .= 'Y.m.d';
  641. $string .= '\';
  642. </script>
  643. <script type="text/javascript" src="'.WP_PLUGIN_URL.'/si-contact-form/date/ctf_epoch_classes.js?'.time().'"></script>
  644. <script type="text/javascript">
  645. var ';
  646. $ex_date_var_string = '';
  647. foreach ($ex_date_found as $v) {
  648. $ex_date_var_string .= "dp_cal$form_id_num".'_'."$v,";
  649. }
  650. $ex_date_var_string = substr($ex_date_var_string,0,-1);
  651. $string .= "$ex_date_var_string;\n";
  652. $string .= 'window.onload = function () {
  653. ';
  654. foreach ($ex_date_found as $v) {
  655. $string .= "dp_cal$form_id_num".'_'."$v = new Epoch('epoch_popup$form_id_num".'_'."$v','popup',document.getElementById('si_contact_ex_field$form_id_num".'_'."$v'));\n";
  656. }
  657. $string .= "};\n</script>\n";
  658. }
  659. if($ex_fieldset)
  660. $string .= "</fieldset>\n";
  661. ?>