Skip to content

Commit

Permalink
Moved the emails templates from elements to views. Renamed the path i…
Browse files Browse the repository at this point in the history
…n layouts to keep the same name. Fixes #1415.
  • Loading branch information
jrbasso committed Apr 21, 2011
1 parent 599d631 commit fac5ae5
Show file tree
Hide file tree
Showing 22 changed files with 16 additions and 13 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 16 additions & 13 deletions lib/Cake/Network/CakeEmail.php
Expand Up @@ -1261,14 +1261,13 @@ protected function _render($content) {
}

$View = new $viewClass(null);
$View->layout = $this->_layout;
$View->viewVars = $this->_viewVars;
$msg = array();

$content = implode("\n", $content);

if ($this->_emailFormat === 'both') {
$htmlContent = $content;
$originalContent = $content;
if (!empty($this->_attachments)) {
$msg[] = '--' . $this->_boundary;
$msg[] = 'Content-Type: multipart/alternative; boundary="alt-' . $this->_boundary . '"';
Expand All @@ -1279,10 +1278,10 @@ protected function _render($content) {
$msg[] = 'Content-Transfer-Encoding: 7bit';
$msg[] = '';

$content = $View->element('email' . DS . 'text' . DS . $this->_template, array('content' => $content), true);
$View->layoutPath = 'email' . DS . 'text';
$content = explode("\n", $this->_textMessage = str_replace(array("\r\n", "\r"), "\n", $View->renderLayout($content)));

$View->viewPath = $View->layoutPath = 'emails' . DS . 'text';
$View->viewVars['content'] = $originalContent;
$this->_textMessage = str_replace(array("\r\n", "\r"), "\n", $View->render($this->_template, $this->_layout));
$content = explode("\n", $this->_textMessage);
$msg = array_merge($msg, $content);

$msg[] = '';
Expand All @@ -1291,10 +1290,13 @@ protected function _render($content) {
$msg[] = 'Content-Transfer-Encoding: 7bit';
$msg[] = '';

$htmlContent = $View->element('email' . DS . 'html' . DS . $this->_template, array('content' => $htmlContent), true);
$View->layoutPath = 'email' . DS . 'html';
$htmlContent = explode("\n", $this->_htmlMessage = str_replace(array("\r\n", "\r"), "\n", $View->renderLayout($htmlContent)));
$msg = array_merge($msg, $htmlContent);
$View->viewPath = $View->layoutPath = 'emails' . DS . 'html';
$View->viewVars['content'] = $originalContent;
$View->hasRendered = false;
$this->_htmlMessage = str_replace(array("\r\n", "\r"), "\n", $View->render($this->_template, $this->_layout));
$content = explode("\n", $this->_htmlMessage);
$msg = array_merge($msg, $content);

$msg[] = '';
$msg[] = '--alt-' . $this->_boundary . '--';
$msg[] = '';
Expand All @@ -1317,9 +1319,10 @@ protected function _render($content) {
}
}

$content = $View->element('email' . DS . $this->_emailFormat . DS . $this->_template, array('content' => $content), true);
$View->layoutPath = 'email' . DS . $this->_emailFormat;
$content = explode("\n", $rendered = str_replace(array("\r\n", "\r"), "\n", $View->renderLayout($content)));
$View->viewPath = $View->layoutPath = 'emails' . DS . $this->_emailFormat;
$View->viewVars['content'] = $content;
$rendered = $View->render($this->_template, $this->_layout);
$content = explode("\n", $rendered);

if ($this->_emailFormat === 'html') {
$this->_htmlMessage = $rendered;
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit fac5ae5

Please sign in to comment.