PHP Класс Piwik\Site

**Data Cache** Site data can be cached in order to avoid performing too many queries. If a method needs many site entities, it is more efficient to query all of what you need beforehand via the **SitesManager** API, then cache it using {@link setSites()} or {@link setSitesFromArray()}. Subsequent calls to new Site($id) will use the data in the cache instead of querying the database. ### Examples **Basic usage** $site = new Site($idSite); $name = $site->getName(); **Without allocation** $name = Site::getNameFor($idSite);
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$id integer | null
$infoSites array

Открытые методы

Метод Описание
__construct ( integer $idsite ) Constructor.
__toString ( ) : string Returns a string representation of the site this instance references.
clearCache ( ) Clears the site data cache.
clearCacheForSite ( $idSite ) Clears the site data cache.
getCreationDate ( ) : Date Returns the creation date of the site.
getCreationDateFor ( integer $idsite ) : string Returns the creation date of the site with the specified ID.
getCurrency ( ) : string Returns the currency of the site.
getCurrencyFor ( integer $idsite ) : string Returns the currency of the site with the specified ID.
getCurrencyList ( ) : array Returns the list of all known currency symbols.
getCurrencySymbolFor ( integer $idsite ) : string Returns the currency of the site with the specified ID.
getExcludedIps ( ) : string Returns the excluded ips of the site.
getExcludedIpsFor ( integer $idsite ) : string Returns the excluded IP addresses of the site with the specified ID.
getExcludedQueryParameters ( ) : string Returns the excluded query parameters of the site.
getExcludedQueryParametersFor ( integer $idsite ) : string Returns the excluded query parameters for the site with the specified ID.
getGroupFor ( integer $idsite ) : string Returns the group of the site with the specified ID.
getId ( ) : integer Returns the id of the site.
getIdSitesFromIdSitesString ( string | array $ids, boolean | string $_restrictSitesToLogin = false ) : array Checks the given string for valid site IDs and returns them as an array.
getMainUrl ( ) : string Returns the main url of the site.
getMainUrlFor ( integer $idsite ) : string Returns the url for the site with the specified ID.
getMinMaxDateAcrossWebsites ( array $siteIds ) : Date[] The Multisites reports displays the first calendar date as the earliest day available for all websites.
getName ( ) : string Returns the name of the site.
getNameFor ( integer $idsite ) : string Returns the name of the site with the specified ID.
getSearchCategoryParameters ( ) : string Returns the site search category query parameters for the site.
getSearchKeywordParameters ( ) : string Returns the site search keyword query parameters for the site.
getSite ( $idsite )
getSites ( ) Returns all websites pre-cached
getTimezone ( ) : string Returns the timezone of the size.
getTimezoneFor ( integer $idsite ) : string Returns the timezone of the site with the specified ID.
getType ( ) : string Returns the website type (by default "website", which means it is a single website).
getTypeFor ( $idsite ) : string Returns the type of the site with the specified ID.
isEcommerceEnabled ( ) : boolean Returns whether ecommerce is enabled for the site.
isEcommerceEnabledFor ( integer $idsite ) : string Returns whether the site with the specified ID is ecommerce enabled or not.
isSiteSearchEnabled ( ) : boolean Returns whether Site Search Tracking is enabled for the site.
isSiteSearchEnabledFor ( integer $idsite ) : string Returns whether the site with the specified ID is Site Search enabled.
setSiteFromArray ( $idSite, $infoSite ) Sets a site information in memory (statically cached).
setSites ( array $sites ) Sets the cached site data with an array that associates site IDs with individual site data.
setSitesFromArray ( array $sites ) Sets the cached Site data with a non-associated array of site data.

Защищенные методы

Метод Описание
get ( string $name ) : mixed Returns a site property by name.
getFor ( integer $idsite, string $field ) : string Utility function. Returns the value of the specified field for the site with the specified ID.

Приватные методы

Метод Описание
triggerSetSitesEvent ( &$sites )

Описание методов

__construct() публичный Метод

Constructor.
public __construct ( integer $idsite )
$idsite integer The ID of the site we want data for.

__toString() публичный Метод

Useful for debugging.
public __toString ( ) : string
Результат string

clearCache() публичный статический Метод

See also {@link setSites()} and {@link setSitesFromArray()}.
public static clearCache ( )

clearCacheForSite() публичный статический Метод

See also {@link setSites()} and {@link setSitesFromArray()}.
public static clearCacheForSite ( $idSite )

get() защищенный Метод

Returns a site property by name.
protected get ( string $name ) : mixed
$name string Name of the property to return (eg, `'main_url'` or `'name'`).
Результат mixed

getCreationDate() публичный Метод

Returns the creation date of the site.
public getCreationDate ( ) : Date
Результат Date

getCreationDateFor() публичный статический Метод

Returns the creation date of the site with the specified ID.
public static getCreationDateFor ( integer $idsite ) : string
$idsite integer The site ID.
Результат string

getCurrency() публичный Метод

Returns the currency of the site.
public getCurrency ( ) : string
Результат string

getCurrencyFor() публичный статический Метод

Returns the currency of the site with the specified ID.
public static getCurrencyFor ( integer $idsite ) : string
$idsite integer The site ID.
Результат string

getCurrencyList() публичный статический Метод

Returns the list of all known currency symbols.
См. также: Piwik\Intl\Data\Provider\CurrencyDataProvider::getCurrencyList()
Устаревший: Use Piwik\Intl\Data\Provider\CurrencyDataProvider instead.
public static getCurrencyList ( ) : array
Результат array An array mapping currency codes to their respective currency symbols and a description, eg, `array('USD' => array('$', 'US dollar'))`.

