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);
ファイルを表示 Open project: piwik/piwik Class Usage Examples

Protected Properties

Property Type Description
$id integer | null
$infoSites array

Public Methods

Method 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.

Protected Methods

Method 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

Method Description
triggerSetSitesEvent ( &$sites )

Method Details

__construct() public method

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

__toString() public method

Useful for debugging.
public __toString ( ) : string
return string

clearCache() public static method

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

clearCacheForSite() public static method

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

get() protected method

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

getCreationDate() public method

Returns the creation date of the site.
public getCreationDate ( ) : Date
return Date

getCreationDateFor() public static method

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

getCurrency() public method

Returns the currency of the site.
public getCurrency ( ) : string
return string

getCurrencyFor() public static method

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

getCurrencyList() public static method

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
return array An array mapping currency codes to their respective currency symbols and a description, eg, `array('USD' => array('$', 'US dollar'))`.

getCurrencySymbolFor() public static method

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

getExcludedIps() public method

Returns the excluded ips of the site.
public getExcludedIps ( ) : string
return string

getExcludedIpsFor() public static method

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

getExcludedQueryParameters() public method

Returns the excluded query parameters of the site.

getExcludedQueryParametersFor() public static method

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

getFor() protected static method

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.
return string

getGroupFor() public static method

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

getId() public method

Returns the id of the site.
public getId ( ) : integer
return integer

getIdSitesFromIdSitesString() public static method

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

getMainUrl() public method

Returns the main url of the site.
public getMainUrl ( ) : string
return string

getMainUrlFor() public static method

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

getMinMaxDateAcrossWebsites() public static method

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

getName() public method

Returns the name of the site.
public getName ( ) : string
return string

getNameFor() public static method

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

getSearchCategoryParameters() public method

Returns the site search category query parameters for the site.

getSearchKeywordParameters() public method

Returns the site search keyword query parameters for the site.

getSite() public static method

public static getSite ( $idsite )

getSites() public static method

Returns all websites pre-cached
public static getSites ( )

getTimezone() public method

Returns the timezone of the size.
public getTimezone ( ) : string
return string

getTimezoneFor() public static method

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

getType() public method

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

getTypeFor() public static method

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

isEcommerceEnabled() public method

Returns whether ecommerce is enabled for the site.
public isEcommerceEnabled ( ) : boolean
return boolean

isEcommerceEnabledFor() public static method

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

isSiteSearchEnabled() public method

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

isSiteSearchEnabledFor() public static method

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

setSiteFromArray() public static method

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 method

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 method

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
return integer | null

$infoSites protected_oe static_oe property

protected static array $infoSites
return array