Page.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. <?php namespace Manage\Lib;
  2. use Dever;
  3. # 通用页面
  4. class Page extends Auth
  5. {
  6. protected $db;
  7. protected $key;
  8. protected $id = 0;
  9. protected $input = false;
  10. protected $recycler = false;
  11. protected $menu = array();
  12. protected $config = array();
  13. protected $field = array();
  14. public $info = array();
  15. public function __construct($key = '', $load = '', $input = true, $config = array())
  16. {
  17. parent::__construct();
  18. $this->key = $key;
  19. $this->input = $input;
  20. $this->id = $this->input('id', 0);
  21. if (!$load) {
  22. $load = Dever::input('load');
  23. }
  24. list($this->db, $this->menu) = Dever::load('common', 'manage')->db($load);
  25. if ($this->menu && $this->menu['show'] == 1) {
  26. $this->checkMenu($this->menu['id'], false);
  27. }
  28. $this->config = $this->db->config['manage'][$key] ?? array();
  29. if ($config) {
  30. $this->config = array_merge($this->config, $config);
  31. }
  32. if ($this->id && !strstr($this->id, ',')) {
  33. $this->info = $this->db->find($this->id);
  34. }
  35. }
  36. public function setting($key, &$data, $struct = true, $type = 'show', $disable = false)
  37. {
  38. if (empty($this->config[$key]) && $struct && isset($this->db->config['struct']) && $this->db->config['struct']) {
  39. $this->config[$key] = $this->db->config['struct'];
  40. }
  41. if (empty($this->config[$key])) {
  42. return;
  43. }
  44. $setting = $this->config[$key];
  45. if (is_string($setting)) {
  46. $setting = explode(',', $setting);
  47. }
  48. $field = $this->input('field', '');
  49. if ($field && is_string($field) && strstr($field, 'dever_')) {
  50. $field = '';
  51. }
  52. return $this->setData($setting, $data, $field, $type, $disable);
  53. }
  54. # 获取某个数据的具体展示值
  55. public function getValue($key, $value, $data, $field = array())
  56. {
  57. if ($key == 'cdate') {
  58. $this->db->config['manage']['update']['field'][$key]['type'] = 'date';
  59. }
  60. $update = $this->db->config['manage']['update']['field'] ?? array();
  61. if ($show = Dever::issets($field, 'show')) {
  62. $value = $this->getShow($show, $data);
  63. } elseif ($value && isset($this->db->config['struct'][$key]['value']) && $this->db->config['struct'][$key]['value']) {
  64. $value = $this->db->value($key, $value);
  65. } elseif ($value && (isset($update[$key]) && isset($update[$key]['type']) && $update[$key]['type'] == 'date')) {
  66. if (isset($update[$key]['date_type']) && $update[$key]['date_type'] == 'year') {
  67. if ($update[$key]['date_type'] == 'year') {
  68. $value = date('Y', $value);
  69. } elseif ($update[$key]['date_type'] == 'month') {
  70. $value = date('Ym', $value);
  71. } else {
  72. $value = date('Ymd', $value);
  73. }
  74. } else {
  75. if (strstr($value, 'T')) {
  76. $value = date('Y-m-d H:i:s', strtotime($value));
  77. } elseif (is_numeric($value)) {
  78. $value = date('Y-m-d H:i:s', $value);
  79. } else {
  80. $value = '-';
  81. }
  82. }
  83. }
  84. return $value;
  85. }
  86. # 获取关联数据
  87. public function getOther($key, $set, $data)
  88. {
  89. $where = $config = array();
  90. if (isset($set['where'])) {
  91. foreach ($set['where'] as $k => $v) {
  92. if (!is_array($v) && isset($data[$v])) {
  93. $where[$k] = $data[$v];
  94. } else {
  95. $where[$k] = $v;
  96. }
  97. }
  98. }
  99. if (isset($set['col'])) {
  100. $config['col'] = $set['col'];
  101. }
  102. if ($where) {
  103. return Dever::db($key)->select($where, $config);
  104. }
  105. return array();
  106. }
  107. public function getShow($show, $data)
  108. {
  109. return \Dever\Helper\Str::val($show, $data);
  110. }
  111. # 获取菜单标题
  112. public function getTitle()
  113. {
  114. return $this->menu['name'];
  115. }
  116. # 获取左侧分栏
  117. protected function column(&$data, $name = '左侧分栏')
  118. {
  119. $data['column'] = false;
  120. if (isset($this->config['column'])) {
  121. if (empty($this->config['column']['hidden'])) {
  122. $data['column'] = $this->config['column'];
  123. if (isset($this->config['column']['add'])) {
  124. $data['column']['add'] = array('name' => $this->config['column']['add'], 'func' => $this->getFunc('column_add', $name . '-' . $this->config['column']['add'], 101));
  125. }
  126. if (isset($this->config['column']['edit'])) {
  127. $data['column']['edit'] = array('name' => '编辑', 'func' => $this->getFunc('column_edit', $name . '-编辑', 102));
  128. }
  129. if (isset($this->config['column']['delete'])) {
  130. $data['column']['delete'] = array('name' => '删除', 'func' => $this->getFunc('column_delete', $name . '-删除', 103));
  131. }
  132. $data['column']['data'] = $this->config['column']['data'];
  133. if (is_string($data['column']['data'])) {
  134. $data['column']['data'] = Dever::call($data['column']['data']);
  135. }
  136. $data['height'] = '100%';
  137. }
  138. if (isset($this->config['column']['active']) && $this->config['column']['where'] == 'id') {
  139. return $this->config['column']['active'];
  140. }
  141. }
  142. }
  143. # 通用的规则验证 一般为更新数据时使用
  144. protected function checkRules($set, $data)
  145. {
  146. if ($set['rules']) {
  147. if (!is_array($set['rules'])) {
  148. $set['rules'] = array
  149. (
  150. array
  151. (
  152. 'required' => true,
  153. 'trigger' => 'blur',
  154. 'message' => $set['name'] . '不能为空',
  155. ),
  156. );
  157. }
  158. foreach ($set['rules'] as $k => $v) {
  159. if (isset($v['required']) && $v['required'] && !$data && $data !== 0) {
  160. Dever::error($v['message']);
  161. }
  162. if ($data || $data === 0) {
  163. if (isset($v['pattern']) && $v['pattern'] && !preg_match('/' . $v['pattern'] . '/', $data)) {
  164. Dever::error($v['message']);
  165. }
  166. if (isset($v['type']) && $v['type']) {
  167. if ($v['type'] == 'number' && !is_numeric($data)) {
  168. Dever::error($v['message']);
  169. } elseif ($v['type'] == 'array' && !is_array($data)) {
  170. Dever::error($v['message']);
  171. } elseif ($v['type'] == 'integer' && !is_int($data)) {
  172. Dever::error($v['message']);
  173. } elseif ($v['type'] == 'float' && !is_float($data)) {
  174. Dever::error($v['message']);
  175. } elseif ($v['type'] == 'string' && !is_string($data)) {
  176. Dever::error($v['message']);
  177. } elseif ($v['type'] == 'boolean' && !is_bool($data)) {
  178. Dever::error($v['message']);
  179. } elseif ($v['type'] == 'url' && !filter_var($data, FILTER_VALIDATE_URL)) {
  180. Dever::error($v['message']);
  181. } elseif ($v['type'] == 'email' && !filter_var($data, FILTER_VALIDATE_EMAIL)) {
  182. Dever::error($v['message']);
  183. } elseif ($v['type'] == 'enum' && isset($v['enum']) && !in_array($data, $v['enum'])) {
  184. Dever::error($v['message']);
  185. }
  186. }
  187. if (isset($v['len']) && $v['len'] && strlen($data) > $v['len']) {
  188. Dever::error($v['message']);
  189. }
  190. if (isset($v['min']) && $v['min'] && strlen($data) < $v['min']) {
  191. Dever::error($v['message']);
  192. }
  193. if (isset($v['max']) && $v['max'] && strlen($data) > $v['max']) {
  194. Dever::error($v['message']);
  195. }
  196. }
  197. }
  198. }
  199. }
  200. private function setData($setting, &$data, $field, $type, $disable)
  201. {
  202. $result = array();
  203. foreach ($setting as $k => $v) {
  204. if (!is_array($v)) {
  205. if (is_numeric($k)) {
  206. $k = $v;
  207. $v = $type;
  208. }
  209. if ($k == 'id') {
  210. $v = array('name' => 'ID', 'type' => $v);
  211. } elseif ($k == 'cdate') {
  212. $v = array('name' => '创建时间', 'type' => $v);
  213. } elseif(isset($this->db->config['struct'][$k])) {
  214. $v = array('name' => $this->db->config['struct'][$k]['name'], 'type' => $v);
  215. } else {
  216. $v = array('name' => $v);
  217. }
  218. } else {
  219. if (isset($v['only'])) {
  220. if ($v['only'] == 'edit' && !$this->id) {
  221. continue;
  222. } elseif ($v['only'] == 'add' && $this->id) {
  223. continue;
  224. }
  225. }
  226. }
  227. if ($field) {
  228. if (is_string($field) && (strstr($field, '{') || strstr($field, '%7B'))) {
  229. $field = htmlspecialchars_decode($field);
  230. $field = Dever::json_decode($field);
  231. }
  232. if (is_array($field)) {
  233. if (isset($field['param'])) {
  234. if (isset($field['param']['set'])) {
  235. $field = array_merge($field, $field['param']['set']);
  236. }
  237. if (isset($field['param']['search'])) {
  238. $field = array_merge($field, $field['param']['search']);
  239. }
  240. } elseif (isset($field['field']) && !Dever::check($field['field'], $k)) {
  241. continue;
  242. }
  243. if (isset($field[$k]) && $field[$k] != $k) {
  244. $v['default'] = $field[$k];
  245. $v['type'] = 'hidden';
  246. }
  247. } elseif (!Dever::check($field, $k)) {
  248. continue;
  249. }
  250. }
  251. $info = $this->setField($data, $k, $v, $field, $type, $disable);
  252. if ($info) {
  253. $result[] = $info;
  254. }
  255. }
  256. return $result;
  257. }
  258. private function setField(&$data, $key, $value, $field, $type = 'show', $disable = false)
  259. {
  260. $value['key'] = $key;
  261. $this->setName($value);
  262. # 对每个字段进行权限设置
  263. if (isset($value['func']) && $value['func']) {
  264. $func = $this->getFunc('field_' . $value['key'], '字段-' . $value['name'], 200);
  265. if (!$func) {
  266. return false;
  267. }
  268. }
  269. if (strpos($key, '/') && $this->key == 'update') {
  270. $this->setType($value, 'table');
  271. $this->setShow($value);
  272. if (strpos($key, '#')) {
  273. $key = str_replace('#', '', $key);
  274. }
  275. $sku = $value['type'] == 'sku' ? true : false;
  276. $value['value'] = $this->getOther($key, $value, $this->info);
  277. if (isset($value['default'])) {
  278. $value['value'] += $value['default'];
  279. }
  280. if (isset($value['field'])) {
  281. list($app, $table) = explode('/', $key);
  282. $set = Dever::project($app);
  283. $manage = @include($set['path'] . 'manage/'.$table.'.php');
  284. if (isset($manage['update']['field'][$value['field']])) {
  285. $value = array_merge($value, $manage['update']['field'][$value['field']]);
  286. }
  287. if ($value['value']) {
  288. $data[$key . '_id'] = array
  289. (
  290. 'key' => $key . '_id',
  291. 'type' => 'hidden',
  292. 'value' => $value['value'][0]['id'],
  293. );
  294. $value['value'] = $value['value'][0][$value['field']];
  295. }
  296. $this->setRules($value);
  297. $this->setForm($value);
  298. $data[] = $value;
  299. return $value['name'] ?? 'test';
  300. }
  301. $update = new \Manage\Api\Page\Update($key, false);
  302. $value['option'] = array();
  303. $value['content'] = $update->get($value['value'], $value['option'], $sku);
  304. $data[] = $value;
  305. return $value['name'];
  306. } else {
  307. $this->setType($value, $type);
  308. $this->setDisable($value, $disable);
  309. if ($this->key == 'update') {
  310. # 一般为更新页面需要的参数
  311. $this->setShow($value);
  312. $this->setRules($value);
  313. } elseif (isset($value['remote'])) {
  314. $value['remote'] = Dever::url($value['remote']);
  315. }
  316. if ($type == 'show') {
  317. if (!isset($value['tip'])) {
  318. $value['tip'] = false;
  319. }
  320. $in = array('switch', 'select', 'input');
  321. if (in_array($value['type'], $in)) {
  322. $value['func'] = $this->getFunc('list_edit_' . $value['key'], '列表更新-' . $value['name'], 104);
  323. if (!$value['func']) {
  324. $value['type'] = 'show';
  325. if (isset($value['show'])) {
  326. unset($value['show']);
  327. }
  328. }
  329. }
  330. if (isset($value['child'])) {
  331. $child = array();
  332. $this->setData($value['child'], $child, $field, $type, $disable);
  333. $value['child'] = $child;
  334. } else {
  335. $this->field[$key] = $value;
  336. }
  337. }
  338. $this->setForm($value);
  339. $data[] = $value;
  340. return $value['name'] ?? 'test';
  341. }
  342. }
  343. private function setShow(&$value)
  344. {
  345. if ($value['type'] == 'hidden') {
  346. $value['show'] = false;
  347. } elseif (!isset($value['show'])) {
  348. $value['show'] = true;
  349. }
  350. }
  351. private function setName(&$value)
  352. {
  353. if (empty($value['name']) && isset($this->db->config['struct'][$value['key']])) {
  354. $value['name'] = $this->db->config['struct'][$value['key']]['name'];
  355. }
  356. if (empty($value['placeholder']) && isset($value['name'])) {
  357. $value['placeholder'] = $value['name'];
  358. }
  359. }
  360. private function setType(&$value, $type)
  361. {
  362. if (empty($value['type'])) {
  363. $value['type'] = $type;
  364. }
  365. if (strpos($value['type'], '(')) {
  366. $value['type'] = $type;
  367. }
  368. if (empty($value['width'])) {
  369. $value['width'] = 'auto';
  370. }
  371. if (isset($value['upload']) && Dever::project('upload')) {
  372. $upload['cate_id'] = 1;
  373. $upload['group_key'] = $this->db->config['table'] . '-' . $value['key'];
  374. $upload['group_name'] = $this->db->config['name'];
  375. $upload['user_token'] = Dever::load('common', 'manage')->getToken();
  376. $upload['user_table'] = $this->user['table'];
  377. $upload['user_id'] = $this->user['id'];
  378. if (is_array($value['upload'])) {
  379. $upload += $value['upload'];
  380. } else {
  381. $upload += array('id' => $value['upload']);
  382. }
  383. if (empty($upload['id'])) {
  384. Dever::error('上传配置错误');
  385. }
  386. $value['config'] = Dever::load('save', 'upload')->get($upload['id']);
  387. $value['yun'] = false;
  388. if ($value['config']['method'] == 2) {
  389. $value['yun'] = true;
  390. }
  391. $value['url'] = Dever::url('upload/save.act', $upload);
  392. $upload['wh'] = $value['wh'] ?? '500*500';
  393. $value['set'] = Dever::url('image/manage.set', $upload);
  394. if (isset($value['multiple']) && $value['multiple']) {
  395. $value['limit'] = 10;
  396. } else {
  397. $value['limit'] = 1;
  398. }
  399. }
  400. if (isset($value['editorMenu'])) {
  401. if (isset($value['editorMenu']['uploadImage'])) {
  402. if (!is_array($value['editorMenu']['uploadImage'])) {
  403. $value['editorMenu']['uploadImage'] = array('upload' => $value['editorMenu']['uploadImage']);
  404. }
  405. $value['editorMenu']['uploadImage']['server'] = Dever::url('upload/save.wangEditor', array('id' => $value['editorMenu']['uploadImage']['upload']));
  406. if (empty($value['editorMenu']['uploadImage']['fieldName'])) {
  407. $value['editorMenu']['uploadImage']['fieldName'] = 'file';
  408. }
  409. }
  410. if (isset($value['editorMenu']['uploadVideo'])) {
  411. if (!is_array($value['editorMenu']['uploadVideo'])) {
  412. $value['editorMenu']['uploadVideo'] = array('upload' => $value['editorMenu']['uploadVideo']);
  413. }
  414. $value['editorMenu']['uploadVideo']['server'] = Dever::url('upload/save.wangEditor', array('id' => $value['editorMenu']['uploadVideo']['upload']));
  415. if (empty($value['editorMenu']['uploadImage']['fieldName'])) {
  416. $value['editorMenu']['uploadImage']['fieldName'] = 'file';
  417. }
  418. }
  419. }
  420. if (isset($value['date_type']) && $value['date_type'] == 'datetimerange' && empty($value['default_time'])) {
  421. $value['default_time'] = array(\Dever\Helper\Date::mktime(date('Y-m-d 00:00:00'))*1000, \Dever\Helper\Date::mktime(date('Y-m-d 23:59:59'))*1000);
  422. }
  423. }
  424. private function setDisable(&$value, $disable)
  425. {
  426. if (isset($value['disable'])) {
  427. $disable = $value['disable'];
  428. }
  429. $value['disable'] = $disable;
  430. }
  431. private function setForm(&$value)
  432. {
  433. if (empty($value['value'])) {
  434. $value['value'] = Dever::input('search')[$value['key']] ?? '';
  435. }
  436. if (is_array($value['value'])) {
  437. foreach ($value['value'] as &$v) {
  438. $v = (float) $v;
  439. }
  440. }
  441. if (!$value['value']) {
  442. if (isset($value['default']) && !strstr($value['default'], '{')) {
  443. $value['value'] = $value['default'];
  444. } elseif ($this->key == 'update' && isset($this->db->config['struct'][$value['key']]['default'])) {
  445. $value['value'] = $this->db->config['struct'][$value['key']]['default'];
  446. }
  447. }
  448. if (isset($value['option']) && $value['option']) {
  449. $this->db->config['option'][$value['key']] = $value['option'];
  450. }
  451. if ($option = $this->db->value($value['key'])) {
  452. if ($value['type'] == 'checkbox') {
  453. $value['value'] = $value['value'] ? explode(',', $value['value']) : array();
  454. }
  455. $value['option'] = $option;
  456. if ($value['type'] == 'text') {
  457. $value['type'] = 'select';
  458. }
  459. if (!is_array($value['value']) && $value['value']) {
  460. $value['value'] = (float) $value['value'];
  461. }
  462. }
  463. }
  464. private function setRules(&$value)
  465. {
  466. if (isset($value['rules']) && $value['rules']) {
  467. if (!is_array($value['rules'])) {
  468. $value['rules'] = array
  469. (
  470. array
  471. (
  472. 'required' => true,
  473. 'trigger' => 'blur',
  474. 'message' => $value['name'] . '不能为空',
  475. ),
  476. );
  477. }
  478. foreach ($value['rules'] as $k => $v) {
  479. if (isset($v['only'])) {
  480. if ($v['only'] == 'edit' && !$this->id) {
  481. unset($value['rules'][$k]);
  482. break;
  483. } elseif ($v['only'] == 'add' && $this->id) {
  484. unset($value['rules'][$k]);
  485. break;
  486. }
  487. }
  488. }
  489. if (!isset($value['rules'][0])) {
  490. $value['rules'] = array_values($value['rules']);
  491. }
  492. }
  493. }
  494. protected function input($key, $value = '')
  495. {
  496. return $this->input ? Dever::input($key) : $value;
  497. }
  498. public function button($key = 'button', $data = array())
  499. {
  500. $result = array();
  501. if (!isset($this->config[$key])) {
  502. $num = 0;
  503. if (isset($this->db->config['manage']['update']['field'])) {
  504. $num = count($this->db->config['manage']['update']['field']);
  505. } elseif (isset($this->db->config['struct']) && $this->db->config['struct']) {
  506. $num = count($this->db->config['struct']);
  507. }
  508. $fast = 'fast';
  509. if ($num > 8) {
  510. $fast = '';
  511. }
  512. if ($key == 'button') {
  513. $this->config[$key] = array('新增' => $fast . 'add');
  514. } else {
  515. $this->config[$key] = array('编辑' => $fast . 'edit', '删除' => 'recycle');
  516. }
  517. }
  518. $sort = 1;
  519. foreach ($this->config[$key] as $k => $v) {
  520. $d = '';
  521. $p = '';
  522. $i = '';
  523. if (is_array($v)) {
  524. if (isset($v[3]) && $data) {
  525. $d = $v[3];
  526. parse_str($d, $t);
  527. $state = true;
  528. foreach ($t as $k1 => $v1) {
  529. if (!isset($data[$k1]) || (isset($data[$k1]) && $data[$k1] != $v1)) {
  530. $state = false;
  531. }
  532. }
  533. if (!$state) {
  534. continue;
  535. }
  536. }
  537. if (isset($v[2])) {
  538. $i = $v[2];
  539. }
  540. if (isset($v[1])) {
  541. $p = $v[1];
  542. }
  543. $v = $v[0];
  544. }
  545. if (strstr($v, 'add')) {
  546. $icon = 'Plus';
  547. $button = 'primary';
  548. } elseif (strstr($v, 'edit')) {
  549. $icon = 'Edit';
  550. $button = 'primary';
  551. } elseif (strstr($v, 'view')) {
  552. $icon = 'View';
  553. $button = '';
  554. } elseif ($v == 'delete') {
  555. if ($key == 'button') {
  556. if (isset($this->config['layout'])) {
  557. continue;
  558. }
  559. $this->config['selection'] = true;
  560. }
  561. $icon = 'Delete';
  562. $button = 'danger';
  563. } elseif ($v == 'recycle') {
  564. if ($key == 'button') {
  565. if (isset($this->config['layout'])) {
  566. continue;
  567. }
  568. $this->config['selection'] = true;
  569. }
  570. $icon = 'Delete';
  571. $button = 'danger';
  572. } elseif ($v == 'oper') {
  573. if ($key == 'button') {
  574. if (isset($this->config['layout'])) {
  575. continue;
  576. }
  577. $this->config['selection'] = true;
  578. }
  579. $icon = 'Notification';
  580. $button = 'warning';
  581. } elseif ($v == 'api') {
  582. if ($key == 'button') {
  583. if (isset($this->config['layout'])) {
  584. continue;
  585. }
  586. $this->config['selection'] = true;
  587. }
  588. $p = Dever::url($p);
  589. $icon = 'Notification';
  590. $button = 'warning';
  591. } elseif ($v == 'link') {
  592. $icon = 'Link';
  593. $button = 'success';
  594. } elseif ($v == 'route') {
  595. $icon = 'Link';
  596. $button = 'success';
  597. } elseif ($v == 'recover') {
  598. $icon = 'CirclePlus';
  599. $button = 'info';
  600. } else {
  601. continue;
  602. }
  603. # 权限验证
  604. $sort++;
  605. $func = $this->getFunc($v, $k, $sort, $p);
  606. if ($this->menu && $this->menu['show'] == 1 && !$func) {
  607. continue;
  608. }
  609. if ($i) {
  610. $icon = $i;
  611. }
  612. $result[] = array
  613. (
  614. 'name' => $k,
  615. 'type' => $v,
  616. 'param' => $p,
  617. 'icon' => $icon,
  618. 'button' => $button,
  619. 'func' => $func,
  620. );
  621. if (!$this->recycler && $v == 'recycle') {
  622. $this->recycler = true;
  623. }
  624. }
  625. return $result;
  626. }
  627. }