comment_api.class.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. defined('IN_PHPCMS') or exit('No permission resources.');
  3. if (!module_exists('comment')) showmessage(L('module_not_exists'));
  4. class comment_api {
  5. private $db;
  6. function __construct() {
  7. $this->db = pc_base::load_model('content_model');
  8. }
  9. /**
  10. * 获取评论信息
  11. * @param $module 模型
  12. * @param $contentid 文章ID
  13. * @param $siteid 站点ID
  14. */
  15. function get_info($module, $contentid, $siteid) {
  16. list($module, $catid) = explode('_', $module);
  17. if (empty($contentid) || empty($catid)) {
  18. return false;
  19. }
  20. //判断栏目是否存在 s
  21. $CATEGORYS = getcache('category_content_'.$siteid,'commons');
  22. if(!$CATEGORYS[$catid]){
  23. return false;
  24. }
  25. //判断模型是否存在
  26. $this_modelid = $CATEGORYS[$catid]['modelid'];
  27. $MODEL = getcache('model','commons');
  28. if(!$MODEL[$this_modelid]){
  29. return false;
  30. }
  31. $this->db->set_catid($catid);
  32. $r = $this->db->get_one(array('catid'=>$catid, 'id'=>$contentid), '`title`');
  33. $category = getcache('category_content_'.$siteid, 'commons');
  34. $model = getcache('model', 'commons');
  35. $cat = $category[$catid];
  36. $data_info = array();
  37. if ($cat['type']==0) {
  38. if ($model[$cat['modelid']]['tablename']) {
  39. $this->db->table_name = $this->db->db_tablepre.$model[$cat['modelid']]['tablename'].'_data';
  40. $data_info = $this->db->get_one(array('id'=>$contentid));
  41. }
  42. }
  43. if ($r) {
  44. return array('title'=>$r['title'], 'url'=>go($catid, $contentid, 1), 'allow_comment'=>(isset($data_info['allow_comment']) ? $data_info['allow_comment'] : 1));
  45. } else {
  46. return false;
  47. }
  48. }
  49. }