|
@@ -10,11 +10,11 @@ class Update extends Page
|
|
|
{
|
|
|
parent::__construct('update', $load, $input);
|
|
|
}
|
|
|
- public function get(&$value = array(), &$option = array())
|
|
|
+ public function get(&$value = [], &$option = [])
|
|
|
{
|
|
|
$func = $this->checkFunc();
|
|
|
- $remote = $show = $spec = $source = $default = array();
|
|
|
- $data['update'] = $data['field'] = $data['option'] = array();
|
|
|
+ $remote = $show = $spec = $source = $default = [];
|
|
|
+ $data['update'] = $data['field'] = $data['option'] = [];
|
|
|
$this->setting('field', $data['update'], true, 'text');
|
|
|
foreach ($data['update'] as $k => $v) {
|
|
|
if ($v['type'] == 'tree' || $v['type'] == 'upload' || $v['type'] == 'cascader' || $v['type'] == 'checkbox' || isset($v['multiple'])) {
|
|
@@ -26,26 +26,26 @@ class Update extends Page
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- $v['value'] = array();
|
|
|
+ $v['value'] = [];
|
|
|
}
|
|
|
}
|
|
|
if (isset($v['source'])) {
|
|
|
$source[$v['key']] = $v['source'];
|
|
|
}
|
|
|
if (isset($v['remote'])) {
|
|
|
- $remote[$v['key']] = array($k, $v['remote'], $v['key']);
|
|
|
+ $remote[$v['key']] = [$k, $v['remote'], $v['key']];
|
|
|
if (isset($v['remote_default']) && !$v['remote_default']) {
|
|
|
unset($remote[$v['key']][2]);
|
|
|
}
|
|
|
}
|
|
|
if (isset($v['spec_data'])) {
|
|
|
- $spec[$v['key']] = array($k, $v['spec_data'], $v['key'] . '_spec', $v['spec'], $v['spec_field']);
|
|
|
+ $spec[$v['key']] = [$k, $v['spec_data'], $v['key'] . '_spec', $v['spec'], $v['spec_field']];
|
|
|
}
|
|
|
if (isset($v['show']) && is_string($v['show'])) {
|
|
|
- $show[$v['key']] = array($k, $v['show']);
|
|
|
+ $show[$v['key']] = [$k, $v['show']];
|
|
|
}
|
|
|
if (isset($v['default']) && is_string($v['default']) && strstr($v['default'], '{')) {
|
|
|
- $default[$v['key']] = array($k, $v['default']);
|
|
|
+ $default[$v['key']] = [$k, $v['default']];
|
|
|
}
|
|
|
$data['field'][$v['key']] = $v['value'];
|
|
|
if ($v['type'] == 'sku') {
|
|
@@ -80,15 +80,15 @@ class Update extends Page
|
|
|
$this->setInfo($info, $data, $remote, $show, $source, $default, 1, $this->config['field']);
|
|
|
if ($spec) {
|
|
|
foreach ($spec as $k => $v) {
|
|
|
- $data['update'][$spec[$k][0]]['remote'] = Dever::url($spec[$k][1], array('value' => '', 'table' => $this->db->config['load'], 'id' => false));
|
|
|
- $result = Dever::call($spec[$k][1], array($spec[$k][3], $spec[$k][4], $this->info['id']));
|
|
|
+ $data['update'][$spec[$k][0]]['remote'] = Dever::url($spec[$k][1], ['value' => '', 'table' => $this->db->config['load'], 'id' => false]);
|
|
|
+ $result = Dever::call($spec[$k][1], [$spec[$k][3], $spec[$k][4], $this->info['id']]);
|
|
|
if ($result) {
|
|
|
$data['field'][$spec[$k][2]] = $result;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} elseif ($value) {
|
|
|
- $field = array();
|
|
|
+ $field = [];
|
|
|
if (isset($this->config['field']) && $this->config['field']) {
|
|
|
foreach ($this->config['field'] as $k => $v) {
|
|
|
if (isset($v['field'])) {
|
|
@@ -115,13 +115,13 @@ class Update extends Page
|
|
|
}
|
|
|
} else {
|
|
|
if ($remote) {
|
|
|
- $info = array();
|
|
|
+ $info = [];
|
|
|
foreach ($remote as $k => $v) {
|
|
|
- $data['update'][$v[0]]['remote'] = Dever::url($v[1], array('value' => '', 'table' => $this->db->config['load'], 'id' => false));
|
|
|
+ $data['update'][$v[0]]['remote'] = Dever::url($v[1], ['value' => '', 'table' => $this->db->config['load'], 'id' => false]);
|
|
|
if (isset($v[2]) && isset($data['option'][$v[2]]) && $data['option'][$v[2]] && $m = Dever::issets($data['option'][$v[2]][0], 'id')) {
|
|
|
$path = 'api';
|
|
|
if (strstr($v[1], 'mapi')) $path = 'manage';
|
|
|
- $result = Dever::call($v[1], array($m, $this->db->config['load'], false), $path);
|
|
|
+ $result = Dever::call($v[1], [$m, $this->db->config['load'], false], $path);
|
|
|
if ($result) {
|
|
|
$this->setUpdate($info, $data, $result);
|
|
|
}
|
|
@@ -146,11 +146,11 @@ class Update extends Page
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
- private function setInfo(&$info, &$data, $remote, $show, $source, $default, $type = 1, $field = array())
|
|
|
+ private function setInfo(&$info, &$data, $remote, $show, $source, $default, $type = 1, $field = [])
|
|
|
{
|
|
|
if ($source) {
|
|
|
foreach ($source as $k => $v) {
|
|
|
- $t = array();
|
|
|
+ $t = [];
|
|
|
foreach ($v as $v1) {
|
|
|
$t[] = $info[$v1] ?? '';
|
|
|
}
|
|
@@ -171,7 +171,7 @@ class Update extends Page
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- $v = array();
|
|
|
+ $v = [];
|
|
|
}
|
|
|
$info[$k] = $v;
|
|
|
}
|
|
@@ -188,13 +188,13 @@ class Update extends Page
|
|
|
$data['field'][$k] = $v;
|
|
|
}
|
|
|
if (isset($remote[$k])) {
|
|
|
- $data['update'][$remote[$k][0]]['remote'] = Dever::url($remote[$k][1], array('value' => '', 'table' => $this->db->config['load'], 'id' => false));
|
|
|
+ $data['update'][$remote[$k][0]]['remote'] = Dever::url($remote[$k][1], ['value' => '', 'table' => $this->db->config['load'], 'id' => false]);
|
|
|
if ($field[$k]['type'] == 'cascader' && !isset($field[$k]['option'])) {
|
|
|
|
|
|
} else {
|
|
|
$path = 'api';
|
|
|
if (strstr($remote[$k][1], 'mapi')) $path = 'manage';
|
|
|
- $result = Dever::call($remote[$k][1], array($v, $this->db->config['load'], $info['id'] ?? false), $path);
|
|
|
+ $result = Dever::call($remote[$k][1], [$v, $this->db->config['load'], $info['id'] ?? false], $path);
|
|
|
if ($result) {
|
|
|
$this->setUpdate($info, $data, $result);
|
|
|
}
|
|
@@ -219,7 +219,7 @@ class Update extends Page
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function setUpdate(&$info, &$data, $result, $remote = array())
|
|
|
+ private function setUpdate(&$info, &$data, $result, $remote = [])
|
|
|
{
|
|
|
foreach ($data['update'] as $k => $v) {
|
|
|
if (isset($result[$v['key']])) {
|
|
@@ -248,7 +248,7 @@ class Update extends Page
|
|
|
|
|
|
private function control(&$data)
|
|
|
{
|
|
|
- $result = array();
|
|
|
+ $result = [];
|
|
|
if (isset($this->config['control']) && $this->config['control']) {
|
|
|
foreach ($this->config['control'] as $k => $v) {
|
|
|
if (is_string($v)) {
|
|
@@ -309,12 +309,12 @@ class Update extends Page
|
|
|
private function tab(&$data, $type = 'tab')
|
|
|
{
|
|
|
$field = $this->input('field', '');
|
|
|
- $data[$type] = array();
|
|
|
+ $data[$type] = [];
|
|
|
//if (empty($data['layout']) && !$field && isset($this->config[$type])) {
|
|
|
if (empty($data['layout']) && isset($this->config[$type])) {
|
|
|
foreach ($this->config[$type] as $k => $v) {
|
|
|
if (is_string($v)) {
|
|
|
- $field = array();
|
|
|
+ $field = [];
|
|
|
$data[$type][] = array
|
|
|
(
|
|
|
'name' => $k,
|
|
@@ -322,8 +322,8 @@ class Update extends Page
|
|
|
'field' => $field,
|
|
|
);
|
|
|
} else {
|
|
|
- $field = array();
|
|
|
- $result = array();
|
|
|
+ $field = [];
|
|
|
+ $result = [];
|
|
|
$result['name'] = $k;
|
|
|
foreach ($v as $v1) {
|
|
|
$result['layout'][] = $this->getUpdate($v1, $data['update'], $field);
|
|
@@ -332,26 +332,26 @@ class Update extends Page
|
|
|
$data[$type][] = $result;
|
|
|
}
|
|
|
}
|
|
|
- $data['update'] = array();
|
|
|
+ $data['update'] = [];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private function layout(&$data)
|
|
|
{
|
|
|
$field = $this->input('field', '');
|
|
|
- $data['layout'] = array();
|
|
|
+ $data['layout'] = [];
|
|
|
if (!$field && isset($this->config['layout'])) {
|
|
|
foreach ($this->config['layout'] as $k => $v) {
|
|
|
- $field = array();
|
|
|
+ $field = [];
|
|
|
$data['layout'][] = $this->getUpdate($v, $data['update'], $field);
|
|
|
}
|
|
|
- $data['update'] = array();
|
|
|
+ $data['update'] = [];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private function getUpdate($set, $update, &$field)
|
|
|
{
|
|
|
- $result = array();
|
|
|
+ $result = [];
|
|
|
if (is_string($set)) {
|
|
|
$set = explode(',', $set);
|
|
|
foreach ($set as $k => $v) {
|
|
@@ -366,7 +366,7 @@ class Update extends Page
|
|
|
foreach ($set as $k => $v) {
|
|
|
foreach ($update as $value) {
|
|
|
if ($value['key'] == $k) {
|
|
|
- $result[] = array('span' => $v, 'update' => array($value));
|
|
|
+ $result[] = array('span' => $v, 'update' => [$value]);
|
|
|
$field[] = $k;
|
|
|
}
|
|
|
}
|
|
@@ -379,10 +379,10 @@ class Update extends Page
|
|
|
public function do()
|
|
|
{
|
|
|
$this->checkFunc();
|
|
|
- $update = array();
|
|
|
+ $update = [];
|
|
|
$this->setting('field', $update, true, 'text');
|
|
|
if ($update) {
|
|
|
- $data = $other = $sku = array();
|
|
|
+ $data = $other = $sku = [];
|
|
|
$input = Dever::input();
|
|
|
$id = false;
|
|
|
if (isset($input['id']) && $input['id'] > 0) {
|
|
@@ -396,7 +396,7 @@ class Update extends Page
|
|
|
}
|
|
|
if ($v['type'] == 'sku') {
|
|
|
if (isset($input[$v['key'] . '_spec']) && isset($input[$v['key']])) {
|
|
|
- $sku[$v['key']] = array($v['where'], $v['content']['field'], $v['spec'], $v['spec_field'], $input[$v['key'] . '_spec'], $input[$v['key']]);
|
|
|
+ $sku[$v['key']] = [$v['where'], $v['content']['field'], $v['spec'], $v['spec_field'], $input[$v['key'] . '_spec'], $input[$v['key']]];
|
|
|
}
|
|
|
|
|
|
} elseif (strpos($v['key'], '/') && $v['type'] != 'hidden') {
|
|
@@ -408,15 +408,15 @@ class Update extends Page
|
|
|
$other_id = $input[$v['key'] . '_id'] ?? 0;
|
|
|
$value = array
|
|
|
(
|
|
|
- 0 => array('id' => $other_id, $v['field'] => $value)
|
|
|
+ 0 => ['id' => $other_id, $v['field'] => $value]
|
|
|
);
|
|
|
if (isset($other[$v['key']])) {
|
|
|
$other[$v['key']][3][0] += $value[0];
|
|
|
} else {
|
|
|
- $other[$v['key']] = array($v['where'], false, false, $value);
|
|
|
+ $other[$v['key']] = [$v['where'], false, false, $value];
|
|
|
}
|
|
|
} else {
|
|
|
- $other[$v['key']] = array($v['where'], $v['content']['field'], $v['content']['drag'], $input[$v['key']]);
|
|
|
+ $other[$v['key']] = [$v['where'], $v['content']['field'], $v['content']['drag'], $input[$v['key']]];
|
|
|
}
|
|
|
} else {
|
|
|
$this->doData($data, $v['key'], $input[$v['key']], $this->config['field'], $control);
|
|
@@ -464,7 +464,7 @@ class Update extends Page
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function doData(&$data, $key, $value, $field = array(), $control = array())
|
|
|
+ private function doData(&$data, $key, $value, $field = [], $control = [])
|
|
|
{
|
|
|
if (is_array($value)) {
|
|
|
if (isset($value[0])) {
|
|
@@ -490,7 +490,7 @@ class Update extends Page
|
|
|
}
|
|
|
}
|
|
|
if ($value && isset($field[$key]) && $handle = Dever::issets($field[$key], 'handle')) {
|
|
|
- $value = Dever::call($handle, array($value));
|
|
|
+ $value = Dever::call($handle, [$value]);
|
|
|
if (is_array($value) && isset($value[$key])) {
|
|
|
foreach ($value as $k => $v) {
|
|
|
$data[$k] = trim($v);
|
|
@@ -511,8 +511,8 @@ class Update extends Page
|
|
|
private function exists($db, $check, $id, $data, $field)
|
|
|
{
|
|
|
$check = explode(',', $check);
|
|
|
- $where = array();
|
|
|
- $name = array();
|
|
|
+ $where = [];
|
|
|
+ $name = [];
|
|
|
foreach ($check as $k => $v) {
|
|
|
if (isset($data[$v]) && $data[$v]) {
|
|
|
if (isset($field[$v]) && isset($field[$v]['name'])) {
|
|
@@ -528,7 +528,7 @@ class Update extends Page
|
|
|
}
|
|
|
if ($where) {
|
|
|
if ($id) {
|
|
|
- $where['id'] = array('!=', $id);
|
|
|
+ $where['id'] = ['!=', $id];
|
|
|
}
|
|
|
$info = $db->find($where);
|
|
|
if ($info) {
|
|
@@ -545,10 +545,10 @@ class Update extends Page
|
|
|
if (is_array($this->config['start'])) {
|
|
|
$result = $data;
|
|
|
foreach ($this->config['start'] as $k => $v) {
|
|
|
- $result = Dever::call($v, array($this->db, $result));
|
|
|
+ $result = Dever::call($v, [$this->db, $result]);
|
|
|
}
|
|
|
} else {
|
|
|
- $result = Dever::call($this->config['start'], array($this->db, $data));
|
|
|
+ $result = Dever::call($this->config['start'], [$this->db, $data]);
|
|
|
}
|
|
|
if ($result) {
|
|
|
if ($result == 'end') {
|
|
@@ -569,10 +569,10 @@ class Update extends Page
|
|
|
$data['id'] = $id;
|
|
|
if (is_array($this->config['end'])) {
|
|
|
foreach ($this->config['end'] as $k => $v) {
|
|
|
- Dever::call($v, array($this->db, $data));
|
|
|
+ Dever::call($v, [$this->db, $data]);
|
|
|
}
|
|
|
} else {
|
|
|
- Dever::call($this->config['end'], array($this->db, $data));
|
|
|
+ Dever::call($this->config['end'], [$this->db, $data]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -589,7 +589,7 @@ class Update extends Page
|
|
|
$update = $v[1];
|
|
|
$drag = $v[2];
|
|
|
$input = $v[3];
|
|
|
- $value = array();
|
|
|
+ $value = [];
|
|
|
foreach ($input as $k1 => $v1) {
|
|
|
if (isset($v1['id']) && $v1['id']) {
|
|
|
$value['id'] = $v1['id'];
|
|
@@ -652,11 +652,11 @@ class Update extends Page
|
|
|
$spec_field = $v[3];
|
|
|
$spec = $v[4];
|
|
|
$input = $v[5];
|
|
|
- $value = $spec_value = array();
|
|
|
- Dever::db($spec_table)->update(array($spec_field => $rid), array('state' => 2));
|
|
|
- Dever::db($spec_value_table)->update(array($spec_field => $rid), array('state' => 2));
|
|
|
+ $value = $spec_value = [];
|
|
|
+ Dever::db($spec_table)->update([$spec_field => $rid], ['state' => 2]);
|
|
|
+ Dever::db($spec_value_table)->update([$spec_field => $rid], ['state' => 2]);
|
|
|
foreach ($spec as $k1 => &$v1) {
|
|
|
- $spec_data = array();
|
|
|
+ $spec_data = [];
|
|
|
$spec_data['state'] = 1;
|
|
|
$spec_data[$spec_field] = $rid;
|
|
|
$spec_data['name'] = $v1['name'];
|
|
@@ -668,7 +668,7 @@ class Update extends Page
|
|
|
}
|
|
|
if ($v1['id']) {
|
|
|
foreach ($v1['value'] as $k2 => &$v2) {
|
|
|
- $spec_value_data = array();
|
|
|
+ $spec_value_data = [];
|
|
|
$spec_value_data['state'] = 1;
|
|
|
$spec_value_data[$spec_field] = $rid;
|
|
|
$spec_value_data['spec_id'] = $v1['id'];
|
|
@@ -680,13 +680,13 @@ class Update extends Page
|
|
|
} else {
|
|
|
$v2['id'] = Dever::db($spec_value_table)->insert($spec_value_data);
|
|
|
}
|
|
|
- $spec_value[$v1['key']][$spec_value_data['value']] = array($v2['id'], $spec_data['sort']);
|
|
|
+ $spec_value[$v1['key']][$spec_value_data['value']] = [$v2['id'], $spec_data['sort']];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- Dever::db($spec_table)->delete(array($spec_field => $rid, 'state' => 2));
|
|
|
- Dever::db($spec_value_table)->delete(array($spec_field => $rid, 'state' => 2));
|
|
|
- Dever::db($k)->update(array($spec_field => $rid), array('state' => 2));
|
|
|
+ Dever::db($spec_table)->delete([$spec_field => $rid, 'state' => 2]);
|
|
|
+ Dever::db($spec_value_table)->delete([$spec_field => $rid, 'state' => 2]);
|
|
|
+ Dever::db($k)->update([$spec_field => $rid], ['state' => 2]);
|
|
|
foreach ($input as $k1 => $v1) {
|
|
|
if (isset($v1['id'])) {
|
|
|
$value['id'] = $v1['id'];
|
|
@@ -707,7 +707,7 @@ class Update extends Page
|
|
|
$value[$k2] = $v1[$k2];
|
|
|
}
|
|
|
}
|
|
|
- $value['key'] = array();
|
|
|
+ $value['key'] = [];
|
|
|
foreach ($v1 as $k2 => $v2) {
|
|
|
if (isset($spec_value[$k2]) && isset($spec_value[$k2][$v2])) {
|
|
|
$value['key'][$spec_value[$k2][$v2][1]] = $spec_value[$k2][$v2][0];
|
|
@@ -725,7 +725,7 @@ class Update extends Page
|
|
|
Dever::db($k)->insert($value);
|
|
|
}
|
|
|
}
|
|
|
- Dever::db($k)->delete(array($spec_field => $rid, 'state' => 2));
|
|
|
+ Dever::db($k)->delete([$spec_field => $rid, 'state' => 2]);
|
|
|
}
|
|
|
}
|
|
|
}
|