WYSIJA_help_bookmarks

The MailPoet Newsletters WYSIJA help bookmarks class.

Defined (1)

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

/helpers/bookmarks.php  
  1. class WYSIJA_help_bookmarks extends WYSIJA_object { 
  2.  
  3. function __construct() { 
  4. parent::__construct(); 
  5.  
  6. /** 
  7. * Get all bookmarks based on size 
  8. * @param string $size 
  9. * @return array 
  10. */ 
  11. function getAll($size = 'medium', $theme = 'default') { 
  12. $theme = basename($theme); 
  13. $fileHelper = WYSIJA::get('file', 'helper'); 
  14. $dirHandle = $fileHelper->exists('bookmarks'.DS.$size); 
  15.  
  16. if($dirHandle['result'] === FALSE) { 
  17. return array(); 
  18. } else { 
  19. $bookmarks = array(); 
  20.  
  21. // if size is medium and the current theme is not default, load theme's bookmarks 
  22. if($size === 'medium' and $theme !== 'default') { 
  23. $themeIcons = $this->getAllByTheme($theme, 'url'); 
  24. if(!empty($themeIcons)) { 
  25. $bookmarks['00'] = $themeIcons; 
  26.  
  27. $sourceDir = $dirHandle['file']; 
  28. $iconsets = scandir($sourceDir); 
  29. foreach($iconsets as $iconset) { 
  30. // loop through each iconset 
  31. if(in_array($iconset, array('.', '..', '.DS_Store', 'Thumbs.db')) === FALSE and is_dir($sourceDir.DS.$iconset)) { 
  32.  
  33. // get all icons from current iconset 
  34. $icons = scandir($sourceDir.DS.$iconset); 
  35. foreach($icons as $icon) { 
  36. if(in_array($icon, array('.', '..', '.DS_Store', 'Thumbs.db')) === FALSE and strrpos($icon, '.txt') === FALSE) { 
  37. $info = pathinfo($sourceDir.DS.$iconset.DS.$icon); 
  38. $bookmarks[$iconset][basename($icon, '.'.$info['extension'])] = $fileHelper->url($icon, 'bookmarks'.DS.$size.DS.$iconset); 
  39. return $bookmarks; 
  40.  
  41. /** 
  42. * Get all bookmarks based on size for a given iconset 
  43. * @param string $size 
  44. * @param string $iconset 
  45. * @return array 
  46. */ 
  47. function getAllByIconset($size = 'medium', $iconset) 
  48. $iconset = basename($iconset); 
  49. $fileHelper = WYSIJA::get('file', 'helper'); 
  50. $dirHandle = $fileHelper->exists('bookmarks'.DS.$size.DS.$iconset); 
  51.  
  52. if($dirHandle['result'] === FALSE) { 
  53. return array(); 
  54. } else { 
  55. $bookmarks = array(); 
  56. $sourceDir = $dirHandle['file']; 
  57. $icons = scandir($sourceDir); 
  58. foreach($icons as $icon) { 
  59. if(in_array($icon, array('.', '..', '.DS_Store', 'Thumbs.db')) === FALSE and strrpos($icon, '.txt') === FALSE) { 
  60. $info = pathinfo($sourceDir.DS.$icon); 
  61. $dimensions = @getimagesize($sourceDir.DS.$icon); 
  62. $bookmarks[basename($icon, '.'.$info['extension'])] = array( 
  63. 'src' => $fileHelper->url($icon, 'bookmarks/'.$size.'/'.$iconset),  
  64. 'width' => $dimensions[0],  
  65. 'height' => $dimensions[1] 
  66. ); 
  67. return $bookmarks; 
  68.  
  69. function getAllByTheme($theme, $type = 'all') 
  70. $theme = basename($theme); 
  71. $fileHelper = WYSIJA::get('file', 'helper'); 
  72. $dirHandle = $fileHelper->exists('themes'.DS.$theme.DS.'bookmarks'); 
  73.  
  74. if($dirHandle['result'] === FALSE) { 
  75. return array(); 
  76. } else { 
  77. $bookmarks = array(); 
  78. $sourceDir = $dirHandle['file']; 
  79. $icons = scandir($sourceDir); 
  80. foreach($icons as $icon) { 
  81. if(in_array($icon, array('.', '..', '.DS_Store', 'Thumbs.db')) === FALSE and strrpos($icon, '.txt') === FALSE) { 
  82.  
  83. if($type === 'all') { 
  84. $info = pathinfo($sourceDir.DS.$icon); 
  85. $dimensions = @getimagesize($sourceDir.DS.$icon); 
  86. $bookmarks[basename($icon, '.'.$info['extension'])] = array( 
  87. 'src' => $fileHelper->url($icon, 'themes/'.$theme.'/bookmarks'),  
  88. 'width' => $dimensions[0],  
  89. 'height' => $dimensions[1] 
  90. ); 
  91. } else if($type === 'url') { 
  92. $info = pathinfo($sourceDir.DS.$icon); 
  93. $bookmarks[basename($icon, '.'.$info['extension'])] = $fileHelper->url($icon, 'themes/'.$theme.'/bookmarks'); 
  94. return $bookmarks;