/** * 获取国家的栏目列表. * * @access public * @return void */ public function getListByCountry() { $intParentId = I('post.pid', NULL); // 上级栏目 ID, 默认 NULL, 表示获取国家的全部栏目列表. if (NULL !== $intParentId && (int) $intParentId < 1) { $this->setAjaxData(Message::PARAM_ERROR, Message::get(Message::PARAM_ERROR))->myAjaxReturn(); } $arrLocateCountry = $this->getLocateCountry(); // 获取当前请求的定位国家. $countryId = (int) $arrLocateCountry['id']; // 国家 ID. unset($arrLocateCountry); $modelCtgClass = new CtgClassModel(); // 实例化 CtgClass 模型. if (NULL === $intParentId) { // 获取国家的全部栏目, 要格式化. $categoryList = $modelCtgClass->formatList($modelCtgClass->fetchListByCountry($countryId, $intParentId)); } else { // 获取子栏目时, 不用格式化. $categoryList = $modelCtgClass->fetchListByCountry($countryId, (int) $intParentId); } $this->setAjaxData(Message::SUCCESS, Message::get(Message::SUCCESS), $categoryList)->myAjaxReturn(); }