/** * 获取分类导航 * * @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()); $cateInfo = getNewCate($cateid); if (empty($cateInfo)) { return array(); } $parentid = $cateInfo["parentid"]; $result["cate" . $cateInfo["level"]] = array("cateid" => $cateid, "catename" => $cateInfo["catename"], "catezh" => $cateInfo["catezh"]); while (1) { if ($parentid <= 0) { break; } $parentInfo = getNewCate($parentid); if (empty($parentInfo)) { break; } $result["cate" . $parentInfo["level"]] = array("cateid" => $parentid, "catename" => $parentInfo["catename"], "catezh" => $parentInfo["catezh"]); $parentid = $parentInfo["parentid"]; } return $result; }
$new3 = isset($_POST["level_three_id"]) ? intval($_POST["level_three_id"]) : 0; $new4 = isset($_POST["level_four_id"]) ? intval($_POST["level_four_id"]) : 0; if (empty($new1) || empty($new2)) { exit("对应到的新分类至少需要到达二级分类"); } $newEnd = 0; if ($new4) { $newEnd = $new4; } elseif ($new3) { $newEnd = $new3; } elseif ($new2) { $newEnd = $new2; } $conn = new Table("local189"); /* 检测下对应到的分类是否是末级分类 */ $newcateEnd = getNewCate($newEnd); if ($newcateEnd["is_leaf"] != 1) { exit("不允许对应非叶子分类"); } $old1 = isset($_POST["old1"]) ? intval($_POST["old1"]) : 0; $old2 = isset($_POST["old2"]) ? intval($_POST["old2"]) : 0; $old3 = isset($_POST["old3"]) ? intval($_POST["old3"]) : 0; $old4 = isset($_POST["old4"]) ? intval($_POST["old4"]) : 0; if (empty($old1) || empty($old2)) { exit("被对应的分类数据不准备,请检查"); } $oldEnd = 0; if ($old4) { $oldEnd = $old4; } elseif ($old3) { $oldEnd = $old3;