Article.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Content\Lib;
  3. use Dever;
  4. class Article
  5. {
  6. # 根据文章id 获取文章信息
  7. public function get($data)
  8. {
  9. if (!is_array($data)) {
  10. $data = Dever::db('content/article')->getOne($data);
  11. }
  12. if (!$data) {
  13. Dever::alert('错误的文章信息');
  14. }
  15. //embed
  16. $data['content_array'] = array();
  17. if (strstr($data['content'], 'embed')) {
  18. //print_r($data['content']);die;
  19. preg_match_all('/<embed src="(.*?)"(.*?)\/>/i', $data['content'], $matches);
  20. if (isset($matches[1])) {
  21. foreach ($matches[1] as $k => $v) {
  22. }
  23. }
  24. //print_r($matches);die;
  25. }
  26. return $data;
  27. }
  28. # 获取相关推荐
  29. public function getRelation($info)
  30. {
  31. $where['noid'] = $info['id'];
  32. $where['cate_id'] = $info['cate_id'];
  33. return Dever::db('content/article')->getRelation($where);
  34. }
  35. # 增加浏览量
  36. public function addView($id)
  37. {
  38. Dever::db('content/article')->addView($id);
  39. }
  40. }