WYSIJA_module_view_archive_std_view

The MailPoet Newsletters WYSIJA module view archive std class.

Defined (1)

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

/modules/archive_std/archive_std_view.php  
  1. class WYSIJA_module_view_archive_std_view extends WYSIJA_view { 
  2.  
  3. public function hook_settings_super_advanced($data) { 
  4. ?> 
  5. <tr class="super-advanced"> 
  6. <th> 
  7. <label><?php echo __('Archive page shortcode', WYSIJA); ?></label> 
  8. <p class="description"><?php echo __('Paste this shortcode in a page to display a list of past newsletters.', WYSIJA); ?></p> 
  9. </th> 
  10. <td> 
  11. <?php 
  12. $key = 'archive'; 
  13. $forms_helper = WYSIJA::get('forms', 'helper'); 
  14. ?> 
  15. <div id="<?php echo $key; ?>_linkname" class="linknamecboxes"> 
  16. <?php echo $forms_helper->input(array( 'name' => 'wysija[config]['.$key.'_linkname]', 'size' => '75', 'class' => 'archive-shortcode', 'readonly' => 'readonly' ), '[wysija_archive]'); ?> 
  17. <div class="clearfix"> 
  18. <?php 
  19. foreach ($data['lists'] as $list) { 
  20. ?> 
  21. <p class="labelcheck"> 
  22. <label for="<?php echo $key; ?>list-<?php echo $list['list_id']; ?>"> 
  23. <?php echo $forms_helper->checkbox(array( 'id' => $key.'list-'.$list['list_id'], 'name' => 'wysija[config]['.$key.'_lists][]', 'class' => $key.'-list' ), $list['list_id']); ?> 
  24. <?php echo $list['name']; ?> 
  25. </label> 
  26. </p> 
  27. <?php 
  28. ?> 
  29. </div> 
  30. </div> 
  31. </td> 
  32. </tr> 
  33. <script type="text/javascript"> 
  34. (function($) { 
  35.  
  36. /** 
  37. * class ArchiveShortcode: Shortcode refactor 
  38. * @param {string} shortcode 
  39. * @param {string} targetShortcode DOM element selector 
  40. * @returns {_L2.ArchiveShortcode} 
  41. */ 
  42. var ArchiveShortcode = function(shortcode, targetShortcode) { 
  43. this.shortcode = shortcode; 
  44. this.targetShortcode = targetShortcode; 
  45. this.lists = []; 
  46. this.getLists = function() { 
  47.  
  48. }; 
  49. this.addToLists = function(id) { 
  50. this.lists.push(id); 
  51. }; 
  52.  
  53. this.removeFromList = function(id) { 
  54. var i = this.lists.indexOf(id); 
  55. if (i !== -1) { 
  56. this.lists.splice(i, 1); 
  57. }; 
  58.  
  59. this.renderShortcode = function() { 
  60. shortCode = '[' + +' ' + this.lists.join() + ']'; 
  61. shortCode = '['; 
  62. shortCode += this.shortcode; 
  63. if (this.lists.length > 0) { 
  64. shortCode += ' list_id="' + this.lists.join() + '"'; 
  65. shortCode += ']'; 
  66. $(this.targetShortcode).val(shortCode); 
  67. }; 
  68.  
  69. this.onChangeList = function(isSelected, listId) { 
  70. if (isSelected) 
  71. this.addToLists(listId); 
  72. else 
  73. this.removeFromList(listId); 
  74. this.renderShortcode(); 
  75. }; 
  76.  
  77. this.onClick = function() { 
  78. $(this).select(); 
  79. }; 
  80.  
  81. $(this.targetShortcode).click(this.onClick); 
  82. }; 
  83. $(document).ready(function() { 
  84. var achiveShortcode = new ArchiveShortcode('wysija_archive', '.archive-shortcode'); 
  85. $('.archive-list').change(function(e) { 
  86. achiveShortcode.onChangeList($(e.target).is(':checked'), $(e.target).val()); 
  87. }); 
  88. }); 
  89. })(jQuery); 
  90. </script> 
  91. <?php 
  92.  
  93. /** 
  94. * Render archieve shortcode at frontend 
  95. * @param array $data 
  96. */ 
  97. public function render_archive(Array $data) { 
  98. if (empty($data['newsletters'])) { 
  99. echo apply_filters('mpoet_archive_no_newsletters', __('Oops! There are no newsletters to display.', WYSIJA)); 
  100. return; 
  101. $filter_mpoet_archive_title = apply_filters('mpoet_archive_title', '' /** __('Newsletter Archives') */); 
  102. if (!empty($filter_mpoet_archive_title)) { 
  103. echo '<h3 class="wysija_archive_title">'.$filter_mpoet_archive_title.'</h3>'; 
  104. echo '<ul class="wysija_archive">'; 
  105. foreach ($data['newsletters'] as $newsletter) { 
  106. ?> 
  107. <li> 
  108. <span class="wysija_archive_date"> 
  109. <?php 
  110. add_filter('mpoet_archive_date', array( $this, 'filter_mpoet_archive_date' ), 2); 
  111. echo apply_filters('mpoet_archive_date', $newsletter->sent_at); 
  112. ?> 
  113. </span> 
  114. <span class="wysija_archive_subject"> 
  115. <?php 
  116. add_filter('mpoet_archive_subject', array( $this, 'filter_mpoet_archive_subject' ), 2); 
  117. echo apply_filters('mpoet_archive_subject', $newsletter); 
  118. ?> 
  119. </span> 
  120. </li> 
  121. <?php 
  122. echo '</ul>'; 
  123. ?> 
  124. <style type="text/css"> 
  125. ul.wysija_archive { 
  126. list-style-type: none; 
  127. ul.wysija_archive li { 
  128. padding-top: 5px; 
  129. </style> 
  130. <?php 
  131.  
  132. /** 
  133. * Filter Wysija_archive_date 
  134. * @param type $sent_at 
  135. * @return type 
  136. */ 
  137. public function filter_mpoet_archive_date($sent_at) { 
  138. return $this->fieldListHTML_created_at($sent_at).' : '; 
  139.  
  140. /** 
  141. * Filter Wysija_archive_date 
  142. * @param type $sent_at 
  143. * @return type 
  144. */ 
  145. public function filter_mpoet_archive_subject($newsletter) { 
  146. $email_helper = WYSIJA::get('email', 'helper'); 
  147. $full_url = $email_helper->getVIB($newsletter); 
  148. ?> 
  149. <a href="<?php echo $full_url ?>" target="_blank" class="viewnews" title="<?php _e('Preview in new tab', WYSIJA) ?>"> 
  150. <?php echo $newsletter->subject; ?> 
  151. </a> 
  152. <?php 
  153.