From fac5ae50d0491f8941b9f8d43faf272406adaf00 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 20 Apr 2011 23:47:21 -0400 Subject: [PATCH] Moved the emails templates from elements to views. Renamed the path in layouts to keep the same name. Fixes #1415. --- .../{elements/email => emails}/html/empty | 0 .../{elements/email => emails}/text/empty | 0 app/View/layouts/{email => emails}/html/empty | 0 app/View/layouts/{email => emails}/text/empty | 0 .../email => emails}/html/default.ctp | 0 .../email => emails}/text/default.ctp | 0 .../{email => emails}/html/default.ctp | 0 .../{email => emails}/text/default.ctp | 0 lib/Cake/Network/CakeEmail.php | 29 ++++++++++--------- .../email => emails}/html/default.ctp | 0 .../email => emails}/text/default.ctp | 0 .../{email => emails}/html/default.ctp | 0 .../{email => emails}/text/default.ctp | 0 .../email => emails}/html/custom.ctp | 0 .../email => emails}/html/default.ctp | 0 .../email => emails}/html/nested_element.ctp | 0 .../email => emails}/text/custom.ctp | 0 .../email => emails}/text/default.ctp | 0 .../{elements/email => emails}/text/wide.ctp | 0 .../{email => emails}/html/default.ctp | 0 .../layouts/{email => emails}/html/thin.ctp | 0 .../{email => emails}/text/default.ctp | 0 22 files changed, 16 insertions(+), 13 deletions(-) rename app/View/{elements/email => emails}/html/empty (100%) rename app/View/{elements/email => emails}/text/empty (100%) rename app/View/layouts/{email => emails}/html/empty (100%) rename app/View/layouts/{email => emails}/text/empty (100%) rename lib/Cake/Console/templates/skel/View/{elements/email => emails}/html/default.ctp (100%) rename lib/Cake/Console/templates/skel/View/{elements/email => emails}/text/default.ctp (100%) rename lib/Cake/Console/templates/skel/View/layouts/{email => emails}/html/default.ctp (100%) rename lib/Cake/Console/templates/skel/View/layouts/{email => emails}/text/default.ctp (100%) rename lib/Cake/View/{elements/email => emails}/html/default.ctp (100%) rename lib/Cake/View/{elements/email => emails}/text/default.ctp (100%) rename lib/Cake/View/layouts/{email => emails}/html/default.ctp (100%) rename lib/Cake/View/layouts/{email => emails}/text/default.ctp (100%) rename lib/Cake/tests/test_app/View/{elements/email => emails}/html/custom.ctp (100%) rename lib/Cake/tests/test_app/View/{elements/email => emails}/html/default.ctp (100%) rename lib/Cake/tests/test_app/View/{elements/email => emails}/html/nested_element.ctp (100%) rename lib/Cake/tests/test_app/View/{elements/email => emails}/text/custom.ctp (100%) rename lib/Cake/tests/test_app/View/{elements/email => emails}/text/default.ctp (100%) rename lib/Cake/tests/test_app/View/{elements/email => emails}/text/wide.ctp (100%) rename lib/Cake/tests/test_app/View/layouts/{email => emails}/html/default.ctp (100%) rename lib/Cake/tests/test_app/View/layouts/{email => emails}/html/thin.ctp (100%) rename lib/Cake/tests/test_app/View/layouts/{email => emails}/text/default.ctp (100%) diff --git a/app/View/elements/email/html/empty b/app/View/emails/html/empty similarity index 100% rename from app/View/elements/email/html/empty rename to app/View/emails/html/empty diff --git a/app/View/elements/email/text/empty b/app/View/emails/text/empty similarity index 100% rename from app/View/elements/email/text/empty rename to app/View/emails/text/empty diff --git a/app/View/layouts/email/html/empty b/app/View/layouts/emails/html/empty similarity index 100% rename from app/View/layouts/email/html/empty rename to app/View/layouts/emails/html/empty diff --git a/app/View/layouts/email/text/empty b/app/View/layouts/emails/text/empty similarity index 100% rename from app/View/layouts/email/text/empty rename to app/View/layouts/emails/text/empty diff --git a/lib/Cake/Console/templates/skel/View/elements/email/html/default.ctp b/lib/Cake/Console/templates/skel/View/emails/html/default.ctp similarity index 100% rename from lib/Cake/Console/templates/skel/View/elements/email/html/default.ctp rename to lib/Cake/Console/templates/skel/View/emails/html/default.ctp diff --git a/lib/Cake/Console/templates/skel/View/elements/email/text/default.ctp b/lib/Cake/Console/templates/skel/View/emails/text/default.ctp similarity index 100% rename from lib/Cake/Console/templates/skel/View/elements/email/text/default.ctp rename to lib/Cake/Console/templates/skel/View/emails/text/default.ctp diff --git a/lib/Cake/Console/templates/skel/View/layouts/email/html/default.ctp b/lib/Cake/Console/templates/skel/View/layouts/emails/html/default.ctp similarity index 100% rename from lib/Cake/Console/templates/skel/View/layouts/email/html/default.ctp rename to lib/Cake/Console/templates/skel/View/layouts/emails/html/default.ctp diff --git a/lib/Cake/Console/templates/skel/View/layouts/email/text/default.ctp b/lib/Cake/Console/templates/skel/View/layouts/emails/text/default.ctp similarity index 100% rename from lib/Cake/Console/templates/skel/View/layouts/email/text/default.ctp rename to lib/Cake/Console/templates/skel/View/layouts/emails/text/default.ctp diff --git a/lib/Cake/Network/CakeEmail.php b/lib/Cake/Network/CakeEmail.php index 251b179ed0c..7b49eeeb6ab 100644 --- a/lib/Cake/Network/CakeEmail.php +++ b/lib/Cake/Network/CakeEmail.php @@ -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 . '"'; @@ -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[] = ''; @@ -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[] = ''; @@ -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; diff --git a/lib/Cake/View/elements/email/html/default.ctp b/lib/Cake/View/emails/html/default.ctp similarity index 100% rename from lib/Cake/View/elements/email/html/default.ctp rename to lib/Cake/View/emails/html/default.ctp diff --git a/lib/Cake/View/elements/email/text/default.ctp b/lib/Cake/View/emails/text/default.ctp similarity index 100% rename from lib/Cake/View/elements/email/text/default.ctp rename to lib/Cake/View/emails/text/default.ctp diff --git a/lib/Cake/View/layouts/email/html/default.ctp b/lib/Cake/View/layouts/emails/html/default.ctp similarity index 100% rename from lib/Cake/View/layouts/email/html/default.ctp rename to lib/Cake/View/layouts/emails/html/default.ctp diff --git a/lib/Cake/View/layouts/email/text/default.ctp b/lib/Cake/View/layouts/emails/text/default.ctp similarity index 100% rename from lib/Cake/View/layouts/email/text/default.ctp rename to lib/Cake/View/layouts/emails/text/default.ctp diff --git a/lib/Cake/tests/test_app/View/elements/email/html/custom.ctp b/lib/Cake/tests/test_app/View/emails/html/custom.ctp similarity index 100% rename from lib/Cake/tests/test_app/View/elements/email/html/custom.ctp rename to lib/Cake/tests/test_app/View/emails/html/custom.ctp diff --git a/lib/Cake/tests/test_app/View/elements/email/html/default.ctp b/lib/Cake/tests/test_app/View/emails/html/default.ctp similarity index 100% rename from lib/Cake/tests/test_app/View/elements/email/html/default.ctp rename to lib/Cake/tests/test_app/View/emails/html/default.ctp diff --git a/lib/Cake/tests/test_app/View/elements/email/html/nested_element.ctp b/lib/Cake/tests/test_app/View/emails/html/nested_element.ctp similarity index 100% rename from lib/Cake/tests/test_app/View/elements/email/html/nested_element.ctp rename to lib/Cake/tests/test_app/View/emails/html/nested_element.ctp diff --git a/lib/Cake/tests/test_app/View/elements/email/text/custom.ctp b/lib/Cake/tests/test_app/View/emails/text/custom.ctp similarity index 100% rename from lib/Cake/tests/test_app/View/elements/email/text/custom.ctp rename to lib/Cake/tests/test_app/View/emails/text/custom.ctp diff --git a/lib/Cake/tests/test_app/View/elements/email/text/default.ctp b/lib/Cake/tests/test_app/View/emails/text/default.ctp similarity index 100% rename from lib/Cake/tests/test_app/View/elements/email/text/default.ctp rename to lib/Cake/tests/test_app/View/emails/text/default.ctp diff --git a/lib/Cake/tests/test_app/View/elements/email/text/wide.ctp b/lib/Cake/tests/test_app/View/emails/text/wide.ctp similarity index 100% rename from lib/Cake/tests/test_app/View/elements/email/text/wide.ctp rename to lib/Cake/tests/test_app/View/emails/text/wide.ctp diff --git a/lib/Cake/tests/test_app/View/layouts/email/html/default.ctp b/lib/Cake/tests/test_app/View/layouts/emails/html/default.ctp similarity index 100% rename from lib/Cake/tests/test_app/View/layouts/email/html/default.ctp rename to lib/Cake/tests/test_app/View/layouts/emails/html/default.ctp diff --git a/lib/Cake/tests/test_app/View/layouts/email/html/thin.ctp b/lib/Cake/tests/test_app/View/layouts/emails/html/thin.ctp similarity index 100% rename from lib/Cake/tests/test_app/View/layouts/email/html/thin.ctp rename to lib/Cake/tests/test_app/View/layouts/emails/html/thin.ctp diff --git a/lib/Cake/tests/test_app/View/layouts/email/text/default.ctp b/lib/Cake/tests/test_app/View/layouts/emails/text/default.ctp similarity index 100% rename from lib/Cake/tests/test_app/View/layouts/email/text/default.ctp rename to lib/Cake/tests/test_app/View/layouts/emails/text/default.ctp