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


PHP Range::getRelativeToEndDate方法代码示例

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


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

示例1: getGraphParamsModified

 /**
  * Returns the array of new processed parameters once the parameters are applied.
  * For example: if you set range=last30 and date=2008-03-10,
  *  the date element of the returned array will be "2008-02-10,2008-03-10"
  *
  * Parameters you can set:
  * - range: last30, previous10, etc.
  * - date: YYYY-MM-DD, today, yesterday
  * - period: day, week, month, year
  *
  * @param array $paramsToSet array( 'date' => 'last50', 'viewDataTable' =>'sparkline' )
  * @throws \Piwik\NoAccessException
  * @return array
  */
 protected function getGraphParamsModified($paramsToSet = array())
 {
     if (!isset($paramsToSet['period'])) {
         $period = Common::getRequestVar('period');
     } else {
         $period = $paramsToSet['period'];
     }
     if ($period == 'range') {
         return $paramsToSet;
     }
     if (!isset($paramsToSet['range'])) {
         $range = 'last30';
     } else {
         $range = $paramsToSet['range'];
     }
     if (!isset($paramsToSet['date'])) {
         $endDate = $this->strDate;
     } else {
         $endDate = $paramsToSet['date'];
     }
     if (is_null($this->site)) {
         throw new NoAccessException("Website not initialized, check that you are logged in and/or using the correct token_auth.");
     }
     $paramDate = Range::getRelativeToEndDate($period, $range, $endDate, $this->site);
     $params = array_merge($paramsToSet, array('date' => $paramDate));
     return $params;
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:41,代码来源:Controller.php

示例2: getReportMetadata

 /**
  * @param array $reports
  * @param array $info
  * @return mixed
  */
 public function getReportMetadata(&$reports, $info)
 {
     $idSites = $info['idSites'];
     // If only one website is selected, we add the Graph URL
     if (count($idSites) != 1) {
         return;
     }
     $idSite = reset($idSites);
     // in case API.getReportMetadata was not called with date/period we use sane defaults
     if (empty($info['period'])) {
         $info['period'] = 'day';
     }
     if (empty($info['date'])) {
         $info['date'] = 'today';
     }
     // need two sets of period & date, one for single period graphs, one for multiple periods graphs
     if (Period::isMultiplePeriod($info['date'], $info['period'])) {
         $periodForMultiplePeriodGraph = $info['period'];
         $dateForMultiplePeriodGraph = $info['date'];
         $periodForSinglePeriodGraph = 'range';
         $dateForSinglePeriodGraph = $info['date'];
     } else {
         $periodForSinglePeriodGraph = $info['period'];
         $dateForSinglePeriodGraph = $info['date'];
         $piwikSite = new Site($idSite);
         if ($periodForSinglePeriodGraph == 'range') {
             // for period=range, show the configured sub-periods
             $periodForMultiplePeriodGraph = Config::getInstance()->General['graphs_default_period_to_plot_when_period_range'];
             $dateForMultiplePeriodGraph = $dateForSinglePeriodGraph;
         } else {
             if ($info['period'] == 'day' || !Config::getInstance()->General['graphs_show_evolution_within_selected_period']) {
                 // for period=day, always show the last n days
                 // if graphs_show_evolution_within_selected_period=false, show the last n periods
                 $periodForMultiplePeriodGraph = $periodForSinglePeriodGraph;
                 $dateForMultiplePeriodGraph = Range::getRelativeToEndDate($periodForSinglePeriodGraph, 'last' . self::GRAPH_EVOLUTION_LAST_PERIODS, $dateForSinglePeriodGraph, $piwikSite);
             } else {
                 // if graphs_show_evolution_within_selected_period=true, show the days within the period
                 // (except if the period is day, see above)
                 $periodForMultiplePeriodGraph = 'day';
                 $period = PeriodFactory::build($info['period'], $info['date']);
                 $start = $period->getDateStart()->toString();
                 $end = $period->getDateEnd()->toString();
                 $dateForMultiplePeriodGraph = $start . ',' . $end;
             }
         }
     }
     $token_auth = Common::getRequestVar('token_auth', false);
     $segment = Request::getRawSegmentFromRequest();
     /** @var Scheduler $scheduler */
     $scheduler = StaticContainer::getContainer()->get('Piwik\\Scheduler\\Scheduler');
     $isRunningTask = $scheduler->isRunningTask();
     // add the idSubtable if it exists
     $idSubtable = Common::getRequestVar('idSubtable', false);
     $urlPrefix = "index.php?";
     foreach ($reports as &$report) {
         $reportModule = $report['module'];
         $reportAction = $report['action'];
         $reportUniqueId = $reportModule . '_' . $reportAction;
         $parameters = array();
         $parameters['module'] = 'API';
         $parameters['method'] = 'ImageGraph.get';
         $parameters['idSite'] = $idSite;
         $parameters['apiModule'] = $reportModule;
         $parameters['apiAction'] = $reportAction;
         if (!empty($token_auth)) {
             $parameters['token_auth'] = $token_auth;
         }
         // Forward custom Report parameters to the graph URL
         if (!empty($report['parameters'])) {
             $parameters = array_merge($parameters, $report['parameters']);
         }
         if (empty($report['dimension'])) {
             $parameters['period'] = $periodForMultiplePeriodGraph;
             $parameters['date'] = $dateForMultiplePeriodGraph;
         } else {
             $parameters['period'] = $periodForSinglePeriodGraph;
             $parameters['date'] = $dateForSinglePeriodGraph;
         }
         if ($idSubtable !== false) {
             $parameters['idSubtable'] = $idSubtable;
         }
         if (!empty($_GET['_restrictSitesToLogin']) && $isRunningTask) {
             $parameters['_restrictSitesToLogin'] = $_GET['_restrictSitesToLogin'];
         }
         if (!empty($segment)) {
             $parameters['segment'] = $segment;
         }
         $report['imageGraphUrl'] = $urlPrefix . Url::getQueryStringFromParameters($parameters);
         // thanks to API.getRowEvolution, reports with dimensions can now be plotted using an evolution graph
         // however, most reports with a fixed set of dimension values are excluded
         // this is done so Piwik Mobile and Scheduled Reports do not display them
         $reportWithDimensionsSupportsEvolution = empty($report['constantRowsCount']) || in_array($reportUniqueId, self::$CONSTANT_ROW_COUNT_REPORT_EXCEPTIONS);
         $reportSupportsEvolution = !in_array($reportUniqueId, self::$REPORTS_DISABLED_EVOLUTION_GRAPH);
         if ($reportSupportsEvolution && $reportWithDimensionsSupportsEvolution) {
             $parameters['period'] = $periodForMultiplePeriodGraph;
//.........这里部分代码省略.........
开发者ID:diosmosis,项目名称:piwik,代码行数:101,代码来源:ImageGraph.php

示例3: getDateRangeAndLastN

 /**
  * Returns the entire date range and lastN value for the current request, based on
  * a period type and end date.
  *
  * @param string $period The period type, 'day', 'week', 'month' or 'year'
  * @param string $endDate The end date.
  * @param int|null $defaultLastN The default lastN to use. If null, the result of
  *                               getDefaultLastN is used.
  * @return array An array w/ two elements. The first is a whole date range and the second
  *               is the lastN number used, ie, array('2010-01-01,2012-01-02', 2).
  */
 public static function getDateRangeAndLastN($period, $endDate, $defaultLastN = null)
 {
     if ($defaultLastN === null) {
         $defaultLastN = self::getDefaultLastN($period);
     }
     $lastNParamName = self::getLastNParamName($period);
     $lastN = Common::getRequestVar($lastNParamName, $defaultLastN, 'int');
     $site = new Site(Common::getRequestVar('idSite'));
     $dateRange = Range::getRelativeToEndDate($period, 'last' . $lastN, $endDate, $site);
     return array($dateRange, $lastN);
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:22,代码来源:Evolution.php

示例4: getReportMetadata

 /**
  * @param array $reports
  * @param array $info
  * @return mixed
  */
 public function getReportMetadata(&$reports, $info)
 {
     $idSites = $info['idSites'];
     // If only one website is selected, we add the Graph URL
     if (count($idSites) != 1) {
         return;
     }
     $idSite = reset($idSites);
     // in case API.getReportMetadata was not called with date/period we use sane defaults
     if (empty($info['period'])) {
         $info['period'] = 'day';
     }
     if (empty($info['date'])) {
         $info['date'] = 'today';
     }
     // need two sets of period & date, one for single period graphs, one for multiple periods graphs
     if (Period::isMultiplePeriod($info['date'], $info['period'])) {
         $periodForMultiplePeriodGraph = $info['period'];
         $dateForMultiplePeriodGraph = $info['date'];
         $periodForSinglePeriodGraph = 'range';
         $dateForSinglePeriodGraph = $info['date'];
     } else {
         $periodForSinglePeriodGraph = $info['period'];
         $dateForSinglePeriodGraph = $info['date'];
         $piwikSite = new Site($idSite);
         if ($periodForSinglePeriodGraph == 'range') {
             $periodForMultiplePeriodGraph = Config::getInstance()->General['graphs_default_period_to_plot_when_period_range'];
             $dateForMultiplePeriodGraph = $dateForSinglePeriodGraph;
         } else {
             $periodForMultiplePeriodGraph = $periodForSinglePeriodGraph;
             $dateForMultiplePeriodGraph = Range::getRelativeToEndDate($periodForSinglePeriodGraph, 'last' . self::GRAPH_EVOLUTION_LAST_PERIODS, $dateForSinglePeriodGraph, $piwikSite);
         }
     }
     $token_auth = Common::getRequestVar('token_auth', false);
     $urlPrefix = "index.php?";
     foreach ($reports as &$report) {
         $reportModule = $report['module'];
         $reportAction = $report['action'];
         $reportUniqueId = $reportModule . '_' . $reportAction;
         $parameters = array();
         $parameters['module'] = 'API';
         $parameters['method'] = 'ImageGraph.get';
         $parameters['idSite'] = $idSite;
         $parameters['apiModule'] = $reportModule;
         $parameters['apiAction'] = $reportAction;
         if (!empty($token_auth)) {
             $parameters['token_auth'] = $token_auth;
         }
         // Forward custom Report parameters to the graph URL
         if (!empty($report['parameters'])) {
             $parameters = array_merge($parameters, $report['parameters']);
         }
         if (empty($report['dimension'])) {
             $parameters['period'] = $periodForMultiplePeriodGraph;
             $parameters['date'] = $dateForMultiplePeriodGraph;
         } else {
             $parameters['period'] = $periodForSinglePeriodGraph;
             $parameters['date'] = $dateForSinglePeriodGraph;
         }
         // add the idSubtable if it exists
         $idSubtable = Common::getRequestVar('idSubtable', false);
         if ($idSubtable !== false) {
             $parameters['idSubtable'] = $idSubtable;
         }
         if (!empty($_GET['_restrictSitesToLogin']) && TaskScheduler::isTaskBeingExecuted()) {
             $parameters['_restrictSitesToLogin'] = $_GET['_restrictSitesToLogin'];
         }
         $report['imageGraphUrl'] = $urlPrefix . Url::getQueryStringFromParameters($parameters);
         // thanks to API.getRowEvolution, reports with dimensions can now be plotted using an evolution graph
         // however, most reports with a fixed set of dimension values are excluded
         // this is done so Piwik Mobile and Scheduled Reports do not display them
         $reportWithDimensionsSupportsEvolution = empty($report['constantRowsCount']) || in_array($reportUniqueId, self::$CONSTANT_ROW_COUNT_REPORT_EXCEPTIONS);
         $reportSupportsEvolution = !in_array($reportUniqueId, self::$REPORTS_DISABLED_EVOLUTION_GRAPH);
         if ($reportSupportsEvolution && $reportWithDimensionsSupportsEvolution) {
             $parameters['period'] = $periodForMultiplePeriodGraph;
             $parameters['date'] = $dateForMultiplePeriodGraph;
             $report['imageGraphEvolutionUrl'] = $urlPrefix . Url::getQueryStringFromParameters($parameters);
         }
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:85,代码来源:ImageGraph.php


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