Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Commit

Permalink
ThinkPHP 版本升级为 v5.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
yuan1994 committed Nov 12, 2016
1 parent 90b6306 commit 55b794e
Show file tree
Hide file tree
Showing 28 changed files with 335 additions and 193 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
> 当前版本: v1.2
## tpadmin 是什么?
tpadmin 是一个基于 ThinkPHP5.0 正式版和 Hui.admin v2.5 的管理后台,简化管理后台的开发流程,简化代码的编写,提高代码复用率,同时集成完整的权限管理和其他管理后台中常用的功能

## 官方文档
[http://www.kancloud.cn/yuan1994/tpadmin](http://www.kancloud.cn/yuan1994/tpadmin)
[http://doc.tpadmin.yuan1994.com](http://doc.tpadmin.yuan1994.com)

## 在线体验
[http://tpadmin.yuan1994.com](http://tpadmin.yuan1994.com)
Expand Down Expand Up @@ -62,10 +60,13 @@ https://github.com/yuan1994/tpadmin/archive/master.zip
* 图片预览
* 二维码生成

### 终端模式
* 支持终端生成代码
* 支持终端查看数据库详情

## 鸣谢:
本平台使用了如下框架或插件、源码
* ThinkPHP 5.0正式版
* ThinkPHP 5.0.3 正式版
* Hui.admin v2.5
* layer
* jQuery Validform
Expand Down
16 changes: 8 additions & 8 deletions application/admin/extra/site.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
/**
* tpAdmin [a web admin based ThinkPHP5]
*
* @author yuan1994 <[email protected]>
* @link http://tpadmin.yuan1994.com/
* @author yuan1994 <[email protected]>
* @link http://tpadmin.yuan1994.com/
* @copyright 2016 yuan1994 all rights reserved.
* @license http://www.apache.org/licenses/LICENSE-2.0
* @license http://www.apache.org/licenses/LICENSE-2.0
*/

return [
//网站信息
'name' => 'tpAdmin',
'title' => 'tpAdmin',
'version' => 'v1.2',
'keywords' => '后台管理系统,网站后台模版,后台模版下载,HTML后台模版下载',
'description' => '一个基于ThinkPHP5的管理后台,支持代码自动生成,RBAC权限管理,无限级节点权限管理,一个智能化的管理后台。'
'name' => 'tpAdmin',
'title' => 'tpAdmin',
'version' => 'v1.2',
'keywords' => '后台管理系统,网站后台模版,后台模版下载,HTML后台模版下载',
'description' => '一个基于ThinkPHP5的管理后台,支持代码自动生成,RBAC权限管理,无限级节点权限管理,一个智能化的管理后台。',
];
2 changes: 1 addition & 1 deletion application/admin/view/index/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<h2>官方文档</h2>

<p><a target="_blank" class="c-blue" href="http://www.kancloud.cn/yuan1994/tpadmin">http://www.kancloud.cn/yuan1994/tpadmin</a></p>
<p><a target="_blank" class="c-blue" href="http://doc.tpadmin.yuan1994.com">http://doc.tpadmin.yuan1994.com</a></p>

<p class="c-red">tpadmin 官方交流群:518162472</p>

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{
"name": "tianpian",
"email": "[email protected]",
"homepage": "http://www.tianpian.net.cn",
"homepage": "http://tpadmin.yuan1994.com/",
"role": "Owner"
}
],
Expand Down
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion thinkphp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ThinkPHP 5.0
[![Latest Unstable Version](https://poser.pugx.org/topthink/framework/v/unstable)](https://packagist.org/packages/topthink/framework)
[![License](https://poser.pugx.org/topthink/framework/license)](https://packagist.org/packages/topthink/framework)

ThinkPHP5在保持快速开发和大道至简的核心理念不变的同时,PHP版本要求提升到5.4,对已有的CBD模式做了更深的强化,优化核心,减少依赖,基于全新的架构思想和命名空间实现,是ThinkPHP突破原有框架思路的颠覆之作,其主要特性包括:
ThinkPHP5在保持快速开发和大道至简的核心理念不变的同时,PHP版本要求提升到5.4,优化核心,减少依赖,基于全新的架构思想和命名空间实现,是ThinkPHP突破原有框架思路的颠覆之作,其主要特性包括:

+ 基于命名空间和众多PHP新特性
+ 核心功能组件化
Expand Down
2 changes: 1 addition & 1 deletion thinkphp/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// | Author: liu21st <[email protected]>
// +----------------------------------------------------------------------

define('THINK_VERSION', '5.0.2');
define('THINK_VERSION', '5.0.3');
define('THINK_START_TIME', microtime(true));
define('THINK_START_MEM', memory_get_usage());
define('EXT', '.php');
Expand Down
4 changes: 4 additions & 0 deletions thinkphp/convention.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
'var_ajax' => '_ajax',
// 表单pjax伪装变量
'var_pjax' => '_pjax',
// 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
'request_cache' => false,
// 请求缓存有效期
'request_cache_expire' => null,

// +----------------------------------------------------------------------
// | 模板设置
Expand Down
16 changes: 10 additions & 6 deletions thinkphp/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,17 @@ function config($name = '', $value = null, $range = '')
* @param string $filter 过滤方法
* @return mixed
*/
function input($key = '', $default = null, $filter = null)
function input($key = '', $default = null, $filter = '')
{
if (0 === strpos($key, '?')) {
$key = substr($key, 1);
$has = true;
}
if ($pos = strpos($key, '.')) {
// 指定参数来源
$method = substr($key, 0, $pos);
if (in_array($method, ['get', 'post', 'put', 'patch', 'delete', 'param', 'request', 'session', 'cookie', 'server', 'env', 'path', 'file'])) {
$key = substr($key, $pos + 1);
} else {
list($method, $key) = explode('.', $key);
if (!in_array($method, ['get', 'post', 'put', 'patch', 'delete', 'param', 'request', 'session', 'cookie', 'server', 'env', 'path', 'file'])) {
$key = $method . '.' . $key;
$method = 'param';
}
} else {
Expand Down Expand Up @@ -359,12 +358,17 @@ function cache($name, $value = '', $options = null, $tag = null)
// 缓存初始化
return Cache::connect($name);
}
if ('' === $value) {
if (is_null($name)) {
return Cache::clear($value);
} elseif ('' === $value) {
// 获取缓存
return 0 === strpos($name, '?') ? Cache::has(substr($name, 1)) : Cache::get($name);
} elseif (is_null($value)) {
// 删除缓存
return Cache::rm($name);
} elseif (0 === strpos($name, '?') && '' !== $value) {
$expire = is_numeric($options) ? $options : null;
return Cache::remember(substr($name, 1), $value, $expire);
} else {
// 缓存数据
if (is_array($options)) {
Expand Down
8 changes: 5 additions & 3 deletions thinkphp/library/think/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public static function run(Request $request = null)

// 监听app_begin
Hook::listen('app_begin', $dispatch);
// 请求缓存检查
$request->cache($config['request_cache'], $config['request_cache_expire']);

switch ($dispatch['type']) {
case 'redirect':
Expand Down Expand Up @@ -377,22 +379,22 @@ public static function module($result, $config, $convert = null)
// 获取当前操作名
$action = $actionName . $config['action_suffix'];

$vars = [];
if (is_callable([$instance, $action])) {
// 执行操作方法
$call = [$instance, $action];
} elseif (is_callable([$instance, '_empty'])) {
// 空操作
$call = [$instance, '_empty'];
$vars = [$action];
} else {
// 操作不存在
throw new HttpException(404, 'method not exists:' . get_class($instance) . '->' . $action . '()');
}

Hook::listen('action_begin', $call);

$data = self::invokeMethod($call);

return $data;
return self::invokeMethod($call, $vars);
}

/**
Expand Down
1 change: 1 addition & 0 deletions thinkphp/library/think/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public static function load($file, $name = '', $range = '')
self::$config[$range] = [];
}
if (is_file($file)) {
$name = strtolower($name);
$type = pathinfo($file, PATHINFO_EXTENSION);
if ('php' == $type) {
return self::set(include $file, $name, $range);
Expand Down
3 changes: 3 additions & 0 deletions thinkphp/library/think/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
* @method integer execute(string $sql, array $bind = [], boolean $fetch = false, boolean $getLastInsID = false, string $sequence = null) static SQL执行
* @method PaginatorCollection paginate(integer $listRows = 15, mixed $simple = false, array $config = []) static 分页查询
* @method mixed transaction(callable $callback) static 执行数据库事务
* @method void startTrans() static 启动事务
* @method void commit() static 用于非自动提交状态下面的查询提交
* @method void rollback() static 事务回滚
* @method boolean batchQuery(array $sqlArray) static 批处理执行SQL语句
*/
class Db
Expand Down
2 changes: 1 addition & 1 deletion thinkphp/library/think/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class File extends SplFileObject
public function __construct($filename, $mode = 'r')
{
parent::__construct($filename, $mode);
$this->filename = $this->getRealPath();
$this->filename = $this->getRealPath() ?: $this->getPathname();
}

/**
Expand Down
32 changes: 16 additions & 16 deletions thinkphp/library/think/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
protected $failException = false;
// 全局查询范围
protected $useGlobalScope = true;
// 是否采用批量验证
protected $batchValidate = false;

/**
* 初始化过的模型.
Expand Down Expand Up @@ -741,7 +743,7 @@ public function saveAll($dataSet, $replace = true)
// 数据批量验证
$validate = $this->validate;
foreach ($dataSet as $data) {
if (!$this->validate($validate)->validateData($data)) {
if (!$this->validateData($data, $validate)) {
return false;
}
}
Expand Down Expand Up @@ -854,9 +856,10 @@ public function auto($fields)
* @access public
* @param array|string|bool $rule 验证规则 true表示自动读取验证器类
* @param array $msg 提示信息
* @param bool $batch 批量验证
* @return $this
*/
public function validate($rule = true, $msg = [])
public function validate($rule = true, $msg = [], $batch = false)
{
if (is_array($rule)) {
$this->validate = [
Expand All @@ -866,6 +869,7 @@ public function validate($rule = true, $msg = [])
} else {
$this->validate = true === $rule ? $this->name : $rule;
}
$this->batchValidate = $batch;
return $this;
}

Expand All @@ -885,12 +889,15 @@ public function validateFailException($fail = true)
* 自动验证数据
* @access protected
* @param array $data 验证数据
* @param mixed $rule 验证规则
* @param bool $batch 批量验证
* @return bool
*/
protected function validateData($data)
protected function validateData($data, $rule = null, $batch = null)
{
if (!empty($this->validate)) {
$info = $this->validate;
$info = is_null($rule) ? $this->validate : $rule;

if (!empty($info)) {
if (is_array($info)) {
$validate = Loader::validate();
$validate->rule($info['rule']);
Expand All @@ -905,7 +912,9 @@ protected function validateData($data)
$validate->scene($scene);
}
}
if (!$validate->check($data)) {
$batch = is_null($batch) ? $this->batchValidate : $batch;

if (!$validate->batch($batch)->check($data)) {
$this->error = $validate->getError();
if ($this->failException) {
throw new ValidateException($this->error);
Expand Down Expand Up @@ -1356,19 +1365,10 @@ public function __call($method, $args)

public static function __callStatic($method, $params)
{
$query = self::getDb();
$query = (new static())->db();
return call_user_func_array([$query, $method], $params);
}

protected static function getDb()
{
$model = get_called_class();
if (!isset(self::$links[$model])) {
self::$links[$model] = (new static())->db();
}
return self::$links[$model];
}

/**
* 修改器 设置数据对象的值
* @access public
Expand Down
Loading

0 comments on commit 55b794e

Please sign in to comment.