Skip to content
Snippets Groups Projects
Commit 240dee31 authored by Fabio Stegmeyer's avatar Fabio Stegmeyer
Browse files

Merge branch 'feature_mail_preview' into 'master'

[TASK] Add mail preview function

See merge request !32
parents ee51c0df 195391a9
No related branches found
No related tags found
1 merge request!32[TASK] Add mail preview function
...@@ -182,6 +182,18 @@ class QueueController extends ActionController { ...@@ -182,6 +182,18 @@ class QueueController extends ActionController {
$this->redirect('index', NULL, NULL, $this->request->getArguments()); $this->redirect('index', NULL, NULL, $this->request->getArguments());
} }
/**
* Preview for a mail
*
* @param int $uid
*/
public function previewAction($uid): void {
$mailService = new MailTemplateService();
$mailToPreview = $mailService->getMailObjectByUid($uid);
$this->view->assign('mail', $mailToPreview);
}
/** /**
* Download the queue data as a csv file, respecting the filter settings * Download the queue data as a csv file, respecting the filter settings
* *
...@@ -225,7 +237,8 @@ class QueueController extends ActionController { ...@@ -225,7 +237,8 @@ class QueueController extends ActionController {
// save the Template filter to the session // save the Template filter to the session
if (!isset($_SESSION[$this->session->getSessionKey()]['filterTemplate']) if (!isset($_SESSION[$this->session->getSessionKey()]['filterTemplate'])
|| (isset($_POST['filterTemplate']) && $this->session->getDataByKey('filterTemplate') !== $_POST['filterTemplate'])) { || (isset($_POST['filterTemplate'])
&& $this->session->getDataByKey('filterTemplate') !== $_POST['filterTemplate'])) {
$this->session->setDataByKey('filterTemplate', $_POST['filterTemplate']); $this->session->setDataByKey('filterTemplate', $_POST['filterTemplate']);
} }
......
...@@ -1263,7 +1263,7 @@ class MailTemplateService { ...@@ -1263,7 +1263,7 @@ class MailTemplateService {
* @param int $uid * @param int $uid
* @return bool|object * @return bool|object
*/ */
private function getMailObjectByUid($uid) { public function getMailObjectByUid($uid) {
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) { if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var MailRepository $mailRepository */ /** @var MailRepository $mailRepository */
$mailRepository = $this->objectManager->get(MailRepository::class); $mailRepository = $this->objectManager->get(MailRepository::class);
......
...@@ -589,6 +589,30 @@ Die Templates declined und approved der Extension sg_comments sind für alle Dom ...@@ -589,6 +589,30 @@ Die Templates declined und approved der Extension sg_comments sind für alle Dom
<source><![CDATA[Do you want to send the newsletter to all recipients?]]></source> <source><![CDATA[Do you want to send the newsletter to all recipients?]]></source>
<target><![CDATA[Möchten Sie den Newsletter an allen Empfänger senden?]]></target> <target><![CDATA[Möchten Sie den Newsletter an allen Empfänger senden?]]></target>
</trans-unit> </trans-unit>
<trans-unit id="backend.preview.date">
<source><![CDATA[Date]]></source>
<target><![CDATA[Datum]]></target>
</trans-unit>
<trans-unit id="backend.preview.from">
<source><![CDATA[From]]></source>
<target><![CDATA[Von]]></target>
</trans-unit>
<trans-unit id="backend.preview.subject">
<source><![CDATA[Subject]]></source>
<target><![CDATA[Betreff]]></target>
</trans-unit>
<trans-unit id="backend.preview.to">
<source><![CDATA[To]]></source>
<target><![CDATA[An]]></target>
</trans-unit>
<trans-unit id="backend.preview.cc">
<source><![CDATA[CC]]></source>
<target><![CDATA[CC]]></target>
</trans-unit>
<trans-unit id="backend.preview.bcc">
<source><![CDATA[BCC]]></source>
<target><![CDATA[BCC]]></target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>
...@@ -441,6 +441,24 @@ The templates declined and approved of the sg_comments extension are blacklisted ...@@ -441,6 +441,24 @@ The templates declined and approved of the sg_comments extension are blacklisted
<trans-unit id="backend.newsletter.confirm_send"> <trans-unit id="backend.newsletter.confirm_send">
<source><![CDATA[Do you want to send the newsletter to all recipients?]]></source> <source><![CDATA[Do you want to send the newsletter to all recipients?]]></source>
</trans-unit> </trans-unit>
<trans-unit id="backend.preview.date">
<source><![CDATA[Date]]></source>
</trans-unit>
<trans-unit id="backend.preview.from">
<source><![CDATA[From]]></source>
</trans-unit>
<trans-unit id="backend.preview.subject">
<source><![CDATA[Subject]]></source>
</trans-unit>
<trans-unit id="backend.preview.to">
<source><![CDATA[To]]></source>
</trans-unit>
<trans-unit id="backend.preview.cc">
<source><![CDATA[CC]]></source>
</trans-unit>
<trans-unit id="backend.preview.bcc">
<source><![CDATA[BCC]]></source>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>
{namespace sgm=SGalinski\SgMail\ViewHelpers}
<head>
<link rel="stylesheet" href="{f:uri.resource(path: 'StyleSheets/preview.css')}">
</head>
<body>
<f:render section="mailPreview"></f:render>
</body>
{namespace sgm=SGalinski\SgMail\ViewHelpers} {namespace sgm=SGalinski\SgMail\ViewHelpers}
<f:layout name="Queue" /> <f:layout name="Queue"/>
<f:section name="iconButtons"> <f:section name="iconButtons">
</f:section> </f:section>
<f:section name="content"> <f:section name="content">
<f:flashMessages /> <f:flashMessages/>
<f:if condition="!{pages}"> <f:if condition="!{pages}">
<f:render partial="Queue/Filter" arguments="{filterFields: filterFields, filters: filters, languages: languages, templatesFilter: templatesFilter, selectedTemplateFilter: selectedTemplateFilter, selectedExtensionFilter: selectedExtensionFilter}" /> <f:render partial="Queue/Filter"
arguments="{filterFields: filterFields, filters: filters, languages: languages, templatesFilter: templatesFilter, selectedTemplateFilter: selectedTemplateFilter, selectedExtensionFilter: selectedExtensionFilter}"/>
<f:if condition="{queue -> f:count()} > 0"> <f:if condition="{queue -> f:count()} > 0">
<f:then> <f:then>
<div class="panel panel-default recordlist"> <div class="panel panel-default recordlist">
<div class="table-fit"> <div class="table-fit">
<table data-table="tx_sgmail_domain_model_mail" class="table table-striped table-hover"> <table data-table="tx_sgmail_domain_model_mail" class="table table-striped table-hover">
<sgm:backend.widget.paginate objects="{queue}" as="paginatedMails" configuration="{insertAbove: 1, itemsPerPage: 20}"> <sgm:backend.widget.paginate objects="{queue}" as="paginatedMails"
configuration="{insertAbove: 1, itemsPerPage: 20}">
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
<th><f:translate key="backend.from" /> <br> <f:translate key="backend.to" /> <th>
</th> <f:translate key="backend.from"/>
<th><f:translate key="backend.filter.extension" />: <br>
<f:translate key="backend.filter.template" /> <br> <f:translate key="backend.to"/>
<f:translate key="backend.subject" /></th> </th>
<th><f:translate key="backend.entry_date" /> <br> <th>
<f:translate key="backend.last_sent" /></th> <f:translate key="backend.filter.extension"/>
<th></th> :
<th></th> <f:translate key="backend.filter.template"/>
</tr> <br>
<f:translate key="backend.subject"/>
</th>
<th>
<f:translate key="backend.entry_date"/>
<br>
<f:translate key="backend.last_sent"/>
</th>
<th></th>
<th></th>
</tr>
</thead> </thead>
<tbody> <tbody>
<f:for each="{paginatedMails}" as="mail"> <f:for each="{paginatedMails}" as="mail">
<tr data-uid="{mail.uid}"> <tr data-uid="{mail.uid}">
<td nowrap="nowrap" class="col-icon"> <td nowrap="nowrap" class="col-icon">
<sgm:backend.icon table="tx_sgmail_domain_model_mail" row="{mail}" /> <sgm:backend.icon table="tx_sgmail_domain_model_mail" row="{mail}"/>
</td> </td>
<td> <td>
<span>{mail.from_address}</span> <span>{mail.from_address}</span>
<hr> <hr>
<span>{mail.to_address}</span> <span>{mail.to_address}</span>
</td> </td>
<td> <td>
<span>{mail.extension_key}: {mail.template_name}</span> <span>{mail.extension_key}: {mail.template_name}</span>
<hr> <hr>
<f:if condition="{mail.mail_subject}"> <f:if condition="{mail.mail_subject}">
<f:then> <f:then>
<span><f:format.crop maxCharacters="40" append="...">{mail.mail_subject}</f:format.crop></span> <span><f:format.crop maxCharacters="40" append="...">{mail.mail_subject}</f:format.crop></span>
</f:then> </f:then>
<f:else> <f:else>
&nbsp; &nbsp;
</f:else> </f:else>
</f:if> </f:if>
</td> </td>
<td> <td>
<span><f:format.date format="d.m.Y H:i">{mail.crdate}</f:format.date></span> <span><f:format.date format="d.m.Y H:i">{mail.crdate}</f:format.date></span>
<hr> <hr>
<f:if condition="{mail.last_sending_time} != 0"> <f:if condition="{mail.last_sending_time} != 0">
<f:then> <f:then>
<span><f:format.date format="d.m.Y H:i">{mail.last_sending_time}</f:format.date></span> <span><f:format.date
</f:then> format="d.m.Y H:i">{mail.last_sending_time}</f:format.date></span>
<f:else> </f:then>
<f:translate key="backend.not_sent" /> <f:else>
</f:else> <f:translate key="backend.not_sent"/>
</f:if> </f:else>
</td> </f:if>
<td nowrap="nowrap" class="col-control"> </td>
<sgm:backend.control table="tx_sgmail_domain_model_mail" row="{mail}" /> <td nowrap="nowrap" class="col-control">
</td> <sgm:backend.control table="tx_sgmail_domain_model_mail" row="{mail}"/>
<td> </td>
<f:if condition="{mail.blacklisted}"> <td>
<f:then> <f:if condition="{mail.blacklisted}">
<b><f:translate key="backend.queue.blacklisted" /></b> <f:then>
</f:then> <b>
<f:else> <f:translate key="backend.queue.blacklisted"/>
<f:link.action class="btn btn-default btn-send-now" controller="Queue" action="sendMail" arguments="{uid: mail.uid, selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}"> </b>
<span class="t3js-icon icon icon-size-small icon-state-default actions-document-import-t3d"> </f:then>
<f:else>
<f:link.action class="btn btn-default btn-send-now"
controller="Queue" action="sendMail"
arguments="{uid: mail.uid, selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}">
<span
class="t3js-icon icon icon-size-small icon-state-default actions-document-import-t3d">
<span class="icon-markup"> <span class="icon-markup">
<img src="/typo3/sysext/core/Resources/Public/Icons/T3Icons/actions/actions-document-import-t3d.svg" width="16" height="16"> <core:icon identifier="actions-document-import-t3d"/>
</span> </span>
</span> </span>
<f:translate key="backend.send_now" /> <f:translate key="backend.send_now"/>
</f:link.action> </f:link.action>
</f:else> </f:else>
</f:if> </f:if>
</td> <button class="btn btn-default btn-preview"
</f:for> onClick="MailPreviewWindow{mail.uid}=window.open('{f:uri.action( controller: 'Queue', action: 'preview', noCacheHash: true, arguments: {uid: mail.uid, selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey})}','MailPreviewWindow{mail.uid}','width=1200,height=768'); return false;">
<core:icon identifier="actions-view-page"/>
</button>
</td>
</f:for>
</tbody> </tbody>
</sgm:backend.widget.paginate> </sgm:backend.widget.paginate>
</table> </table>
...@@ -93,27 +115,27 @@ ...@@ -93,27 +115,27 @@
</div> </div>
</f:then> </f:then>
<f:else> <f:else>
<f:render partial="Queue/Empty" /> <f:render partial="Queue/Empty"/>
</f:else> </f:else>
</f:if> </f:if>
</f:if> </f:if>
<f:if condition="{pages}"> <f:if condition="{pages}">
<f:render partial="Mail/Empty" /> <f:render partial="Mail/Empty"/>
<div class="panel panel-default recordlist"> <div class="panel panel-default recordlist">
<div class="table-fit"> <div class="table-fit">
<table data-table="pages" class="table table-striped table-hover"> <table data-table="pages" class="table table-striped table-hover">
<tbody> <tbody>
<f:for each="{pages}" as="page"> <f:for each="{pages}" as="page">
<tr data-uid="{page.pid}"> <tr data-uid="{page.pid}">
<td nowrap="nowrap" class="col-title"> <td nowrap="nowrap" class="col-title">
<f:link.action action="index" additionalParams="{id: page.uid, returnUrl: returnUrl}"> <f:link.action action="index" additionalParams="{id: page.uid, returnUrl: returnUrl}">
<sgm:backend.icon table="pages" row="{page}" clickMenu="0" /> <sgm:backend.icon table="pages" row="{page}" clickMenu="0"/>
{page._thePathFull} {page._thePathFull}
</f:link.action> </f:link.action>
</td> </td>
</tr> </tr>
</f:for> </f:for>
</tbody> </tbody>
</table> </table>
</div> </div>
......
<f:layout name="Preview"/>
<f:section name="mailPreview">
<div class="mail-header">
<table>
<tr>
<th>
<f:translate key="backend.preview.date"/>
</th>
<td>
<f:format.date format="d.m.Y H:i">
<f:format.stripTags>{mail.sendingTime}</f:format.stripTags>
</f:format.date>
</td>
</tr>
<tr>
<th>
<f:translate key="backend.preview.from"/>
</th>
<td>
<f:format.stripTags>{mail.fromName}</f:format.stripTags>
&lt;<f:format.stripTags>{mail.fromAddress}</f:format.stripTags>&gt;
</td>
</tr>
<tr>
<th>
<f:translate key="backend.preview.subject"/>
</th>
<td>
<strong>
<f:format.stripTags>{mail.mailSubject}</f:format.stripTags>
</strong>
</td>
</tr>
<tr>
<th>
<f:translate key="backend.preview.to"/>
</th>
<td class="ng-binding">
<f:format.stripTags>{mail.toAddress}</f:format.stripTags>
</td>
</tr>
<f:if condition="{mail.ccAddresses}">
<tr>
<th>
<f:translate key="backend.preview.cc"/>
</th>
<td class="ng-binding">
<f:format.stripTags>{mail.ccAddresses}</f:format.stripTags>
</td>
</tr>
</f:if>
<f:if condition="{mail.bccAddresses}">
<tr>
<th>
<f:translate key="backend.preview.bcc"/>
</th>
<td class="ng-binding">
<f:format.stripTags>{mail.bccAddresses}</f:format.stripTags>
</td>
</tr>
</f:if>
</table>
</div>
<div class="mail-body">
<iframe class="mail-body-iframe" srcdoc="{mail.mailBody}" sandbox></iframe>
</div>
</f:section>
* {
font-family: Sans-Serif;
}
body {
margin: 0;
}
.mail-header {
border-bottom: 1px solid #666;
padding: 5px 7px;
}
.mail-header tbody td {
width: 100%;
font-size: 15px;
}
.mail-header tbody th {
white-space: nowrap;
text-align: right;
color: #666;
font-weight: normal;
font-size: 15px;
}
.mail-header table td,
.mail-header table th {
padding: 2px 7px;
}
.mail-body {
padding: 10px;
}
.mail-body-iframe{
border: none;
width: 100%;
max-width: 1280px;
height:100vh;
}
...@@ -32,7 +32,7 @@ call_user_func( ...@@ -32,7 +32,7 @@ call_user_func(
'', '',
[ [
'Mail' => 'index, sendTestMail, empty, reset', 'Mail' => 'index, sendTestMail, empty, reset',
'Queue' => 'index, sendMail, export', 'Queue' => 'index, sendMail, export, preview',
'Configuration' => 'index, create, edit, delete', 'Configuration' => 'index, create, edit, delete',
'Layout' => 'index', 'Layout' => 'index',
'Newsletter' => 'index, sendTestMail, empty', 'Newsletter' => 'index, sendTestMail, empty',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment