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

defined('IN_UQ') or exit('Access Denied'); class category_mod extends module { function __construct() { parent::__construct(); } function get_child_cid($uq0) { $uq1 = $this->get_child_in($uq0); if($uq1){ return $uq1; }else{ return false; } } private function get_child_in($uq0) { static $uq2 = array(); $uq3 = $this->db->get_all("select cid,pcid,status from ".table('category')." where pcid in(".$uq0.") and status = 1"); if($uq3){ foreach($uq3 as $uq4=>$uq5){ $uq6[] = $uq5['cid']; $uq2[] = $uq5['cid']; } $uq7 = implode(',', $uq6); $this->get_child_in($uq7); } return $uq2; } function child_cid($uq8) { $uq0 = $uq8['cid']??''; if(!empty($uq0)){ $uq9 = $this->db->get_all("select cid,pcid,name,status from ".table('category')." where status = 1"); if($uq9){ foreach($uq9 as $uq4=>$uq5){ $uq10[$uq5['pcid']][$uq5['cid']] = ''; } $uq11 = recursion($uq0, $uq10); return $uq11; }else{ return false; } }else{ return false; } } public function get_parents_cid($uq8) { $uq0 = $uq8['cid']??false; if($uq0){ $uq1 = $this->get_parents_in($uq0); if($uq1){ foreach($uq1 as $uq4=>$uq5){ $uq12[] = $uq5['cid']; } sort($uq12); return $uq12; }else{ return false; } }else{ return false; } } public function get_parents_name($uq8) { $uq0 = $uq8['cid']??false; if($uq0){ $uq1 = $this->get_parents_in($uq0); if($uq1){ foreach($uq1 as $uq4=>$uq5){ $uq12[$uq5['cid']] = $uq5['name']; } ksort($uq12); return $uq12; } }else{ return false; } } private function get_parents_in($uq0, &$uq13 = array()) { $uq3 = $this->db->get_one("select cid,pcid,name from ".table('category')." where cid = ".$uq0." limit 1"); if($uq3['cid']){ $uq13[] = $uq3; $uq13 = $this->get_parents_in($uq3['pcid'], $uq13); } return $uq13; } function get_parents_list($uq14) { $uq15 = $this->db->get_all("select cid,pcid,name from ".table('category')." where pcid = 0 and status = 1"); if($uq15){ $uq16['cid'] = $uq14[0]; $uq16['list']= $uq15; $uq17[] = $uq16; if(empty($uq14)){ return $uq17; }else{ $uq18 = $uq14[count($uq14)-1]; foreach($uq14 as $uq4=>$uq5){ if($uq5 != $uq18){ $uq15 = $this->db->get_all("select cid,pcid,name from ".table('category')." where pcid = ".$uq5." and status = 1"); if($uq15){ $uq11['cid'] = $uq14[$uq4+1]; $uq11['list'] = $uq15; $uq17[] = $uq11; } } } return $uq17; } }else{ return false; } } function get_one($uq8) { $uq0 = $uq8['cid']??false; $uq19 = $this->db->get_one("select * from ".table("category")." where cid = ".$uq0); return $uq19; } function get_list($uq8) { $uq0 = $uq8['cid']??false; $uq20 = $this->db->get_all("select * from ".table("category")." where pcid = ".$uq0); return $uq20; } public function get_one_list($uq8) { $uq0 = $uq8['cid']??false; if($uq0){ return $this->db->get_all("select * from ".table("category")." where pcid = ".$uq0); }else{ return false; } } public function get_all() { $uq21 = cache::get("config/category_index"); if(empty($uq21)){ $uq22 = $this->db->get_all("select cid,pcid,name,sname,images,px_recommend,px_asc,status from ".table('category')." where status = 1 order by px_asc asc"); if($uq22){ foreach($uq22 as $uq4=>$uq5){ if($uq5['pcid'] == '0'){ foreach($uq22 as $uq23=>$uq24){ if($uq24['pcid'] == $uq5['cid']){ foreach($uq22 as $uq25=>$uq26){ if($uq26['pcid'] == $uq24['cid']){ $uq24['pparent'][] = $uq26; if($uq26['px_recommend'] == '1'){ $uq27[] = $uq26; } } } $uq5['parent'][] = $uq24; } $uq5['px_recommend'] = $uq27; } $uq21[] = $uq5; unset($uq27); } } cache::add("config/category_index", $uq21); } } return $uq21; } } 