WYSIJA_module_view_stats_newsletter_std_view

The MailPoet Newsletters WYSIJA module view stats newsletter std class.

Defined (1)

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

/modules/stats_newsletter_std/stats_newsletter_std_view.php  
  1. class WYSIJA_module_view_stats_newsletter_std_view extends WYSIJA_view_back { 
  2.  
  3. public function hook_newsletter_top($data) { 
  4. echo '<div class="stats_newsletter_std hook-column left" style="height:300px;">'; 
  5. if (empty($data['emails_count'])) 
  6. return; 
  7. if (!empty($data['dataset'])) 
  8. foreach ($data['dataset'] as $index => $dataset) { 
  9. $data['dataset'][$index]['container'] = 'chart'.md5($dataset['title'].rand()); 
  10. echo '<div id="'.$data['dataset'][$index]['container'].'" style="height: 300px; width:100%"></div>'; 
  11. ?> 
  12. <script type="text/javascript"> 
  13. // Load the Visualization API and the piechart package. 
  14. google.load('visualization', '1.0', {'packages': ['corechart']}); 
  15. // Set a callback to run when the Google Visualization API is loaded. 
  16. google.setOnLoadCallback(function() { 
  17. <?php 
  18. foreach ($data['dataset'] as $dataset) { 
  19. ?> 
  20. var dataTable = new google.visualization.DataTable(); 
  21. <?php 
  22. foreach ($dataset['columns'] as $column) { 
  23. ?> 
  24. dataTable.addColumn('<?php echo $column['type']; ?>', '<?php echo $column['label']; ?>'); 
  25. <?php 
  26. ?> 
  27. dataTable.addRows([ 
  28. <?php 
  29. $count = 0; 
  30. foreach ($dataset['data'] as $index => $value) { 
  31. if ($count++ > 0) 
  32. echo ', '; 
  33. echo '["'.$index.'", '.$value.']'; 
  34. ?> 
  35. ]); 
  36. var options = { 
  37. title: '<?php echo $dataset['title']; ?>',  
  38. is3D: false,  
  39. chartArea: {left: 0},  
  40. backgroundColor: 'transparent' 
  41. }; 
  42. var chart = new google.visualization.PieChart(document.getElementById('<?php echo $dataset['container']; ?>')); 
  43. chart.draw(dataTable, options); 
  44. <?php 
  45. ?> 
  46. }); 
  47. </script> 
  48. <?php 
  49. echo '</div>'; 
  50.  
  51. public function hook_newsletter_top_links($data) { 
  52. ?> 
  53. <div class="container-top-links container clear" rel="<?php echo $data['module_name']; ?>"> 
  54. <h3 class="title"><?php echo __('Top links', WYSIJA); ?></h3> 
  55. <?php if (empty($data['top_links'])) { ?> 
  56. <div class="notice-msg updated inline"><ul><li><?php echo $data['messages']['data_not_available']; ?></li></ul></div> 
  57. <?php } 
  58. else { ?> 
  59. <table class="widefat fixed"> 
  60. <thead> 
  61. <th class="check-column" style="width:40px"> </th> 
  62. <th class="link_column" style="width:40%"><?php echo __('Link', WYSIJA); ?></th> 
  63. <!--th class="sortable sort-filter <?php // echo $data['order_direction']['clicks']; ?>" rel="click"> 
  64. <a href="" class="orderlink"> 
  65. <span><?php // echo __('Clicks'); ?></span><span class="sorting-indicator"></span> 
  66. </a> 
  67. </th--> 
  68. <th class="click_column"><?php echo __('Unique clicks'); ?></th> 
  69. <th class="click_column"><?php echo __('Total clicks'); ?></th> 
  70. <th> </th> 
  71. </thead> 
  72. <tbody class=""> 
  73. <?php 
  74. $i = 1; 
  75. $alt = false; 
  76. $link_helper = WYSIJA::get('links', 'helper'); 
  77. add_filter('wysija_link', array( $link_helper, 'render_link' ), 1, 6); 
  78. foreach ($data['top_links'] as $url) { 
  79. if ($i === 1) 
  80. $wysija_link = apply_filters('wysija_link', '', $url['url'], 50, 15, true); 
  81. else 
  82. $wysija_link = apply_filters('wysija_link', '', $url['url'], 50, 15, true, '...'); 
  83. ?> 
  84. <tr class="<?php echo $alt ? 'alternate' : ''; 
  85. $alt = !$alt; 
  86. ?>"> 
  87. <td><?php echo $i; 
  88. $i++; ?></td> 
  89. <td><?php echo $wysija_link; ?></td> 
  90. <td> 
  91. <?php 
  92. echo $url['unique_clicks']; 
  93. if ($data['is_premium']) { 
  94. echo ' - '; 
  95. if ($url['is_viewing']) 
  96. echo __('Currently viewing', WYSIJA); 
  97. else 
  98. echo '<a href="'.$url['view_subscriber_url'].'">'.__('View subscribers', WYSIJA).'</a>'; 
  99. ?> 
  100. </td> 
  101. <td><?php echo $url['total_clicks']; ?></td> 
  102. <td> </td> 
  103. </tr> 
  104. <?php 
  105. ?> 
  106. </tbody> 
  107. </table> 
  108. <?php } ?> 
  109. <?php 
  110. //$this->model->countRows = 103;//$data['top_subscribers']['count']; 
  111. // if (empty($this->viewObj)) $this->viewObj = new stdClass(); 
  112. // $this->viewObj->msgPerPage = __('Show', WYSIJA).':'; 
  113. // $this->viewObj->title = ''; 
  114. //$this->limitPerPage(); // not implemented yet 
  115. ?> 
  116. <div class="cl"></div> 
  117. </div> 
  118. <?php 
  119.  
  120. /** 
  121. * Render actions of a newsletter 
  122. * @param type $data 
  123. */ 
  124. public function hook_newsletter_action_buttons($data) { 
  125. echo '<div class="actions right">'; 
  126.  
  127. $classes = function_exists('wp_star_rating') ? 'add-new-h2' : 'button-secondary2'; 
  128.  
  129. // view button 
  130. $email_helper = WYSIJA::get('email', 'helper'); 
  131. $link_view = $email_helper->getVIB($data['email_object']); 
  132. echo '<a id="action-view" target="_blank" href="'.$link_view.'" class="action-view '.$classes.'">'.__('View', WYSIJA).'</a>'; 
  133.  
  134. //duplicate button 
  135. $action = 'duplicate'; 
  136. $params = array( 
  137. 'page' => 'wysija_campaigns',  
  138. 'action' => $action,  
  139. 'id' => $data['id'],  
  140. 'email_id' => $data['email_id'],  
  141. '_wpnonce' => WYSIJA_view::secure(array('action' => $action , 'id' => $data['id']), true) 
  142. ); 
  143. $link_duplicate = 'admin.php?'.http_build_query($params); 
  144. echo '<a id="action-'.$action.'" href="'.$link_duplicate.'" class="action-'.$action.' '.$classes.'">'.__('Duplicate', WYSIJA).'</a>'; 
  145.  
  146. $alternate = false; 
  147. echo '<table class="newsletter-stats-block widefat fixed">'; 
  148. // Google tracking code 
  149. if (!empty($data['email_object']['params']['googletrackingcode'])) { 
  150. // echo '<div class="googletrackingcode"><span>' . __('Google Analytics', WYSIJA) . ':</span> ' . $data['email_object']['params']['googletrackingcode'] . '</div>'; 
  151. echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Google Analytics', WYSIJA).'</td><td>'.$data['email_object']['params']['googletrackingcode'].'</td></tr>'; 
  152. $alternate = !$alternate; 
  153.  
  154. // Sent on: 
  155. // echo '<div class="googletrackingcode"><span>' . __('Sent on', WYSIJA) . ':</span> ' . $this->fieldListHTML_created_at_time($data['email_object']['sent_at']) . '</div>'; 
  156. echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Sent on', WYSIJA).'</td><td>'.$this->fieldListHTML_created_at_time($data['email_object']['sent_at']).'</td></tr>'; 
  157. $alternate = !$alternate; 
  158.  
  159. // Lists: 
  160. if (!empty($data['lists'])) { 
  161. // echo '<div class="googletrackingcode"><span>' . __('Lists', WYSIJA) . ':</span> ' . implode(', ', $data['lists']) . '</div>'; 
  162. echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Lists', WYSIJA).'</td><td>'.implode(', ', $data['lists']).'</td></tr>'; 
  163. $alternate = !$alternate; 
  164.  
  165. // From address: 
  166. $_from_address = array( ); 
  167. if (!empty($data['email_object']['from_name'])) { 
  168. $_from_address[] = $data['email_object']['from_name']; 
  169. if (!empty($data['email_object']['from_email'])) { 
  170. $_from_address[] = $data['email_object']['from_email']; 
  171. if (!empty($_from_address)) { 
  172. // echo '<div class="googletrackingcode"><span>' . __('From', WYSIJA) . ':</span> ' . implode(', ', $_from_address) . '</div>'; 
  173. echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('From', WYSIJA).'</td><td>'.implode(' <', $_from_address).(count($_from_address) > 1 ? '>' : '').'</td></tr>'; 
  174. $alternate = !$alternate; 
  175.  
  176. // Reply-to address 
  177. $_reply_to_address = array( ); 
  178. if (!empty($data['email_object']['replyto_name'])) { 
  179. $_reply_to_address[] = $data['email_object']['replyto_name']; 
  180. if (!empty($data['email_object']['replyto_email'])) { 
  181. $_reply_to_address[] = $data['email_object']['replyto_email']; 
  182.  
  183. if (!empty($_reply_to_address)) { 
  184. // echo '<div class="googletrackingcode"><span>' . __('Reply-to', WYSIJA) . ':</span> ' . implode(', ', $_reply_to_address) . '</div>'; 
  185. echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Reply-to', WYSIJA).'</td><td>'.implode(' <', $_reply_to_address).(count($_reply_to_address) > 1 ? '>' : '').'</td></tr>'; 
  186. $alternate = !$alternate; 
  187.  
  188. if (!empty($data['bounce'])) { 
  189. // echo '<div class="googletrackingcode"><span>' . __('Bounce', WYSIJA) . ':</span> ' . $data['bounce'] . '</div>'; 
  190. echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Bounce', WYSIJA).'</td><td>'.$data['bounce'].'</td></tr>'; 
  191. $alternate = !$alternate; 
  192.  
  193. echo '</table>'; 
  194. echo '</div>'; 
  195.