updating EmailComponent, making lineLength public, deprecating protected _lineLength, default value of 70, updating docblocks,

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7105 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-06-03 17:26:30 +00:00
parent 2d2096d9f7
commit 6affb7f70a

View file

@ -27,9 +27,10 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description for file.
* EmailComponent
*
* Long description for file
* This component is used for handling Internet Message Format based
* based on the standard outlined in http://www.rfc-editor.org/rfc/rfc2822.txt
*
* @package cake
* @subpackage cake.cake.libs.controller.components
@ -103,7 +104,7 @@ class EmailComponent extends Object{
var $subject = null;
/**
* Associative array of a user defined headers
* Keys will be prefixed 'X-' as per RFC822 Section 4.7.5
* Keys will be prefixed 'X-' as per RFC2822 Section 4.7.5
*
* @var array
* @access public
@ -132,6 +133,17 @@ class EmailComponent extends Object{
* @access public
*/
var $template = null;
/**
* as per RFC2822 Section 2.1.1
*
* @var integer
* @access public
*/
var $lineLength = 70;
/**
* @deprecated see lineLength
*/
var $_lineLength = null;
/**
* What format should the email be sent in
*
@ -199,9 +211,9 @@ class EmailComponent extends Object{
* @var array
* @access public
*/
var $smtpOptions = array('port'=> 25,
'host' => 'localhost',
'timeout' => 30);
var $smtpOptions = array(
'port'=> 25, 'host' => 'localhost', 'timeout' => 30
);
/**
* Placeholder for any errors that might happen with the
* smtp mail methods
@ -231,13 +243,6 @@ class EmailComponent extends Object{
* @access protected
*/
var $_newLine = "\r\n";
/**
* Enter description here...
*
* @var integer
* @access protected
*/
var $_lineLength = 70;
/**
* Enter description here...
*
@ -548,7 +553,7 @@ class EmailComponent extends Object{
return null;
}
/**
* Wrap the message using EmailComponet::$_lineLength
* Wrap the message using EmailComponent::$lineLength
*
* @param string $message Message to wrap
* @return string Wrapped message
@ -560,11 +565,16 @@ class EmailComponent extends Object{
$lines = explode("\n", $message);
$formatted = null;
if ($this->_lineLength !== null) {
trigger_error('_lineLength cannot be accessed please use lineLength', E_USER_WARNING);
$this->lineLength = $this->_lineLength;
}
foreach ($lines as $line) {
if(substr($line, 0, 1) == '.') {
$line = '.' . $line;
}
$formatted .= wordwrap($line, $this->_lineLength, $this->_newLine, true);
$formatted .= wordwrap($line, $this->lineLength, $this->_newLine, true);
$formatted .= $this->_newLine;
}
return $formatted;