mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
注释和规范化调整及完善
注释和规范化调整及完善,以及部分代码优化
This commit is contained in:
@@ -66,8 +66,9 @@ class App
|
||||
// 执行操作
|
||||
if (!preg_match('/^[A-Za-z](\/|\.|\w)*$/', CONTROLLER_NAME)) {
|
||||
// 安全检测
|
||||
$instance = false;
|
||||
} elseif ($config['action_bind_class']) {
|
||||
throw new Exception('[ ' . MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . Loader::parseName(str_replace('.', '\\', CONTROLLER_NAME), 1) . ' ] not exists');
|
||||
}
|
||||
if ($config['action_bind_class']) {
|
||||
$class = self::bindActionClass($config['empty_controller']);
|
||||
$instance = new $class;
|
||||
// 操作绑定到类后 固定执行run入口
|
||||
@@ -77,9 +78,6 @@ class App
|
||||
// 获取当前操作名
|
||||
$action = ACTION_NAME . $config['action_suffix'];
|
||||
}
|
||||
if (!$instance) {
|
||||
throw new Exception('[ ' . MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . Loader::parseName(str_replace('.', '\\', CONTROLLER_NAME), 1) . ' ] not exists');
|
||||
}
|
||||
|
||||
try {
|
||||
// 操作方法开始监听
|
||||
@@ -213,7 +211,10 @@ class App
|
||||
/**
|
||||
* URL调度
|
||||
* @access public
|
||||
* @return void
|
||||
*
|
||||
* @param $config
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function dispatch($config)
|
||||
{
|
||||
|
||||
54
library/think/behavior.php
Normal file
54
library/think/behavior.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace think;
|
||||
/**
|
||||
* ThinkPHP Behavior基础类
|
||||
* @category Think
|
||||
* @package Think
|
||||
* @subpackage Core
|
||||
* @author liu21st <liu21st@gmail.com>
|
||||
*/
|
||||
abstract class Behavior {
|
||||
|
||||
// 行为参数 和配置参数设置相同
|
||||
protected $options = array();
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct() {
|
||||
if(!empty($this->options)) {
|
||||
foreach ($this->options as $name=>$val){
|
||||
if(NULL !== C($name)) { // 参数已设置 则覆盖行为参数
|
||||
$this->options[$name] = C($name);
|
||||
}else{ // 参数未设置 则传入默认值到配置
|
||||
C($name,$val);
|
||||
}
|
||||
}
|
||||
array_change_key_case($this->options);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取行为参数
|
||||
public function __get($name){
|
||||
return $this->options[strtolower($name)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行行为 run方法是Behavior唯一的接口
|
||||
* @access public
|
||||
* @param mixed $params 行为参数
|
||||
* @return void
|
||||
*/
|
||||
abstract public function run(&$params);
|
||||
|
||||
}
|
||||
14
library/think/cache/driver/apc.php
vendored
14
library/think/cache/driver/apc.php
vendored
@@ -28,7 +28,10 @@ class Apc
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
*
|
||||
* @param array $options 缓存参数
|
||||
*
|
||||
* @throws Exception
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
@@ -58,7 +61,7 @@ class Apc
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return bool
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
@@ -89,11 +92,12 @@ class Apc
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
/**删除缓存
|
||||
* @access public
|
||||
*
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
*
|
||||
* @return bool|\string[]
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
@@ -103,7 +107,7 @@ class Apc
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolen
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
12
library/think/cache/driver/memcache.php
vendored
12
library/think/cache/driver/memcache.php
vendored
@@ -72,7 +72,7 @@ class Memcache
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return bool
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
@@ -106,9 +106,11 @@ class Memcache
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
*
|
||||
* @param string $name 缓存变量名
|
||||
* @param bool|false $ttl
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function rm($name, $ttl = false)
|
||||
{
|
||||
@@ -121,7 +123,7 @@ class Memcache
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolen
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
6
library/think/cache/driver/redis.php
vendored
6
library/think/cache/driver/redis.php
vendored
@@ -67,7 +67,7 @@ class Redis
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
@@ -107,7 +107,7 @@ class Redis
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ class Redis
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
2
library/think/cache/driver/secache.php
vendored
2
library/think/cache/driver/secache.php
vendored
@@ -65,7 +65,7 @@ class Secache
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function set($name, $value)
|
||||
{
|
||||
|
||||
24
library/think/cache/driver/simple.php
vendored
24
library/think/cache/driver/simple.php
vendored
@@ -26,6 +26,8 @@ class Simple
|
||||
/**
|
||||
* 架构函数
|
||||
* @access public
|
||||
*
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
{
|
||||
@@ -67,13 +69,15 @@ class Simple
|
||||
|
||||
/**
|
||||
* 写入缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return boolen
|
||||
* @access public
|
||||
*
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
*
|
||||
* @return bool
|
||||
* @internal param int $expire 有效时间 0为永久
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
public function set($name, $value)
|
||||
{
|
||||
$filename = $this->filename($name);
|
||||
// 缓存数据
|
||||
@@ -88,7 +92,7 @@ class Simple
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
@@ -97,9 +101,9 @@ class Simple
|
||||
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
* @access public
|
||||
* @return bool
|
||||
* @internal param string $name 缓存变量名
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
9
library/think/cache/driver/sqlite.php
vendored
9
library/think/cache/driver/sqlite.php
vendored
@@ -31,7 +31,10 @@ class Sqlite
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
*
|
||||
* @param array $options 缓存参数
|
||||
*
|
||||
* @throws Exception
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
@@ -74,7 +77,7 @@ class Sqlite
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
@@ -103,7 +106,7 @@ class Sqlite
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
@@ -116,7 +119,7 @@ class Sqlite
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
9
library/think/cache/driver/wincache.php
vendored
9
library/think/cache/driver/wincache.php
vendored
@@ -28,7 +28,10 @@ class Wincache
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
*
|
||||
* @param array $options 缓存参数
|
||||
*
|
||||
* @throws Exception
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
@@ -59,7 +62,7 @@ class Wincache
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
@@ -95,7 +98,7 @@ class Wincache
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
@@ -105,7 +108,7 @@ class Wincache
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
6
library/think/cache/driver/xcache.php
vendored
6
library/think/cache/driver/xcache.php
vendored
@@ -62,7 +62,7 @@ class Xcache
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
@@ -98,7 +98,7 @@ class Xcache
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ class Xcache
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
@@ -26,6 +26,8 @@ class Controller
|
||||
/**
|
||||
* 架构函数 初始化视图类 并采用内置模板引擎
|
||||
* @access public
|
||||
*
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
@@ -63,8 +65,8 @@ class Controller
|
||||
$this->config[$key] = $config[$key];
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,9 +57,12 @@ abstract class rest
|
||||
/**
|
||||
* REST 调用
|
||||
* @access public
|
||||
*
|
||||
* @param string $method 方法名
|
||||
* @param array $args 参数
|
||||
* @param array $args 参数
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function _empty($method, $args)
|
||||
{
|
||||
|
||||
@@ -51,17 +51,19 @@ class Cookie
|
||||
{
|
||||
if (empty($prefix)) {
|
||||
return self::$config['prefix'];
|
||||
} else {
|
||||
self::$config['prefix'] = $prefix;
|
||||
}
|
||||
self::$config['prefix'] = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cookie 设置、获取、删除
|
||||
* @param string $name cookie名称
|
||||
* @param mixed $value cookie值
|
||||
* @param mixed $options cookie参数
|
||||
*
|
||||
* @param string $name cookie名称
|
||||
* @param mixed $value cookie值
|
||||
* @param null $option
|
||||
*
|
||||
* @return mixed
|
||||
* @internal param mixed $options cookie参数
|
||||
*/
|
||||
public static function set($name, $value = '', $option = null)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,10 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 架构函数 读取数据库配置信息
|
||||
* @access public
|
||||
* @param array $config 数据库配置数组
|
||||
*
|
||||
* @param array|string $config 数据库配置数组
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($config = '')
|
||||
{
|
||||
@@ -45,11 +48,18 @@ class Mongo extends Driver
|
||||
$this->config['params'] = [];
|
||||
}
|
||||
}
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接数据库方法
|
||||
* @access public
|
||||
*
|
||||
* @param string $config
|
||||
* @param int $linkNum
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public function connect($config = '', $linkNum = 0)
|
||||
{
|
||||
@@ -71,10 +81,12 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 切换当前操作的Db和Collection
|
||||
* @access public
|
||||
* @param string $collection collection
|
||||
* @param string $db db
|
||||
* @param boolean $master 是否主服务器
|
||||
* @return void
|
||||
*
|
||||
* @param string $collection collection
|
||||
* @param string $db db
|
||||
* @param boolean $master 是否主服务器
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function switchCollection($collection, $db = '', $master = true)
|
||||
{
|
||||
@@ -137,9 +149,12 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 执行语句
|
||||
* @access public
|
||||
* @param string $code sql指令
|
||||
* @param array $args 参数
|
||||
*
|
||||
* @param string $code sql指令
|
||||
* @param array $args 参数
|
||||
*
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute($code, $args = [])
|
||||
{
|
||||
@@ -185,10 +200,13 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 插入记录
|
||||
* @access public
|
||||
* @param mixed $data 数据
|
||||
* @param array $options 参数表达式
|
||||
*
|
||||
* @param mixed $data 数据
|
||||
* @param array $options 参数表达式
|
||||
* @param boolean $replace 是否replace
|
||||
* @return false | integer
|
||||
*
|
||||
* @return false|int
|
||||
* @throws Exception
|
||||
*/
|
||||
public function insert($data, $options = [], $replace = false)
|
||||
{
|
||||
@@ -222,9 +240,12 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 插入多条记录
|
||||
* @access public
|
||||
*
|
||||
* @param array $dataList 数据
|
||||
* @param array $options 参数表达式
|
||||
* @param array $options 参数表达式
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function insertAll($dataList, $options = [])
|
||||
{
|
||||
@@ -246,8 +267,11 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 生成下一条记录ID 用于自增非MongoId主键
|
||||
* @access public
|
||||
*
|
||||
* @param string $pk 主键名
|
||||
* @return integer
|
||||
*
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getMongoNextId($pk)
|
||||
{
|
||||
@@ -268,9 +292,12 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 更新记录
|
||||
* @access public
|
||||
* @param mixed $data 数据
|
||||
*
|
||||
* @param mixed $data 数据
|
||||
* @param array $options 表达式
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function update($data, $options)
|
||||
{
|
||||
|
||||
@@ -42,6 +42,9 @@ class Mysql extends Driver
|
||||
/**
|
||||
* 取得数据表的字段信息
|
||||
* @access public
|
||||
* @param $tableName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFields($tableName)
|
||||
{
|
||||
@@ -68,6 +71,10 @@ class Mysql extends Driver
|
||||
/**
|
||||
* 取得数据库的表信息
|
||||
* @access public
|
||||
*
|
||||
* @param string $dbName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTables($dbName = '')
|
||||
{
|
||||
|
||||
@@ -94,6 +94,10 @@ class Oracle extends Driver
|
||||
/**
|
||||
* 取得数据表的字段信息
|
||||
* @access public
|
||||
*
|
||||
* @param $tableName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFields($tableName)
|
||||
{
|
||||
@@ -120,9 +124,11 @@ class Oracle extends Driver
|
||||
|
||||
/**
|
||||
* 取得数据库的表信息(暂时实现取得用户表信息)
|
||||
* @access public
|
||||
* @access public
|
||||
* @return array
|
||||
* @internal param string $dbName
|
||||
*/
|
||||
public function getTables($dbName = '')
|
||||
public function getTables()
|
||||
{
|
||||
$result = $this->query("select table_name from user_tables");
|
||||
$info = [];
|
||||
@@ -151,10 +157,11 @@ class Oracle extends Driver
|
||||
}
|
||||
return $limitStr ? ' WHERE ' . $limitStr : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置锁机制
|
||||
* @access protected
|
||||
* @param bool|false $lock
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function parseLock($lock = false)
|
||||
|
||||
@@ -332,6 +332,7 @@ class Lite
|
||||
* 并显示当前的SQL语句
|
||||
* @access public
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
|
||||
@@ -84,9 +84,11 @@ class Error
|
||||
|
||||
/**
|
||||
* 错误输出
|
||||
*
|
||||
* @param mixed $error 错误
|
||||
* @param int $errno 错误代码
|
||||
* @return void
|
||||
* @param int $code
|
||||
*
|
||||
* @internal param int $errno 错误代码
|
||||
*/
|
||||
public static function halt($error, $code = 1)
|
||||
{
|
||||
@@ -99,7 +101,8 @@ class Error
|
||||
$data['code'] = $code;
|
||||
$data['msg'] = $message;
|
||||
$data['time'] = NOW_TIME;
|
||||
exit(Response::returnData($data));
|
||||
Response::returnData($data);
|
||||
exit();
|
||||
}
|
||||
$e = [];
|
||||
if (APP_DEBUG) {
|
||||
|
||||
@@ -159,10 +159,16 @@ class Input
|
||||
|
||||
/**
|
||||
* 获取系统变量 支持过滤和默认值
|
||||
* @access public
|
||||
* @param string $method 输入数据类型
|
||||
* @param array $args 参数 [key,filter,default]
|
||||
* @access public
|
||||
*
|
||||
* @param $name
|
||||
* @param $input
|
||||
* @param $filter
|
||||
* @param $default
|
||||
*
|
||||
* @return mixed
|
||||
* @internal param string $method 输入数据类型
|
||||
* @internal param array $args 参数 [key,filter,default]
|
||||
*/
|
||||
private static function getData($name, $input, $filter, $default)
|
||||
{
|
||||
|
||||
@@ -229,12 +229,14 @@ class Loader
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得对象实例 支持调用类的静态方法
|
||||
* @param string $class 对象类名
|
||||
*
|
||||
* @param string $class 对象类名
|
||||
* @param string $method 类的静态方法名
|
||||
* @return object
|
||||
*
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function instance($class, $method = '')
|
||||
{
|
||||
@@ -244,7 +246,7 @@ class Loader
|
||||
if (class_exists($class)) {
|
||||
$o = new $class();
|
||||
if (!empty($method) && method_exists($o, $method)) {
|
||||
$_instance[$identify] = call_user_func_array([ & $o, $method]);
|
||||
$_instance[$identify] = call_user_func_array([ & $o, $method],[]);
|
||||
} else {
|
||||
$_instance[$identify] = $o;
|
||||
}
|
||||
|
||||
@@ -29,11 +29,12 @@ class Log
|
||||
|
||||
/**
|
||||
* 记录日志 并且会过滤未经设置的级别
|
||||
* @access public
|
||||
* @access public
|
||||
*
|
||||
* @param string $message 日志信息
|
||||
* @param string $level 日志级别
|
||||
* @param boolean $record 是否强制记录
|
||||
* @return void
|
||||
* @param string $level 日志级别
|
||||
*
|
||||
* @internal param bool $record 是否强制记录
|
||||
*/
|
||||
public static function record($message, $level = 'INFO')
|
||||
{
|
||||
|
||||
@@ -36,9 +36,12 @@ class MongoModel extends \Think\Model
|
||||
/**
|
||||
* 利用__call方法实现一些特殊的Model方法
|
||||
* @access public
|
||||
*
|
||||
* @param string $method 方法名称
|
||||
* @param array $args 调用参数
|
||||
* @param array $args 调用参数
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
@@ -54,7 +57,6 @@ class MongoModel extends \Think\Model
|
||||
return $this->where($where)->getField($args[1]);
|
||||
} else {
|
||||
throw new \think\Exception(__CLASS__ . ':' . $method . Lang::get('_METHOD_NOT_EXIST_'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -179,9 +179,12 @@ class Session
|
||||
|
||||
/**
|
||||
* 判断session数据
|
||||
*
|
||||
* @param string $name session名称
|
||||
* @param mixed $value session值
|
||||
* @return boolean
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return bool
|
||||
* @internal param mixed $value session值
|
||||
*/
|
||||
public static function has($name, $prefix = '')
|
||||
{
|
||||
|
||||
@@ -74,9 +74,14 @@ class TagLib
|
||||
|
||||
/**
|
||||
* TagLib标签属性分析 返回标签属性数组
|
||||
* @access public
|
||||
* @param string $tagStr 标签内容
|
||||
* @access public
|
||||
*
|
||||
* @param $attr
|
||||
* @param $tag
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
* @internal param string $tagStr 标签内容
|
||||
*/
|
||||
public function parseXmlAttr($attr, $tag)
|
||||
{
|
||||
@@ -92,25 +97,25 @@ class TagLib
|
||||
}
|
||||
$xml = (array) ($xml->tag->attributes());
|
||||
$array = array_change_key_case($xml['@attributes']);
|
||||
if ($array) {
|
||||
$tag = strtolower($tag);
|
||||
if (isset($this->tags[$tag]['attr'])) {
|
||||
$attrs = explode(',', $this->tags[$tag]['attr']);
|
||||
if (isset($this->tags[strtolower($tag)]['must'])) {
|
||||
$must = explode(',', $this->tags[$tag]['must']);
|
||||
} else {
|
||||
$must = [];
|
||||
}
|
||||
foreach ($attrs as $name) {
|
||||
if (isset($array[$name])) {
|
||||
$array[$name] = str_replace('___', '&', $array[$name]);
|
||||
} elseif (false !== array_search($name, $must)) {
|
||||
throw new Exception('_PARAM_ERROR_:' . $name);
|
||||
}
|
||||
if (!is_array($array)) return [];
|
||||
$tag = strtolower($tag);
|
||||
if (isset($this->tags[$tag]['attr'])) {
|
||||
$attrs = explode(',', $this->tags[$tag]['attr']);
|
||||
if (isset($this->tags[strtolower($tag)]['must'])) {
|
||||
$must = explode(',', $this->tags[$tag]['must']);
|
||||
} else {
|
||||
$must = [];
|
||||
}
|
||||
foreach ($attrs as $name) {
|
||||
if (isset($array[$name])) {
|
||||
$array[$name] = str_replace('___', '&', $array[$name]);
|
||||
} elseif (false !== array_search($name, $must)) {
|
||||
throw new Exception('_PARAM_ERROR_:' . $name);
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -113,10 +113,14 @@ class View
|
||||
/**
|
||||
* 解析和获取模板内容 用于输出
|
||||
* @access public
|
||||
*
|
||||
* @param string $template 模板文件名或者内容
|
||||
* @param array $vars 模板输出变量
|
||||
* @param string $cache_id 模板缓存标识
|
||||
* @param bool $renderContent
|
||||
*
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function fetch($template = '', $vars = [], $cache_id = '', $renderContent = false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user