接口封装,添加getBody和getSubject函数

This commit is contained in:
wlx 2011-10-13 10:12:00 +00:00
parent b6d78f51ad
commit 81258f1700
1 changed files with 27 additions and 21 deletions

View File

@ -1,20 +1,19 @@
<?php
class EmailText{
private $tmpid;
private $db;
private $data;
protected $tmpinfo;
var $tmpid;
var $db;
var $data;
var $tmpinfo;
function __construct()
function __construct($db,$id,$replace)
{
if(empty($this->tmpid))
{
$this->tmpid = 0;
}
$this->db=$db;
$this->tmpid=$id;
$this->data=$replace;
$this->load();
}
public function getinfo(){
protected function getinfo(){
if(is_numeric($this->tmpid))
$sql = "select * from emailtext where id='".$this->tmpid."'";
@ -27,18 +26,19 @@ class EmailText{
}
public function loadtmp(){
public function load($body){
if(empty($this->tmpid))
{
return false;
}else{
if (empty($body))
{
$this->getinfo();
$body=$this->tmpinfo['body'];
}
$c = $this->tmpinfo;
if(!empty($c['id']))
if(!empty($body))
{
if(count($this->data)==0)
{
@ -55,8 +55,8 @@ class EmailText{
}
ksort($patterns);
ksort($replacements);
$newString=preg_replace($patterns, $replacements, $c['body']);
return $newString;
$this->tmpinfo['body']=preg_replace($patterns, $replacements, $body);
return true;
}//count($this->data)
}
else
@ -65,4 +65,10 @@ class EmailText{
}
}//empty($this->tmpid)
}//function loadtmp
public function getBody() {
return $this->tmpinfo['body'];
}
public function getSubject() {
return $this->tmpinfo['subject'];
}
}