From 646beea9851b12acac1579b3717c79874f783f00 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Thu, 13 Oct 2011 08:18:12 +0000 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=BC=96=E5=86=99=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/SysController.php | 34 ++++++-- .../views/scripts/sys/emailtexthelp.phtml | 79 +++++++++++++++++++ 2 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 application/admin/views/scripts/sys/emailtexthelp.phtml diff --git a/application/admin/controllers/SysController.php b/application/admin/controllers/SysController.php index 0a3ac65b..074b8665 100644 --- a/application/admin/controllers/SysController.php +++ b/application/admin/controllers/SysController.php @@ -91,14 +91,29 @@ class Admin_SysController extends Zend_Controller_Action { try{ $subject = $this->_request->getParam('subject'); - $email = $this->_request->getParam('email'); - $body = $this->_request->getParam('body'); - $body=str_replace("[username]",$this->_request->getParam('user'),$body); + $email = $this->_request->getParam('email'); + $body = $this->_request->getParam('body'); + if(empty($subject) || empty($email)) { $this->messenger->addMessage('请填写测试邮件发送信息'); $this->_redirect('/admin/sys/emailtext/ac/test/id/'.$id); - } + } + + $mailtp=new EmailText(); + $mailtp->db = $this->db; + $mailtp->tmpid = $this->_request->getParam('id'); + $mailtp->data = array( + 'user' => $this->_request->getParam('user') + ); + $body = $mailtp->loadtmp(); + if($body === false) + { + $this->messenger->addMessage('模板加载失败'); + $this->_redirect('/admin/sys/emailtext/ac/test/id/'.$id); + } + + $mail=new WestdcMailer($this->view->config->smtp); $mail->setBodyText($body); @@ -119,7 +134,7 @@ class Admin_SysController extends Zend_Controller_Action } } else - { + { $sql = "select * from emailtext where id='$id'"; $rs = $this->db->query($sql); $rows = $rs->fetch(); @@ -129,8 +144,14 @@ class Admin_SysController extends Zend_Controller_Action }//模板测试 + else if($ac=='help') + { + $this->_helper->viewRenderer('emailtexthelp'); + } + else { + try{ $sql = "select id,subject,template,ts_created,ts_changed from emailtext"; $rs = $this->db->query($sql); $rows = $rs->fetchAll(); @@ -141,6 +162,9 @@ class Admin_SysController extends Zend_Controller_Action $paginator->setView($this->view); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml'); $this->view->paginator=$paginator; + }catch (Exception $e){ + echo $e->getMessage(); + } }//邮件模板管理首页 }//emailtextAction 邮件模板管理 diff --git a/application/admin/views/scripts/sys/emailtexthelp.phtml b/application/admin/views/scripts/sys/emailtexthelp.phtml new file mode 100644 index 00000000..11bbe822 --- /dev/null +++ b/application/admin/views/scripts/sys/emailtexthelp.phtml @@ -0,0 +1,79 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台首页'); + $this->breadcrumb('系统管理'); + $this->breadcrumb('邮件模板管理'); + $this->breadcrumb()->setSeparator(' > '); +?> +
+partial('sys/left.phtml'); ?> +
+ +
+ msg or $this->messages) :?> +
+ msg) : ?> + msg; ?> + messages): foreach($this->messages as $msg): ?> + + + +
+ + +

邮件模板编写说明:

+
+

邮件模板编写时暂时不支持html格式,只能使用纯文本编写

+
+

+模板中可以使用变量标记,比如 {user} 将被替换为用户名,变量的起始使用“{”,结束使用"}",完整的变量格式应类似“{param}” +

+
+

+目前程序中已预制的变量包括: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
变量名说明输出值举例作用域
{user}用户名张三全局
{uuid}元数据UUID76bce7bb-e1b2-49c4-9537-668a6bac42a2全局
{title}元数据title黑河流域气象观测站点分布图专家邀请模板
+

+
+

+一个邮件模板例子:
+
+ +尊敬的{user}您好!想获得元数据《{title}》,请访问 http://westdc.westgis.ac.cn/data/{uuid} +

+ +
\ No newline at end of file