forked from bopoda/fl-ru-damp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcountrys.server.php
73 lines (60 loc) · 2.21 KB
/
countrys.server.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?
$rpath = "../";
require_once($_SERVER['DOCUMENT_ROOT'] . "/xajax/countrys.common.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/city.php");
/**
* Âîçâðàùàåò select ñî ñïèñêîì ãîðîäîâ óêàçàííîé ñòðàíû â áëîê ñ id="frm_city"
*
* @param int $country_id ID ñòðàíû
* @param array $attr îïöèîíàëüíî. àòðèáóòû select íàïðèìåð: array('name'=>'pf_city', 'class'=>'flt-p-sel',...);
* @return unknown
*/
function GetCitysByCid( $country_id, $attr = array() ){
$objResponse = new xajaxResponse();
if ( !$attr ) {
$attr = array( 'name'=>'pf_city', 'class'=>'b-select__select' );
}
$sAttr = '';
foreach ( $attr as $key => $val ) {
$sAttr .= ' ' . $key . '="' . $val . '"';
}
if ($country_id){
$cities = city::GetCities($country_id);
}
$out_text = "<select $sAttr><option value=\"0\">Âñå ãîðîäà</option>";
if($cities) foreach ($cities as $cityid => $city)
$out_text .= "<option value=".$cityid.">".$city."</option>";
$out_text .= "</select>";
$objResponse->assign("frm_city","innerHTML",$out_text);
$objResponse->script("$('pf_country').erase('disabled')");
return $objResponse;
}
/**
* Âîçâðàùàåò select ñî ñïèñêîì ãîðîäîâ óêàçàííîé ñòðàíû â äëÿ ôèëüòðà ðåãèîíîâ â êàòàëîãå ôðèëàíñåðîâ
*
* @param int $country íàçâàíèå ñòðàíû òðàíñëèò
* @param array $attr îïöèîíàëüíî. àòðèáóòû select íàïðèìåð: array('name'=>'pf_city', 'class'=>'flt-p-sel',...);
* @return unknown
*/
function RFGetCitysByCid( $country, $attr = array() ){
$objResponse = new xajaxResponse();
if ( !$attr ) {
$attr = array( 'name'=>'pf_city', 'class'=>'b-select__select' );
}
$sAttr = '';
foreach ( $attr as $key => $val ) {
$sAttr .= ' ' . $key . '="' . $val . '"';
}
if ($country){
$cities = city::GetCities(country::getCountryIDByTranslit($country));
}
$objResponse->script('$("b-select__city").set("html","");');
$objResponse->script('new Element("option", { value: "0", text: "Âñå ãîðîäà" }).inject($("b-select__city"));');
$js = '';
if($cities) foreach ($cities as $cityid => $city)
$js .= 'new Element("option", { value: "'.translit(strtolower($city)).'", text: "'.$city.'" }).inject($("b-select__city"));'."\n";
if($js) $objResponse->script($js);
return $objResponse;
}
$xajax->processRequest();
?>