CFDBShortCodeSavePostData

The Contact Form DB CFDBShortCodeSavePostData class.

Defined (1)

The class is defined in the following location(s).

/CFDBShortCodeSavePostData.php  
  1. class CFDBShortCodeSavePostData extends ShortCodeLoader { 
  2.  
  3. const FORM_TITLE_FIELD = 'form_title'; 
  4.  
  5. /** 
  6. * @param $atts array of short code attributes 
  7. * @param $content string not used 
  8. * @return void 
  9. */ 
  10. public function handleShortcode($atts, $content = null) { 
  11.  
  12. $atts = $this->decodeAttributes($atts); 
  13.  
  14. if (is_array($atts) && isset($atts['debug']) && $atts['debug'] == 'true') { 
  15. echo '<pre>'; 
  16. print_r($_POST); 
  17. echo "\n"; 
  18. print_r($_FILES); 
  19. echo '</pre>'; 
  20.  
  21. if (is_array($_POST) && !empty($_POST)) { 
  22. $title = isset($_POST[self::FORM_TITLE_FIELD]) ? $_POST[self::FORM_TITLE_FIELD] : 'Untitled'; 
  23. $posted_data = array(); 
  24. $uploaded_files = array(); 
  25.  
  26. // Get posted values 
  27. foreach ($_POST as $key => $val) { 
  28. if ($key != self::FORM_TITLE_FIELD) { 
  29. $posted_data[$key] = $val; 
  30.  
  31.  
  32. // Deal with upload files 
  33. // $_FILES = Array ( 
  34. // [your-upload] => Array 
  35. // ( 
  36. // [name] => readme.txt 
  37. // [type] => text/plain 
  38. // [tmp_name] => /tmp/php3tQ1zg 
  39. // [error] => 0 
  40. // [size] => 1557 
  41. // ) 
  42. //) 
  43. if (is_array($_FILES) && !empty($_FILES)) { 
  44. foreach ($_FILES as $key => $file) { 
  45. if (is_uploaded_file($file['tmp_name'])) { 
  46. $posted_data[$key] = $file['name']; 
  47. $uploaded_files[$key] = $file['tmp_name']; 
  48.  
  49.  
  50. // Prepare data structure for call to hook 
  51. $data = (object)array('title' => $title,  
  52. 'posted_data' => $posted_data,  
  53. 'uploaded_files' => $uploaded_files); 
  54.  
  55. // Call hook to submit data 
  56. do_action_ref_array('cfdb_submit', array(&$data));