/** * Show a preview or the final version of an email * For this method we don't use extbase parameters system to have an URL as short as possible */ public function showAction() { // Override settings to NOT embed images inlines (doesn't make sense for web display) global $TYPO3_CONF_VARS; $theConf = unserialize($TYPO3_CONF_VARS['EXT']['extConf']['newsletter']); $theConf['attach_images'] = false; $TYPO3_CONF_VARS['EXT']['extConf']['newsletter'] = serialize($theConf); $newsletter = null; $email = null; $isPreview = empty($_GET['c']); // If we don't have an authentification code, we are in preview mode // If it's a preview, an email which was not sent yet, we will simulate it the best we can if ($isPreview) { // Create a fake newsletter and configure it with given parameters $newsletter = $this->objectManager->get('Ecodev\\Newsletter\\Domain\\Model\\Newsletter'); $newsletter->setPid(@$_GET['pid']); $newsletter->setUidRecipientList(@$_GET['uidRecipientList']); if ($newsletter) { // Find the recipient $recipientList = $newsletter->getRecipientList(); $recipientList->init(); while ($record = $recipientList->getRecipient()) { // Got him if ($record['email'] == $_GET['email']) { // Build a fake email $email = $this->objectManager->get('Ecodev\\Newsletter\\Domain\\Model\\Email'); $email->setRecipientAddress($record['email']); $email->setRecipientData($record); } } } } else { $email = $this->emailRepository->findByAuthcode($_GET['c']); if ($email) { $newsletter = $email->getNewsletter(); // Here we need to ensure that we have real newsletter instance because of type hinting on \Ecodev\Newsletter\Tools::getConfiguredMailer() if ($newsletter instanceof \TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy) { $newsletter = $newsletter->_loadRealInstance(); } } } // If we found everything needed, we can render the email $content = null; if ($newsletter && $email) { // Override some configuration // so we can customise the preview according to selected settings via JS, // and we can also prevent fake statistics when admin 'view' a sent email if (isset($_GET['plainConverter'])) { $newsletter->setPlainConverter($_GET['plainConverter']); } if (isset($_GET['injectOpenSpy'])) { $newsletter->setInjectOpenSpy($_GET['injectOpenSpy']); } if (isset($_GET['injectLinksSpy'])) { $newsletter->setInjectLinksSpy($_GET['injectLinksSpy']); } $mailer = Tools::getConfiguredMailer($newsletter, @$_GET['L']); $mailer->prepare($email, $isPreview); if (@$_GET['plain']) { $content = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><pre>'; $content .= $mailer->getPlain(); $content .= '</pre></body></html>'; } else { $content = $mailer->getHtml(); } } $this->view->assign('content', $content); }