本文整理匯總了PHP中Piwik\SettingsPiwik::isUniqueVisitorsEnabled方法的典型用法代碼示例。如果您正苦於以下問題:PHP SettingsPiwik::isUniqueVisitorsEnabled方法的具體用法?PHP SettingsPiwik::isUniqueVisitorsEnabled怎麽用?PHP SettingsPiwik::isUniqueVisitorsEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Piwik\SettingsPiwik
的用法示例。
在下文中一共展示了SettingsPiwik::isUniqueVisitorsEnabled方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: enrichWithUniqueVisitorsMetric
protected function enrichWithUniqueVisitorsMetric(Row $row)
{
if (!$this->getParams()->isSingleSite()) {
// we only compute unique visitors for a single site
return;
}
if ($row->getColumn('nb_uniq_visitors') !== false) {
if (SettingsPiwik::isUniqueVisitorsEnabled($this->getParams()->getPeriod()->getLabel())) {
$uniqueVisitors = (double) $this->computeNbUniqVisitors();
$row->setColumn('nb_uniq_visitors', $uniqueVisitors);
} else {
$row->deleteColumn('nb_uniq_visitors');
}
}
}
示例2: setPeriodVariablesView
/**
* Sets general period variables on a view, including:
*
* - **displayUniqueVisitors** - Whether unique visitors should be displayed for the current
* period.
* - **period** - The value of the **period** query parameter.
* - **otherPeriods** - `array('day', 'week', 'month', 'year', 'range')`
* - **periodsNames** - List of available periods mapped to their singular and plural translations.
*
* @param View $view
* @throws Exception if the current period is invalid.
* @api
*/
public static function setPeriodVariablesView($view)
{
if (isset($view->period)) {
return;
}
$currentPeriod = Common::getRequestVar('period');
$view->displayUniqueVisitors = SettingsPiwik::isUniqueVisitorsEnabled($currentPeriod);
$availablePeriods = self::getEnabledPeriodsInUI();
if (!in_array($currentPeriod, $availablePeriods)) {
throw new Exception("Period must be one of: " . implode(", ", $availablePeriods));
}
$found = array_search($currentPeriod, $availablePeriods);
unset($availablePeriods[$found]);
$view->period = $currentPeriod;
$view->otherPeriods = $availablePeriods;
$view->periodsNames = self::getEnabledPeriodsNames();
}
示例3: enrichWithUniqueVisitorsMetric
protected function enrichWithUniqueVisitorsMetric(Row $row)
{
// skip unique visitors metrics calculation if calculating for multiple sites is disabled
if (!$this->getParams()->isSingleSite() && $this->skipUniqueVisitorsCalculationForMultipleSites) {
return;
}
if ($row->getColumn('nb_uniq_visitors') === false && $row->getColumn('nb_users') === false) {
return;
}
if (!SettingsPiwik::isUniqueVisitorsEnabled($this->getParams()->getPeriod()->getLabel())) {
$row->deleteColumn('nb_uniq_visitors');
$row->deleteColumn('nb_users');
return;
}
$metrics = array(Metrics::INDEX_NB_USERS);
if ($this->getParams()->isSingleSite()) {
$uniqueVisitorsMetric = Metrics::INDEX_NB_UNIQ_VISITORS;
} else {
if (!SettingsPiwik::isSameFingerprintAcrossWebsites()) {
throw new Exception("Processing unique visitors across websites is enabled for this instance,\n but to process this metric you must first set enable_fingerprinting_across_websites=1\n in the config file, under the [Tracker] section.");
}
$uniqueVisitorsMetric = Metrics::INDEX_NB_UNIQ_FINGERPRINTS;
}
$metrics[] = $uniqueVisitorsMetric;
$uniques = $this->computeNbUniques($metrics);
// see edge case as described in https://github.com/piwik/piwik/issues/9357 where uniq_visitors might be higher
// than visits because we archive / process it after nb_visits. Between archiving nb_visits and nb_uniq_visitors
// there could have been a new visit leading to a higher nb_unique_visitors than nb_visits which is not possible
// by definition. In this case we simply use the visits metric instead of unique visitors metric.
$visits = $row->getColumn('nb_visits');
if ($visits !== false && $uniques[$uniqueVisitorsMetric] !== false) {
$uniques[$uniqueVisitorsMetric] = min($uniques[$uniqueVisitorsMetric], $visits);
}
$row->setColumn('nb_uniq_visitors', $uniques[$uniqueVisitorsMetric]);
$row->setColumn('nb_users', $uniques[Metrics::INDEX_NB_USERS]);
}
示例4: checkUniqueIsEnabledOrFail
/**
* @param $period
* @param $metric
* @throws \Exception
*/
private function checkUniqueIsEnabledOrFail($period, $metric)
{
if (!SettingsPiwik::isUniqueVisitorsEnabled($period)) {
throw new \Exception("The metric " . $metric . " is not enabled for the requested period. " . "Please see this FAQ: http://piwik.org/faq/how-to/faq_113/");
}
}
示例5: enrichWithUniqueVisitorsMetric
protected function enrichWithUniqueVisitorsMetric(Row $row)
{
// skip unique visitors metrics calculation if calculating for multiple sites is disabled
if (!$this->getParams()->isSingleSite() && $this->skipUniqueVisitorsCalculationForMultipleSites) {
return;
}
if ($row->getColumn('nb_uniq_visitors') === false && $row->getColumn('nb_users') === false) {
return;
}
if (!SettingsPiwik::isUniqueVisitorsEnabled($this->getParams()->getPeriod()->getLabel())) {
$row->deleteColumn('nb_uniq_visitors');
$row->deleteColumn('nb_users');
return;
}
$metrics = array(Metrics::INDEX_NB_USERS);
if ($this->getParams()->isSingleSite()) {
$uniqueVisitorsMetric = Metrics::INDEX_NB_UNIQ_VISITORS;
} else {
if (!SettingsPiwik::isSameFingerprintAcrossWebsites()) {
throw new Exception("Processing unique visitors across websites is enabled for this instance,\n but to process this metric you must first set enable_fingerprinting_across_websites=1\n in the config file, under the [Tracker] section.");
}
$uniqueVisitorsMetric = Metrics::INDEX_NB_UNIQ_FINGERPRINTS;
}
$metrics[] = $uniqueVisitorsMetric;
$uniques = $this->computeNbUniques($metrics);
$row->setColumn('nb_uniq_visitors', $uniques[$uniqueVisitorsMetric]);
$row->setColumn('nb_users', $uniques[Metrics::INDEX_NB_USERS]);
}
示例6: addSparklineColumns
private function addSparklineColumns(Sparklines $view)
{
$currentPeriod = Common::getRequestVar('period');
$currentIdSite = Common::getRequestVar('idSite');
$currentDate = Common::getRequestVar('date');
$displayUniqueVisitors = SettingsPiwik::isUniqueVisitorsEnabled($currentPeriod);
$isActionPluginEnabled = Common::isActionsPluginEnabled();
$view->config->addSparklineMetric($displayUniqueVisitors ? array('nb_visits', 'nb_uniq_visitors') : array('nb_visits'), 5);
if ($isActionPluginEnabled) {
$view->config->addSparklineMetric(array('nb_actions'), 10);
// either actions or pageviews will be displayed
$view->config->addSparklineMetric(array('nb_pageviews', 'nb_uniq_pageviews'), 20);
} else {
// make sure to still create a div on the right side for this, just leave it empty
$view->config->addPlaceholder(10);
}
$userId = new UserId();
if ($userId->isUsedInAtLeastOneSite(array($currentIdSite), $currentPeriod, $currentDate)) {
$view->config->addSparklineMetric(array('nb_users'), 30);
$view->config->addPlaceholder(31);
}
$view->config->addSparklineMetric(array('avg_time_on_site'), 40);
$idSite = Common::getRequestVar('idSite');
if ($isActionPluginEnabled && Site::isSiteSearchEnabledFor($idSite)) {
$view->config->addSparklineMetric(array('nb_searches', 'nb_keywords'), 50);
} else {
// make sure to still create a div on the right side for this, just leave it empty
$view->config->addPlaceholder(50);
}
$view->config->addSparklineMetric(array('bounce_rate'), 60);
if ($isActionPluginEnabled) {
$view->config->addSparklineMetric(array('nb_downloads', 'nb_uniq_downloads'), 70);
$view->config->addSparklineMetric(array('nb_actions_per_visit'), 71);
$view->config->addSparklineMetric(array('nb_outlinks', 'nb_uniq_outlinks'), 72);
$view->config->addSparklineMetric(array('avg_time_generation'), 73);
$view->config->addSparklineMetric(array('max_actions'), 74);
}
}
示例7: enrichWithUniqueVisitorsMetric
protected function enrichWithUniqueVisitorsMetric(Row $row)
{
// skip unique visitors metrics calculation if calculating for multiple sites is disabled
if (!$this->getParams()->isSingleSite() && $this->skipUniqueVisitorsCalculationForMultipleSites) {
return;
}
if ($row->getColumn('nb_uniq_visitors') !== false || $row->getColumn('nb_users') !== false) {
if (SettingsPiwik::isUniqueVisitorsEnabled($this->getParams()->getPeriod()->getLabel())) {
$metrics = array(Metrics::INDEX_NB_UNIQ_VISITORS, Metrics::INDEX_NB_USERS);
$uniques = $this->computeNbUniques($metrics);
$row->setColumn('nb_uniq_visitors', $uniques[Metrics::INDEX_NB_UNIQ_VISITORS]);
$row->setColumn('nb_users', $uniques[Metrics::INDEX_NB_USERS]);
} else {
$row->deleteColumn('nb_uniq_visitors');
$row->deleteColumn('nb_users');
}
}
}
示例8: getCoreColumns
protected function getCoreColumns($period)
{
$columns = array('nb_visits', 'nb_actions', 'nb_visits_converted', 'bounce_count', 'sum_visit_length', 'max_actions');
if (SettingsPiwik::isUniqueVisitorsEnabled($period)) {
$columns = array_merge(array('nb_uniq_visitors'), $columns);
}
$columns = array_values($columns);
return $columns;
}
示例9: setPeriodVariablesView
/**
* Sets general period variables on a view, including:
*
* - **displayUniqueVisitors** - Whether unique visitors should be displayed for the current
* period.
* - **period** - The value of the **period** query parameter.
* - **otherPeriods** - `array('day', 'week', 'month', 'year', 'range')`
* - **periodsNames** - List of available periods mapped to their singular and plural translations.
*
* @param View $view
* @throws Exception if the current period is invalid.
* @api
*/
public static function setPeriodVariablesView($view)
{
if (isset($view->period)) {
return;
}
$currentPeriod = Common::getRequestVar('period');
$view->displayUniqueVisitors = SettingsPiwik::isUniqueVisitorsEnabled($currentPeriod);
$availablePeriods = array('day', 'week', 'month', 'year', 'range');
if (!in_array($currentPeriod, $availablePeriods)) {
throw new Exception("Period must be one of: " . implode(",", $availablePeriods));
}
$periodNames = array('day' => array('singular' => Piwik::translate('CoreHome_PeriodDay'), 'plural' => Piwik::translate('CoreHome_PeriodDays')), 'week' => array('singular' => Piwik::translate('CoreHome_PeriodWeek'), 'plural' => Piwik::translate('CoreHome_PeriodWeeks')), 'month' => array('singular' => Piwik::translate('CoreHome_PeriodMonth'), 'plural' => Piwik::translate('CoreHome_PeriodMonths')), 'year' => array('singular' => Piwik::translate('CoreHome_PeriodYear'), 'plural' => Piwik::translate('CoreHome_PeriodYears')), 'range' => array('singular' => Piwik::translate('General_DateRangeInPeriodList'), 'plural' => Piwik::translate('General_DateRangeInPeriodList')));
$found = array_search($currentPeriod, $availablePeriods);
if ($found !== false) {
unset($availablePeriods[$found]);
}
$view->period = $currentPeriod;
$view->otherPeriods = $availablePeriods;
$view->periodsNames = $periodNames;
}