接口封装,添加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; $this->db=$db;
var $tmpinfo; $this->tmpid=$id;
$this->data=$replace;
function __construct() $this->load();
{
if(empty($this->tmpid))
{
$this->tmpid = 0;
}
} }
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();
$body=$this->tmpinfo['body'];
}
$this->getinfo(); if(!empty($body))
$c = $this->tmpinfo;
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
@ -64,5 +64,11 @@ class EmailText{
return false; return false;
} }
}//empty($this->tmpid) }//empty($this->tmpid)
}//function loadtmp }//function loadtmp
public function getBody() {
return $this->tmpinfo['body'];
}
public function getSubject() {
return $this->tmpinfo['subject'];
}
} }