Example #1
0
 public static function GetPhoneRegions($country, $countryState = '', $type = self::PHONE_TYPE_FIXED)
 {
     $arResult = array();
     if (!in_array($type, array(self::PHONE_TYPE_FIXED, self::PHONE_TYPE_TOLLFREE, self::PHONE_TYPE_TOLLFREE804, self::PHONE_TYPE_MOBILE, self::PHONE_TYPE_MOSCOW495))) {
         return $arResult;
     }
     $viHttp = new CVoxImplantHttp();
     $result = $viHttp->GetPhoneNumberRegions($type, $country, $countryState);
     if ($result && !empty($result->result)) {
         if ($country == 'RU' && $type == self::PHONE_TYPE_FIXED) {
             $arResult[15] = array('REGION_ID' => 15, 'REGION_NAME' => GetMessage('VI_PHONE_CODE_RU_495') . ' (495)', 'REGION_CODE' => '495', 'PHONE_COUNT' => 20);
         }
         foreach ($result->result as $value) {
             $regionName = '';
             if ($country == 'RU' || $country == 'KZ') {
                 $regionName = GetMessage('VI_PHONE_CODE_' . $country . '_' . $value->phone_region_code);
                 if ($regionName != '') {
                     $regionName = $regionName . ' (' . $value->phone_region_code . ')';
                 }
             }
             if ($regionName == '') {
                 $regionName = $value->phone_region_name != $value->phone_region_code ? $value->phone_region_name . ' (' . $value->phone_region_code . ')' : $value->phone_region_name;
             }
             $arResult[$value->phone_region_id] = array('REGION_ID' => $value->phone_region_id, 'REGION_NAME' => $regionName, 'REGION_CODE' => $value->phone_region_code, 'PHONE_COUNT' => $value->phone_count);
         }
     }
     return $arResult;
 }