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

View File

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

View File

@@ -225,7 +225,7 @@ class App
}
$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);
}
@@ -245,8 +245,6 @@ class App
} else {
$args = [];
}
self::$debug && Log::record('[ RUN ] ' . $reflect->__toString(), 'info');
return $reflect->newInstanceArgs($args);
}

View File

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

View File

@@ -943,8 +943,16 @@ class Route
if (is_array($item)) {
list($rule, $option) = $item;
if (isset($option['method'][$array[0]])) {
$option['method'] = $option['method'][$array[0]];
$action = $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 {
$rule = $item;
@@ -957,7 +965,7 @@ class Route
} elseif (0 === strpos($rule, '\\')) {
// 路由到类
return self::bindToClass($bind, substr($rule, 1), $depr);
} elseif (0 === strpos($url, '@')) {
} elseif (0 === strpos($rule, '@')) {
// 路由到控制器类
return self::bindToController($bind, substr($rule, 1), $depr);
} else {
@@ -1406,7 +1414,7 @@ class Route
if ($route instanceof \Closure) {
// 执行闭包
$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];
} elseif (false !== strpos($route, '\\')) {

View File

@@ -85,13 +85,28 @@ class Url
} elseif (!empty($rule) && isset($name)) {
throw new \InvalidArgumentException('route name not exists:' . $name);
} 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'])) {
// 解析地址里面参数 合并到vars
parse_str($info['query'], $params);
$vars = array_merge($params, $vars);
}
// 路由标识不存在 直接解析
$url = self::parseUrl($url, $domain);
}
// 检测URL绑定
@@ -119,7 +134,11 @@ class Url
} else {
foreach ($vars as $var => $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;