PHP 클래스 Piwik\Plugins\UserCountry\LocationProvider

LocationProviders attempt to determine a visitor's location using visit information. All LocationProviders require a visitor's IP address, some require more, such as the browser language.
파일 보기 프로젝트 열기: piwik/piwik 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$providers array An array of all provider instances. Access it through static methods.

공개 메소드들

메소드 설명
completeLocationResult ( array &$location ) Tries to fill in any missing information in a location result.
getAllProviderInfo ( string $newline = " ", boolean $includeExtra = false ) : array Returns an array mapping provider IDs w/ information about the provider, for each location provider.
getAllProviders ( ) : LocationProvider[] Returns every available provider instance.
getAvailableProviders ( ) : array Returns all provider instances that are 'available'. An 'available' provider is one that is available for use. They may not necessarily be working.
getCurrentProvider ( ) : LocationProvider | null Returns the provider instance of the current location provider.
getCurrentProviderId ( ) : string Returns the ID of the currently used location provider.
getId ( )
getLocation ( array $info ) : array | false Returns location information based on visitor information.
getProviderById ( string $providerId ) : LocationProvider | null Returns a provider instance by ID or false if the ID is invalid or unavailable.
getSupportedLocationInfo ( ) : array Returns an array mapping location result keys w/ bool values indicating whether that information is supported by this provider. If it is not supported, that means this provider either cannot get this information, or is not configured to get it.
isAvailable ( ) : boolean Returns true if this provider is available for use, false if otherwise.
isWorking ( ) : boolean Returns true if this provider is working, false if otherwise.
prettyFormatLocation ( array | false $locationInfo, string $newline = " ", boolean $includeExtra = false ) : string Returns a prettified location result.
setCurrentProvider ( string $providerId ) : LocationProvider Sets the provider to use when tracking.

보호된 메소드들

메소드 설명
getIpFromInfo ( array $info ) : string | null Returns an IP address from an array that was passed into getLocation. This will return an IPv4 address or IPv6 address.
getLocationProviders ( Plugin $plugin ) : LocationProvider[] Get all lo that are defined by the given plugin.

메소드 상세

completeLocationResult() 공개 메소드

This method will try to set the continent code, continent name and country code using other information. Note: This function must always be called by location providers in getLocation.
public completeLocationResult ( array &$location )
$location array The location information to modify.

getAllProviderInfo() 공개 정적인 메소드

The following information is provided for each provider: 'id' - The provider's unique string ID. 'title' - The provider's title. 'description' - A description of how the location provider works. 'status' - Either self::NOT_INSTALLED, self::INSTALLED or self::BROKEN. 'statusMessage' - If the status is self::BROKEN, then the message describes why. 'location' - A pretty formatted location of the current IP address (IP::getIpFromHeader()). An example result: array( 'geoip_php' => array('id' => 'geoip_php', 'title' => '...', 'desc' => '...', 'status' => GeoIp::BROKEN, 'statusMessage' => '...', 'location' => '...') 'geoip_serverbased' => array(...) )
public static getAllProviderInfo ( string $newline = " ", boolean $includeExtra = false ) : array
$newline string What to separate lines with in the pretty locations.
$includeExtra boolean Whether to include ISP/Org info in formatted location.
리턴 array

getAllProviders() 공개 정적인 메소드

Returns every available provider instance.
public static getAllProviders ( ) : LocationProvider[]
리턴 LocationProvider[]

getAvailableProviders() 공개 정적인 메소드

Returns all provider instances that are 'available'. An 'available' provider is one that is available for use. They may not necessarily be working.
public static getAvailableProviders ( ) : array
리턴 array

getCurrentProvider() 공개 정적인 메소드

This function should not be called by the Tracker.
public static getCurrentProvider ( ) : LocationProvider | null
리턴 LocationProvider | null

getCurrentProviderId() 공개 정적인 메소드

