Person.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace Content\Lib;
  3. use Dever;
  4. class Person
  5. {
  6. # 获取文章信息
  7. public function getInfo()
  8. {
  9. $id = Dever::input('id');
  10. $data = Dever::db('content/person')->getOne($id);
  11. if (!$data) {
  12. Dever::alert('错误的信息');
  13. }
  14. if ($data['source_id']) {
  15. $data['source'] = Dever::db('content/source')->one($data['source_id']);
  16. }
  17. $data['bdate'] = date('Y年m月d日', $data['bdate']);
  18. $data['skill'] = Dever::array_decode($data['skill']);
  19. $data['learn'] = Dever::array_decode($data['learn']);
  20. $data['life'] = Dever::array_decode($data['life']);
  21. $data['ability_array'] = array($data['ability']);
  22. if (strstr($data['ability'], ',')) {
  23. $data['ability_array'] = explode(',', $data['ability']);
  24. }
  25. if (strstr($data['ability'], ',')) {
  26. $data['ability_array'] = explode(',', $data['ability']);
  27. }
  28. $data['ability_html'] = '';
  29. if ($data['ability_array']) {
  30. foreach ($data['ability_array'] as $v) {
  31. $data['ability_html'] .= '<span>'.$v.'</span>';
  32. }
  33. }
  34. $data['skill_html'] = '';
  35. if ($data['skill']) {
  36. foreach ($data['skill'] as $v) {
  37. $data['skill_html'] .= '<li class="tec'.$v['level'].'">'.$v['name'].'<span></span></li>';
  38. }
  39. }
  40. $data['content'] = '';
  41. if ($data['desc']) {
  42. $data['content'] = '<h2>人物简介</h2><p>'.$data['desc'].'</p>';
  43. }
  44. if ($data['learn']) {
  45. $data['content'] .= '<h2>学习经历</h2>';
  46. foreach ($data['learn'] as $v) {
  47. $data['content'] .= '<p><span style="color:#808080;">'.$v['name'].'</span></p>';
  48. $desc = Dever::split($v['desc']);
  49. foreach ($desc as $v1) {
  50. $data['content'] .= '<p>'.$v1.'</p>';
  51. }
  52. }
  53. }
  54. if ($data['life']) {
  55. $data['content'] .= '<h2>生活经历</h2>';
  56. foreach ($data['life'] as $v) {
  57. $data['content'] .= '<p><span style="color:#808080;">'.$v['name'].'</span></p>';
  58. $desc = Dever::split($v['desc']);
  59. foreach ($desc as $v1) {
  60. $data['content'] .= '<p>'.$v1.'</p>';
  61. }
  62. }
  63. }
  64. return $data;
  65. }
  66. # 获取精彩推荐
  67. public function getTop()
  68. {
  69. $where = array();
  70. $data = Dever::db('content/person')->getTop($where);
  71. if ($data) {
  72. foreach ($data as $k => $v) {
  73. $data[$k]['link'] = Dever::url('about?id=' . $v['id'], 'main');
  74. $data[$k]['bdate'] = date('Y-m-d', $v['bdate']);
  75. }
  76. }
  77. return $data;
  78. }
  79. }