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
......@@ -182,6 +182,18 @@ class QueueController extends ActionController {
$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
*
......@@ -225,7 +237,8 @@ class QueueController extends ActionController {
// save the Template filter to the session
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']);
}
......
......@@ -1263,7 +1263,7 @@ class MailTemplateService {
* @param int $uid
* @return bool|object
*/
private function getMailObjectByUid($uid) {
public function getMailObjectByUid($uid) {
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var MailRepository $mailRepository */
$mailRepository = $this->objectManager->get(MailRepository::class);
......
......@@ -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>
<target><![CDATA[Möchten Sie den Newsletter an allen Empfänger senden?]]></target>
</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>
</file>
</xliff>
......@@ -441,6 +441,24 @@ The templates declined and approved of the sg_comments extension are blacklisted
<trans-unit id="backend.newsletter.confirm_send">
<source><![CDATA[Do you want to send the newsletter to all recipients?]]></source>
</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>
</file>
</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}
<f:layout name="Queue" />
<f:layout name="Queue"/>
<f:section name="iconButtons">
</f:section>
<f:section name="content">
<f:flashMessages />
<f:flashMessages/>
<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:then>
<div class="panel panel-default recordlist">
<div class="table-fit">
<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>
<tr>
<th></th>
<th><f:translate key="backend.from" /> <br> <f:translate key="backend.to" />
</th>
<th><f:translate key="backend.filter.extension" />:
<f:translate key="backend.filter.template" /> <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>
<tr>
<th></th>
<th>
<f:translate key="backend.from"/>
<br>
<f:translate key="backend.to"/>
</th>
<th>
<f:translate key="backend.filter.extension"/>
:
<f:translate key="backend.filter.template"/>
<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>
<tbody>
<f:for each="{paginatedMails}" as="mail">
<tr data-uid="{mail.uid}">
<td nowrap="nowrap" class="col-icon">
<sgm:backend.icon table="tx_sgmail_domain_model_mail" row="{mail}" />
</td>
<td>
<span>{mail.from_address}</span>
<hr>
<span>{mail.to_address}</span>
</td>
<td>
<span>{mail.extension_key}: {mail.template_name}</span>
<hr>
<f:if condition="{mail.mail_subject}">
<f:then>
<span><f:format.crop maxCharacters="40" append="...">{mail.mail_subject}</f:format.crop></span>
</f:then>
<f:else>
&nbsp;
</f:else>
</f:if>
<f:for each="{paginatedMails}" as="mail">
<tr data-uid="{mail.uid}">
<td nowrap="nowrap" class="col-icon">
<sgm:backend.icon table="tx_sgmail_domain_model_mail" row="{mail}"/>
</td>
<td>
<span>{mail.from_address}</span>
<hr>
<span>{mail.to_address}</span>
</td>
<td>
<span>{mail.extension_key}: {mail.template_name}</span>
<hr>
<f:if condition="{mail.mail_subject}">
<f:then>
<span><f:format.crop maxCharacters="40" append="...">{mail.mail_subject}</f:format.crop></span>
</f:then>
<f:else>
&nbsp;
</f:else>
</f:if>
</td>
<td>
<span><f:format.date format="d.m.Y H:i">{mail.crdate}</f:format.date></span>
<hr>
<f:if condition="{mail.last_sending_time} != 0">
<f:then>
<span><f:format.date format="d.m.Y H:i">{mail.last_sending_time}</f:format.date></span>
</f:then>
<f:else>
<f:translate key="backend.not_sent" />
</f:else>
</f:if>
</td>
<td nowrap="nowrap" class="col-control">
<sgm:backend.control table="tx_sgmail_domain_model_mail" row="{mail}" />
</td>
<td>
<f:if condition="{mail.blacklisted}">
<f:then>
<b><f:translate key="backend.queue.blacklisted" /></b>
</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">
</td>
<td>
<span><f:format.date format="d.m.Y H:i">{mail.crdate}</f:format.date></span>
<hr>
<f:if condition="{mail.last_sending_time} != 0">
<f:then>
<span><f:format.date
format="d.m.Y H:i">{mail.last_sending_time}</f:format.date></span>
</f:then>
<f:else>
<f:translate key="backend.not_sent"/>
</f:else>
</f:if>
</td>
<td nowrap="nowrap" class="col-control">
<sgm:backend.control table="tx_sgmail_domain_model_mail" row="{mail}"/>
</td>
<td>
<f:if condition="{mail.blacklisted}">
<f:then>
<b>
<f:translate key="backend.queue.blacklisted"/>
</b>
</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">
<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>
<f:translate key="backend.send_now" />
</f:link.action>
</f:else>
</f:if>
</td>
</f:for>
<f:translate key="backend.send_now"/>
</f:link.action>
</f:else>
</f:if>
<button class="btn btn-default btn-preview"
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>
</sgm:backend.widget.paginate>
</table>
......@@ -93,27 +115,27 @@
</div>
</f:then>
<f:else>
<f:render partial="Queue/Empty" />
<f:render partial="Queue/Empty"/>
</f:else>
</f:if>
</f:if>
<f:if condition="{pages}">
<f:render partial="Mail/Empty" />
<f:render partial="Mail/Empty"/>
<div class="panel panel-default recordlist">
<div class="table-fit">
<table data-table="pages" class="table table-striped table-hover">
<tbody>
<f:for each="{pages}" as="page">
<tr data-uid="{page.pid}">
<td nowrap="nowrap" class="col-title">
<f:link.action action="index" additionalParams="{id: page.uid, returnUrl: returnUrl}">
<sgm:backend.icon table="pages" row="{page}" clickMenu="0" />
{page._thePathFull}
</f:link.action>
</td>
</tr>
</f:for>
<f:for each="{pages}" as="page">
<tr data-uid="{page.pid}">
<td nowrap="nowrap" class="col-title">
<f:link.action action="index" additionalParams="{id: page.uid, returnUrl: returnUrl}">
<sgm:backend.icon table="pages" row="{page}" clickMenu="0"/>
{page._thePathFull}
</f:link.action>
</td>
</tr>
</f:for>
</tbody>
</table>
</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(
'',
[
'Mail' => 'index, sendTestMail, empty, reset',
'Queue' => 'index, sendMail, export',
'Queue' => 'index, sendMail, export, preview',
'Configuration' => 'index, create, edit, delete',
'Layout' => 'index',
'Newsletter' => 'index, sendTestMail, empty',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment