|
@@ -2886,10 +2886,6 @@ class Database
|
|
|
{
|
|
|
$config = $this->config();
|
|
|
|
|
|
- $result = array();
|
|
|
-
|
|
|
- $prefix = 'update';
|
|
|
-
|
|
|
$data = array();
|
|
|
|
|
|
if ($this->id) {
|
|
@@ -2899,23 +2895,155 @@ class Database
|
|
|
}
|
|
|
|
|
|
$data = $this->load('one', $this->id);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if (Dever::load('manage/auth.oper', 4) == false) {
|
|
|
+ Dever::alert('你没有权限');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $data = $this->getAdminInfo($data);
|
|
|
+ $col = Dever::input('col');
|
|
|
+
|
|
|
+ $result = $this->update_struct($config, $col, $data);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function update_content()
|
|
|
+ {
|
|
|
+ $config = $this->config();
|
|
|
|
|
|
- if ($data) {
|
|
|
-
|
|
|
+ $data = array();
|
|
|
+
|
|
|
+ if ($this->id) {
|
|
|
+
|
|
|
+ if (Dever::load('manage/auth.oper', 3) == false) {
|
|
|
+ Dever::alert('你没有权限');
|
|
|
}
|
|
|
+ $data = $this->load('one', $this->id);
|
|
|
} else {
|
|
|
|
|
|
if (Dever::load('manage/auth.oper', 4) == false) {
|
|
|
-
|
|
|
+ Dever::alert('你没有权限');
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
$data = $this->getAdminInfo($data);
|
|
|
$col = Dever::input('col');
|
|
|
|
|
|
+ Dever::setInput('ajax', 1);
|
|
|
+
|
|
|
+ $result = '<div class="layui-col-md12"><div class="layui-card" {style}><div class="layui-card-body">';
|
|
|
+ if (isset($config['manage']['lang']) && Dever::config('base')->lang_set) {
|
|
|
+ $result .= '<div class="layui-tab layui-tab-card"><ul class="layui-tab-title">';
|
|
|
+ $tab = '<div class="layui-tab-content">';
|
|
|
+ $i = 0;
|
|
|
+ if ($col) {
|
|
|
+ $col = explode(',', $col);
|
|
|
+ $config['manage']['lang'] = explode(',', $config['manage']['lang']);
|
|
|
+ $config['manage']['lang'] = array_intersect($config['manage']['lang'], $col);
|
|
|
+ $config['manage']['lang'] = implode(',', $config['manage']['lang']);
|
|
|
+ $col = implode(',', $col);
|
|
|
+ }
|
|
|
+ foreach (Dever::config('base')->lang_set as $k => $v) {
|
|
|
+ if ($i == 0) {
|
|
|
+ $prefix = '';
|
|
|
+ } else {
|
|
|
+ $prefix = $k;
|
|
|
+ $col = $config['manage']['lang'];
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ if (isset($config['manage']['tab'])) {
|
|
|
+ $content = '';
|
|
|
+ $j = 0;
|
|
|
+ foreach ($config['manage']['tab'] as $k1 => $v1) {
|
|
|
+ $html = $this->update_struct($config, $col, $data, $k1, $prefix);
|
|
|
+ if ($html) {
|
|
|
+ $content .= '<div class="layui-colla-item"><h2 class="layui-colla-title">'.$v1.'</h2><div class="layui-colla-content layui-show">' . $html . '</div></div>';
|
|
|
+ $j++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($content) {
|
|
|
+ $class_0 = $class_1 = '';
|
|
|
+ if ($i == 0) {
|
|
|
+ $class_0 = 'layui-this';
|
|
|
+ $class_1 = 'layui-show';
|
|
|
+ }
|
|
|
+ $result .= '<li class="'.$class_0.'">'.$v.'</li>';
|
|
|
+ $tab .= '<div class="layui-tab-item '.$class_1.'"><div class="layui-collapse" lay-filter="component-panel">'.$content.'</div></div>';
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $content = $this->update_struct($config, $col, $data, -1, $prefix);
|
|
|
+ if ($content) {
|
|
|
+ $class_0 = $class_1 = '';
|
|
|
+ if ($i == 0) {
|
|
|
+ $class_0 = 'layui-this';
|
|
|
+ $class_1 = 'layui-show';
|
|
|
+ }
|
|
|
+ $result .= '<li class="'.$class_0.'">'.$v.'</li>';
|
|
|
+ $tab .= '<div class="layui-tab-item '.$class_1.'">'.$content.'</div>';
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $tab .= '</div>';
|
|
|
+ $result .= '</ul>' . $tab . '</div>';
|
|
|
+ } elseif (isset($config['manage']['tab'])) {
|
|
|
+ $result .= '<div class="layui-tab layui-tab-card"><ul class="layui-tab-title">';
|
|
|
+ $tab = '<div class="layui-tab-content">';
|
|
|
+ $i = 0;
|
|
|
+ foreach ($config['manage']['tab'] as $k => $v) {
|
|
|
+ $content = $this->update_struct($config, $col, $data, $k);
|
|
|
+ if ($content) {
|
|
|
+ $class_0 = $class_1 = '';
|
|
|
+ if ($i == 0) {
|
|
|
+ $class_0 = 'layui-this';
|
|
|
+ $class_1 = 'layui-show';
|
|
|
+ }
|
|
|
+ $result .= '<li class="'.$class_0.'">'.$v.'</li>';
|
|
|
+ $tab .= '<div class="layui-tab-item '.$class_1.'">'.$content.'</div>';
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $tab .= '</div>';
|
|
|
+ $result .= '</ul>' . $tab . '</div>';
|
|
|
+ } else {
|
|
|
+ $result .= $this->update_struct($config, $col, $data);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($this->card) && $this->card) {
|
|
|
+ $result = str_replace('{style}', 'style="display:none"', $result);
|
|
|
+ }
|
|
|
+
|
|
|
+ $button = '<div class="layui-card-body"><div class="layui-form-item">' . $this->update_button() . '</div></div>';
|
|
|
+
|
|
|
+ $result .= '</div>'.$button.'</div></div>';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function update_struct($config, $col, $data, $tab = -1, $prefix = '')
|
|
|
+ {
|
|
|
+ $result = array();
|
|
|
foreach ($config['struct'] as $k => $v) {
|
|
|
- if (isset($v['update']) && $v['update']) {
|
|
|
+ $state = false;
|
|
|
+ if ($tab == 0) {
|
|
|
+ if (!isset($v['tab']) || (isset($v['tab']) && $v['tab'] == $tab)) {
|
|
|
+ $state = true;
|
|
|
+ }
|
|
|
+ } elseif ($tab > 0) {
|
|
|
+ if (isset($v['tab']) && $v['tab'] == $tab) {
|
|
|
+ $state = true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $state = true;
|
|
|
+ }
|
|
|
+ if (isset($v['update']) && $v['update'] && $state) {
|
|
|
if ($col && !strstr(',' . $col . ',', ',' . $k . ',')) {
|
|
|
continue;
|
|
|
}
|
|
@@ -2926,6 +3054,10 @@ class Database
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
+ $index = $k;
|
|
|
+ if ($prefix) {
|
|
|
+ $k = $prefix . '_' . $k;
|
|
|
+ }
|
|
|
|
|
|
$class = $this->update_class($k, $v, '', $data);
|
|
|
|
|
@@ -2958,8 +3090,6 @@ class Database
|
|
|
return implode('', $result);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
@@ -3046,7 +3176,7 @@ class Database
|
|
|
*
|
|
|
* @return string
|
|
|
*/
|
|
|
- public function create_update_html($key, $value, $data = array())
|
|
|
+ public function create_update_html($key, $value, $data = array(), $index = false)
|
|
|
{
|
|
|
$result = '';
|
|
|
|
|
@@ -3071,7 +3201,10 @@ class Database
|
|
|
$value['update'] = 'hidden';
|
|
|
}
|
|
|
|
|
|
- $this->update_html($value, $key, $key, $data, $result);
|
|
|
+ if (!$index) {
|
|
|
+ $index = $key;
|
|
|
+ }
|
|
|
+ $this->update_html($value, $key, $index, $data, $result);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
@@ -3366,7 +3499,7 @@ class Database
|
|
|
$prefix = 'add';
|
|
|
}
|
|
|
if ($method && $input) {
|
|
|
- $update = $order = array();
|
|
|
+ $update = $order = $update_other = array();
|
|
|
$i = 0;
|
|
|
$c = array();
|
|
|
foreach ($input as $k => $v) {
|
|
@@ -3424,7 +3557,11 @@ class Database
|
|
|
$update[$i]['where_id'] = $v;
|
|
|
}
|
|
|
} else {
|
|
|
- if (strpos($k, '-')) {
|
|
|
+ if (strpos($k, 'l-l')) {
|
|
|
+ $temp = explode('l-l', $k);
|
|
|
+ $k = str_replace('_', '', $temp[2]);
|
|
|
+ $update_other[$i][$temp[1]][$k] = $v;
|
|
|
+ } elseif (strpos($k, '-')) {
|
|
|
$k = str_replace('update_', '', $k);
|
|
|
if (isset($config['struct'][$k]) && isset($config['struct'][$k]['sync'])) {
|
|
|
$s_col = $config['struct'][$k]['sync'][0];
|
|
@@ -3438,13 +3575,13 @@ class Database
|
|
|
$temp = explode('-', $k);
|
|
|
$index = $temp[0] . '/' . $temp[1];
|
|
|
|
|
|
- $update_other_set[$index]['set_' . $temp[2]] = $v;
|
|
|
-
|
|
|
+ $update_set[$index]['set_' . $temp[2]] = $v;
|
|
|
+
|
|
|
|
|
|
- $update_other_add[$index]['add_' . $temp[2]] = $v;
|
|
|
- $update_other_add[$index]['add_' . $m_col] = $s_value;
|
|
|
+ $update_add[$index]['add_' . $temp[2]] = $v;
|
|
|
+ $update_add[$index]['add_' . $m_col] = $s_value;
|
|
|
|
|
|
- $update_other_id[$index]['option_' . $m_col] = $s_value;
|
|
|
+ $update_id[$index]['option_' . $m_col] = $s_value;
|
|
|
}
|
|
|
} else {
|
|
|
if (is_array($v)) {
|
|
@@ -3474,9 +3611,9 @@ class Database
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
$copy_num = Dever::input('copy_num');
|
|
@@ -3513,21 +3650,29 @@ class Database
|
|
|
if ($id) {
|
|
|
$struct = $this->struct_data($config['struct'], $v, $old);
|
|
|
Log::add($this->project, $this->table, $this->menu_id, '', $method, $struct, $id ? $id : $this->id);
|
|
|
+
|
|
|
+ if ($update_other && isset($update_other[$k])) {
|
|
|
+ foreach ($update_other[$k] as $k1 => $v1) {
|
|
|
+ $v1['id'] = $id;
|
|
|
+ $this->load($method, $v1, $this->table . '__' . $k1);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (isset($update_other_id) && $update_other_id) {
|
|
|
- foreach ($update_other_set as $k => $v) {
|
|
|
- $check = Dever::load($k . '-one', $update_other_id[$k]);
|
|
|
+ if (isset($update_id) && $update_id) {
|
|
|
+ foreach ($update_set as $k => $v) {
|
|
|
+ $check = Dever::load($k . '-one', $update_id[$k]);
|
|
|
|
|
|
if ($check) {
|
|
|
$v['where_id'] = $check['id'];
|
|
|
Dever::load($k . '-update', $v);
|
|
|
} else {
|
|
|
- Dever::load($k . '-insert', $update_other_add[$k]);
|
|
|
+ Dever::load($k . '-insert', $update_add[$k]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
Dever::out('yes');
|
|
@@ -4098,9 +4243,12 @@ class Database
|
|
|
*
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- private function load($method = 'one', $param = array())
|
|
|
+ private function load($method = 'one', $param = array(), $table = false)
|
|
|
{
|
|
|
- return Dever::load($this->project . '/' . $this->table . '-' . $method, $param);
|
|
|
+ if (!$table) {
|
|
|
+ $table = $this->table;
|
|
|
+ }
|
|
|
+ return Dever::load($this->project . '/' . $table . '-' . $method, $param);
|
|
|
}
|
|
|
|
|
|
|