PHP Class 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);
Afficher le fichier Open project: piwik/piwik Class Usage Examples

Protected Properties

Свойство Type Description
$id integer | null
$infoSites array

Méthodes publiques

Méthode Description
__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.

Méthodes protégées

Méthode Description
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.

Private Methods

Méthode Description
triggerSetSitesEvent ( &$sites )

Method Details

__construct() public méthode

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

__toString() public méthode

Useful for debugging.
public __toString ( ) : string
Résultat string

clearCache() public static méthode

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

clearCacheForSite() public static méthode

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

get() protected méthode

Returns a site property by name.
protected get ( string $name ) : mixed
$name string Name of the property to return (eg, `'main_url'` or `'name'`).
Résultat mixed

getCreationDate() public méthode

Returns the creation date of the site.
public getCreationDate ( ) : Date
Résultat Date

getCreationDateFor() public static méthode

Returns the creation date of the site with the specified ID.
public static getCreationDateFor ( integer $idsite ) : string
$idsite integer The site ID.
Résultat string

getCurrency() public méthode

Returns the currency of the site.
public getCurrency ( ) : string
Résultat string

getCurrencyFor() public static méthode

Returns the currency of the site with the specified ID.
public static getCurrencyFor ( integer $idsite ) : string
$idsite integer The site ID.
Résultat string

getCurrencyList() public static méthode

Returns the list of all known currency symbols.
See also: Piwik\Intl\Data\Provider\CurrencyDataProvider::getCurrencyList()
Deprecation: Use Piwik\Intl\Data\Provider\CurrencyDataProvider instead.
public static getCurrencyList ( ) : array
Résultat array An array mapping currency codes to their respective currency symbols and a description, eg, `array('USD' => array('$', 'US dollar'))`.

getCurrencySymbolFor() public static méthode

Returns the currency of the site with the specified ID.
public static getCurrencySymbolFor ( integer $idsite ) : string
$idsite integer The site ID.
Résultat string

getExcludedIps() public méthode

Returns the excluded ips of the site.
public getExcludedIps ( ) : string
Résultat string

getExcludedIpsFor() public static méthode

Returns the excluded IP addresses of the site with the specified ID.
public static getExcludedIpsFor ( integer $idsite ) : string
$idsite integer The site ID.
Résultat string

getExcludedQueryParameters() public méthode

Returns the excluded query parameters of the site.
public getExcludedQueryParameters ( ) : string
Résultat string

getExcludedQueryParametersFor() public static méthode

Returns the excluded query parameters for the site with the specified ID.
public static getExcludedQueryParametersFor ( integer $idsite ) : string
$idsite integer The site ID.
Résultat string

getFor() protected static méthode

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.
Résultat string

getGroupFor() public static méthode

Returns the group of the site with the specified ID.
public static getGroupFor ( integer $idsite ) : string
$idsite integer The site ID.
Résultat string

getId() public méthode

Returns the id of the site.
public getId ( ) : integer
Résultat integer

getIdSitesFromIdSitesString() public static méthode

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.
Résultat array An array of valid, unique integers.

getMainUrl() public méthode

Returns the main url of the site.
public getMainUrl ( ) : string
Résultat string

getMainUrlFor() public static méthode

Returns the url for the site with the specified ID.
public static getMainUrlFor ( integer $idsite ) : string
$idsite integer The site ID.
Résultat string

getMinMaxDateAcrossWebsites() public static méthode

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.
Résultat Date[] of two Date instances. First is the min-date & the second is the max date.

getName() public méthode

Returns the name of the site.
public getName ( ) : string
Résultat string

getNameFor() public static méthode

Returns the name of the site with the specified ID.
public static getNameFor ( integer $idsite ) : string
$idsite integer The site ID.
Résultat string

getSearchCategoryParameters() public méthode

Returns the site search category query parameters for the site.
public getSearchCategoryParameters ( ) : string
Résultat string

getSearchKeywordParameters() public méthode

Returns the site search keyword query parameters for the site.
public getSearchKeywordParameters ( ) : string
Résultat string

getSite() public static méthode

public static getSite ( $idsite )

getSites() public static méthode

Returns all websites pre-cached
public static getSites ( )

getTimezone() public méthode

Returns the timezone of the size.
public getTimezone ( ) : string
Résultat string

getTimezoneFor() public static méthode

Returns the timezone of the site with the specified ID.
public static getTimezoneFor ( integer $idsite ) : string
$idsite integer The site ID.
Résultat string

getType() public méthode

Returns the website type (by default "website", which means it is a single website).
public getType ( ) : string
Résultat string

getTypeFor() public static méthode

Returns the type of the site with the specified ID.
public static getTypeFor ( $idsite ) : string
$idsite
Résultat string

isEcommerceEnabled() public méthode

Returns whether ecommerce is enabled for the site.
public isEcommerceEnabled ( ) : boolean
Résultat boolean

isEcommerceEnabledFor() public static méthode

Returns whether the site with the specified ID is ecommerce enabled or not.
public static isEcommerceEnabledFor ( integer $idsite ) : string
$idsite integer The site ID.
Résultat string

isSiteSearchEnabled() public méthode

Returns whether Site Search Tracking is enabled for the site.
public isSiteSearchEnabled ( ) : boolean
Résultat boolean

isSiteSearchEnabledFor() public static méthode

Returns whether the site with the specified ID is Site Search enabled.
public static isSiteSearchEnabledFor ( integer $idsite ) : string
$idsite integer The site ID.
Résultat string

setSiteFromArray() public static méthode

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() public static méthode

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() public static méthode

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', ...), )

Property Details

$id protected_oe property

protected int|null $id
Résultat integer | null

$infoSites protected_oe static_oe property

protected static array $infoSites
Résultat array