BaseAction.class.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 BaseAction extends Action{
  10. //后台基础类构造
  11. protected $lang_pack;
  12. public function __construct()
  13. {
  14. parent::__construct();
  15. check_install();
  16. //重新处理后台的语言加载机制,后台语言环境配置于后台config.php文件
  17. $langSet = conf('DEFAULT_LANG');
  18. // 定义当前语言
  19. define('LANG_SET',strtolower($langSet));
  20. // 读取项目公共语言包
  21. if (is_file(LANG_PATH.$langSet.'/common.php'))
  22. {
  23. L(include LANG_PATH.$langSet.'/common.php');
  24. $this->lang_pack = require LANG_PATH.$langSet.'/common.php';
  25. if(is_file(LANG_PATH.$langSet.'/weixin.php')){
  26. L(include LANG_PATH.$langSet.'/weixin.php');
  27. $weixin_lang= require LANG_PATH.$langSet.'/weixin.php';
  28. $this->lang_pack=array_merge($this->lang_pack,$weixin_lang);
  29. }
  30. if(!file_exists(APP_ROOT_PATH."public/runtime/admin/lang.js"))
  31. {
  32. $str = "var LANG = {";
  33. foreach($this->lang_pack as $k=>$lang)
  34. {
  35. $str .= "\"".$k."\":\"".$lang."\",";
  36. }
  37. $str = substr($str,0,-1);
  38. $str .="};";
  39. file_put_contents(APP_ROOT_PATH."public/runtime/admin/lang.js",$str);
  40. }
  41. }
  42. }
  43. protected function error($message,$ajax = 0)
  44. {
  45. if(!$this->get("jumpUrl"))
  46. {
  47. if($_SERVER["HTTP_REFERER"]) $default_jump = $_SERVER["HTTP_REFERER"]; else $default_jump = u("Index/main");
  48. $this->assign("jumpUrl",$default_jump);
  49. }
  50. parent::error($message,$ajax);
  51. }
  52. protected function success($message,$ajax = 0)
  53. {
  54. if(!$this->get("jumpUrl"))
  55. {
  56. if($_SERVER["HTTP_REFERER"]) $default_jump = $_SERVER["HTTP_REFERER"]; else $default_jump = u("Index/main");
  57. $this->assign("jumpUrl",$default_jump);
  58. }
  59. parent::success($message,$ajax);
  60. }
  61. }
  62. ?>