private function init($request, $response) { $facultyId = Codec::getInstance()->decodeId($request->id); if ($facultyId <= 0) { exit; } $this->faculty = DAL::get()->find('faculty', $facultyId); if ($this->faculty->isNull()) { exit; } $this->facultyIdFrom = $this->faculty->id; $this->facultyIdTo = $facultyId + $this->faculty->mask; $province = $request->province; $this->province = empty($province) ? 'quanguo' : $province; $provList = area::provInfo(); $provinceList = array(); foreach($provList as $provkey => $value) { $provinceList[$provkey] = $value['Name']; } array_pop($provinceList); $provinceList = array_merge(array('quanguo'=>'х╚╧З'),$provinceList); $this->provinceList = $provinceList; $this->provinceName = $this->provinceList[$this->province]; $this->page = $request->getRequest('p', 1); $response->faculty = $this->faculty; $response->provinceName = $this->provinceName; $response->province = $this->province; $response->provinceList = $this->provinceList; }
private function initialize($request, $response) {/*{{{*/ $key = $this->key = $request->key; $firstFacultyName = urldecode($request->firstFacultyName); $secFacultyName = urldecode($request->secFacultyName); $this->nowPage = $request->getRequest('p', 1); $diseaseInfo = $this->diseaseInfo(); if (empty($key) || false == isset($diseaseInfo[$key])) { $this->_exit404(); } $orderby = $request->orderby; $this->orderby = empty($orderby)? self::ORDER_BY_DEFAULT :$orderby; $province = $request->province; $this->province = empty($province) ? 'quanguo' : $province; $provList = area::provInfo(); $provinceList = array(); foreach($provList as $provkey => $value) { $provinceList[$provkey] = $value['Name']; } array_pop($provinceList); $provinceList = array_merge(array('quanguo'=>'È«¹ú'),$provinceList); $this->provinceList = $provinceList; $this->provinceName = $this->provinceList[$this->province]; $this->disease = DiseaseClient::getInstance()->getByDiseaseKey($key); if($this->disease == null || $this->disease->isNull()){ $this->_exit404(); } $fir2SecFacultyArr = BaiduAppData::getParent2ChildFacultyArr(); $faculty2DiseaseArr = BaiduAppData::getFaculty2DiseaseArr(); if(empty($firstFacultyId) || empty($secFacultyId)) { foreach($faculty2DiseaseArr as $secId => $secArr) { if(in_array($this->disease->name, $secArr['diseases'])) { $secFacultyId = $secId; } } foreach($fir2SecFacultyArr as $firId => $firArr) { if(array_key_exists($secFacultyId, $firArr['children'])) { $firstFacultyId = $firId; } } } if(empty($firstFacultyId) || empty($secFacultyId)) { $firIdAndSecId = $this->getFirIdAndSecIdByDisease($diseaseId); $firstFacultyId = $firIdAndSecId['firstFacultyId']; $secFacultyId = $firIdAndSecId['secFacultyId']; } $response->key = $this->key; $response->firstFacultyId4Encoded =Codec::getInstance()->encodeId($firstFacultyId); $response->secFacultyId4Encoded = Codec::getInstance()->encodeId($secFacultyId); $response->province = $this->province; $response->provinceList = $this->provinceList; $response->disease = $this->disease; $response->orderby = $this->orderby; $response->nowPage = $this->nowPage; }/*}}}*/