WYSIJA_view_back_statistics

The MailPoet Newsletters WYSIJA view back statistics class.

Defined (1)

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

/views/back/statistics.php  
  1. class WYSIJA_view_back_statistics extends WYSIJA_view_back{ 
  2. public $icon = 'icon-stats'; 
  3. function __construct() { 
  4. $this->title = __('Stats dashboard'); 
  5. if (empty($this->viewObj)) 
  6. $this->viewObj = new stdClass (); 
  7. $this->viewObj->msgPerPage = __('Show'); 
  8.  
  9. function main($data) { 
  10. $this->assign_js($data); 
  11. $this->render_date_filter($data); 
  12. echo '<div id="hook_stats">'; 
  13. if (!$data['lazy_load']) { 
  14. echo $data['hooks']['hook_stats']; 
  15. else { 
  16. if (!empty($data['first_module'])) 
  17. echo $data['first_module']; 
  18. echo '</div>'; 
  19. $this->render_loading_indicator(); 
  20. $this->render_feedback_form(); 
  21.  
  22. protected function render_date_filter($data) { 
  23.  
  24. ?> 
  25. <div class="stats_date_filter"> 
  26. <form action="#" name="stats-filter" id="stats-filter"> 
  27. <select class="custom_date" name="custom_date" id="custom-date"> 
  28. <?php 
  29. foreach($data['custom_dates'] as $custom_date) { 
  30. $selected = $data['default_duration']->last_days == $custom_date['value'] ? 'selected' : ''; 
  31. ?> 
  32. <option value="<?php echo $custom_date['value']; ?>" <?php echo $selected; ?> from="<?php echo $custom_date['from']; ?>" to="<?php echo $custom_date['to']; ?>"> 
  33. <?php echo $custom_date['label']; ?> 
  34. </option> 
  35. <?php 
  36. ?> 
  37. <?php 
  38. }?> 
  39. </select> 
  40. <?php echo __('From', WYSIJA); ?>: <input type="text" class="datepicker" name="from" id="stats-filter-from" value="<?php echo esc_attr($data['default_duration']->from); ?>" size="8" /> 
  41. <?php echo __('To', WYSIJA); ?>: <input type="text" class="datepicker" name="to" id="stats-filter-to" value="<?php echo esc_attr($data['default_duration']->to); ?>" size="8" /> 
  42. <input type="submit" class="button-secondary" value="<?php echo __('Filter', WYSIJA); ?>" /> 
  43. <!--(<input type="reset" class="reset"></input>)--><?php // this function does not work correctly. Need to implement: on reset => onchange (from/date) => notify object StatsFilter. ?> 
  44. </form> 
  45. </div> 
  46. <?php 
  47.  
  48. protected function render_loading_indicator() { 
  49. ?> 
  50. <div class="spinner" > </div> 
  51. <?php 
  52.  
  53. protected function render_feedback_form() { 
  54. $url = 'http://support.mailpoet.com/feedback/?utm_source=wpadmin&utm_campaign=contact_stats'; 
  55. echo "<div class='stats_feedback'>". 
  56. str_replace( 
  57. array('[link]', '[/link]'),  
  58. array('<a target="_blank" href="' . $url . '">', '</a>'),  
  59. __('You have feedback on these stats? [link]Contact us[/link] directly to let us know.', WYSIJA) 
  60. . "</div>"; 
  61.  
  62.  
  63. protected function assign_js($data) { 
  64. ?> 
  65. <script type="text/javascript"> 
  66. var wysijaStatisticVars = {}; // holds all global variables in this page. 
  67. wysijaStatisticVars.lazyLoad = { 
  68. lazyLoadBlocks : <?php echo '["'.implode('", "', $data['lazy_load_modules']).'"]'; ?>,  
  69. blocks : <?php echo '["'.implode('", "', $data['modules']).'"]'; ?>,  
  70. targetContainer: '#hook_stats',  
  71. task:'get_block',  
  72. active: <?php echo !empty($data['lazy_load_modules']) ? 'true' : 'false'; ?> 
  73. }; 
  74. wysijaStatisticVars.filter = { 
  75. datePickerElements: '.datepicker',  
  76. dateFormat: '<?php echo $data['js_date_format']; ?>' 
  77. }; 
  78. </script> 
  79. <?php