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


PHP Piwik\Period类代码示例

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


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

示例1: getArchiveIdAndVisits

 public static function getArchiveIdAndVisits(Site $site, Period $period, Segment $segment, $minDatetimeArchiveProcessedUTC, $requestedPlugin)
 {
     $dateStart = $period->getDateStart();
     $bindSQL = array($site->getId(), $dateStart->toString('Y-m-d'), $period->getDateEnd()->toString('Y-m-d'), $period->getId());
     $timeStampWhere = '';
     if ($minDatetimeArchiveProcessedUTC) {
         $timeStampWhere = " AND ts_archived >= ? ";
         $bindSQL[] = Date::factory($minDatetimeArchiveProcessedUTC)->getDatetime();
     }
     $pluginOrVisitsSummary = array("VisitsSummary", $requestedPlugin);
     $pluginOrVisitsSummary = array_unique($pluginOrVisitsSummary);
     $sqlWhereArchiveName = self::getNameCondition($pluginOrVisitsSummary, $segment);
     $sqlQuery = "\tSELECT idarchive, value, name, date1 as startDate\n\t\t\t\t\t\tFROM " . ArchiveTableCreator::getNumericTable($dateStart) . "``\n\t\t\t\t\t\tWHERE idsite = ?\n\t\t\t\t\t\t\tAND date1 = ?\n\t\t\t\t\t\t\tAND date2 = ?\n\t\t\t\t\t\t\tAND period = ?\n\t\t\t\t\t\t\tAND ( ({$sqlWhereArchiveName})\n\t\t\t\t\t\t\t\t  OR name = '" . self::NB_VISITS_RECORD_LOOKED_UP . "'\n\t\t\t\t\t\t\t\t  OR name = '" . self::NB_VISITS_CONVERTED_RECORD_LOOKED_UP . "')\n\t\t\t\t\t\t\t{$timeStampWhere}\n\t\t\t\t\t\tORDER BY idarchive DESC";
     $results = Db::fetchAll($sqlQuery, $bindSQL);
     if (empty($results)) {
         return false;
     }
     $idArchive = self::getMostRecentIdArchiveFromResults($segment, $requestedPlugin, $results);
     $idArchiveVisitsSummary = self::getMostRecentIdArchiveFromResults($segment, "VisitsSummary", $results);
     list($visits, $visitsConverted) = self::getVisitsMetricsFromResults($idArchive, $idArchiveVisitsSummary, $results);
     if ($visits === false && $idArchive === false) {
         return false;
     }
     return array($idArchive, $visits, $visitsConverted);
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:25,代码来源:ArchiveSelector.php

示例2: hasReportBeenPurged

 /**
  * Returns true if it is likely that the data for this report has been purged and if the
  * user should be told about that.
  *
  * In order for this function to return true, the following must also be true:
  * - The data table for this report must either be empty or not have been fetched.
  * - The period of this report is not a multiple period.
  * - The date of this report must be older than the delete_reports_older_than config option.
  * @param  DataTableInterface $dataTable
  * @return bool
  */
 public static function hasReportBeenPurged($dataTable)
 {
     $strPeriod = Common::getRequestVar('period', false);
     $strDate = Common::getRequestVar('date', false);
     if (false !== $strPeriod && false !== $strDate && (is_null($dataTable) || !empty($dataTable) && $dataTable->getRowsCount() == 0)) {
         // if range, only look at the first date
         if ($strPeriod == 'range') {
             $idSite = Common::getRequestVar('idSite', '');
             if (intval($idSite) != 0) {
                 $site = new Site($idSite);
                 $timezone = $site->getTimezone();
             } else {
                 $timezone = 'UTC';
             }
             $period = new Range('range', $strDate, $timezone);
             $reportDate = $period->getDateStart();
         } elseif (Period::isMultiplePeriod($strDate, $strPeriod)) {
             // if a multiple period, this function is irrelevant
             return false;
         } else {
             // otherwise, use the date as given
             $reportDate = Date::factory($strDate);
         }
         $reportYear = $reportDate->toString('Y');
         $reportMonth = $reportDate->toString('m');
         if (static::shouldReportBePurged($reportYear, $reportMonth)) {
             return true;
         }
     }
     return false;
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:42,代码来源:PrivacyManager.php

示例3: getRowEvolution

 public function getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label = false, $segment = false, $column = false, $language = false, $idGoal = false, $legendAppendMetric = true, $labelUseAbsoluteUrl = true)
 {
     // validation of requested $period & $date
     if ($period == 'range') {
         // load days in the range
         $period = 'day';
     }
     if (!Period::isMultiplePeriod($date, $period)) {
         throw new Exception("Row evolutions can not be processed with this combination of \\'date\\' and \\'period\\' parameters.");
     }
     $label = ResponseBuilder::unsanitizeLabelParameter($label);
     $labels = Piwik::getArrayFromApiParameter($label);
     $metadata = $this->getRowEvolutionMetaData($idSite, $period, $date, $apiModule, $apiAction, $language, $idGoal);
     $dataTable = $this->loadRowEvolutionDataFromAPI($metadata, $idSite, $period, $date, $apiModule, $apiAction, $labels, $segment, $idGoal);
     if (empty($labels)) {
         $labels = $this->getLabelsFromDataTable($dataTable, $labels);
         $dataTable = $this->enrichRowAddMetadataLabelIndex($labels, $dataTable);
     }
     if (count($labels) != 1) {
         $data = $this->getMultiRowEvolution($dataTable, $metadata, $apiModule, $apiAction, $labels, $column, $legendAppendMetric, $labelUseAbsoluteUrl);
     } else {
         $data = $this->getSingleRowEvolution($idSite, $dataTable, $metadata, $apiModule, $apiAction, $labels[0], $labelUseAbsoluteUrl);
     }
     return $data;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:25,代码来源:RowEvolution.php

示例4: generate

 /**
  * Generates the subperiods (one for each day in the month)
  */
 protected function generate()
 {
     if ($this->subperiodsProcessed) {
         return;
     }
     parent::generate();
     $date = $this->date;
     $startMonth = $date->setDay(1)->setTime('00:00:00');
     $endMonth = $startMonth->addPeriod(1, 'month')->setDay(1)->subDay(1);
     $this->processOptimalSubperiods($startMonth, $endMonth);
 }
开发者ID:jniebuhr,项目名称:piwik,代码行数:14,代码来源:Month.php

示例5: 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($period, $date);
     $params = new ArchiveProcessor\Parameters($site, $period, $segment);
     $logAggregator = new LogAggregator($params);
     // prepare the report
     $report = array('date' => Period::factory($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:KiwiJuicer,项目名称:handball-dachau,代码行数:58,代码来源:API.php

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

示例7: build

 /**
  * Creates a new Period instance with a period ID and {@link Date} instance.
  *
  * _Note: This method cannot create {@link Period\Range} periods._
  *
  * @param string $period `"day"`, `"week"`, `"month"`, `"year"`, `"range"`.
  * @param Date|string $date A date within the period or the range of dates.
  * @param Date|string $timezone Optional timezone that will be used only when $period is 'range' or $date is 'last|previous'
  * @throws Exception If `$strPeriod` is invalid.
  * @return \Piwik\Period
  */
 public static function build($period, $date, $timezone = 'UTC')
 {
     self::checkPeriodIsEnabled($period);
     if (is_string($date)) {
         if (Period::isMultiplePeriod($date, $period) || $period == 'range') {
             return new Range($period, $date, $timezone);
         }
         $date = Date::factory($date);
     }
     switch ($period) {
         case 'day':
             return new Day($date);
             break;
         case 'week':
             return new Week($date);
             break;
         case 'month':
             return new Month($date);
             break;
         case 'year':
             return new Year($date);
             break;
     }
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:35,代码来源:Factory.php

示例8: fillArraySubPeriods

 /**
  * Adds new subperiods
  *
  * @param Date $startDate
  * @param Date $endDate
  * @param string $period
  */
 protected function fillArraySubPeriods($startDate, $endDate, $period)
 {
     $arrayPeriods = array();
     $endSubperiod = Period::factory($period, $endDate);
     $arrayPeriods[] = $endSubperiod;
     // set end date to start of end period since we're comparing against start date.
     $endDate = $endSubperiod->getDateStart();
     while ($endDate->isLater($startDate)) {
         $endDate = $endDate->addPeriod(-1, $period);
         $subPeriod = Period::factory($period, $endDate);
         $arrayPeriods[] = $subPeriod;
     }
     $arrayPeriods = array_reverse($arrayPeriods);
     foreach ($arrayPeriods as $period) {
         $this->addSubperiod($period);
     }
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:24,代码来源:Range.php

示例9: isRequestingSingleDataTable

 /**
  * Returns `true` if this instance will request a single DataTable, `false` if requesting
  * more than one.
  *
  * @return bool
  */
 public function isRequestingSingleDataTable()
 {
     $requestArray = $this->request->getRequestArray() + $_GET + $_POST;
     $date = Common::getRequestVar('date', null, 'string', $requestArray);
     $period = Common::getRequestVar('period', null, 'string', $requestArray);
     $idSite = Common::getRequestVar('idSite', null, 'string', $requestArray);
     if (Period::isMultiplePeriod($date, $period) || strpos($idSite, ',') !== false || $idSite == 'all') {
         return false;
     }
     return true;
 }
开发者ID:hichnik,项目名称:piwik,代码行数:17,代码来源:ViewDataTable.php

示例10: testValidate_InvalidDates

 /**
  * @expectedException \Exception
  * @expectedExceptionMessage General_ExceptionInvalidDateFormat
  * @dataProvider getInvalidDateFormats
  */
 public function testValidate_InvalidDates($invalidDateFormat)
 {
     Period::checkDateFormat($invalidDateFormat);
 }
开发者ID:qiuai,项目名称:piwik,代码行数:9,代码来源:PeriodTest.php

示例11: prepareArchive

 /**
  * @param $archiveGroups
  * @param $site
  * @param $period
  */
 private function prepareArchive(array $archiveGroups, Site $site, Period $period)
 {
     $parameters = new ArchiveProcessor\Parameters($site, $period, $this->params->getSegment(), $this->params->isSkipAggregationOfSubTables());
     $archiveLoader = new ArchiveProcessor\Loader($parameters);
     $periodString = $period->getRangeString();
     // process for each plugin as well
     foreach ($archiveGroups as $plugin) {
         $doneFlag = $this->getDoneStringForPlugin($plugin);
         $this->initializeArchiveIdCache($doneFlag);
         $idArchive = $archiveLoader->prepareArchive($plugin);
         if ($idArchive) {
             $this->idarchives[$doneFlag][$periodString][] = $idArchive;
         }
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:20,代码来源:Archive.php

示例12: makeSureToWorkOnFirstLevelDataTable

 private function makeSureToWorkOnFirstLevelDataTable($table)
 {
     if (!array_key_exists('idSubtable', $this->request)) {
         return $table;
     }
     $firstLevelReport = $this->findFirstLevelReport();
     if (empty($firstLevelReport)) {
         // it is not a subtable report
         $module = $this->apiModule;
         $action = $this->apiMethod;
     } else {
         $module = $firstLevelReport->getModule();
         $action = $firstLevelReport->getAction();
     }
     $request = $this->request;
     /** @var \Piwik\Period $period */
     $period = $table->getMetadata('period');
     if (!empty($period)) {
         // we want a dataTable, not a dataTable\map
         if (Period::isMultiplePeriod($request['date'], $request['period']) || 'range' == $period->getLabel()) {
             $request['date'] = $period->getRangeString();
             $request['period'] = 'range';
         } else {
             $request['date'] = $period->getDateStart()->toString();
             $request['period'] = $period->getLabel();
         }
     }
     $table = $this->callApiAndReturnDataTable($module, $action, $request);
     if ($table instanceof DataTable\Map) {
         $table = $table->mergeChildren();
     }
     return $table;
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:33,代码来源:ReportTotalsCalculator.php

示例13: getDateRangeForPeriod

 /**
  * Returns start & end dates for the range described by a period and optional lastN
  * argument.
  *
  * @param string|bool $date The start date of the period (or the date range of a range
  *                           period).
  * @param string $period The period type ('day', 'week', 'month', 'year' or 'range').
  * @param bool|int $lastN Whether to include the last N periods in the range or not.
  *                         Ignored if period == range.
  *
  * @return Date[]   array of Date objects or array(false, false)
  * @ignore
  */
 public static function getDateRangeForPeriod($date, $period, $lastN = false)
 {
     if ($date === false) {
         return array(false, false);
     }
     // if the range is just a normal period (or the period is a range in which case lastN is ignored)
     if ($lastN === false || $period == 'range') {
         if ($period == 'range') {
             $oPeriod = new Range('day', $date);
         } else {
             $oPeriod = Period::factory($period, Date::factory($date));
         }
         $startDate = $oPeriod->getDateStart();
         $endDate = $oPeriod->getDateEnd();
     } else {
         list($date, $lastN) = EvolutionViz::getDateRangeAndLastN($period, $date, $lastN);
         list($startDate, $endDate) = explode(',', $date);
         $startDate = Date::factory($startDate);
         $endDate = Date::factory($endDate);
     }
     return array($startDate, $endDate);
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:35,代码来源:API.php

示例14: getCalendarPrettyDate

 /**
  * Returns a prettified date string for use in period selector widget.
  *
  * @param Period $period The period to return a pretty string for.
  * @return string
  * @api
  */
 public static function getCalendarPrettyDate($period)
 {
     if ($period instanceof Month) {
         // show month name when period is for a month
         return $period->getLocalizedLongString();
     } else {
         return $period->getPrettyString();
     }
 }
开发者ID:piwik,项目名称:piwik,代码行数:16,代码来源:Controller.php

示例15: getProcessedReport

 public function getProcessedReport($idSite, $period, $date, $apiModule, $apiAction, $segment = false, $apiParameters = false, $idGoal = false, $language = false, $showTimer = true, $hideMetricsDoc = false, $idSubtable = false, $showRawMetrics = false)
 {
     $timer = new Timer();
     if (empty($apiParameters)) {
         $apiParameters = array();
     }
     if (!empty($idGoal) && empty($apiParameters['idGoal'])) {
         $apiParameters['idGoal'] = $idGoal;
     }
     // Is this report found in the Metadata available reports?
     $reportMetadata = $this->getMetadata($idSite, $apiModule, $apiAction, $apiParameters, $language, $period, $date, $hideMetricsDoc, $showSubtableReports = true);
     if (empty($reportMetadata)) {
         throw new Exception("Requested report {$apiModule}.{$apiAction} for Website id={$idSite} not found in the list of available reports. \n");
     }
     $reportMetadata = reset($reportMetadata);
     // Generate Api call URL passing custom parameters
     $parameters = array_merge($apiParameters, array('method' => $apiModule . '.' . $apiAction, 'idSite' => $idSite, 'period' => $period, 'date' => $date, 'format' => 'original', 'serialize' => '0', 'language' => $language, 'idSubtable' => $idSubtable));
     if (!empty($segment)) {
         $parameters['segment'] = $segment;
     }
     $url = Url::getQueryStringFromParameters($parameters);
     $request = new Request($url);
     try {
         /** @var DataTable */
         $dataTable = $request->process();
     } catch (Exception $e) {
         throw new Exception("API returned an error: " . $e->getMessage() . " at " . basename($e->getFile()) . ":" . $e->getLine() . "\n");
     }
     list($newReport, $columns, $rowsMetadata, $totals) = $this->handleTableReport($idSite, $dataTable, $reportMetadata, $showRawMetrics);
     foreach ($columns as $columnId => &$name) {
         $name = ucfirst($name);
     }
     $website = new Site($idSite);
     $period = Period::factory($period, $date);
     $period = $period->getLocalizedLongString();
     $return = array('website' => $website->getName(), 'prettyDate' => $period, 'metadata' => $reportMetadata, 'columns' => $columns, 'reportData' => $newReport, 'reportMetadata' => $rowsMetadata, 'reportTotal' => $totals);
     if ($showTimer) {
         $return['timerMillis'] = $timer->getTimeMs(0);
     }
     return $return;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:41,代码来源:ProcessedReport.php


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