修改文件:phpcms/modules/content/class/content_tag.class.php
调整过的方法:
php
public function __construct() {
$this->db = pc_base::load_model('content_model');
$this->position = pc_base::load_model('position_model');
$this->position_data = pc_base::load_model('position_data_model');
}
/**
* 推荐位
* WY EDIT AT 2024-01-09 已修复未审核信息出现在推荐列表中的问题
* @param $data
*/
public function position($data) {
$sql = '';
$array = array();
$posid = intval($data['posid']);
$position = $this->position->get_one(array('posid'=>$posid));
$this->db->set_model($position['modelid']);
$this->tablename = $this->db->table_name;
$result = $this->db->select("status=99 AND posids=1", '*', '', '', '');
foreach ($result as $r) {
$ids_array[] = $r['id'];
}
$ids = implode(',', $ids_array);
if($ids) {
$sql = "id IN ($ids) AND ";
} else {
$sql = '1<>1 AND';
}
$order = $data['order'];
$thumb = (empty($data['thumb']) || intval($data['thumb']) == 0) ? 0 : 1;
$siteid = $GLOBALS['siteid'] ? intval($GLOBALS['siteid']) : 1;
$catid = (empty($data['catid']) || $data['catid'] == 0) ? '' : intval($data['catid']);
if($catid) {
$siteids = getcache('category_content','commons');
if(!$siteids[$catid]) return false;
$siteid = $siteids[$catid];
$this->category = getcache('category_content_'.$siteid,'commons');
}
if($catid && $this->category[$catid]['child']) {
$catids_str = $this->category[$catid]['arrchildid'];
$pos = strpos($catids_str,',')+1;
$catids_str = substr($catids_str, $pos);
$sql .= "`catid` IN ($catids_str) AND ";
} elseif($catid && !$this->category[$catid]['child']) {
$sql .= "`catid` = '$catid' AND ";
}
if($thumb) $sql .= "`thumb` = '1' AND ";
if(isset($data['where'])) $sql .= $data['where'].' AND ';
if(isset($data['expiration']) && $data['expiration']==1) $sql .= '(`expiration` >= \''.SYS_TIME.'\' OR `expiration` = \'0\' ) AND ';
$sql .= "`posid` = '$posid' AND `siteid` = '".$siteid."'";
$pos_arr = $this->position_data->select($sql, '*', $data['limit'],$order);
if(!empty($pos_arr)) {
foreach ($pos_arr as $info) {
$key = $info['catid'].'-'.$info['id'];
$array[$key] = string2array($info['data']);
$array[$key]['url'] = go($info['catid'],$info['id']);
$array[$key]['id'] = $info['id'];
$array[$key]['catid'] = $info['catid'];
$array[$key]['listorder'] = $info['listorder'];
}
}
return $array;
}