WYSIJA_help_dividers

The MailPoet Newsletters WYSIJA help dividers class.

Defined (1)

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

/helpers/dividers.php  
  1. class WYSIJA_help_dividers extends WYSIJA_object { 
  2.  
  3. function __construct() { 
  4. parent::__construct(); 
  5.  
  6. /** 
  7. * Returns all dividers 
  8. * @return array 
  9. */ 
  10. function getAll() { 
  11. $fileHelper = WYSIJA::get('file', 'helper'); 
  12. $dirHandle = $fileHelper->exists('dividers'); 
  13.  
  14. if($dirHandle['result'] === FALSE) { 
  15. return array(); 
  16. } else { 
  17. $dividers = array(); 
  18. $files = scandir($dirHandle['file']); 
  19. foreach($files as $filename) { 
  20. // don't add meta files 
  21. if(in_array($filename, array('.', '..', '.DS_Store', 'Thumbs.db')) === FALSE) { 
  22. // get dimensions of image 
  23. $dimensions = @getimagesize($dirHandle['file'].DS.$filename); 
  24. if($dimensions !== FALSE) { 
  25. $width = (int)$dimensions[0]; 
  26. $height = (int)$dimensions[1]; 
  27. } else { 
  28. $width = 564; 
  29. $height = 1; 
  30.  
  31. // only add divider if height is superior to 0 
  32. if($height > 0) { 
  33. $ratio = round(($width / $height) * 1000) / 1000; 
  34. $width = min($width, 564); 
  35. $height = (int)($width / $ratio); 
  36.  
  37. $dividers[] = array( 
  38. 'src' => $fileHelper->url($filename, 'dividers'),  
  39. 'width' => $width,  
  40. 'height' => $height 
  41. ); 
  42. return $dividers; 
  43.  
  44. /** 
  45. * Get default divider 
  46. * @return array 
  47. */ 
  48. function getDefault() { 
  49. $fileHelper = WYSIJA::get('file', 'helper'); 
  50. return array( 
  51. 'src' => $fileHelper->url('solid.jpg', 'dividers'),  
  52. 'width' => 564,  
  53. 'height' => 1 
  54. );