From dcc821f3c612cdff59f33b460df91ea187973727 Mon Sep 17 00:00:00 2001 From: Michael van Schaik Date: Tue, 14 Mar 2017 06:10:27 +0100 Subject: [PATCH 1/3] Update UserFormRecipientItemRequest::preview to use theme-templates Fixes #556 --- code/model/recipients/UserFormRecipientItemRequest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/model/recipients/UserFormRecipientItemRequest.php b/code/model/recipients/UserFormRecipientItemRequest.php index 171efb4..cbd2341 100644 --- a/code/model/recipients/UserFormRecipientItemRequest.php +++ b/code/model/recipients/UserFormRecipientItemRequest.php @@ -20,6 +20,9 @@ class UserFormRecipientItemRequest extends GridFieldDetailForm_ItemRequest */ public function preview() { + // Enable theme for preview (may be needed for Shortcodes) + Config::inst()->update('SSViewer', 'theme_enabled', true); + return $this->customise(new ArrayData(array( 'Body' => $this->record->getEmailBodyContent(), 'HideFormData' => $this->record->HideFormData, From 091997027b95901d1a430230b3426b4426aef6e2 Mon Sep 17 00:00:00 2001 From: Michael van Schaik Date: Fri, 2 Jun 2017 09:17:39 +0200 Subject: [PATCH 2/3] Adding back previous value for SSViewer::theme_enabled --- code/model/recipients/UserFormRecipientItemRequest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/model/recipients/UserFormRecipientItemRequest.php b/code/model/recipients/UserFormRecipientItemRequest.php index cbd2341..1d9e494 100644 --- a/code/model/recipients/UserFormRecipientItemRequest.php +++ b/code/model/recipients/UserFormRecipientItemRequest.php @@ -21,13 +21,19 @@ class UserFormRecipientItemRequest extends GridFieldDetailForm_ItemRequest public function preview() { // Enable theme for preview (may be needed for Shortcodes) + $previous_theme_enabled = Config::inst()->get('SSViewer', 'theme_enabled'); Config::inst()->update('SSViewer', 'theme_enabled', true); - return $this->customise(new ArrayData(array( + $ret = $this->customise(new ArrayData(array( 'Body' => $this->record->getEmailBodyContent(), 'HideFormData' => $this->record->HideFormData, 'Fields' => $this->getPreviewFieldData() )))->renderWith($this->record->EmailTemplate); + + // reset theme preview value + Config::inst()->update('SSViewer', 'theme_enabled', $previous_theme_enabled); + + return $ret; } /** From c02181e69b4b7b060ac17959d52bf45255769f5e Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 9 Jun 2017 10:19:58 +1200 Subject: [PATCH 3/3] FIX Use configuration nesting wrapper around themed preview logic --- .../recipients/UserFormRecipientItemRequest.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/code/model/recipients/UserFormRecipientItemRequest.php b/code/model/recipients/UserFormRecipientItemRequest.php index 1d9e494..777e92a 100644 --- a/code/model/recipients/UserFormRecipientItemRequest.php +++ b/code/model/recipients/UserFormRecipientItemRequest.php @@ -21,19 +21,18 @@ class UserFormRecipientItemRequest extends GridFieldDetailForm_ItemRequest public function preview() { // Enable theme for preview (may be needed for Shortcodes) - $previous_theme_enabled = Config::inst()->get('SSViewer', 'theme_enabled'); + Config::nest(); Config::inst()->update('SSViewer', 'theme_enabled', true); - - $ret = $this->customise(new ArrayData(array( + + $content = $this->customise(new ArrayData(array( 'Body' => $this->record->getEmailBodyContent(), 'HideFormData' => $this->record->HideFormData, 'Fields' => $this->getPreviewFieldData() )))->renderWith($this->record->EmailTemplate); - - // reset theme preview value - Config::inst()->update('SSViewer', 'theme_enabled', $previous_theme_enabled); - - return $ret; + + Config::unnest(); + + return $content; } /**