getCurrencySymbolFor() публичный статический Метод

Returns the currency of the site with the specified ID.
public static getCurrencySymbolFor ( integer $idsite ) : string
$idsite integer The site ID.
Результат string

getExcludedIps() публичный Метод

Returns the excluded ips of the site.
public getExcludedIps ( ) : string
Результат string

getExcludedIpsFor() публичный статический Метод

Returns the excluded IP addresses of the site with the specified ID.
public static getExcludedIpsFor ( integer $idsite ) : string
$idsite integer The site ID.
Результат string

getExcludedQueryParameters() публичный Метод

Returns the excluded query parameters of the site.
public getExcludedQueryParameters ( ) : string
Результат string

getExcludedQueryParametersFor() публичный статический Метод

Returns the excluded query parameters for the site with the specified ID.
public static getExcludedQueryParametersFor ( integer $idsite ) : string
$idsite integer The site ID.
Результат string

getFor() защищенный статический Метод

Utility function. Returns the value of the specified field for the site with the specified ID.
protected static getFor ( integer $idsite, string $field ) : string
$idsite integer The ID of the site whose data is being accessed.
$field string The name of the field to get.
Результат string

getGroupFor() публичный статический Метод

Returns the group of the site with the specified ID.
public static getGroupFor ( integer $idsite ) : string
$idsite integer The site ID.
Результат string

getId() публичный Метод

Returns the id of the site.
public getId ( ) : integer
Результат integer

getIdSitesFromIdSitesString() публичный статический Метод

Checks the given string for valid site IDs and returns them as an array.
public static getIdSitesFromIdSitesString ( string | array $ids, boolean | string $_restrictSitesToLogin = false ) : array
$ids string | array Comma separated idSite list, eg, `'1,2,3,4'` or an array of IDs, eg, `array(1, 2, 3, 4)`.
$_restrictSitesToLogin boolean | string Implementation detail. Used only when running as a scheduled task.
Результат array An array of valid, unique integers.

getMainUrl() публичный Метод

Returns the main url of the site.
public getMainUrl ( ) : string
Результат string

getMainUrlFor() публичный статический Метод

Returns the url for the site with the specified ID.
public static getMainUrlFor ( integer $idsite ) : string
$idsite integer The site ID.
Результат string

getMinMaxDateAcrossWebsites() публичный статический Метод

Also, today is the later "today" available across all timezones.
public static getMinMaxDateAcrossWebsites ( array $siteIds ) : Date[]
$siteIds array Array of IDs for each site being displayed.
Результат Date[] of two Date instances. First is the min-date & the second is the max date.

getName() публичный Метод

Returns the name of the site.
public getName ( ) : string
Результат string

getNameFor() публичный статический Метод

Returns the name of the site with the specified ID.
public static getNameFor ( integer $idsite ) : string
$idsite integer The site ID.
Результат string

getSearchCategoryParameters() публичный Метод

Returns the site search category query parameters for the site.
public getSearchCategoryParameters ( ) : string
Результат string

getSearchKeywordParameters() публичный Метод

Returns the site search keyword query parameters for the site.
public getSearchKeywordParameters ( ) : string
Результат string

getSite() публичный статический Метод

public static getSite ( $idsite )

getSites() публичный статический Метод

Returns all websites pre-cached
public static getSites ( )

getTimezone() публичный Метод

Returns the timezone of the size.
public getTimezone ( ) : string
Результат string

getTimezoneFor() публичный статический Метод

Returns the timezone of the site with the specified ID.
public static getTimezoneFor ( integer $idsite ) : string
$idsite integer The site ID.
Результат string

getType() публичный Метод

Returns the website type (by default "website", which means it is a single website).
public getType ( ) : string
Результат string

getTypeFor() публичный статический Метод

Returns the type of the site with the specified ID.
public static getTypeFor ( $idsite ) : string
$idsite
Результат string

isEcommerceEnabled() публичный Метод

Returns whether ecommerce is enabled for the site.
public isEcommerceEnabled ( ) : boolean
Результат boolean

isEcommerceEnabledFor() публичный статический Метод

Returns whether the site with the specified ID is ecommerce enabled or not.
public static isEcommerceEnabledFor ( integer $idsite ) : string
$idsite integer The site ID.
Результат string

isSiteSearchEnabled() публичный Метод

Returns whether Site Search Tracking is enabled for the site.
public isSiteSearchEnabled ( ) : boolean
Результат boolean

isSiteSearchEnabledFor() публичный статический Метод

Returns whether the site with the specified ID is Site Search enabled.
public static isSiteSearchEnabledFor ( integer $idsite ) : string
$idsite integer The site ID.
Результат string

setSiteFromArray() публичный статический Метод

Plugins can filter the website attributes before it is cached, eg. to change the website name, creation date, etc.
public static setSiteFromArray ( $idSite, $infoSite )
$idSite
$infoSite

setSites() публичный статический Метод

Sets the cached site data with an array that associates site IDs with individual site data.
public static setSites ( array $sites )
$sites array The array of sites data. Indexed by site ID. eg, array('1' => array('name' => 'Site 1', ...), '2' => array('name' => 'Site 2', ...))`

setSitesFromArray() публичный статический Метод

Sets the cached Site data with a non-associated array of site data.
public static setSitesFromArray ( array $sites )
$sites array The array of sites data. eg, array( array('idsite' => '1', 'name' => 'Site 1', ...), array('idsite' => '2', 'name' => 'Site 2', ...), )

Описание свойств

$id защищенное свойство

protected int|null $id
Результат integer | null

$infoSites защищенное статическое свойство

protected static array $infoSites
Результат array