1、内核更新

2、代码更新
This commit is contained in:
2016-10-14 23:09:43 +08:00
parent e70d287e89
commit 47159578a7
6 changed files with 70 additions and 42 deletions

View File

@@ -12,10 +12,10 @@ namespace app\common\model;
/** /**
* 设置模型 * 设置模型
*/ */
class Document extends \think\model\Merge{ class Document extends \think\Model{
protected $fk = 'doc_id'; protected $fk = 'doc_id';
protected $relationModel = array('document_article'); protected $pk = 'id';
// 定义需要自动写入时间戳格式的字段 // 定义需要自动写入时间戳格式的字段
protected $autoWriteTimestamp = array('create_time','update_time','deadline'); protected $autoWriteTimestamp = array('create_time','update_time','deadline');
@@ -70,10 +70,8 @@ class Document extends \think\model\Merge{
} }
public function extend($name){ public function extend($name){
if (is_numeric($name)) { $name = strtoupper($name);
$name = db('model')->where(array('id'=>$name))->value('name'); $this->join('__DOCUMENT_' . $name . '__', $this->fk . '=' . $this->pk, 'LEFT');
}
$this->relationModel = array('document_' . $name);
return $this; return $this;
} }
@@ -82,23 +80,24 @@ class Document extends \think\model\Merge{
$data = \think\Request::instance()->post(); $data = \think\Request::instance()->post();
if ($data !== false) { if ($data !== false) {
//增加增加复选框 shu'zu数组保存 //增加增加复选框 shu'zu数组保存
foreach($data as $key=>$val){ foreach($data as $key=>$val){
if(is_array($val)){ if(is_array($val)){
$data[$key] = implode(',', $val); $data[$key] = implode(',', $val);
} }
} }
/* 添加或新增基础内容 */ /* 添加或新增基础内容 */
if(empty($data['id'])){ //新增数据 if(empty($data['id'])){ //新增数据
unset($data['id']); unset($data['id']);
$id = $this->validate('document.edit')->save($data); //添加基础内容 $id = $this->validate('document.edit')->insert($data); //添加基础内容
if(!$id){ if(!$id){
return false; return false;
} }
$data['id'] = $id; $data['id'] = $id;
} else { //更新数据 } else { //更新数据
$status = $this->validate('document.edit')->save($data, array('id'=>$data['id'])); //更新基础内容 $status = $this->validate('document.edit')->fetchSql(true)->update($data, array('id'=>$data['id'])); //更新基础内容
dump($status);exit();
if(false === $status){ if(false === $status){
return false; return false;
} }
@@ -116,10 +115,10 @@ class Document extends \think\model\Merge{
public function detail($id){ public function detail($id){
$data = $this->get($id); $data = $this->get($id);
$map = array('model_id'=>$data['model_id'], 'type'=>array('in', 'checkbox')); $map = array('model_id'=>$data['model_id'], 'type'=>array('in', 'checkbox'));
$model_type = db('attribute')->where($map)->column('name'); $model_type = db('attribute')->where($map)->column('name');
foreach($model_type as $val){ foreach($model_type as $val){
$data->setAttr($val, explode(',', $data[$val])); $data->setAttr($val, explode(',', $data[$val]));
} }
return $data; return $data;
} }

View File

@@ -72,7 +72,7 @@ class Auth{
protected $_config = array( protected $_config = array(
'auth_on' => true, // 认证开关 'auth_on' => true, // 认证开关
'auth_type' => 1, // 认证方式1为实时认证2为登录认证。 'auth_type' => 1, // 认证方式1为实时认证2为登录认证。
'auth_group' => 'auth_group', // 用户组数据表名 'auth_group' => '__AUTH_GROUP__', // 用户组数据表名
'auth_group_access' => 'auth_group_access', // 用户-用户组关系表 'auth_group_access' => 'auth_group_access', // 用户-用户组关系表
'auth_rule' => 'auth_rule', // 权限规则表 'auth_rule' => 'auth_rule', // 权限规则表
'auth_user' => 'member' // 用户信息表 'auth_user' => 'member' // 用户信息表

View File

@@ -225,7 +225,7 @@ class App
} }
$args = self::bindParams($reflect, $vars); $args = self::bindParams($reflect, $vars);
self::$debug && Log::record('[ RUN ] ' . $reflect->__toString(), 'info'); self::$debug && Log::record('[ RUN ] ' . $reflect->class . '->' . $reflect->name . '[ ' . $reflect->getFileName() . ' ]', 'info');
return $reflect->invokeArgs(isset($class) ? $class : null, $args); return $reflect->invokeArgs(isset($class) ? $class : null, $args);
} }
@@ -245,8 +245,6 @@ class App
} else { } else {
$args = []; $args = [];
} }
self::$debug && Log::record('[ RUN ] ' . $reflect->__toString(), 'info');
return $reflect->newInstanceArgs($args); return $reflect->newInstanceArgs($args);
} }

View File

@@ -124,10 +124,10 @@ class Request
/** /**
* 架构函数 * 架构函数
* @access public * @access protected
* @param array $options 参数 * @param array $options 参数
*/ */
public function __construct($options = []) protected function __construct($options = [])
{ {
foreach ($options as $name => $item) { foreach ($options as $name => $item) {
if (property_exists($this, $name)) { if (property_exists($this, $name)) {
@@ -910,18 +910,22 @@ class Request
{ {
if (empty($this->header)) { if (empty($this->header)) {
$header = []; $header = [];
$server = $this->server ?: $_SERVER; if (function_exists('apache_request_headers') && $result = apache_request_headers()) {
foreach ($server as $key => $val) { $header = $result;
if (0 === strpos($key, 'HTTP_')) { } else {
$key = str_replace('_', '-', strtolower(substr($key, 5))); $server = $this->server ?: $_SERVER;
$header[$key] = $val; foreach ($server as $key => $val) {
if (0 === strpos($key, 'HTTP_')) {
$key = str_replace('_', '-', strtolower(substr($key, 5)));
$header[$key] = $val;
}
}
if (isset($server['CONTENT_TYPE'])) {
$header['content-type'] = $server['CONTENT_TYPE'];
}
if (isset($server['CONTENT_LENGTH'])) {
$header['content-length'] = $server['CONTENT_LENGTH'];
} }
}
if (isset($server['CONTENT_TYPE'])) {
$header['content-type'] = $server['CONTENT_TYPE'];
}
if (isset($server['CONTENT_LENGTH'])) {
$header['content-length'] = $server['CONTENT_LENGTH'];
} }
$this->header = array_change_key_case($header); $this->header = array_change_key_case($header);
} }

View File

@@ -943,8 +943,16 @@ class Route
if (is_array($item)) { if (is_array($item)) {
list($rule, $option) = $item; list($rule, $option) = $item;
if (isset($option['method'][$array[0]])) { $action = $array[0];
$option['method'] = $option['method'][$array[0]]; if (isset($option['allow']) && !in_array($action, explode(',', $option['allow']))) {
// 允许操作
return false;
} elseif (isset($option['except']) && in_array($action, explode(',', $option['except']))) {
// 排除操作
return false;
}
if (isset($option['method'][$action])) {
$option['method'] = $option['method'][$action];
} }
} else { } else {
$rule = $item; $rule = $item;
@@ -957,7 +965,7 @@ class Route
} elseif (0 === strpos($rule, '\\')) { } elseif (0 === strpos($rule, '\\')) {
// 路由到类 // 路由到类
return self::bindToClass($bind, substr($rule, 1), $depr); return self::bindToClass($bind, substr($rule, 1), $depr);
} elseif (0 === strpos($url, '@')) { } elseif (0 === strpos($rule, '@')) {
// 路由到控制器类 // 路由到控制器类
return self::bindToController($bind, substr($rule, 1), $depr); return self::bindToController($bind, substr($rule, 1), $depr);
} else { } else {
@@ -1406,7 +1414,7 @@ class Route
if ($route instanceof \Closure) { if ($route instanceof \Closure) {
// 执行闭包 // 执行闭包
$result = ['type' => 'function', 'function' => $route]; $result = ['type' => 'function', 'function' => $route];
} elseif (0 === strpos($route, '/') || 0 === strpos($route, 'http')) { } elseif (0 === strpos($route, '/') || strpos($route, '://')) {
// 路由到重定向地址 // 路由到重定向地址
$result = ['type' => 'redirect', 'url' => $route, 'status' => isset($option['status']) ? $option['status'] : 301]; $result = ['type' => 'redirect', 'url' => $route, 'status' => isset($option['status']) ? $option['status'] : 301];
} elseif (false !== strpos($route, '\\')) { } elseif (false !== strpos($route, '\\')) {

View File

@@ -85,13 +85,28 @@ class Url
} elseif (!empty($rule) && isset($name)) { } elseif (!empty($rule) && isset($name)) {
throw new \InvalidArgumentException('route name not exists:' . $name); throw new \InvalidArgumentException('route name not exists:' . $name);
} else { } else {
// 检查别名路由
$alias = Route::rules('alias');
if ($alias) {
// 别名路由解析
foreach ($alias as $key => $val) {
if (is_array($val)) {
$val = $val[0];
}
if (0 === strpos($url, $val)) {
$url = $key . substr($url, strlen($val));
break;
}
}
} else {
// 路由标识不存在 直接解析
$url = self::parseUrl($url, $domain);
}
if (isset($info['query'])) { if (isset($info['query'])) {
// 解析地址里面参数 合并到vars // 解析地址里面参数 合并到vars
parse_str($info['query'], $params); parse_str($info['query'], $params);
$vars = array_merge($params, $vars); $vars = array_merge($params, $vars);
} }
// 路由标识不存在 直接解析
$url = self::parseUrl($url, $domain);
} }
// 检测URL绑定 // 检测URL绑定
@@ -119,7 +134,11 @@ class Url
} else { } else {
foreach ($vars as $var => $val) { foreach ($vars as $var => $val) {
if ('' !== trim($val)) { if ('' !== trim($val)) {
$url .= $depr . $var . $depr . urlencode($val); if (Config::get('url_param_type')) {
$url .= $depr . urlencode($val);
} else {
$url .= $depr . $var . $depr . urlencode($val);
}
} }
} }
$url .= $suffix . $anchor; $url .= $suffix . $anchor;