Action.class.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. * @param string $method 方法名
  26. * @param array $parms 参数
  27. +----------------------------------------------------------
  28. * @return mixed
  29. +----------------------------------------------------------
  30. */
  31. public function __call($method,$parms) {
  32. if(strtolower($method) == strtolower(ACTION_NAME)) {
  33. // 如果定义了_empty操作 则调用
  34. if(method_exists($this,'_empty')) {
  35. $this->_empty($method,$parms);
  36. }else {
  37. // 抛出异常
  38. exit(L('_ERROR_ACTION_').ACTION_NAME);
  39. }
  40. }else{
  41. exit(__CLASS__.':'.$method.L('_METHOD_NOT_EXIST_'));
  42. }
  43. }
  44. }//类定义结束
  45. ?>