예제 #1
0
  * @param string $templateFile 指定要调用的模板文件
  * 默认为空 由系统自动定位模板文件
  * @param string $content 模板输出内容
  * @param string $prefix 模板缓存前缀* 
  * @return string
  */
 protected function fetch($templateFile = '', $content = '', $prefix = '')
 {
     return $this->view->fetch($templateFile, $content, $prefix);
 }
 /**
  * 模板主题设置
  * @access protected
  * @param string $theme 模版主题
  * @return Action
  */
 protected function theme($theme)
 {
예제 #2
0
 protected function alert($message = '', $jumpUrl = '')
 {
     $alert['message'] = $message;
     $alert['jumpUrl'] = $jumpUrl;
     $this->assign('alert', $alert);
     $templateFile = $this->view->parseTemplate($jumpUrl);
     // 模板文件不存在直接返回
     if (!is_file($templateFile)) {
         redirect($jumpUrl);
     } else {
         $this->display();
     }
     exit;
 }
예제 #3
0
파일: Action.class.php 프로젝트: lzygjq/Tp
 /**
  * 魔术方法 有不存在的操作的时候执行
  * @access public
  * @param string $method 方法名
  * @param array $args 参数
  * @return mixed
  */
 public function __call($method, $args)
 {
     if (0 === strcasecmp($method, ACTION_NAME . C('ACTION_SUFFIX'))) {
         if (method_exists($this, '_empty')) {
             // 如果定义了_empty操作 则调用
             $this->_empty($method, $args);
         } elseif (file_exists_case($this->view->parseTemplate())) {
             // 检查是否存在默认模版 如果有直接输出模版
             $this->display();
         } elseif (function_exists('__hack_action')) {
             // hack 方式定义扩展操作
             __hack_action();
         } else {
             _404(L('_ERROR_ACTION_') . ':' . ACTION_NAME);
         }
     } else {
         switch (strtolower($method)) {
             // 判断提交方式
             case 'ispost':
             case 'isget':
             case 'ishead':
             case 'isdelete':
             case 'isput':
                 return strtolower($_SERVER['REQUEST_METHOD']) == strtolower(substr($method, 2));
                 // 获取变量 支持过滤和默认值 调用方式 $this->_post($key,$filter,$default);
             // 获取变量 支持过滤和默认值 调用方式 $this->_post($key,$filter,$default);
             case '_get':
                 $input =& $_GET;
                 break;
             case '_post':
                 $input =& $_POST;
                 break;
             case '_put':
                 parse_str(file_get_contents('php://input'), $input);
                 break;
             case '_param':
                 switch ($_SERVER['REQUEST_METHOD']) {
                     case 'POST':
                         $input = $_POST;
                         break;
                     case 'PUT':
                         parse_str(file_get_contents('php://input'), $input);
                         break;
                     default:
                         $input = $_GET;
                 }
                 if (C('VAR_URL_PARAMS') && isset($_GET[C('VAR_URL_PARAMS')])) {
                     $input = array_merge($input, $_GET[C('VAR_URL_PARAMS')]);
                 }
                 break;
             case '_request':
                 $input =& $_REQUEST;
                 break;
             case '_session':
                 $input =& $_SESSION;
                 break;
             case '_cookie':
                 $input =& $_COOKIE;
                 break;
             case '_server':
                 $input =& $_SERVER;
                 break;
             case '_globals':
                 $input =& $GLOBALS;
                 break;
             default:
                 throw_exception(__CLASS__ . ':' . $method . L('_METHOD_NOT_EXIST_'));
         }
         if (!isset($args[0])) {
             // 获取全局变量
             $data = $input;
             // 由VAR_FILTERS配置进行过滤
         } elseif (isset($input[$args[0]])) {
             // 取值操作
             $data = $input[$args[0]];
             $filters = isset($args[1]) ? $args[1] : C('DEFAULT_FILTER');
             if ($filters) {
                 // 2012/3/23 增加多方法过滤支持
                 $filters = explode(',', $filters);
                 foreach ($filters as $filter) {
                     if (function_exists($filter)) {
                         $data = is_array($data) ? array_map($filter, $data) : $filter($data);
                         // 参数过滤
                     }
                 }
             }
         } else {
             // 变量默认值
             $data = isset($args[2]) ? $args[2] : NULL;
         }
         Log::record('建议使用I方法替代' . $method, Log::NOTICE);
         return $data;
     }
 }