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


PHP Factory::build方法代码示例

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


在下文中一共展示了Factory::build方法的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: 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

示例3: _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

示例4: __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

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

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

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

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

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

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

示例11: getWhereClauseAndBind

 /**
  * @param string $whereClause
  * @param array $bindIdSites
  * @param $idSite
  * @param $period
  * @param $date
  * @param $visitorId
  * @param $minTimestamp
  * @return array
  * @throws Exception
  */
 private function getWhereClauseAndBind($whereClause, $bindIdSites, $idSite, $period, $date, $visitorId, $minTimestamp)
 {
     $where = array();
     $where[] = $whereClause;
     $whereBind = $bindIdSites;
     if (!empty($visitorId)) {
         $where[] = "log_visit.idvisitor = ? ";
         $whereBind[] = @Common::hex2bin($visitorId);
     }
     if (!empty($minTimestamp)) {
         $where[] = "log_visit.visit_last_action_time > ? ";
         $whereBind[] = date("Y-m-d H:i:s", $minTimestamp);
     }
     // SQL Filter with provided period
     if (!empty($period) && !empty($date)) {
         $currentSite = $this->makeSite($idSite);
         $currentTimezone = $currentSite->getTimezone();
         $dateString = $date;
         if ($period == 'range') {
             $processedPeriod = new Range('range', $date);
             if ($parsedDate = Range::parseDateRange($date)) {
                 $dateString = $parsedDate[2];
             }
         } else {
             $processedDate = Date::factory($date);
             $processedPeriod = Period\Factory::build($period, $processedDate);
         }
         $dateStart = $processedPeriod->getDateStart()->setTimezone($currentTimezone);
         $where[] = "log_visit.visit_last_action_time >= ?";
         $whereBind[] = $dateStart->toString('Y-m-d H:i:s');
         if (!in_array($date, array('now', 'today', 'yesterdaySameTime')) && strpos($date, 'last') === false && strpos($date, 'previous') === false && Date::factory($dateString)->toString('Y-m-d') != Date::factory('now', $currentTimezone)->toString()) {
             $dateEnd = $processedPeriod->getDateEnd()->setTimezone($currentTimezone);
             $where[] = " log_visit.visit_last_action_time <= ?";
             $dateEndString = $dateEnd->addDay(1)->toString('Y-m-d H:i:s');
             $whereBind[] = $dateEndString;
         }
     }
     if (count($where) > 0) {
         $where = join("\n\t\t\t\tAND ", $where);
     } else {
         $where = false;
     }
     return array($whereBind, $where);
 }
开发者ID:piwik,项目名称:piwik,代码行数:55,代码来源:Model.php

示例12: makePeriodFromQueryParams

 /**
  * Creates a Period instance using a period, date and timezone.
  *
  * @param string $timezone The timezone of the date. Only used if `$date` is `'now'`, `'today'`,
  *                         `'yesterday'` or `'yesterdaySameTime'`.
  * @param string $period The period string: `"day"`, `"week"`, `"month"`, `"year"`, `"range"`.
  * @param string $date The date or date range string. Can be a special value including
  *                     `'now'`, `'today'`, `'yesterday'`, `'yesterdaySameTime'`.
  * @return \Piwik\Period
  */
 public static function makePeriodFromQueryParams($timezone, $period, $date)
 {
     if (empty($timezone)) {
         $timezone = 'UTC';
     }
     if ($period == 'range') {
         self::checkPeriodIsEnabled('range');
         $oPeriod = new Range('range', $date, $timezone, Date::factory('today', $timezone));
     } else {
         if (!$date instanceof Date) {
             if ($date == 'now' || $date == 'today') {
                 $date = date('Y-m-d', Date::factory('now', $timezone)->getTimestamp());
             } elseif ($date == 'yesterday' || $date == 'yesterdaySameTime') {
                 $date = date('Y-m-d', Date::factory('now', $timezone)->subDay(1)->getTimestamp());
             }
             $date = Date::factory($date);
         }
         $oPeriod = Factory::build($period, $date);
     }
     return $oPeriod;
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:31,代码来源:Factory.php

示例13: factory

 /**
  * @deprecated Use Factory::build instead
  * @param $period
  * @param $date
  * @return Period
  */
 public static function factory($period, $date)
 {
     return Factory::build($period, $date);
 }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:10,代码来源:Period.php

示例14: renderHeader

 /**
  * Sends the http headers for csv file
  */
 protected function renderHeader()
 {
     $fileName = 'Piwik ' . Piwik::translate('General_Export');
     $period = Common::getRequestVar('period', false);
     $date = Common::getRequestVar('date', false);
     if ($period || $date) {
         if ($period == 'range') {
             $period = new Range($period, $date);
         } else {
             if (strpos($date, ',') !== false) {
                 $period = new Range('range', $date);
             } else {
                 $period = Period\Factory::build($period, Date::factory($date));
             }
         }
         $prettyDate = $period->getLocalizedLongString();
         $meta = $this->getApiMetaData();
         $fileName .= ' _ ' . $meta['name'] . ' _ ' . $prettyDate . '.csv';
     }
     // silent fail otherwise unit tests fail
     Common::sendHeader('Content-Disposition: attachment; filename="' . $fileName . '"', true);
     ProxyHttp::overrideCacheControlHeaders();
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:26,代码来源:Csv.php

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


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