Caldera_Forms_Email_Attachment

Attachment object.

Defined (1)

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

/classes/email/attachment.php  
  1. class Caldera_Forms_Email_Attachment extends Caldera_Forms_Object { 
  2.  
  3. /** 
  4. * Content type 
  5. *  
  6. * @since 1.4.0 
  7. *  
  8. * @var string 
  9. */ 
  10. protected $type; 
  11.  
  12. /** 
  13. * Actual file contents 
  14. * @since 1.4.0 
  15. * @var string 
  16. */ 
  17. protected $content; 
  18.  
  19. /** 
  20. * The filename 
  21. * @since 1.4.0 
  22. *  
  23. * @var string 
  24. */ 
  25. protected $filename; 
  26.  
  27. /** 
  28. * @inheritdoc 
  29. */ 
  30. protected function get_prefix() { 
  31. return 'attachment'; 
  32.  
  33. /** 
  34. * Get file contents as a base64 encoded string 
  35. *  
  36. * @since 1.4.0 
  37. *  
  38. * @return string 
  39. */ 
  40. public function get_encoded() { 
  41. if( false != ( $file = file_get_contents( $this->filename ) ) ) { 
  42.  
  43. return base64_encode( $file ); 
  44.  
  45.  
  46. /** 
  47. * Make calls to $this->filename only return basename 
  48. *  
  49. * @since 1.4.0 
  50. *  
  51. * @return string 
  52. */ 
  53. protected function filename_get() { 
  54. return basename( $this->filename ); 
  55.  
  56. /** 
  57. * Called when setting content property, and sets everything if value is a filepath 
  58. *  
  59. * @since 1.4.0 
  60. *  
  61. * @param $content 
  62. */ 
  63. protected function content_set( $content ) { 
  64. if( is_file( $content ) ) { 
  65. $this->content = file_get_contents( $content ); 
  66. $this->filename = $content; 
  67. $this->type = mime_content_type( $content ); 
  68. $info = pathinfo( $this->filename ); 
  69. if( 'csv' == $info[ 'extension' ] ) { 
  70. $this->type = 'text/csv'; 
  71.  
  72. }else{ 
  73. $this->content = $content; 
  74.  
  75.  
  76.