The used provider is stored in the 'usercountry.location_provider' option. This function should not be called by the Tracker.
public static getCurrentProviderId ( ) : string
리턴 string

getId() 공개 메소드

public getId ( )

getIpFromInfo() 보호된 메소드

Returns an IP address from an array that was passed into getLocation. This will return an IPv4 address or IPv6 address.
protected getIpFromInfo ( array $info ) : string | null
$info array Must have 'ip' key.
리턴 string | null

getLocation() 추상적인 공개 메소드

The result of this function will be an array. The array can store some or all of the following information: - Continent Code: The code of the visitor's continent. (array key is self::CONTINENT_CODE_KEY) - Continent Name: The name of the visitor's continent. (array key is self::CONTINENT_NAME_KEY) - Country Code: The code of the visitor's country. (array key is self::COUNTRY_CODE_KEY) - Country Name: The name of the visitor's country. (array key is self::COUNTRY_NAME_KEY) - Region Code: The code of the visitor's region. (array key is self::REGION_CODE_KEY) - Region Name: The name of the visitor's region. (array key is self::REGION_NAME_KEY) - City Name: The name of the visitor's city. (array key is self::CITY_NAME_KEY) - Area Code: The visitor's area code. (array key is self::AREA_CODE_KEY) - Latitude: The visitor's latitude. (array key is self::LATITUDE_KEY) - Longitude: The visitor's longitude. (array key is self::LONGITUDE_KEY) - Postal Code: The visitor's postal code. (array key is self::POSTAL_CODE_KEY) - ISP: The visitor's ISP. (array key is self::ISP_KEY) - Org: The company/organization of the visitor's IP. (array key is self::ORG_KEY) All LocationProviders will attempt to return the country of the visitor.
abstract public getLocation ( array $info ) : array | false
$info array What this must contain depends on the specific provider implementation. All providers require an 'ip' key mapped to the visitor's IP address.
리턴 array | false

getLocationProviders() 보호된 정적인 메소드

Get all lo that are defined by the given plugin.
protected static getLocationProviders ( Plugin $plugin ) : LocationProvider[]
$plugin Piwik\Plugin
리턴 LocationProvider[]

getProviderById() 공개 정적인 메소드

Returns a provider instance by ID or false if the ID is invalid or unavailable.
public static getProviderById ( string $providerId ) : LocationProvider | null
$providerId string
리턴 LocationProvider | null

getSupportedLocationInfo() 추상적인 공개 메소드

Returns an array mapping location result keys w/ bool values indicating whether that information is supported by this provider. If it is not supported, that means this provider either cannot get this information, or is not configured to get it.
abstract public getSupportedLocationInfo ( ) : array
리턴 array eg. array(self::CONTINENT_CODE_KEY => true, self::CONTINENT_NAME_KEY => true, self::ORG_KEY => false) The result is not guaranteed to have keys for every type of location info.

isAvailable() 추상적인 공개 메소드

Returns true if this provider is available for use, false if otherwise.
abstract public isAvailable ( ) : boolean
리턴 boolean

isWorking() 추상적인 공개 메소드

Returns true if this provider is working, false if otherwise.
abstract public isWorking ( ) : boolean
리턴 boolean

prettyFormatLocation() 공개 정적인 메소드

Returns a prettified location result.
public static prettyFormatLocation ( array | false $locationInfo, string $newline = " ", boolean $includeExtra = false ) : string
$locationInfo array | false
$newline string The line separator (ie, \n or
).
$includeExtra boolean Whether to include ISP/Organization info.
리턴 string

setCurrentProvider() 공개 정적인 메소드

Sets the provider to use when tracking.
public static setCurrentProvider ( string $providerId ) : LocationProvider
$providerId string The ID of the provider to use.
리턴 LocationProvider The new current provider.

프로퍼티 상세

$providers 공개적으로 정적으로 프로퍼티

An array of all provider instances. Access it through static methods.
public static array $providers
리턴 array