<?php function prepare_region_dataset($dbconn) { $region_level_names=array( 1=>'zc_prefecture', 2=>'zc_city', 3=>'zc_district' ); $region[1]=TGET('zc_prefecture'); $region[2]=TGET('zc_city'); $region[3]=TGET('zc_district'); $countrycode=get_user_countrycode(); foreach ($region as $r) { if (substr($r,0,2)=='#*') { $region=array(); $regionset=array(); parse_str(substr($r,2),$regionset); foreach ($regionset as $rn=>$rv) { $rn=0+substr($rn,-1,1); $region[$rn]=$rv; } } } $dataset=array(); $region_tobedefined_default=false; $region_tobedefined_no=1; if ($region[1]) { $region_tobedefined_no=2; if ($region[2]) $region_tobedefined_no=3; } $dataset['zc_level_tobedefined_name']=$region_level_names[$region_tobedefined_no]; $region_tobedefined_default=$region[$region_tobedefined_no]; $dataset['ZC_LEVEL_TOBEDEFINED']=db_load_zipcode_region( $dbconn, $countrycode, $region[1], $region[2], $region[3], $dataset['zc_level_tobedefined_name'], compere_id_requested() ); $dataset['ZC_LEVEL_DEFINED']=array(); if ($region[1]) array_push($dataset['ZC_LEVEL_DEFINED'],array('text'=>$region[1],'name'=>$region_level_names[1])); if ($region[2]) array_push($dataset['ZC_LEVEL_DEFINED'],array('text'=>$region[2],'name'=>$region_level_names[2])); foreach ($dataset['ZC_LEVEL_TOBEDEFINED'] as &$row) $row['text']=$row[$dataset['zc_level_tobedefined_name']]; unset($row); array_assoc_set_if( $dataset['ZC_LEVEL_TOBEDEFINED'], $dataset['zc_level_tobedefined_name'], $region_tobedefined_default, 'SELECTED', array(0)); $dataset['ZC_LEVEL_SOMESPECIFIED']=$region[1]?array(0):array(); $dataset['ZC_LEVEL_UNSPECIFIED']=$region[1]?array():array(0); $_GET["zc_prefecture"]=$region[1]; $_GET["zc_city"]=$region[2]; $_GET["zc_district"]=$region[3]; return $dataset; } ?>