<?php
/** 
 * UQ云商：	www.uqcms.com  
 * 联系QQ：	2200631718 
 * 可免费商用，需要留UQ云商链接作为交换，只首页底部留取即可，不影响使用。
 */

defined('IN_UQ') or exit('Access Denied'); class category_attr_mod extends module { function __construct(){ parent::__construct(); } public function get_list($uq0, $uq1 = '') { $uq2 = $this->db->query("select * from ".table('category')); while($uq3 = $this->db->fetch_array($uq2)){ $uq4[$uq3['id']] = $uq3['name']; } if(!empty($uq1)){ $uq1 = 'and cid = '.$uq1; }else{ $uq5 = ''; } $uq6 = $this->db->query("select * from ".table('category_attr')." where pid = ".$uq7." ".$uq0); while($uq8 = $this->db->fetch_array($uq6)){ $uq8['gcname'] = $uq4[$uq8['cid']]; $uq9[] = $uq8; } return @$uq9; } function get_attr($uq0) { if($uq0){ $uq10 = $this->db->get_all("select * from ".table('category_attr')." where cid in(".$uq0.") "); if($uq10){ foreach($uq10 as $uq11=>$uq12){ $uq13[] = $uq12['id']; } if(isset($uq13)){ $uq13 = implode(',', $uq13); $uq14 = $this->db->get_all("select * from ".table('category_attr')." where pid in (".$uq13.") "); if($uq14){ foreach($uq14 as $uq15=>$uq16){ $uq17[$uq16['pid']][] = $uq16; } foreach($uq10 as $uq11=>$uq12){ $uq12['p_attr'] = $uq17[$uq12['id']]; $uq9[] = $uq12; } return $uq9; } } } }else{ return false; } } public function get_one($uq7) { return $this->db->get_one("select * from ".table("category_attr")." where id = ".$uq7); } public function attr_list($uq18) { $uq0 = isset($uq18['cid'])?$uq18['cid']:''; if($uq0){ if(cfg('attr_last_show')){ $uq19 = $this->module('category')->get_child_cid($uq0); if($uq19){ $uq20 = implode(',', $uq19); }else{ $uq20 = $uq0; } $uq21 = 'cid in ('.$uq20.')'; }else{ $uq21 = 'cid = '.$uq0; } $uq22 = $this->db->get_all("select id,pid,cid,name,px,status from ".table('category_attr')." where ".$uq21." and status = 1 order by px desc"); if($uq22){ foreach($uq22 as $uq11=>$uq12){ $uq23[] = $uq12; $uq24[] = $uq12['id']; } if($uq24){ $uq25 = implode(',', $uq24); $uq26 = $this->db->query("select id,pid,cid,name,px,status from ".table('category_attr')." where pid in (".$uq25.") and status = 1"); while($uq27 = $this->db->fetch_array($uq26)){ $uq28[$uq27['pid']][] = $uq27; $uq29[$uq27['pid']][] = $uq27['id']; $uq30[$uq27['id']][] = $uq27; } $uq31 = !empty($uq18['attr'])?$uq18['attr']:false; $uq32 = explode('_',$uq31); $uq33 = count($uq23); for($uq34=0; $uq34<$uq33; $uq34++){ if(isset($uq29[$uq23[$uq34]['id']])){ $uq23[$uq34]['pattr'] = $uq28[$uq23[$uq34]['id']]; $uq35 = array_diff($uq32, $uq29[$uq23[$uq34]['id']]); $uq36 = implode(',', $uq35); $uq23[$uq34]['uri_attr'] = $uq36; $uq36 = $uq36.','; $uq36 = ltrim($uq36, ','); $uq23[$uq34]['uri_public'] = $uq36; $uq37 = $uq29[$uq23[$uq34]['id']]; $uq38 = array_intersect($uq32, $uq37); if(count($uq38) == '0'){ $uq9['list'][] = $uq23[$uq34]; } unset($uq28[$uq23[$uq34]['id']]); unset($uq29[$uq23[$uq34]['id']]); } } if($uq32){ foreach($uq32 as $uq12){ if($uq12){ $uq39 = ''; foreach($uq32 as $uq40){ if($uq40 != $uq12){ $uq39 .= $uq40.','; } } $uq39 = trim($uq39,','); $uq41[] = array( 'name'=>$uq30[$uq12][0]['name'], 'id'=>$uq12, 'url_id'=>$uq39 ); } } $uq9['ch'] = $uq41; } return $uq9; } } } } }