mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
wip
This commit is contained in:
parent
ca15b03eda
commit
6d0c2ec5ca
@ -55,15 +55,17 @@ class TemplateEmail extends Mailable
|
||||
$this->build_email->setBody(str_replace('$body', $this->build_email->getBody(), $this->client->getSetting('email_style_custom')));
|
||||
}
|
||||
|
||||
$this->build_email->setBody(
|
||||
DesignHelpers::parseMarkdownToHtml($this->build_email->getBody())
|
||||
);
|
||||
|
||||
$settings = $this->client->getMergedSettings();
|
||||
|
||||
$this->build_email->setBody(
|
||||
TemplateEngine::wrapElementsIntoTables('<div id="content-wrapper"></div>', $this->build_email->getBody(), $settings)
|
||||
);
|
||||
if ($this->build_email->getTemplate() !== 'custom') {
|
||||
$this->build_email->setBody(
|
||||
DesignHelpers::parseMarkdownToHtml($this->build_email->getBody())
|
||||
);
|
||||
|
||||
$this->build_email->setBody(
|
||||
TemplateEngine::wrapElementsIntoTables('<div id="content-wrapper"></div>', $this->build_email->getBody(), $settings)
|
||||
);
|
||||
}
|
||||
|
||||
$company = $this->client->company;
|
||||
|
||||
|
@ -52,6 +52,10 @@ class TemplateEngine
|
||||
private $raw_body;
|
||||
|
||||
private $raw_subject;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $labels_and_values;
|
||||
|
||||
public function __construct($body, $subject, $entity, $entity_id, $template)
|
||||
{
|
||||
@ -165,17 +169,24 @@ class TemplateEngine
|
||||
|
||||
private function entityValues($contact)
|
||||
{
|
||||
$this->labels_and_values = (new HtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues();
|
||||
|
||||
$data = (new HtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues();
|
||||
|
||||
$this->body = strtr($this->body, $data['labels']);
|
||||
$this->body = strtr($this->body, $data['values']);
|
||||
$this->body = strtr($this->body, $this->labels_and_values['labels']);
|
||||
$this->body = strtr($this->body, $this->labels_and_values['values']);
|
||||
// $this->body = str_replace("\n", "<br>", $this->body);
|
||||
|
||||
$this->subject = strtr($this->subject, $data['labels']);
|
||||
$this->subject = strtr($this->subject, $data['values']);
|
||||
$this->subject = strtr($this->subject, $this->labels_and_values['labels']);
|
||||
$this->subject = strtr($this->subject, $this->labels_and_values['values']);
|
||||
|
||||
$this->body = DesignHelpers::parseMarkdownToHtml($this->body);
|
||||
$email_style = $this->settings_entity->getSetting('email_style');
|
||||
|
||||
if ($email_style !== 'custom') {
|
||||
$this->body = DesignHelpers::parseMarkdownToHtml($this->body);
|
||||
}
|
||||
|
||||
if ($email_style == 'custom') {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function renderTemplate()
|
||||
@ -192,6 +203,11 @@ class TemplateEngine
|
||||
if ($email_style == 'custom') {
|
||||
$wrapper = $this->settings_entity->getSetting('email_style_custom');
|
||||
|
||||
// In order to parse variables such as $signature in the body,
|
||||
// we need to replace strings with the values from HTMLEngine.
|
||||
|
||||
$wrapper = strtr($wrapper, $this->labels_and_values['values']);
|
||||
|
||||
/*If no custom design exists, send back a blank!*/
|
||||
if (strlen($wrapper) > 1) {
|
||||
$wrapper = $this->renderView($wrapper, $data);
|
||||
@ -204,9 +220,13 @@ class TemplateEngine
|
||||
$wrapper = str_replace('<head>', $injection, $wrapper);
|
||||
}
|
||||
|
||||
// $body = $email_style == 'custom'
|
||||
// ? $this->body
|
||||
// : self::wrapElementsIntoTables(strtr($wrapper, ['$body' => '']), $this->body, $this->entity_obj->client->getMergedSettings());
|
||||
|
||||
$data = [
|
||||
'subject' => $this->subject,
|
||||
'body' => self::wrapElementsIntoTables(strtr($wrapper, ['$body' => '']), $this->body, $this->entity_obj->client->getMergedSettings()),
|
||||
'body' => $this->body,
|
||||
'wrapper' => $wrapper,
|
||||
'raw_body' => $this->raw_body,
|
||||
'raw_subject' => $this->raw_subject
|
||||
@ -262,10 +282,6 @@ class TemplateEngine
|
||||
|
||||
public static function wrapElementsIntoTables(string $wrapper, string $body, $settings): ?string
|
||||
{
|
||||
$wrapper = $wrapper == strip_tags($wrapper)
|
||||
? '<div id="content-wrapper"></div>'
|
||||
: $wrapper;
|
||||
|
||||
$documents['wrapper'] = new \DOMDocument();
|
||||
$documents['wrapper']->loadHTML($wrapper);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user