123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
- namespace Page\Lib;
- use Dever;
- class Manage
- {
- public function search_api()
- {
- $type = Dever::input('type');
- $func = Dever::db('page/func')->find($type);
- $method = false;
- if ($func && $func['search']) {
- $method = $func['search'];
- }
- if (!$method) {
- Dever::alert('暂无数据');
- }
- return Dever::search($method);
- }
- public function showType_api()
- {
- $value = Dever::input('value');
- $data = array();
- $id = Dever::input('id');
- if ($id) {
- $data = Dever::db('page/data')->find($id);
- }
- $struct = Dever::db('page/data')->config['struct'];
- $config['type_id'] = $struct['type_id'];
- $config['type_id']['name'] = '关联数据';
- if ($value == -1) {
- $config['type_id']['update'] = 'hidden';
- /*
- foreach ($struct as $k => $v) {
- if (strstr($k, 'col_')) {
- $config[$k] = $v;
- $config[$k]['update'] = $v['update_bak'];
- }
- }*/
- } else {
- $config['type_id']['update'] = 'select';
- $config['type_id']['update_search'] = 'page/lib/manage.search?type=' . $value;
- if ($data && $data['type_id']) {
- $config['type_id']['update_search_value'] = $data['type_id'];
- }
- /*
- $func = Dever::db('page/func')->find($value);
- if ($func && $func['col']) {
- $func['col'] = Dever::array_decode($func['col']);
- $col = array();
- foreach ($func['col'] as $v) {
- $col['col_' . $v['col_id']] = 1;
- }
- foreach ($struct as $k => $v) {
- if (strstr($k, 'col_')) {
- if (isset($col[$k])) {
- $config[$k] = $v;
- $config[$k]['update'] = $v['update_bak'];
- } else {
- $config[$k] = $v;
- $config[$k]['update'] = 'hidden';
- }
- }
- }
- }*/
- }
- $data = Dever::load('manage/database')->update_struct(array('struct' => $config), false, $data, -1, '', false, false);
-
- return $data;
- }
- # 查看图片
- public function pic($pic)
- {
- $table = array();
- return '<img src="'.$pic.'" width=“150”/>';
- return Dever::table($table);
- }
- public function show($id)
- {
- $table = Dever::load('page/lib/data')->getOne($id);
- if (count($table) == 1) {
- $table = $table[0];
- }
- return Dever::table($table);
- }
- # 查看模板
- public function template()
- {
- $data = Dever::db('page/template')->state();
- foreach ($data as $k => $v) {
- if (!$v['pic']) {
- $v['pic'] = '';
- }
- $data[$k]['name'] = '<img src="'.$v['pic'].'" style="margin-bottom: 34px;width:300px" alt="'.$v['name'].'"/>';
- }
- return $data;
- }
- public function getPic($col, $id)
- {
- $info = $this->getData($col, $id);
- return $this->pic($info);
- }
- public function getData($col, $id)
- {
- $data = Dever::db('page/data')->find($id);
- if (isset($data['col_' . $col]) && $data['col_' . $col]) {
- return $data['col_' . $col];
- }
- if ($data['type'] > 0 && $data['type_id'] > 0) {
- $func = Dever::db('page/func')->find($data['type']);
- if ($func['col']) {
- $info = Dever::load($func['api'], $data['type_id']);
- if ($info) {
- $func['col'] = Dever::json_decode($func['col']);
- foreach ($func['col'] as $k => $v) {
- if ($v['col_id'] == $col && isset($info[$v['name']])) {
- return $info[$v['name']];
- }
- }
- }
- }
- }
- return $data['col_' . $col];
- }
- }
|