From 81258f170007fcc3c1f5d3423f0ddbea17a63a8e Mon Sep 17 00:00:00 2001 From: wlx Date: Thu, 13 Oct 2011 10:12:00 +0000 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=B0=81=E8=A3=85=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0getBody=E5=92=8CgetSubject=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/models/EmailText.php | 48 ++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/application/models/EmailText.php b/application/models/EmailText.php index da3bcf18..cca59a22 100644 --- a/application/models/EmailText.php +++ b/application/models/EmailText.php @@ -1,20 +1,19 @@ tmpid)) - { - $this->tmpid = 0; - } + function __construct($db,$id,$replace) + { + $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']; + } - $this->getinfo(); - - $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 @@ -64,5 +64,11 @@ class EmailText{ return false; } }//empty($this->tmpid) - }//function loadtmp + }//function loadtmp + public function getBody() { + return $this->tmpinfo['body']; + } + public function getSubject() { + return $this->tmpinfo['subject']; + } } \ No newline at end of file