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


PHP Range::getSubperiods方法代码示例

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


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

示例1: getTemperaturesEvolution

 public function getTemperaturesEvolution($date, $period)
 {
     $temperatures = array();
     $date = Date::factory('2013-10-10', 'UTC');
     $period = new Range($period, 'last30');
     $period->setDefaultEndDate($date);
     foreach ($period->getSubperiods() as $subPeriod) {
         if (self::$disableRandomness) {
             $server1 = 50;
             $server2 = 40;
         } else {
             $server1 = mt_rand(50, 90);
             $server2 = mt_rand(40, 110);
         }
         $value = array('server1' => $server1, 'server2' => $server2);
         $temperatures[$subPeriod->getLocalizedShortString()] = $value;
     }
     return DataTable::makeFromIndexedArray($temperatures);
 }
开发者ID:piwik,项目名称:piwik,代码行数:19,代码来源:API.php

示例2: calculateEvolutionDateRange

 /**
  * Based on the period, date and evolution_{$period}_last_n query parameters,
  * calculates the date range this evolution chart will display data for.
  */
 private function calculateEvolutionDateRange()
 {
     $period = Common::getRequestVar('period');
     $defaultLastN = self::getDefaultLastN($period);
     $originalDate = Common::getRequestVar('date', 'last' . $defaultLastN, 'string');
     if ('range' != $period) {
         // show evolution limit if the period is not a range
         $this->config->show_limit_control = true;
         // set the evolution_{$period}_last_n query param
         if (Range::parseDateRange($originalDate)) {
             // if a multiple period
             // overwrite last_n param using the date range
             $oPeriod = new Range($period, $originalDate);
             $lastN = count($oPeriod->getSubperiods());
         } else {
             // if not a multiple period
             list($newDate, $lastN) = self::getDateRangeAndLastN($period, $originalDate, $defaultLastN);
             $this->requestConfig->request_parameters_to_modify['date'] = $newDate;
             $this->config->custom_parameters['dateUsedInGraph'] = $newDate;
         }
         $lastNParamName = self::getLastNParamName($period);
         $this->config->custom_parameters[$lastNParamName] = $lastN;
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:28,代码来源:Evolution.php

示例3: testRangeComma3_EndDateIncludesToday

 public function testRangeComma3_EndDateIncludesToday()
 {
     $range = new Range('day', '2008-01-01,today');
     $subPeriods = $range->getSubperiods();
     $this->assertEquals('2008-01-01', $subPeriods[0]->toString());
     $this->assertEquals('2008-01-02', $subPeriods[1]->toString());
     $this->assertEquals('2008-01-03', $subPeriods[2]->toString());
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:8,代码来源:RangeTest.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.
  * @return Archive
  */
 public static function build($idSites, $period, $strDate, $segment = false, $_restrictSitesToLogin = false)
 {
     $websiteIds = Site::getIdSitesFromIdSitesString($idSites, $_restrictSitesToLogin);
     if (Period::isMultiplePeriod($strDate, $period)) {
         $oPeriod = new Range($period, $strDate);
         $allPeriods = $oPeriod->getSubperiods();
     } else {
         $timezone = count($websiteIds) == 1 ? Site::getTimezoneFor($websiteIds[0]) : false;
         $oPeriod = Period::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);
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:35,代码来源:Archive.php


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