MsgTemplateAction.class.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class MsgTemplateAction extends CommonAction{
  10. public function index()
  11. {
  12. $tpl_list = M("MsgTemplate")->where("type = 0 ")->findAll();
  13. $this->assign("tpl_list",$tpl_list);
  14. $this->display();
  15. }
  16. public function load_tpl()
  17. {
  18. $name = trim($_REQUEST['name']);
  19. $tpl = M("MsgTemplate")->where("name='".$name."'")->find();
  20. if($tpl)
  21. {
  22. $tpl['tip'] = l("MSG_TIP_".strtoupper($name));
  23. $this->ajaxReturn($tpl,'',1);
  24. }
  25. else
  26. {
  27. $this->ajaxReturn('','',0);
  28. }
  29. }
  30. public function update()
  31. {
  32. //$data = M(MODULE_NAME)->create ();
  33. $data = array();
  34. $data['id'] = intval($_REQUEST['id']);
  35. $data['name'] = strim($_REQUEST['name']);
  36. $data['content'] = $_REQUEST['content'];
  37. //$data['content'] = stripslashes($_REQUEST['content']);
  38. $data['is_html'] = intval($_REQUEST['is_html']);
  39. $return=array('info'=>'','status'=>'0');
  40. if($data['name']=='' || $data['id']==0)
  41. {
  42. $info=l("SELECT_MSG_TPL");
  43. header("Content-Type:text/html; charset=utf-8");
  44. echo $info;
  45. }
  46. $log_info = $data['name'];
  47. // 更新数据
  48. $list=M(MODULE_NAME)->save ($data);
  49. if (false !== $list) {
  50. //成功提示
  51. save_log($log_info.L("UPDATE_SUCCESS"),1);
  52. $info='"'.L("LANG_".$data['name']).'"模板'.L("UPDATE_SUCCESS");
  53. $return['status']=1;
  54. header("Content-Type:text/html; charset=utf-8");
  55. echo $info;
  56. } else {
  57. //错误提示
  58. save_log($log_info.L("UPDATE_FAILED"),0);
  59. $info=L("LANG_".$data['name'])."模板".L("UPDATE_FAILED");
  60. $return['status']=0;
  61. header("Content-Type:text/html; charset=utf-8");
  62. echo $info;
  63. }
  64. }
  65. public function ajax_tpl()
  66. {
  67. $type=intval($_REQUEST['type']);
  68. $tpl_list = M("MsgTemplate")->where("type=".$type)->findAll();
  69. $data['list'] = $tpl_list;
  70. $data['type'] = $type;
  71. $this->ajaxReturn($data,'',1);
  72. }
  73. }
  74. ?>