/** * 获取分类导航 * * @Author tianyunzi * @DateTime 2016-01-27T09:16:59+0800 * @return [type] [description] */ function getCateNav($cateid) { global $conn; $result = array("cate1" => array(), "cate2" => array(), "cate3" => array(), "cate4" => array(), "end" => 0); $cateInfo = getOldCate($cateid); if (empty($cateInfo)) { return array(); } $parentid = $cateInfo["root"]; $result["cate" . $cateInfo["level"]] = array($cateid, $cateInfo["cate"], $cateInfo["catezh"]); $result["end"] = $cateInfo["level"]; $level = $cateInfo["level"]; while (1) { if ($parentid <= 0) { break; } $parentInfo = getOldCate($parentid); if (empty($parentInfo)) { break; } $level--; if ($level <= 0) { break; } $result["cate" . $level] = array($parentid, $parentInfo["cate"], $parentInfo["catezh"]); if ($parentid == $parentInfo["root"]) { break; } $parentid = $parentInfo["root"]; } return $result; }
if ($old3) { $oldCateArr = getOldCate($old3); $cateNewCheck = getCateNew($oldCateArr["cate"]); if (empty($cateNewCheck)) { $insertArr = array("catename" => $oldCateArr["cate"], "catezh" => $oldCateArr["catezh"], "parentid" => $new2, "level" => 3, "is_leaf" => 0, "is_copyadd" => 1); $new3 = $conn->insert($insertArr, "forbuyscateinfo.fbcate_cateinfo"); } else { $new3 = $cateNewCheck["cateid"]; if ($cateNewCheck["parentid"] != $new2) { output("三级分类已经在新分类中存在,但是父分类不一致,停止复用,请联系研发!"); } } } //四级分类不存在,增加 if ($old4) { $oldCateArr = getOldCate($old4); $cateNewCheck = getCateNew($oldCateArr["cate"]); if (empty($cateNewCheck)) { $insertArr = array("catename" => $oldCateArr["cate"], "catezh" => $oldCateArr["catezh"], "parentid" => $new3, "level" => 4, "is_leaf" => 0, "is_copyadd" => 1); $new4 = $conn->insert($insertArr, "forbuyscateinfo.fbcate_cateinfo"); } else { $new4 = $cateNewCheck["cateid"]; if ($cateNewCheck["parentid"] != $new3) { output("四级分类已经在新分类中存在,但是父分类不一致,停止复用,请联系研发!"); } } } $newEnd = 0; if ($new4) { $newEnd = $new4; } elseif ($new3) {