private function listInfo($pro_code, $city_code, $area_code, $public_type, $keyword, $sort, $page_id = 1) { //所有省份 $site = new \Site(); $provinces = $site->getProvince(); $provinces[0]['name'] = '不限'; foreach ($provinces as $key => $val) { $provinces[$key]['url'] = "/child-{$val['code']}-0-0-{$public_type}-{$sort}?key=" . urlencode($keyword); } //当前省份名称 if ($pro_code == 0) { $pro_name = '不限'; } else { $pro_name = $site->getProName($pro_code); $pro_name = empty($pro_name) ? '未知' : $pro_name; } //对应城市 $cities = $site->getCity($pro_code); $cities[0]['name'] = '不限'; foreach ($cities as $key => $val) { $cities[$key]['url'] = "/child-{$pro_code}-{$val['code']}-0-{$public_type}-{$sort}?key=" . urlencode($keyword); } //当前城市名称 if ($city_code == 0) { $city_name = '不限'; } else { $city_name = $site->getCityName($city_code); $city_name = empty($city_name) ? '未知' : $city_name; } //对应区县 $areas = $site->getArea($city_code); $areas[0]['name'] = '不限'; foreach ($areas as $key => $val) { $areas[$key]['url'] = "/child-{$pro_code}-{$city_code}-{$val['code']}-{$public_type}-{$sort}?key=" . urlencode($keyword); } //当前区县名称 if ($area_code == 0) { $area_name = '不限'; } else { $area_name = $site->getAreaName($area_code); $area_name = empty($area_name) ? '未知' : $area_name; } //性质 $public = \Setting::getPublic(); unset($public['-1']); array_unshift($public, '不限'); foreach ($public as $key => $val) { $public[$key] = ['name' => $val, 'url' => "/child-{$pro_code}-{$city_code}-{$area_code}-{$key}-{$sort}?key=" . urlencode($keyword)]; } //排序 $order = [1 => '热度', 2 => '好评']; foreach ($order as $key => $val) { $order[$key] = ['name' => $val, 'url' => "/child-{$pro_code}-{$city_code}-{$area_code}-{$public_type}-{$key}?key=" . urlencode($keyword)]; } //获取大学列表 $list = (new \School())->getChildList($pro_code, $city_code, $area_code, $public_type, $keyword, $sort, $page_id); $page_html = $this->pageHtml($list['page']); return ['list' => $list['list'], 'page' => $list['page'], 'page_html' => $page_html, 'provinces' => $provinces, 'pro_code' => $pro_code, 'pro_name' => $pro_name, 'cities' => $cities, 'city_code' => $city_code, 'city_name' => $city_name, 'areas' => $areas, 'area_code' => $area_code, 'area_name' => $area_name, 'public' => $public, 'public_type' => $public_type, 'keyword' => $keyword, 'order' => $order, 'sort' => $sort]; }
public function listAction() { if ($this->request->isAjax()) { $id = (int) (new \Validate())->getPost('id'); if ($id == 0) { $this->end(404); } $this->end((new \Train())->delTrain($id, $this->session->get('id'))); } //当前页码 $page_id = (int) $this->request->getQuery('page'); $page_id = $page_id < 1 ? 1 : $page_id; //省份code $pro_code = (int) $this->request->getQuery('pro_code'); //城市code $city_code = (int) $this->request->getQuery('city_code'); //区县code $area_code = (int) $this->request->getQuery('area_code'); //关键字 $keyword = preg_replace('/[^\\da-z\\x{4e00}-\\x{9fa5}]/iu', '', mb_substr($this->request->getQuery('keyword'), 0, 10, 'utf-8')); //关键字长度小于10,并且只能是字符数字中文 //每页显示条数 $limit = 20; //省市区县 $site = new \Site(); $provinces = $site->getProvince(); //省 $cities = $site->getCity($pro_code); //城市 $areas = $site->getArea($city_code); //区县 //查询数据 $train = new \Train(); //获取分类 $category = $train->getCategory(); $list = $train->getList($page_id, $limit, $pro_code, $city_code, $keyword); //数据 $page_html = $this->pageHtml($list['page']); //分页html //加载js $this->assets->addJs('backend/mt/train-list.js'); $this->view->setVars(['pro_code' => $pro_code, 'city_code' => $city_code, 'area_code' => $area_code, 'category' => $category, 'keyword' => $keyword, 'provinces' => $provinces, 'cities' => $cities, 'areas' => $areas, 'list' => $list['list'], 'page_html' => $page_html]); }
public function listAction() { if ($this->request->isAjax()) { $validate = new \Validate(); $id = (int) $validate->getPost('id'); if (!$id) { $this->end(404); } $this->end((new \College())->delCollege($id, $this->session->get('id'))); } //当前页码 $page_id = (int) $this->request->getQuery('page'); $page_id = $page_id < 1 ? 1 : $page_id; //省份code $pro_code = (int) $this->request->getQuery('pro_code'); //城市code $city_code = (int) $this->request->getQuery('city_code'); //性质 $col_type = (int) $this->request->getQuery('col_type'); //关键字 $keyword = preg_replace('/[^\\da-z\\x{4e00}-\\x{9fa5}]/iu', '', mb_substr($this->request->getQuery('keyword'), 0, 10, 'utf-8')); //关键字长度小于10,并且只能是字符数字中文 //每页显示条数 $limit = 20; //省市区县 $site = new \Site(); $provinces = $site->getProvince(); //省 $cities = $site->getCity($pro_code); //城市 //查询数据 $college = new \College(); $result = $college->getList($page_id, $limit, $pro_code, $city_code, $col_type, $keyword); //数据 $page_html = $this->pageHtml($result['page']); //分页html //加载js $this->assets->addJs('backend/mt-js/college-list.js'); $this->view->setVars(['pro_code' => $pro_code, 'city_code' => $city_code, 'col_type' => $col_type, 'keyword' => $keyword, 'provinces' => $provinces, 'cities' => $cities, 'list' => $result['list'], 'page_html' => $page_html]); }
/** * 小初高基本信息 */ public function basicAction($sch_id) { //判断是否是ajax if ($this->request->isAjax()) { $validate = new \Validate(); $data['sch_logo'] = $validate->getPost('sch_logo'); //学校logo $data['sch_thumb'] = $validate->getPost('sch_thumb'); //学校缩略图 $data['sch_name'] = $validate->getPost('sch_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}\\(\\)()]{2,30}$/iu')); //学校名称 $data['sch_build'] = $validate->getPost('sch_build', \Validate::regex('/^([a-z0-9\\x{4e00}-\\x{9fa5}\\(\\)\\-()]{2,30})?$/iu')); //学校创建时间 $data['sch_way'] = $validate->getPost('sch_way', \Validate::length(60, 0), ['slashes' => true]); //入学途径 $data['sch_department'] = $validate->getPost('sch_department', \Validate::length(60, 0), ['slashes' => true]); //隶属部门 $data['is_join'] = $validate->getPost('is_join', \Validate::scopeCall('Setting', 'getJoin')); //官方合作 $data['public_type'] = $validate->getPost('public_type', \Validate::scopeCall('Setting', 'getPublic')); //办学性质 $data['home_type'] = $validate->getPost('home_type', \Validate::scopeCall('Setting', 'getHome')); //住宿情况 $data['exam_type'] = $validate->getPost('exam_type', \Validate::scopeCall('Setting', 'getExam')); //入学考试 $data['stress_type'] = $validate->getPost('stress_type', \Validate::scopeCall('Setting', 'getSchStress')); //重点情况 $data['sch_type'] = $validate->getPost('sch_type', \Validate::scopeCall('Setting', 'getSchType')); //学校类型 $data['sch_tel'] = $validate->getPost('sch_tel', \Validate::length(60, 0), ['slashes' => true]); //联系电话 $data['pro_code'] = $validate->getPost('pro_code', \Validate::regex('/^[1-9]\\d{5}$/')); //学校所在省份编码 $data['city_code'] = $validate->getPost('city_code', \Validate::regex('/^[1-9]\\d{5}$/')); //学校所在城市编码 $data['area_code'] = $validate->getPost('area_code', \Validate::regex('/^[1-9]\\d{5}$/')); //学校所在区县编码 $data['sch_addr'] = $validate->getPost('sch_address', \Validate::length(60, 0), ['slashes' => true, 'html' => true]); //详细地址 $data['sch_summary'] = $validate->getPost('sch_summary', \Validate::length(100000, 0), ['slashes' => true]); //学校简介 $data['sch_key'] = $validate->getPost('sch_key', \Validate::regex('/^([a-z0-9\\x{4e00}-\\x{9fa5}]{1,20}([\\s,][a-z0-9\\x{4e00}-\\x{9fa5}]{1,10}){0,9})?$/iu')); //关键词 $data['sch_desc'] = $validate->getPost('sch_desc', \Validate::length(250, 0), ['slashes' => true, 'html' => true]); //描述 $data['sch_cost'] = $validate->getPost('sch_cost', \Validate::length(100000, 0), ['slashes' => true]); //收费情况 $data['sch_lesson'] = $validate->getPost('sch_lesson', \Validate::length(200, 0), ['slashes' => true]); //课程体系 $data['sch_fruit'] = $validate->getPost('sch_fruit', \Validate::length(100000, 0), ['slashes' => true]); //办学成果 $data['sch_power'] = $validate->getPost('sch_power', \Validate::length(100000, 0), ['slashes' => true]); //验证参数 if ($validate->getMessage()) { $this->end(400); } //生成学校logo,缩略图 $sch_logo = \Func::touchImg($data['sch_logo'], 'sch_logo'); $sch_thumb = \Func::touchImg($data['sch_thumb'], 'sch_thumb'); //将生成的图片地址存入img,用户失败时删除 $img = [UPLOAD_PATH . $sch_logo, UPLOAD_PATH . $sch_thumb]; //监测图片是否全部生成成功 if ($data['sch_logo'] && !$sch_logo || $data['sch_thumb'] && !$sch_thumb) { \FileUtil::getInstance()->unlink($img); $this->end(400); } $data['sch_logo'] = $sch_logo; $data['sch_thumb'] = $sch_thumb; $this->end((new \School())->updSchoolBasic($this->session->get('id'), $sch_id, $data)); } //学校id $sch_id = (int) $sch_id; //获取基本数据 $basic = (new \School())->getSchoolBasic($sch_id); //获取区域数据 $site = new \Site(); $provinces = $site->getProvince(); //省份 $cities = $site->getCity($basic['pro_code']); //城市 $areas = $site->getArea($basic['city_code']); //区 //加载js $this->assets->addJs('backend/js/editors/summernote/summernote.js'); $this->assets->addJs('backend/js/datetime/bootstrap-datepicker.js'); $this->assets->addJs('backend/mt-js/school-basic.js'); $this->view->setLayout('school'); $this->view->setVars(['sch_id' => $sch_id, 'basic' => $basic, 'provinces' => $provinces, 'cities' => $cities, 'areas' => $areas]); }
private function listInfo($pro_code, $city_code, $area_code, $public_type, $sch_type, $stress, $keyword, $sort, $page_id = 1) { //所有省份 $site = new \Site(); $provinces = $site->getProvince(); $provinces[0]['name'] = '不限'; foreach ($provinces as $key => $val) { $provinces[$key]['url'] = "/school-{$val['code']}-0-0-{$public_type}-{$sch_type}-{$stress}-{$sort}?key=" . urlencode($keyword); } //当前省份名称 if ($pro_code == 0) { $pro_name = '不限'; } else { $pro_name = $site->getProName($pro_code); $pro_name = empty($pro_name) ? '未知' : $pro_name; } //对应城市 $cities = $site->getCity($pro_code); $cities[0]['name'] = '不限'; foreach ($cities as $key => $val) { $cities[$key]['url'] = "/school-{$pro_code}-{$val['code']}-0-{$public_type}-{$sch_type}-{$stress}-{$sort}?key=" . urlencode($keyword); } //当前城市名称 if ($city_code == 0) { $city_name = '不限'; } else { $city_name = $site->getCityName($city_code); $city_name = empty($city_name) ? '未知' : $city_name; } //对应区县 $areas = $site->getArea($city_code); $areas[0]['name'] = '不限'; foreach ($areas as $key => $val) { $areas[$key]['url'] = "/school-{$pro_code}-{$city_code}-{$val['code']}-{$public_type}-{$sch_type}-{$stress}-{$sort}?key=" . urlencode($keyword); } //当前区县名称 if ($area_code == 0) { $area_name = '不限'; } else { $area_name = $site->getAreaName($area_code); $area_name = empty($area_name) ? '未知' : $area_name; } //性质 $public = \Setting::getPublic(); unset($public['-1']); array_unshift($public, '不限'); foreach ($public as $key => $val) { $public[$key] = ['name' => $val, 'url' => "/school-{$pro_code}-{$city_code}-{$area_code}-{$key}-{$sch_type}-{$stress}-{$sort}?key=" . urlencode($keyword)]; } //学校层次 $type = \Setting::getSchType(); unset($type[1]); foreach ($type as $key => $val) { $type[$key] = ['name' => $val, 'url' => "/school-{$pro_code}-{$city_code}-{$area_code}-{$public_type}-{$key}-{$stress}-{$sort}?key=" . urlencode($keyword)]; } //重点 $stress_type = \Setting::getSchStress(); unset($stress_type[-1]); array_unshift($stress_type, '不限'); foreach ($stress_type as $key => $val) { $stress_type[$key] = ['name' => $val, 'url' => "/school-{$pro_code}-{$city_code}-{$area_code}-{$public_type}-{$sch_type}-{$key}-{$sort}?key=" . urlencode($keyword)]; } //筛选关键字,最长80,并转义 $keyword = addslashes(mb_substr($keyword, 0, 80, 'utf-8')); //排序 $order = [1 => '热度', 2 => '升学率', 3 => '好评']; foreach ($order as $key => $val) { $order[$key] = ['name' => $val, 'url' => "/school-{$pro_code}-{$city_code}-{$area_code}-{$public_type}-{$sch_type}-{$stress}-{$key}?key=" . urlencode($keyword)]; } //获取大学列表 $list = (new \School())->getSchoolList($pro_code, $city_code, $area_code, $public_type, $sch_type, $stress, $keyword, $sort, $page_id); $page_html = $this->pageHtml($list['page']); return ['list' => $list['list'], 'page' => $list['page'], 'page_html' => $page_html, 'provinces' => $provinces, 'pro_code' => $pro_code, 'pro_name' => $pro_name, 'cities' => $cities, 'city_code' => $city_code, 'city_name' => $city_name, 'areas' => $areas, 'area_code' => $area_code, 'area_name' => $area_name, 'public' => $public, 'public_type' => $public_type, 'type' => $type, 'sch_type' => $sch_type, 'stress_type' => $stress_type, 'stress' => $stress, 'keyword' => $keyword, 'order' => $order, 'sort' => $sort]; }