mirror of https://gitee.com/karson/fastadmin.git
parent
b4185e2da8
commit
c8085a406e
|
|
@ -273,39 +273,41 @@ class Backend extends Controller
|
||||||
$op = (array)json_decode($op, true);
|
$op = (array)json_decode($op, true);
|
||||||
$filter = $filter ? $filter : [];
|
$filter = $filter ? $filter : [];
|
||||||
$where = [];
|
$where = [];
|
||||||
|
$alias = [];
|
||||||
|
$bind = [];
|
||||||
$name = '';
|
$name = '';
|
||||||
$tableName = '';
|
$aliasName = '';
|
||||||
if ($relationSearch) {
|
if (!empty($this->model)) {
|
||||||
if (!empty($this->model)) {
|
$name = $this->model->getTable();
|
||||||
$name = $this->model->getTable();
|
$alias[$name] = Loader::parseName(basename(str_replace('\\', '/', get_class($this->model))));
|
||||||
$tableName = $name . '.';
|
$aliasName = $alias[$name] . '.';
|
||||||
}
|
|
||||||
$sortArr = explode(',', $sort);
|
|
||||||
foreach ($sortArr as $index => & $item) {
|
|
||||||
$item = stripos($item, ".") === false ? $tableName . trim($item) : $item;
|
|
||||||
}
|
|
||||||
unset($item);
|
|
||||||
$sort = implode(',', $sortArr);
|
|
||||||
}
|
}
|
||||||
|
$sortArr = explode(',', $sort);
|
||||||
|
foreach ($sortArr as $index => & $item) {
|
||||||
|
$item = stripos($item, ".") === false ? $aliasName . trim($item) : $item;
|
||||||
|
}
|
||||||
|
unset($item);
|
||||||
|
$sort = implode(',', $sortArr);
|
||||||
$adminIds = $this->getDataLimitAdminIds();
|
$adminIds = $this->getDataLimitAdminIds();
|
||||||
if (is_array($adminIds)) {
|
if (is_array($adminIds)) {
|
||||||
$where[] = [$tableName . $this->dataLimitField, 'in', $adminIds];
|
$where[] = [$aliasName . $this->dataLimitField, 'in', $adminIds];
|
||||||
}
|
}
|
||||||
if ($search) {
|
if ($search) {
|
||||||
$searcharr = is_array($searchfields) ? $searchfields : explode(',', $searchfields);
|
$searcharr = is_array($searchfields) ? $searchfields : explode(',', $searchfields);
|
||||||
foreach ($searcharr as $k => &$v) {
|
foreach ($searcharr as $k => &$v) {
|
||||||
$v = stripos($v, ".") === false ? $tableName . $v : $v;
|
$v = stripos($v, ".") === false ? $aliasName . $v : $v;
|
||||||
}
|
}
|
||||||
unset($v);
|
unset($v);
|
||||||
$where[] = [implode("|", $searcharr), "LIKE", "%{$search}%"];
|
$where[] = [implode("|", $searcharr), "LIKE", "%{$search}%"];
|
||||||
}
|
}
|
||||||
|
$index = 0;
|
||||||
foreach ($filter as $k => $v) {
|
foreach ($filter as $k => $v) {
|
||||||
if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $k)) {
|
if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $k)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$sym = isset($op[$k]) ? $op[$k] : '=';
|
$sym = isset($op[$k]) ? $op[$k] : '=';
|
||||||
if (stripos($k, ".") === false) {
|
if (stripos($k, ".") === false) {
|
||||||
$k = $tableName . $k;
|
$k = $aliasName . $k;
|
||||||
}
|
}
|
||||||
$v = !is_array($v) ? trim($v) : $v;
|
$v = !is_array($v) ? trim($v) : $v;
|
||||||
$sym = strtoupper(isset($op[$k]) ? $op[$k] : $sym);
|
$sym = strtoupper(isset($op[$k]) ? $op[$k] : $sym);
|
||||||
|
|
@ -341,10 +343,11 @@ class Backend extends Controller
|
||||||
case 'FINDINSET':
|
case 'FINDINSET':
|
||||||
case 'FIND_IN_SET':
|
case 'FIND_IN_SET':
|
||||||
$v = is_array($v) ? $v : explode(',', str_replace(' ', ',', $v));
|
$v = is_array($v) ? $v : explode(',', str_replace(' ', ',', $v));
|
||||||
foreach ($v as $index => $item) {
|
$findArr = array_values($v);
|
||||||
$item = str_replace([' ', ',', "'"], '', $item);
|
foreach ($findArr as $idx => $item) {
|
||||||
$item = addslashes(htmlentities(strip_tags($item)));
|
$bindName = "item_" . $index . "_" . $idx;
|
||||||
$where[] = "FIND_IN_SET('{$item}', `" . ($relationSearch ? str_replace('.', '`.`', $k) : $k) . "`)";
|
$bind[$bindName] = $item;
|
||||||
|
$where[] = "FIND_IN_SET(:{$bindName}, `" . str_replace('.', '`.`', $k) . "`)";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'IN':
|
case 'IN':
|
||||||
|
|
@ -385,10 +388,10 @@ class Backend extends Controller
|
||||||
$arr = $arr[0];
|
$arr = $arr[0];
|
||||||
}
|
}
|
||||||
$tableArr = explode('.', $k);
|
$tableArr = explode('.', $k);
|
||||||
if (count($tableArr) > 1 && $tableArr[0] != $name) {
|
if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias)) {
|
||||||
//修复关联模型下时间无法搜索的BUG
|
//修复关联模型下时间无法搜索的BUG
|
||||||
$relation = Loader::parseName($tableArr[0], 1, false);
|
$relation = Loader::parseName($tableArr[0], 1, false);
|
||||||
$this->model->alias([$this->model->$relation()->getTable() => $tableArr[0]]);
|
$alias[$this->model->$relation()->getTable()] = $tableArr[0];
|
||||||
}
|
}
|
||||||
$where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' TIME', $arr];
|
$where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' TIME', $arr];
|
||||||
break;
|
break;
|
||||||
|
|
@ -401,8 +404,14 @@ class Backend extends Controller
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$index++;
|
||||||
}
|
}
|
||||||
$where = function ($query) use ($where) {
|
|
||||||
|
$this->model->alias($alias);
|
||||||
|
$model = $this->model;
|
||||||
|
$where = function ($query) use ($where, $alias, $bind, &$model) {
|
||||||
|
$model->alias($alias);
|
||||||
|
$model->bind($bind);
|
||||||
foreach ($where as $k => $v) {
|
foreach ($where as $k => $v) {
|
||||||
if (is_array($v)) {
|
if (is_array($v)) {
|
||||||
call_user_func_array([$query, 'where'], $v);
|
call_user_func_array([$query, 'where'], $v);
|
||||||
|
|
@ -411,7 +420,7 @@ class Backend extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return [$where, $sort, $order, $offset, $limit, $page];
|
return [$where, $sort, $order, $offset, $limit, $page, $alias, $bind];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,31 @@ class Attachment extends Model
|
||||||
// 定义字段类型
|
// 定义字段类型
|
||||||
protected $type = [
|
protected $type = [
|
||||||
];
|
];
|
||||||
|
protected $append = [
|
||||||
|
'thumb_style'
|
||||||
|
];
|
||||||
|
|
||||||
public function setUploadtimeAttr($value)
|
public function setUploadtimeAttr($value)
|
||||||
{
|
{
|
||||||
return is_numeric($value) ? $value : strtotime($value);
|
return is_numeric($value) ? $value : strtotime($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取云储存的缩略图样式字符
|
||||||
|
*/
|
||||||
|
public function getThumbStyleAttr($value, $data)
|
||||||
|
{
|
||||||
|
if (!isset($data['storage']) || $data['storage'] == 'local') {
|
||||||
|
return '';
|
||||||
|
} else {
|
||||||
|
$config = get_addon_config($data['storage']);
|
||||||
|
if ($config && isset($config['thumbstyle'])) {
|
||||||
|
return $config['thumbstyle'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
public static function getMimetypeList()
|
public static function getMimetypeList()
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
|
|
|
||||||
|
|
@ -162,8 +162,7 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin
|
||||||
formatter: {
|
formatter: {
|
||||||
thumb: function (value, row, index) {
|
thumb: function (value, row, index) {
|
||||||
if (row.mimetype.indexOf("image") > -1) {
|
if (row.mimetype.indexOf("image") > -1) {
|
||||||
var style = row.storage === 'upyun' ? '!/fwfh/120x90' : '';
|
return '<a href="' + row.fullurl + '" target="_blank"><img src="' + row.fullurl + row.thumb_style + '" alt="" style="max-height:90px;max-width:120px"></a>';
|
||||||
return '<a href="' + row.fullurl + '" target="_blank"><img src="' + row.fullurl + style + '" alt="" style="max-height:90px;max-width:120px"></a>';
|
|
||||||
} else {
|
} else {
|
||||||
return '<a href="' + row.fullurl + '" target="_blank"><img src="' + Fast.api.fixurl("ajax/icon") + "?suffix=" + row.imagetype + '" alt="" style="max-height:90px;max-width:120px"></a>';
|
return '<a href="' + row.fullurl + '" target="_blank"><img src="' + Fast.api.fixurl("ajax/icon") + "?suffix=" + row.imagetype + '" alt="" style="max-height:90px;max-width:120px"></a>';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@
|
||||||
var extend = typeof vObjCol.extend === 'undefined' ? '' : vObjCol.extend;
|
var extend = typeof vObjCol.extend === 'undefined' ? '' : vObjCol.extend;
|
||||||
var style = typeof vObjCol.style === 'undefined' ? '' : sprintf('style="%s"', vObjCol.style);
|
var style = typeof vObjCol.style === 'undefined' ? '' : sprintf('style="%s"', vObjCol.style);
|
||||||
extend = typeof vObjCol.data !== 'undefined' && extend == '' ? vObjCol.data : extend;
|
extend = typeof vObjCol.data !== 'undefined' && extend == '' ? vObjCol.data : extend;
|
||||||
|
extend = typeof vObjCol.autocomplete !== 'undefined' ? extend + ' autocomplete="' + (vObjCol.autocomplete === false || vObjCol.autocomplete === 'off' ? 'off' : 'on') + '"' : extend;
|
||||||
if (vObjCol.searchList) {
|
if (vObjCol.searchList) {
|
||||||
if (typeof vObjCol.searchList === 'function') {
|
if (typeof vObjCol.searchList === 'function') {
|
||||||
htmlForm.push(vObjCol.searchList.call(this, vObjCol));
|
htmlForm.push(vObjCol.searchList.call(this, vObjCol));
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue