search_api.class.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * search_api.class.php 专题执行接口类
  4. *
  5. */
  6. defined('IN_PHPCMS') or exit('No permission resources.');
  7. class search_api {
  8. private $db, $c;
  9. public function __construct() {
  10. $this->db = pc_base::load_model('special_content_model');
  11. $this->c = pc_base::load_model('special_c_data_model');
  12. }
  13. /**
  14. * 获取内容接口
  15. * @param intval $pagesize 每页个数
  16. * @param intval $page 当前页数
  17. */
  18. public function fulltext_api($pagesize = 100, $page = 1) {
  19. $result = $r = $data = $tem = array();
  20. $offset = ($page-1)*$pagesize;
  21. $result = $this->db->select(array('isdata'=>1), '`id`, `title`, `inputtime`', $offset.','.$pagesize, '`id` ASC');
  22. foreach ($result as $r) {
  23. $d = $this->c->get_one(array('id'=>$r['id']), '`content`');
  24. $tem['title'] = addslashes($r['title']);
  25. $tem['fulltextcontent'] = $d['content'];
  26. $tem['adddate'] = $r['inputtime'];
  27. $data[$r['id']] = $tem;
  28. }
  29. return $data;
  30. }
  31. /**
  32. * 计算总数接口
  33. */
  34. public function total() {
  35. $r = $this->db->get_one(array('isdata'=>1), 'COUNT(*) AS num');
  36. return $r['num'];
  37. }
  38. /**
  39. * 获取专题下内容数据
  40. * @param string/intval $ids 多个id用“,”分开
  41. */
  42. public function get_search_data($ids) {
  43. $where = to_sqls($ids, '', 'id');
  44. $data = $this->db->select($where, '`id`, `title`, `thumb`, `description`, `url`, `inputtime`', '', '', '', 'id');
  45. return $data;
  46. }
  47. }