当前位置: 首页>>代码示例>>PHP>>正文


PHP Period\Factory类代码示例

本文整理汇总了PHP中Piwik\Period\Factory的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Factory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUrlParameterDateString

 public function getUrlParameterDateString($idSite, $period, $date, $segment)
 {
     $segmentCreatedTime = $this->getCreatedTimeOfSegment($idSite, $segment);
     $oldestDateToProcessForNewSegment = $this->getOldestDateToProcessForNewSegment($segmentCreatedTime);
     if (empty($oldestDateToProcessForNewSegment)) {
         return $date;
     }
     // if the start date for the archiving request is before the minimum date allowed for processing this segment,
     // use the minimum allowed date as the start date
     $periodObj = PeriodFactory::build($period, $date);
     if ($periodObj->getDateStart()->getTimestamp() < $oldestDateToProcessForNewSegment->getTimestamp()) {
         $this->logger->debug("Start date of archiving request period ({start}) is older than configured oldest date to process for the segment.", array('start' => $periodObj->getDateStart()));
         $endDate = $periodObj->getDateEnd();
         // if the creation time of a segment is older than the end date of the archiving request range, we cannot
         // blindly rewrite the date string, since the resulting range would be incorrect. instead we make the
         // start date equal to the end date, so less archiving occurs, and no fatal error occurs.
         if ($oldestDateToProcessForNewSegment->getTimestamp() > $endDate->getTimestamp()) {
             $this->logger->debug("Oldest date to process is greater than end date of archiving request period ({end}), so setting oldest date to end date.", array('end' => $endDate));
             $oldestDateToProcessForNewSegment = $endDate;
         }
         $date = $oldestDateToProcessForNewSegment->toString() . ',' . $endDate;
         $this->logger->debug("Archiving request date range changed to {date} w/ period {period}.", array('date' => $date, 'period' => $period));
     }
     return $date;
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:25,代码来源:SegmentArchivingRequestUrlProvider.php

示例2: __construct

 /**
  * The constructor
  * Initialize some local variables from the request
  * @param int $idSite
  * @param Date $date ($this->date from controller)
  * @param null|string $graphType
  * @throws Exception
  */
 public function __construct($idSite, $date, $graphType = 'graphEvolution')
 {
     $this->apiMethod = Common::getRequestVar('apiMethod', '', 'string');
     if (empty($this->apiMethod)) {
         throw new Exception("Parameter apiMethod not set.");
     }
     $this->label = DataTablePostProcessor::getLabelFromRequest($_GET);
     if (!is_array($this->label)) {
         throw new Exception("Expected label to be an array, got instead: " . $this->label);
     }
     $this->label = $this->label[0];
     if ($this->label === '') {
         throw new Exception("Parameter label not set.");
     }
     $this->period = Common::getRequestVar('period', '', 'string');
     PeriodFactory::checkPeriodIsEnabled($this->period);
     $this->idSite = $idSite;
     $this->graphType = $graphType;
     if ($this->period != 'range') {
         // handle day, week, month and year: display last X periods
         $end = $date->toString();
         list($this->date, $lastN) = EvolutionViz::getDateRangeAndLastN($this->period, $end);
     }
     $this->segment = \Piwik\API\Request::getRawSegmentFromRequest();
     $this->loadEvolutionReport();
 }
开发者ID:drabberhorizon,项目名称:ActiveNative,代码行数:34,代码来源:RowEvolution.php

示例3: createArchiveProcessorParamaters

 private function createArchiveProcessorParamaters()
 {
     $oPeriod = PeriodFactory::makePeriodFromQueryParams('UTC', 'day', '2015-01-01');
     $segment = new Segment(false, array(1));
     $params = new Parameters(new Site(1), $oPeriod, $segment);
     return $params;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:7,代码来源:PluginsArchiverTest.php

示例4: testFactoryInvalid

 public function testFactoryInvalid()
 {
     try {
         Period\Factory::build('inValid', Date::today());
     } catch (\Exception $e) {
         return;
     }
     $this->fail('Expected Exception not raised');
 }
开发者ID:qiuai,项目名称:piwik,代码行数:9,代码来源:PeriodTest.php

示例5: _createArchiveProcessor

 /**
  * Creates a new ArchiveProcessor object
  *
  * @param string $periodLabel
  * @param string $dateLabel
  * @param string $siteTimezone
  * @return  \Core_ArchiveProcessorTest
  */
 private function _createArchiveProcessor($periodLabel, $dateLabel, $siteTimezone)
 {
     $site = $this->_createWebsite($siteTimezone);
     $date = Date::factory($dateLabel);
     $period = Period\Factory::build($periodLabel, $date);
     $segment = new Segment('', $site->getId());
     $params = new ArchiveProcessor\Parameters($site, $period, $segment);
     return new \Core_ArchiveProcessorTest($params);
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:17,代码来源:ArchiveProcessingTest.php

示例6: testArchivingProcess

 /**
  * @group        Benchmarks
  */
 public function testArchivingProcess()
 {
     if ($this->archivingLaunched) {
         echo "NOTE: Had to archive data, memory results will not be accurate. Run again for better results.";
     }
     Rules::$archivingDisabledByTests = true;
     $period = Period\Factory::build(self::$fixture->period, Date::factory(self::$fixture->date));
     $dateRange = $period->getDateStart() . ',' . $period->getDateEnd();
     API::getInstance()->get(self::$fixture->idSite, 'day', $dateRange);
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:13,代码来源:ArchiveQueryBenchmark.php

示例7: __construct

 /**
  * @param DataTable $table
  * @param int    $timezone  The timezone of the current selected site / the timezone of the labels
  * @param string $period    The requested period and date is needed to respect daylight saving etc.
  * @param string $date
  */
 public function __construct($table, $timezone, $period, $date)
 {
     $this->timezone = $timezone;
     $this->date = Period\Factory::build($period, $date)->getDateEnd();
     $self = $this;
     parent::__construct($table, function ($label) use($self) {
         $hour = str_pad($label, 2, 0, STR_PAD_LEFT);
         return $self->convertHourToUtc($hour);
     });
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:16,代码来源:AddSegmentByLabelInUTC.php

示例8: getCommonVisitors

 /**
  * Return the number of visitors that visited every site in the given list for the
  * given date range. Includes the number of visitors that visited at least one site
  * and the number that visited every site.
  *
  * This data is calculated on demand, and for very large tables can take a long time
  * to run.
  *
  * See {@link Model\DistinctMetricsAggregator} for more information.
  *
  * @param string $idSite comma separated list of site IDs, ie, `"1,2,3"`
  * @param string $period
  * @param string $date
  * @return array Metrics **nb_total_visitors** and **nb_shared_visitors**.
  * @throws Exception if $idSite references zero sites or just one site.
  */
 public function getCommonVisitors($idSite, $period, $date, $segment = false)
 {
     if (empty($idSite)) {
         throw new Exception("No sites to get common visitors for.");
     }
     $idSites = Site::getIdSitesFromIdSitesString($idSite);
     Piwik::checkUserHasViewAccess($idSites);
     $segment = new Segment($segment, $idSites);
     $period = PeriodFactory::build($period, $date);
     return $this->distinctMetricsAggregator->getCommonVisitorCount($idSites, $period->getDateStart(), $period->getDateEnd(), $segment);
 }
开发者ID:PiwikPRO,项目名称:plugin-InterSites,代码行数:27,代码来源:API.php

示例9: getTriggeredAlertsForPeriod

 public function getTriggeredAlertsForPeriod($period, $date)
 {
     $piwikDate = Date::factory($date);
     $date = Period\Factory::build($period, $piwikDate);
     $db = $this->getDb();
     $sql = $this->getTriggeredAlertsSelectPart() . " WHERE  period = ? AND ts_triggered BETWEEN ? AND ?";
     $values = array($period, $date->getDateStart()->getDateStartUTC(), $date->getDateEnd()->getDateEndUTC());
     $alerts = $db->fetchAll($sql, $values);
     $alerts = $this->completeAlerts($alerts);
     return $alerts;
 }
开发者ID:andrzejewsky,项目名称:plugin-CustomAlerts,代码行数:11,代码来源:Model.php

示例10: getLastVisitsStart

 public function getLastVisitsStart()
 {
     // hack, ensure we load today's visits by default
     $_GET['date'] = 'today';
     \Piwik\Period\Factory::checkPeriodIsEnabled('day');
     $_GET['period'] = 'day';
     $view = new View('@Live/getLastVisitsStart');
     $view->idSite = $this->idSite;
     $api = new Request("method=Live.getLastVisitsDetails&idSite={$this->idSite}&filter_limit=10&format=php&serialize=0&disable_generic_filters=1");
     $visitors = $api->process();
     $view->visitors = $visitors;
     return $this->render($view);
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:13,代码来源:Controller.php

示例11: 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);
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:14,代码来源:LogAggregatorTest.php

示例12: createCollection

 private function createCollection($onlyOnePeriod = false, $onlyOneSite = false)
 {
     $periods = array(Period\Factory::build('day', '2012-12-12'), Period\Factory::build('day', '2012-12-13'));
     $dataType = 'numeric';
     $siteIds = array($this->site1, $this->site2);
     $dataNames = array('Name1', 'Name2');
     $defaultRow = array('default' => 1);
     if ($onlyOnePeriod) {
         $periods = array($periods[0]);
     }
     if ($onlyOneSite) {
         $siteIds = array($siteIds[0]);
     }
     return new DataCollection($dataNames, $dataType, $siteIds, $periods, $defaultRow);
 }
开发者ID:mgou-net,项目名称:piwik,代码行数:15,代码来源:DataCollectionTest.php

示例13: getTransitionsForAction

 /**
  * General method to get transitions for an action
  *
  * @param $actionName
  * @param $actionType "url"|"title"
  * @param $idSite
  * @param $period
  * @param $date
  * @param bool $segment
  * @param bool $limitBeforeGrouping
  * @param string $parts
  * @return array
  * @throws Exception
  */
 public function getTransitionsForAction($actionName, $actionType, $idSite, $period, $date, $segment = false, $limitBeforeGrouping = false, $parts = 'all')
 {
     Piwik::checkUserHasViewAccess($idSite);
     // get idaction of the requested action
     $idaction = $this->deriveIdAction($actionName, $actionType);
     if ($idaction < 0) {
         throw new Exception('NoDataForAction');
     }
     // prepare log aggregator
     $segment = new Segment($segment, $idSite);
     $site = new Site($idSite);
     $period = Period\Factory::build($period, $date);
     $params = new ArchiveProcessor\Parameters($site, $period, $segment);
     $logAggregator = new LogAggregator($params);
     // prepare the report
     $report = array('date' => Period\Factory::build($period->getLabel(), $date)->getLocalizedShortString());
     $partsArray = explode(',', $parts);
     if ($parts == 'all' || in_array('internalReferrers', $partsArray)) {
         $this->addInternalReferrers($logAggregator, $report, $idaction, $actionType, $limitBeforeGrouping);
     }
     if ($parts == 'all' || in_array('followingActions', $partsArray)) {
         $includeLoops = $parts != 'all' && !in_array('internalReferrers', $partsArray);
         $this->addFollowingActions($logAggregator, $report, $idaction, $actionType, $limitBeforeGrouping, $includeLoops);
     }
     if ($parts == 'all' || in_array('externalReferrers', $partsArray)) {
         $this->addExternalReferrers($logAggregator, $report, $idaction, $actionType, $limitBeforeGrouping);
     }
     // derive the number of exits from the other metrics
     if ($parts == 'all') {
         $report['pageMetrics']['exits'] = $report['pageMetrics']['pageviews'] - $this->getTotalTransitionsToFollowingActions() - $report['pageMetrics']['loops'];
     }
     // replace column names in the data tables
     $reportNames = array('previousPages' => true, 'previousSiteSearches' => false, 'followingPages' => true, 'followingSiteSearches' => false, 'outlinks' => true, 'downloads' => true);
     foreach ($reportNames as $reportName => $replaceLabel) {
         if (isset($report[$reportName])) {
             $columnNames = array(Metrics::INDEX_NB_ACTIONS => 'referrals');
             if ($replaceLabel) {
                 $columnNames[Metrics::INDEX_NB_ACTIONS] = 'referrals';
             }
             $report[$reportName]->filter('ReplaceColumnNames', array($columnNames));
         }
     }
     return $report;
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:58,代码来源:API.php

示例14: getByDayOfWeek

 /**
  * Returns datatable describing the number of visits for each day of the week.
  *
  * @param string $idSite The site ID. Cannot refer to multiple sites.
  * @param string $period The period type: day, week, year, range...
  * @param string $date The start date of the period. Cannot refer to multiple dates.
  * @param bool|string $segment The segment.
  * @throws Exception
  * @return DataTable
  */
 public function getByDayOfWeek($idSite, $period, $date, $segment = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     // metrics to query
     $metrics = Metrics::getVisitsMetricNames();
     unset($metrics[Metrics::INDEX_MAX_ACTIONS]);
     // disabled for multiple dates
     if (Period::isMultiplePeriod($date, $period)) {
         throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates.");
     }
     // get metric data for every day within the supplied period
     $oPeriod = Period\Factory::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date);
     $dateRange = $oPeriod->getDateStart()->toString() . ',' . $oPeriod->getDateEnd()->toString();
     $archive = Archive::build($idSite, 'day', $dateRange, $segment);
     // disabled for multiple sites
     if (count($archive->getParams()->getIdSites()) > 1) {
         throw new Exception("VisitTime.getByDayOfWeek does not support multiple sites.");
     }
     $dataTable = $archive->getDataTableFromNumeric($metrics)->mergeChildren();
     // if there's no data for this report, don't bother w/ anything else
     if ($dataTable->getRowsCount() == 0) {
         return $dataTable;
     }
     // group by the day of the week (see below for dayOfWeekFromDate function)
     $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\\dayOfWeekFromDate'));
     // create new datatable w/ empty rows, then add calculated datatable
     $rows = array();
     foreach (array(1, 2, 3, 4, 5, 6, 7) as $day) {
         $rows[] = array('label' => $day, 'nb_visits' => 0);
     }
     $result = new DataTable();
     $result->addRowsFromSimpleArray($rows);
     $result->addDataTable($dataTable);
     // set day of week integer as metadata
     $result->filter('ColumnCallbackAddMetadata', array('label', 'day_of_week'));
     // translate labels
     $result->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\\translateDayOfWeek'));
     // set datatable metadata for period start & finish
     $result->setMetadata('date_start', $oPeriod->getDateStart());
     $result->setMetadata('date_end', $oPeriod->getDateEnd());
     return $result;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:52,代码来源:API.php

示例15: getDateRangeForFooterMessage

 private function getDateRangeForFooterMessage()
 {
     // get query params
     $idSite = Common::getRequestVar('idSite', false);
     $date = Common::getRequestVar('date', false);
     $period = Common::getRequestVar('period', false);
     // create a period instance
     try {
         $oPeriod = Period\Factory::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date);
     } catch (\Exception $ex) {
         return '';
         // if query params are incorrect, forget about the footer message
     }
     // set the footer message using the period start & end date
     $start = $oPeriod->getDateStart()->toString();
     $end = $oPeriod->getDateEnd()->toString();
     if ($start == $end) {
         $dateRange = $start;
     } else {
         $dateRange = $start . " &ndash; " . $end;
     }
     return $dateRange;
 }
开发者ID:piwik,项目名称:piwik,代码行数:23,代码来源:GetByDayOfWeek.php


注:本文中的Piwik\Period\Factory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。