This repository has been archived by the owner on Jan 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<iframe class="htmlPreview" src="" width="100%" height="530" frameborder="1"></iframe> | ||
<hr /> | ||
<pre> | ||
{$plainText} | ||
</pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* @class CM_Component_EmailPreview | ||
* @extends CM_Component_Abstract | ||
*/ | ||
var CM_Component_EmailPreview = CM_Component_Abstract.extend({ | ||
_class: 'CM_Component_EmailPreview', | ||
|
||
html: null, | ||
|
||
ready: function() { | ||
var $iframe = this.$('.htmlPreview'); | ||
$iframe.attr('src', 'data:text/html;charset=utf-8,' + encodeURI(this.html)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
class CM_Component_EmailPreview extends CM_Component_Abstract { | ||
|
||
public function checkAccessible(CM_Render $render) { | ||
} | ||
|
||
public function prepare() { | ||
$email = $this->_params->get('email'); | ||
if (!$email instanceof CM_Mail) { | ||
throw new CM_Exception_InvalidParam('Invalid `email` param'); | ||
} | ||
$userDefault = $this->_getViewer(); | ||
$user = $this->_params->has('user') ? $this->_params->getUser('user') : $userDefault; | ||
|
||
$render = new CM_Render(null, $user); | ||
list($subject, $html, $plainText) = $render->render($email); | ||
$this->setTplParam('plainText', $plainText); | ||
$this->_setJsParam('html', $html); | ||
} | ||
} |