WYSIJA_control_front_email

The MailPoet Newsletters WYSIJA control front email class.

Defined (1)

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

/controllers/front/email.php  
  1. class WYSIJA_control_front_email extends WYSIJA_control_front{ 
  2. var $model='email'; 
  3. var $view='email'; 
  4.  
  5. function __construct() { 
  6. parent::__construct(); 
  7.  
  8. function view() { 
  9.  
  10. $data=array(); 
  11.  
  12. header('Content-type:text/html; charset=utf-8'); 
  13.  
  14. // Get email model as object. 
  15. $emailM = WYSIJA::get('email', 'model'); 
  16. $emailM->getFormat = OBJECT; 
  17. // Get config model 
  18. $configM = WYSIJA::get('config', 'model'); 
  19. $configM->add_translated_default(); 
  20. // Helpers 
  21. $emailH = WYSIJA::get('email', 'helper'); 
  22. $mailerH = WYSIJA::get('mailer', 'helper'); 
  23.  
  24. $email_id = (int)$_REQUEST['email_id']; 
  25. // Get current email object. 
  26. $current_email = $emailM->getOne($email_id); 
  27. if(empty($current_email)) exit; 
  28. if($current_email->type==2) { 
  29.  
  30. $emailM->reset(); 
  31. $autonewsHelper = WYSIJA::get('autonews', 'helper'); 
  32. $autonewsHelper->refresh_automatic_content(array($email_id)); 
  33. $emailM->getFormat = OBJECT; 
  34. $current_email = $emailM->getOne($email_id); 
  35.  
  36. // Get current user object if possible 
  37. $current_user = null; 
  38.  
  39. // Parse and replace user tags. 
  40. $mailerH->parseUserTags($current_email); 
  41. $mailerH->parseSubjectUserTags($current_email); 
  42. $mailerH->replaceusertags($current_email, $current_user); 
  43.  
  44. // Set Body 
  45. $email_render = $current_email->body; 
  46.  
  47. // Parse old shortcodes that we are parsing in the queue. 
  48. $find = array('[unsubscribe_linklabel]'); 
  49. $replace = array($configM->getValue('unsubscribe_linkname')); 
  50. if (isset($current_email->params['autonl']['articles']['first_subject'])) { 
  51. $find[] = '[post_title]'; 
  52. $replace[] = $current_email->params['autonl']['articles']['first_subject']; 
  53. if (isset($current_email->params['autonl']['articles']['total'])) { 
  54. $find[] = '[total]'; 
  55. $replace[] = $current_email->params['autonl']['articles']['total']; 
  56.  
  57. // if (isset($current_email->params['autonl']['articles']['ids'])) { 
  58. // $find[] = '[number]'; 
  59. // $replace[] = count($current_email->params['autonl']['articles']['ids']); 
  60. // } 
  61.  
  62. if (isset($current_email->params['autonl']['total_child'])) { 
  63. $find[] = '[number]'; 
  64. $replace[] = $current_email->params['autonl']['total_child']; 
  65.  
  66. $email_render1 = str_replace($find, $replace, $email_render); 
  67. // Strip unsubscribe links. 
  68. $email_render2 = $emailH->stripPersonalLinks($email_render1); 
  69.  
  70. echo apply_filters('wysija_preview', $email_render2); 
  71.  
  72. exit; 
  73.