Action.class.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2009 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. // $Id$
  12. /**
  13. +------------------------------------------------------------------------------
  14. * ThinkPHP 简洁模式Action控制器基类
  15. +------------------------------------------------------------------------------
  16. */
  17. abstract class Action extends Think
  18. {//类定义开始
  19. /**
  20. +----------------------------------------------------------
  21. * 架构函数
  22. +----------------------------------------------------------
  23. * @access public
  24. +----------------------------------------------------------
  25. */
  26. public function __construct()
  27. {
  28. //控制器初始化
  29. if(method_exists($this,'_initialize')) {
  30. $this->_initialize();
  31. }
  32. }
  33. /**
  34. +----------------------------------------------------------
  35. * 魔术方法 有不存在的操作的时候执行
  36. +----------------------------------------------------------
  37. * @access public
  38. +----------------------------------------------------------
  39. * @param string $method 方法名
  40. * @param array $parms 参数
  41. +----------------------------------------------------------
  42. * @return mixed
  43. +----------------------------------------------------------
  44. */
  45. public function __call($method,$parms) {
  46. if(strtolower($method) == strtolower(ACTION_NAME)) {
  47. // 如果定义了_empty操作 则调用
  48. if(method_exists($this,'_empty')) {
  49. $this->_empty($method,$parms);
  50. }else {
  51. // 抛出异常
  52. throw_exception(L('_ERROR_ACTION_').ACTION_NAME);
  53. }
  54. }else{
  55. throw_exception(__CLASS__.':'.$method.L('_METHOD_NOT_EXIST_'));
  56. }
  57. }
  58. }//类定义结束
  59. ?>