site = $site; $this->period = $period; $this->segment = $segment; } /** * @ignore */ public function setRequestedPlugin($plugin) { $this->requestedPlugin = $plugin; } /** * @ignore */ public function getRequestedPlugin() { return $this->requestedPlugin; } /** * Returns the period we are computing statistics for. * * @return Period * @api */ public function getPeriod() { return $this->period; } /** * Returns the array of Period which make up this archive. * * @return \Piwik\Period[] * @ignore */ public function getSubPeriods() { if ($this->getPeriod()->getLabel() == 'day') { return array( $this->getPeriod() ); } return $this->getPeriod()->getSubperiods(); } /** * @return array * @ignore */ public function getIdSites() { $idSite = $this->getSite()->getId(); $idSites = array($idSite); Piwik::postEvent('ArchiveProcessor.Parameters.getIdSites', array(&$idSites, $this->getPeriod())); return $idSites; } /** * Returns the site we are computing statistics for. * * @return Site * @api */ public function getSite() { return $this->site; } /** * The Segment used to limit the set of visits that are being aggregated. * * @return Segment * @api */ public function getSegment() { return $this->segment; } /** * Returns the end day of the period in the site's timezone. * * @return Date */ public function getDateEnd() { return $this->getPeriod()->getDateEnd()->setTimezone($this->getSite()->getTimezone()); } /** * Returns the start day of the period in the site's timezone. * * @return Date */ public function getDateStart() { return $this->getPeriod()->getDateStart()->setTimezone($this->getSite()->getTimezone()); } /** * @return bool */ public function isSingleSiteDayArchive() { $oneSite = $this->isSingleSite(); $oneDay = $this->getPeriod()->getLabel() == 'day'; return $oneDay && $oneSite; } public function isSingleSite() { return count($this->getIdSites()) == 1; } public function logStatusDebug($isTemporary) { $temporary = 'definitive archive'; if ($isTemporary) { $temporary = 'temporary archive'; } Log::debug( "%s archive, idSite = %d (%s), segment '%s', report = '%s', UTC datetime [%s -> %s]", $this->getPeriod()->getLabel(), $this->getSite()->getId(), $temporary, $this->getSegment()->getString(), $this->getRequestedPlugin(), $this->getDateStart()->getDateStartUTC(), $this->getDateEnd()->getDateEndUTC() ); } }