PHP Class Horde_Nls, horde

This includes common methods for handling language data, timezones, and hostname->country lookups.
Author: Jon Parise ([email protected])
Author: Chuck Hagenbuch ([email protected])
Author: Jan Schneider ([email protected])
Author: Michael Slusarz ([email protected])
Show file Open project: horde/horde Class Usage Examples

Public Properties

Property Type Description
$dnsResolver Net_DNS2_Resolver DNS resolver.

Protected Properties

Property Type Description
$_cache array Cached values.

Public Methods

Method Description
checkCharset ( string $charset ) : boolean Check to see if character set is valid for htmlspecialchars() calls.
getCountryByHost ( string $host, string $datafile = null ) : mixed Get country information from a hostname or IP address.
getCountryISO ( string $code = null ) : mixed Returns either a specific or all ISO-3166 country names.
getLangInfo ( const $item ) : array Get the language info returned by nl_langinfo(), but cache it, to avoid repeated calls.
getLanguageISO ( string $code = null ) : mixed Returns either a specific or all ISO-639 language names.
getLocaleInfo ( ) : array Get the locale info returned by localeconv(), but cache it, to avoid repeated calls.
getTimezones ( ) : array Returns a list of available timezones.
getTimezonesWithAbbreviations ( ) : array Returns a list of available timezones, including timezone abbreviations.
tldLookup ( string $code ) : mixed Do a top level domain (TLD) lookup.

Method Details

checkCharset() public static method

Check to see if character set is valid for htmlspecialchars() calls.
public static checkCharset ( string $charset ) : boolean
$charset string The character set to check.
return boolean Is charset valid for the current system?

getCountryByHost() public static method

Get country information from a hostname or IP address.
public static getCountryByHost ( string $host, string $datafile = null ) : mixed
$host string The hostname or IP address.
$datafile string The datafile for the GeoIP lookup. If not set, will skip this lookup.
return mixed On success, return an array with the following entries: 'code' => Country Code 'name' => Country Name On failure, return false.

getCountryISO() public static method

Returns either a specific or all ISO-3166 country names.
public static getCountryISO ( string $code = null ) : mixed
$code string The ISO 3166 country code.
return mixed If a country code has been requested will return the corresponding country name. If empty will return an array of all the country codes and their names.

getLangInfo() public static method

Get the language info returned by nl_langinfo(), but cache it, to avoid repeated calls.
public static getLangInfo ( const $item ) : array
$item const The langinfo item to return.
return array The results of nl_langinfo().

getLanguageISO() public static method

Returns either a specific or all ISO-639 language names.
public static getLanguageISO ( string $code = null ) : mixed
$code string The ISO 639 language code.
return mixed If a language code has been requested will return the corresponding language name. If empty will return an array of all the language codes (keys) and their names (values).

getLocaleInfo() public static method

Get the locale info returned by localeconv(), but cache it, to avoid repeated calls.
public static getLocaleInfo ( ) : array
return array The results of localeconv().

getTimezones() public static method

Returns a list of available timezones.
public static getTimezones ( ) : array
return array List of timezones.

getTimezonesWithAbbreviations() public static method

Contrary to getTimezones() the timezone IDs are values and the timezone labels are the keys, to allow multiple labels for the same timezone.
Since: 2.2.0
public static getTimezonesWithAbbreviations ( ) : array
return array List of timezones.

tldLookup() public static method

Do a top level domain (TLD) lookup.
public static tldLookup ( string $code ) : mixed
$code string A 2-letter country code.
return mixed The localized country name, or null if not found.

Property Details

$_cache protected static property

Cached values.
protected static array $_cache
return array

$dnsResolver public static property

DNS resolver.
public static Net_DNS2_Resolver $dnsResolver
return Net_DNS2_Resolver