本文整理汇总了PHP中Piwik\Site类的典型用法代码示例。如果您正苦于以下问题:PHP Site类的具体用法?PHP Site怎么用?PHP Site使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Site类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getArchiveIdAndVisits
public static function getArchiveIdAndVisits(Site $site, Period $period, Segment $segment, $minDatetimeArchiveProcessedUTC, $requestedPlugin)
{
$dateStart = $period->getDateStart();
$bindSQL = array($site->getId(), $dateStart->toString('Y-m-d'), $period->getDateEnd()->toString('Y-m-d'), $period->getId());
$timeStampWhere = '';
if ($minDatetimeArchiveProcessedUTC) {
$timeStampWhere = " AND ts_archived >= ? ";
$bindSQL[] = Date::factory($minDatetimeArchiveProcessedUTC)->getDatetime();
}
$pluginOrVisitsSummary = array("VisitsSummary", $requestedPlugin);
$pluginOrVisitsSummary = array_unique($pluginOrVisitsSummary);
$sqlWhereArchiveName = self::getNameCondition($pluginOrVisitsSummary, $segment);
$sqlQuery = "\tSELECT idarchive, value, name, date1 as startDate\n\t\t\t\t\t\tFROM " . ArchiveTableCreator::getNumericTable($dateStart) . "``\n\t\t\t\t\t\tWHERE idsite = ?\n\t\t\t\t\t\t\tAND date1 = ?\n\t\t\t\t\t\t\tAND date2 = ?\n\t\t\t\t\t\t\tAND period = ?\n\t\t\t\t\t\t\tAND ( ({$sqlWhereArchiveName})\n\t\t\t\t\t\t\t\t OR name = '" . self::NB_VISITS_RECORD_LOOKED_UP . "'\n\t\t\t\t\t\t\t\t OR name = '" . self::NB_VISITS_CONVERTED_RECORD_LOOKED_UP . "')\n\t\t\t\t\t\t\t{$timeStampWhere}\n\t\t\t\t\t\tORDER BY idarchive DESC";
$results = Db::fetchAll($sqlQuery, $bindSQL);
if (empty($results)) {
return false;
}
$idArchive = self::getMostRecentIdArchiveFromResults($segment, $requestedPlugin, $results);
$idArchiveVisitsSummary = self::getMostRecentIdArchiveFromResults($segment, "VisitsSummary", $results);
list($visits, $visitsConverted) = self::getVisitsMetricsFromResults($idArchive, $idArchiveVisitsSummary, $results);
if ($visits === false && $idArchive === false) {
return false;
}
return array($idArchive, $visits, $visitsConverted);
}
示例2: hasReportBeenPurged
/**
* Returns true if it is likely that the data for this report has been purged and if the
* user should be told about that.
*
* In order for this function to return true, the following must also be true:
* - The data table for this report must either be empty or not have been fetched.
* - The period of this report is not a multiple period.
* - The date of this report must be older than the delete_reports_older_than config option.
* @param DataTableInterface $dataTable
* @return bool
*/
public static function hasReportBeenPurged($dataTable)
{
$strPeriod = Common::getRequestVar('period', false);
$strDate = Common::getRequestVar('date', false);
if (false !== $strPeriod && false !== $strDate && (is_null($dataTable) || !empty($dataTable) && $dataTable->getRowsCount() == 0)) {
// if range, only look at the first date
if ($strPeriod == 'range') {
$idSite = Common::getRequestVar('idSite', '');
if (intval($idSite) != 0) {
$site = new Site($idSite);
$timezone = $site->getTimezone();
} else {
$timezone = 'UTC';
}
$period = new Range('range', $strDate, $timezone);
$reportDate = $period->getDateStart();
} elseif (Period::isMultiplePeriod($strDate, $strPeriod)) {
// if a multiple period, this function is irrelevant
return false;
} else {
// otherwise, use the date as given
$reportDate = Date::factory($strDate);
}
$reportYear = $reportDate->toString('Y');
$reportMonth = $reportDate->toString('m');
if (static::shouldReportBePurged($reportYear, $reportMonth)) {
return true;
}
}
return false;
}
示例3: realtimeMap
/**
* @param bool $standalone When set to true, the Top controls will be hidden to provide better full screen view
* @param bool $fetch
* @param bool|string $segmentOverride
*
* @return string
*/
public function realtimeMap($standalone = false, $fetch = false, $segmentOverride = false)
{
$this->checkUserCountryPluginEnabled();
$idSite = Common::getRequestVar('idSite', 1, 'int');
Piwik::checkUserHasViewAccess($idSite);
$token_auth = Piwik::getCurrentUserTokenAuth();
$view = new View('@UserCountryMap/realtimeMap');
$view->mapIsStandaloneNotWidget = $standalone;
$view->metrics = $this->getMetrics($idSite, 'range', self::REAL_TIME_WINDOW, $token_auth);
$view->defaultMetric = 'nb_visits';
$liveRefreshAfterMs = (int) Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000;
$goals = APIGoals::getInstance()->getGoals($idSite);
$site = new Site($idSite);
$hasGoals = !empty($goals) || $site->isEcommerceEnabled();
// maximum number of visits to be displayed in the map
$maxVisits = Common::getRequestVar('filter_limit', 100, 'int');
// some translations
$locale = array('nb_actions' => Piwik::translate('VisitsSummary_NbActionsDescription'), 'local_time' => Piwik::translate('VisitTime_ColumnLocalTime'), 'from' => Piwik::translate('General_FromReferrer'), 'seconds' => Piwik::translate('UserCountryMap_Seconds'), 'seconds_ago' => Piwik::translate('UserCountryMap_SecondsAgo'), 'minutes' => Piwik::translate('UserCountryMap_Minutes'), 'minutes_ago' => Piwik::translate('UserCountryMap_MinutesAgo'), 'hours' => Piwik::translate('UserCountryMap_Hours'), 'hours_ago' => Piwik::translate('UserCountryMap_HoursAgo'), 'days_ago' => Piwik::translate('UserCountryMap_DaysAgo'), 'actions' => Piwik::translate('VisitsSummary_NbPageviewsDescription'), 'searches' => Piwik::translate('UserCountryMap_Searches'), 'goal_conversions' => Piwik::translate('UserCountryMap_GoalConversions'));
$segment = $segmentOverride ?: Request::getRawSegmentFromRequest() ?: '';
$params = array('period' => 'range', 'idSite' => $idSite, 'segment' => $segment, 'token_auth' => $token_auth);
$realtimeWindow = Common::getRequestVar('realtimeWindow', self::REAL_TIME_WINDOW, 'string');
if ($realtimeWindow != 'false') {
// handle special value
$params['date'] = $realtimeWindow;
}
$reqParams = $this->getEnrichedRequest($params, $encode = false);
$view->config = array('metrics' => array(), 'svgBasePath' => $view->piwikUrl . 'plugins/UserCountryMap/svg/', 'liveRefreshAfterMs' => $liveRefreshAfterMs, '_' => $locale, 'reqParams' => $reqParams, 'siteHasGoals' => $hasGoals, 'maxVisits' => $maxVisits, 'changeVisitAlpha' => Common::getRequestVar('changeVisitAlpha', true, 'int'), 'removeOldVisits' => Common::getRequestVar('removeOldVisits', true, 'int'), 'showFooterMessage' => Common::getRequestVar('showFooterMessage', true, 'int'), 'showDateTime' => Common::getRequestVar('showDateTime', true, 'int'), 'doNotRefreshVisits' => Common::getRequestVar('doNotRefreshVisits', false, 'int'), 'enableAnimation' => Common::getRequestVar('enableAnimation', true, 'int'), 'forceNowValue' => Common::getRequestVar('forceNowValue', false, 'int'));
return $view->render();
}
示例4: init
protected function init()
{
$idSite = $this->getIdSite();
$site = new Site($idSite);
if ($site->isEcommerceEnabled()) {
$this->addWidget('General_Overview', 'widgetGoalReport', array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER));
$this->addWidget('Goals_EcommerceLog', 'getEcommerceLog');
}
}
示例5: configure
public function configure(WidgetsList $widgetsList)
{
$idSite = Common::getRequestVar('idSite', null, 'int');
$site = new Site($idSite);
if ($site->isEcommerceEnabled()) {
$this->addEcommerceWidgets($widgetsList);
}
$this->addGoalsWidgets($widgetsList, $idSite);
}
示例6: isEnabled
public function isEnabled()
{
$idSite = Common::getRequestVar('idSite', false, 'int');
if (empty($idSite)) {
return false;
}
$site = new Site($idSite);
return $site->isEcommerceEnabled();
}
示例7: configureReportingMenu
public function configureReportingMenu(MenuReporting $menu)
{
$idSite = Common::getRequestVar('idSite', null, 'int');
$site = new Site($idSite);
if ($site->isEcommerceEnabled()) {
$ecommerceParams = array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER);
$menu->addItem('Goals_Ecommerce', '', array(), 24);
$menu->addItem('Goals_Ecommerce', 'General_Overview', $this->urlForAction('ecommerceReport', $ecommerceParams), 1);
$menu->addItem('Goals_Ecommerce', 'Goals_EcommerceLog', $this->urlForAction('ecommerceLogReport'), 2);
$menu->addItem('Goals_Ecommerce', 'Goals_Products', $this->urlForAction('products', $ecommerceParams), 3);
$menu->addItem('Goals_Ecommerce', 'Ecommerce_Sales', $this->urlForAction('sales', $ecommerceParams), 4);
}
}
示例8: configure
public static function configure(WidgetConfig $config)
{
$config->setCategoryId('Goals_Ecommerce');
$config->setSubcategoryId('Goals_EcommerceLog');
$config->setName('Goals_EcommerceLog');
$idSite = Common::getRequestVar('idSite', 0, 'int');
if (empty($idSite)) {
$config->disable();
return;
}
$site = new Site($idSite);
$config->setIsEnabled($site->isEcommerceEnabled());
}
示例9: setUp
public function setUp()
{
parent::setUp();
$idSite = 1;
if (!Fixture::siteCreated($idSite)) {
Fixture::createWebsite('2014-01-01 00:00:00');
}
$site = new Site($idSite);
$date = Date::factory('2012-01-01');
$period = Period\Factory::build('month', $date);
$segment = new Segment('', array($site->getId()));
$params = new Parameters($site, $period, $segment);
$this->logAggregator = new LogAggregator($params);
}
示例10: testGetUnit
/**
* @dataProvider getUnitColumns
* @group Core
*/
public function testGetUnit($column, $expected)
{
Site::setSites(array(1 => array('name' => 'TestSite', 'currency' => 'EUR')));
FakeAccess::$superUser = true;
$actual = Metrics::getUnit($column, 1);
$this->assertEquals($expected, $actual);
}
示例11: configureTopMenu
public function configureTopMenu(MenuTop $menu)
{
$userPreferences = new UserPreferences();
$idSite = $userPreferences->getDefaultWebsiteId();
$tooltip = Piwik::translate('Dashboard_TopLinkTooltip', Site::getNameFor($idSite));
$urlParams = array('module' => 'CoreHome', 'action' => 'index', 'idSite' => $idSite);
$menu->add('Dashboard_Dashboard', null, $urlParams, true, 1, $tooltip);
}
示例12: render
public function render()
{
$idSite = Common::getRequestVar('idSite');
$site = new Site($idSite);
$url = urldecode(Common::getRequestVar('url', '', 'string'));
if (!empty($url) && strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) {
$url = 'http://' . $url;
}
if (empty($url) || !UrlHelper::isLookLikeUrl($url)) {
$url = $site->getMainUrl();
}
$dataTable = API::getInstance()->getRank($url);
/** @var \Piwik\DataTable\Renderer\Php $renderer */
$renderer = Renderer::factory('php');
$renderer->setSerialize(false);
return $this->renderTemplate('getRank', array('urlToRank' => Url::getHostFromUrl($url), 'ranks' => $renderer->render($dataTable)));
}
示例13: configureTopMenu
public function configureTopMenu(MenuTop $menu)
{
$userPreferences = new UserPreferences();
$idSite = $userPreferences->getDefaultWebsiteId();
$tooltip = Piwik::translate('Dashboard_TopLinkTooltip', Site::getNameFor($idSite));
$urlParams = $this->urlForModuleActionWithDefaultUserParams('CoreHome', 'index');
$menu->addItem('Dashboard_Dashboard', null, $urlParams, 1, $tooltip);
}
示例14: testGetUnit
/**
* @dataProvider getUnitColumns
* @group Core
*/
public function testGetUnit($column, $expected)
{
\Piwik\Site::setSites(array(1 => array('name' => 'TestSite', 'currency' => 'EUR')));
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
$actual = Metrics::getUnit($column, 1);
$this->assertEquals($expected, $actual);
}
示例15: getScheduledTimeForSite
/**
* This method takes the websites timezone into consideration when scheduling a task.
* @param int $idSite
* @param string $period Eg 'day', 'week', 'month'
* @return Daily|Monthly|Weekly
* @throws \Exception
* @ignore
*/
public static function getScheduledTimeForSite($idSite, $period)
{
$arbitraryDateInUTC = Date::factory('2011-01-01');
$midnightInSiteTimezone = date('H', Date::factory($arbitraryDateInUTC, Site::getTimezoneFor($idSite))->getTimestamp());
$hourInUTC = (24 - $midnightInSiteTimezone) % 24;
$schedule = self::getScheduledTimeForPeriod($period);
$schedule->setHour($hourInUTC);
return $schedule;
}