Skip to content
Snippets Groups Projects
Commit f159a649 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

BulkMail preview fixes

parent 0efd60b8
No related branches found
No related tags found
No related merge requests found
......@@ -241,6 +241,7 @@
<entityField>
<name>preview</name>
<title>Preview</title>
<contentTypeProcess>%aditoprj%/entity/BulkMail_entity/entityfields/preview/contentTypeProcess.js</contentTypeProcess>
<valueProcess>%aditoprj%/entity/BulkMail_entity/entityfields/preview/valueProcess.js</valueProcess>
</entityField>
</entityFields>
......
import("system.vars");
import("system.result");
import("DocumentTemplate_lib");
result.string(vars.get("$context.currentTemplateType") == DocumentTemplate.types.TXT
? "LONG_TEXT"
: "HTML");
\ No newline at end of file
......@@ -55,18 +55,13 @@ function DocumentTemplate(pTemplateContent, pType, pFilename, pResolveSubtemplat
/**
* @return {String} the text of the content
*/
DocumentTemplate.prototype.toString = function (pWithSubtemplates, pEmlOnlyBody)
DocumentTemplate.prototype.toString = function (pWithSubtemplates)
{
if (this._stringCache == null)
{
var content = this._getTemplatedContent(pWithSubtemplates);
if (this.type == DocumentTemplate.types.PLAIN)
this._stringCache = content;
else if (pEmlOnlyBody && this.type == DocumentTemplate.types.EML)
{
let email = Email.fromRFC(util.encodeBase64String(content))
this._stringCache = email.body;
}
else
this._stringCache = text.parseDocument(content);
}
......@@ -291,14 +286,7 @@ DocumentTemplate.getSelectedTemplate = function (pTemplateId, pDocumentUpload, p
DocumentTemplate.prototype.getReplacedContent = function (pReplacements, pEncoded, pEmlOnlyBody)
{
// if there exists a _subtemplatedContent we use it because then I assume that the replacements are already based on content + subtemplates
if (!pEmlOnlyBody)
{
var content;
if (this._subtemplatedContent == null)
content = this.content
else
content = this._subtemplatedContent
}
var content = this._getTemplatedContent(true);
switch (this.type)
{
......@@ -314,7 +302,10 @@ DocumentTemplate.prototype.getReplacedContent = function (pReplacements, pEncode
case DocumentTemplate.types.EML:
let emlContent
if (pEmlOnlyBody)
emlContent = this.toString(true, true)
{
var email = Email.fromRFC(content)
emlContent = email.body
}
else
emlContent = util.decodeBase64String(content);
emlContent = TemplateHelper._replaceText(emlContent, pReplacements, TemplateHelper._getSpecialRegexp(this));
......@@ -465,8 +456,7 @@ TemplateHelper._replaceText = function (pText, pReplacements, pSpecialCharFilter
TemplateHelper._getRequiredPlaceholders = function (pTemplate)
{
var content = "";
// for eml search the whole file not just the body text as placeholders could be anywhere (e.g. subject)
content = pTemplate.toString(true, false);
content = pTemplate.toString(true);
// get special regexp (e.g. to filter '=' in emls)
var filterRegexpPart = TemplateHelper._getSpecialRegexp(pTemplate);
......
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