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