mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merged revisions 49405 via svnmerge from
svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq ........ r49405 | ischommer | 2008-02-12 12:09:50 +1300 (Tue, 12 Feb 2008) | 2 lines moved Email_Template functionality into Email class reordered methods in Email ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@52408 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
4f46aff087
commit
57ef489ffb
@ -118,20 +118,9 @@ class Email extends ViewableData {
|
||||
$this->customHeaders[$headerName] .= $headerValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Debugging help
|
||||
*/
|
||||
public function debug() {
|
||||
$this->parseVariables();
|
||||
|
||||
return "<h2>Email template $this->class</h2>\n" .
|
||||
"<p><b>From:</b> $this->from\n" .
|
||||
"<b>To:</b> $this->to\n" .
|
||||
"<b>Cc:</b> $this->cc\n" .
|
||||
"<b>Bcc:</b> $this->bcc\n" .
|
||||
"<b>Subject:</b> $this->subject</p>" .
|
||||
$this->body;
|
||||
|
||||
public function BaseURL() {
|
||||
return Director::absoluteBaseURL();
|
||||
}
|
||||
|
||||
protected function templateData() {
|
||||
@ -158,6 +147,20 @@ class Email extends ViewableData {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate this email template with values.
|
||||
* This may be called many times.
|
||||
*/
|
||||
function populateTemplate($data) {
|
||||
if($this->template_data) {
|
||||
$this->template_data = $this->template_data->customise($data);
|
||||
} else {
|
||||
if(is_array($data)) $data = new ArrayData($data);
|
||||
$this->template_data = $this->customise($data);
|
||||
}
|
||||
$this->parseVariables_done = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all the template variables into the internal variables, including
|
||||
* the template into body. Called before send() or debugSend()
|
||||
@ -193,13 +196,28 @@ class Email extends ViewableData {
|
||||
$this->body = HTTP::absoluteURLs($fullBody);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Debugging help
|
||||
*/
|
||||
public function debug() {
|
||||
$this->parseVariables();
|
||||
|
||||
return "<h2>Email template $this->class</h2>\n" .
|
||||
"<p><b>From:</b> $this->from\n" .
|
||||
"<b>To:</b> $this->to\n" .
|
||||
"<b>Cc:</b> $this->cc\n" .
|
||||
"<b>Bcc:</b> $this->bcc\n" .
|
||||
"<b>Subject:</b> $this->subject</p>" .
|
||||
$this->body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc Validates the email address. Returns true of false
|
||||
*/
|
||||
static function validEmailAddress($address) {
|
||||
return ereg('^([a-zA-Z0-9_+\.\-]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$', $address);
|
||||
}
|
||||
/**
|
||||
* @desc Validates the email address. Returns true of false
|
||||
*/
|
||||
static function validEmailAddress($address) {
|
||||
return ereg('^([a-zA-Z0-9_+\.\-]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$', $address);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc Send the email in plaintext
|
||||
@ -383,26 +401,7 @@ class Email extends ViewableData {
|
||||
* @subpackage email
|
||||
*/
|
||||
class Email_Template extends Email {
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
public function BaseURL() {
|
||||
return Director::absoluteBaseURL();
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate this email template with values.
|
||||
* This may be called many times.
|
||||
*/
|
||||
function populateTemplate($data) {
|
||||
if($this->template_data) {
|
||||
$this->template_data = $this->template_data->customise($data);
|
||||
} else {
|
||||
if(is_array($data)) $data = new ArrayData($data);
|
||||
$this->template_data = $this->customise($data);
|
||||
}
|
||||
$this->parseVariables_done = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user