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.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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