本文整理汇总了PHP中Piwik\Site::getCurrency方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::getCurrency方法的具体用法?PHP Site::getCurrency怎么用?PHP Site::getCurrency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Site
的用法示例。
在下文中一共展示了Site::getCurrency方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetDefaultTimezoneAndCurrencyAndExcludedQueryParametersAndExcludedIps
public function testSetDefaultTimezoneAndCurrencyAndExcludedQueryParametersAndExcludedIps()
{
// test that they return default values
$defaultTimezone = API::getInstance()->getDefaultTimezone();
$this->assertEquals('UTC', $defaultTimezone);
$defaultCurrency = API::getInstance()->getDefaultCurrency();
$this->assertEquals('USD', $defaultCurrency);
$excludedIps = API::getInstance()->getExcludedIpsGlobal();
$this->assertEquals('', $excludedIps);
$excludedQueryParameters = API::getInstance()->getExcludedQueryParametersGlobal();
$this->assertEquals('', $excludedQueryParameters);
// test that when not specified, defaults are set as expected
$idsite = API::getInstance()->addSite("site1", array('http://example.org'));
$site = new Site($idsite);
$this->assertEquals('UTC', $site->getTimezone());
$this->assertEquals('USD', $site->getCurrency());
$this->assertEquals('', $site->getExcludedQueryParameters());
$this->assertEquals('', $site->getExcludedIps());
$this->assertEquals(false, $site->isEcommerceEnabled());
// set the global timezone and get it
$newDefaultTimezone = 'UTC+5.5';
API::getInstance()->setDefaultTimezone($newDefaultTimezone);
$defaultTimezone = API::getInstance()->getDefaultTimezone();
$this->assertEquals($newDefaultTimezone, $defaultTimezone);
// set the default currency and get it
$newDefaultCurrency = 'EUR';
API::getInstance()->setDefaultCurrency($newDefaultCurrency);
$defaultCurrency = API::getInstance()->getDefaultCurrency();
$this->assertEquals($newDefaultCurrency, $defaultCurrency);
// set the global IPs to exclude and get it
$newGlobalExcludedIps = '1.1.1.*,1.1.*.*,150.1.1.1';
API::getInstance()->setGlobalExcludedIps($newGlobalExcludedIps);
$globalExcludedIps = API::getInstance()->getExcludedIpsGlobal();
$this->assertEquals($newGlobalExcludedIps, $globalExcludedIps);
// set the global URL query params to exclude and get it
$newGlobalExcludedQueryParameters = 'PHPSESSID,blabla, TesT';
// removed the space
$expectedGlobalExcludedQueryParameters = 'PHPSESSID,blabla,TesT';
API::getInstance()->setGlobalExcludedQueryParameters($newGlobalExcludedQueryParameters);
$globalExcludedQueryParameters = API::getInstance()->getExcludedQueryParametersGlobal();
$this->assertEquals($expectedGlobalExcludedQueryParameters, $globalExcludedQueryParameters);
// create a website and check that default currency and default timezone are set
// however, excluded IPs and excluded query Params are not returned
$idsite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, $siteSearch = 0, $searchKeywordParameters = 'test1,test2', $searchCategoryParameters = 'test2,test1', '', '', $newDefaultTimezone);
$site = new Site($idsite);
$this->assertEquals($newDefaultTimezone, $site->getTimezone());
$this->assertEquals(date('Y-m-d'), $site->getCreationDate()->toString());
$this->assertEquals($newDefaultCurrency, $site->getCurrency());
$this->assertEquals('', $site->getExcludedIps());
$this->assertEquals('', $site->getExcludedQueryParameters());
$this->assertEquals('test1,test2', $site->getSearchKeywordParameters());
$this->assertEquals('test2,test1', $site->getSearchCategoryParameters());
$this->assertFalse($site->isSiteSearchEnabled());
$this->assertFalse(Site::isSiteSearchEnabledFor($idsite));
$this->assertFalse($site->isEcommerceEnabled());
$this->assertFalse(Site::isEcommerceEnabledFor($idsite));
}
示例2: getCurrencySymbol
/**
* Returns the currency symbol for a site.
*
* @param int $idSite The ID of the site to return the currency symbol for.
* @return string eg, `'$'`.
*/
public static function getCurrencySymbol($idSite)
{
$symbols = MetricsFormatter::getCurrencyList();
$site = new Site($idSite);
$currency = $site->getCurrency();
if (isset($symbols[$currency])) {
return $symbols[$currency][0];
}
return '';
}
示例3: addFilterToCleanVisitors
/**
* For an array of visits, query the list of pages for this visit
* as well as make the data human readable
* @param DataTable $dataTable
* @param int $idSite
* @param bool $flat whether to flatten the array (eg. 'customVariables' names/values will appear in the root array rather than in 'customVariables' key
* @param bool $doNotFetchActions If set to true, we only fetch visit info and not actions (much faster)
* @param bool $filterNow If true, the visitors will be cleaned immediately
*/
private function addFilterToCleanVisitors(DataTable $dataTable, $idSite, $flat = false, $doNotFetchActions = false, $filterNow = false)
{
$filter = 'queueFilter';
if ($filterNow) {
$filter = 'filter';
}
$dataTable->{$filter}(function ($table) use($idSite, $flat, $doNotFetchActions) {
/** @var DataTable $table */
$actionsLimit = (int) Config::getInstance()->General['visitor_log_maximum_actions_per_visit'];
$visitorFactory = new VisitorFactory();
$website = new Site($idSite);
$timezone = $website->getTimezone();
$currency = $website->getCurrency();
$currencies = APISitesManager::getInstance()->getCurrencySymbols();
// live api is not summable, prevents errors like "Unexpected ECommerce status value"
$table->deleteRow(DataTable::ID_SUMMARY_ROW);
foreach ($table->getRows() as $visitorDetailRow) {
$visitorDetailsArray = Visitor::cleanVisitorDetails($visitorDetailRow->getColumns());
$visitor = $visitorFactory->create($visitorDetailsArray);
$visitorDetailsArray = $visitor->getAllVisitorDetails();
$visitorDetailsArray['siteCurrency'] = $currency;
$visitorDetailsArray['siteCurrencySymbol'] = @$currencies[$visitorDetailsArray['siteCurrency']];
$visitorDetailsArray['serverTimestamp'] = $visitorDetailsArray['lastActionTimestamp'];
$dateTimeVisit = Date::factory($visitorDetailsArray['lastActionTimestamp'], $timezone);
if ($dateTimeVisit) {
$visitorDetailsArray['serverTimePretty'] = $dateTimeVisit->getLocalized(Date::TIME_FORMAT);
$visitorDetailsArray['serverDatePretty'] = $dateTimeVisit->getLocalized(Date::DATE_FORMAT_LONG);
}
$dateTimeVisitFirstAction = Date::factory($visitorDetailsArray['firstActionTimestamp'], $timezone);
$visitorDetailsArray['serverDatePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized(Date::DATE_FORMAT_LONG);
$visitorDetailsArray['serverTimePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized(Date::TIME_FORMAT);
$visitorDetailsArray['actionDetails'] = array();
if (!$doNotFetchActions) {
$visitorDetailsArray = Visitor::enrichVisitorArrayWithActions($visitorDetailsArray, $actionsLimit, $timezone);
}
if ($flat) {
$visitorDetailsArray = Visitor::flattenVisitorDetailsArray($visitorDetailsArray);
}
$visitorDetailRow->setColumns($visitorDetailsArray);
}
});
}
示例4: addFilterToCleanVisitors
/**
* For an array of visits, query the list of pages for this visit
* as well as make the data human readable
* @param DataTable $dataTable
* @param int $idSite
* @param bool $flat whether to flatten the array (eg. 'customVariables' names/values will appear in the root array rather than in 'customVariables' key
* @param bool $doNotFetchActions If set to true, we only fetch visit info and not actions (much faster)
* @param bool $filterNow If true, the visitors will be cleaned immediately
*/
private function addFilterToCleanVisitors(DataTable $dataTable, $idSite, $flat = false, $doNotFetchActions = false, $filterNow = false)
{
$filter = 'queueFilter';
if ($filterNow) {
$filter = 'filter';
}
$dataTable->{$filter}(function ($table) use($idSite, $flat, $doNotFetchActions) {
/** @var DataTable $table */
$actionsLimit = (int) Config::getInstance()->General['visitor_log_maximum_actions_per_visit'];
$site = new Site($idSite);
$timezone = $site->getTimezone();
$currencies = APISitesManager::getInstance()->getCurrencySymbols();
foreach ($table->getRows() as $visitorDetailRow) {
$visitorDetailsArray = Visitor::cleanVisitorDetails($visitorDetailRow->getColumns());
$visitor = new Visitor($visitorDetailsArray);
$visitorDetailsArray = $visitor->getAllVisitorDetails();
$visitorDetailsArray['siteCurrency'] = $site->getCurrency();
$visitorDetailsArray['siteCurrencySymbol'] = @$currencies[$site->getCurrency()];
$visitorDetailsArray['serverTimestamp'] = $visitorDetailsArray['lastActionTimestamp'];
$dateTimeVisit = Date::factory($visitorDetailsArray['lastActionTimestamp'], $timezone);
$visitorDetailsArray['serverTimePretty'] = $dateTimeVisit->getLocalized('%time%');
$visitorDetailsArray['serverDatePretty'] = $dateTimeVisit->getLocalized(Piwik::translate('CoreHome_ShortDateFormat'));
$dateTimeVisitFirstAction = Date::factory($visitorDetailsArray['firstActionTimestamp'], $timezone);
$visitorDetailsArray['serverDatePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized(Piwik::translate('CoreHome_ShortDateFormat'));
$visitorDetailsArray['serverTimePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized('%time%');
$visitorDetailsArray['actionDetails'] = array();
if (!$doNotFetchActions) {
$visitorDetailsArray = Visitor::enrichVisitorArrayWithActions($visitorDetailsArray, $actionsLimit, $timezone);
}
if ($flat) {
$visitorDetailsArray = Visitor::flattenVisitorDetailsArray($visitorDetailsArray);
}
$visitorDetailRow->setColumns($visitorDetailsArray);
}
});
}