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


PHP Factory::makePeriodFromQueryParams方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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 . " – " . $end;
     }
     return $dateRange;
 }
开发者ID:piwik,项目名称:piwik,代码行数:23,代码来源:GetByDayOfWeek.php

示例4: build

 /**
  * Returns a new Archive instance that will query archive data for the given set of
  * sites and periods, using an optional Segment.
  *
  * This method uses data that is found in query parameters, so the parameters to this
  * function can be string values.
  *
  * If you want to create an Archive instance with an array of Period instances, use
  * {@link Archive::factory()}.
  *
  * @param string|int|array $idSites A single ID (eg, `'1'`), multiple IDs (eg, `'1,2,3'` or `array(1, 2, 3)`),
  *                                  or `'all'`.
  * @param string $period 'day', `'week'`, `'month'`, `'year'` or `'range'`
  * @param Date|string $strDate 'YYYY-MM-DD', magic keywords (ie, 'today'; {@link Date::factory()}
  *                             or date range (ie, 'YYYY-MM-DD,YYYY-MM-DD').
  * @param bool|false|string $segment Segment definition or false if no segment should be used. {@link Piwik\Segment}
  * @param bool|false|string $_restrictSitesToLogin Used only when running as a scheduled task.
  * @param bool $skipAggregationOfSubTables Whether the archive, when it is processed, should also aggregate all sub-tables
  * @return Archive
  */
 public static function build($idSites, $period, $strDate, $segment = false, $_restrictSitesToLogin = false, $skipAggregationOfSubTables = false)
 {
     $websiteIds = Site::getIdSitesFromIdSitesString($idSites, $_restrictSitesToLogin);
     if (Period::isMultiplePeriod($strDate, $period)) {
         $oPeriod = Factory::build($period, $strDate);
         $allPeriods = $oPeriod->getSubperiods();
     } else {
         $timezone = count($websiteIds) == 1 ? Site::getTimezoneFor($websiteIds[0]) : false;
         $oPeriod = Factory::makePeriodFromQueryParams($timezone, $period, $strDate);
         $allPeriods = array($oPeriod);
     }
     $segment = new Segment($segment, $websiteIds);
     $idSiteIsAll = $idSites == self::REQUEST_ALL_WEBSITES_FLAG;
     $isMultipleDate = Period::isMultiplePeriod($strDate, $period);
     return Archive::factory($segment, $allPeriods, $websiteIds, $idSiteIsAll, $isMultipleDate, $skipAggregationOfSubTables);
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:36,代码来源:Archive.php

示例5: createArchiveBlobEntry

 private function createArchiveBlobEntry($date, $blobs)
 {
     $oPeriod = PeriodFactory::makePeriodFromQueryParams('UTC', 'day', $date);
     $segment = new Segment(false, array(1));
     $params = new Parameters(new Site(1), $oPeriod, $segment);
     $writer = new ArchiveWriter($params, false);
     $writer->initNewArchive();
     foreach ($blobs as $name => $blob) {
         $writer->insertBlobRecord($name, $blob);
     }
     $writer->finalizeArchive();
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:12,代码来源:ArchiveTest.php


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