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


PHP Piwik\Archive类代码示例

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


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

示例1: getNumeric

 protected function getNumeric($idSite, $period, $date, $segment, $toFetch)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $archive = Archive::build($idSite, $period, $date, $segment);
     $dataTable = $archive->getDataTableFromNumeric($toFetch);
     return $dataTable;
 }
开发者ID:piwik,项目名称:piwik,代码行数:7,代码来源:API.php

示例2: getDataTable

 private function getDataTable($name, $idSite, $period, $date, $segment, $expanded, $idSubtable)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $recordName = Dimensions::getRecordNameForAction($name);
     $dataTable = Archive::getDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded, $idSubtable);
     $this->filterDataTable($dataTable);
     return $dataTable;
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:8,代码来源:API.php

示例3: getDataTable

 /**
  * @param int $idSite
  * @param string $period
  * @param Date $date
  * @param string $segment
  * @param bool $expanded
  * @param int $idSubtable
  *
  * @return DataTable|DataTable\Map
  */
 protected function getDataTable($idSite, $period, $date, $segment, $expanded, $idSubtable)
 {
     $dataTable = Archive::getDataTableFromArchive(Archiver::CUSTOM_VARIABLE_RECORD_NAME, $idSite, $period, $date, $segment, $expanded, $idSubtable);
     $dataTable->filter('Sort', array(Metrics::INDEX_NB_ACTIONS, 'desc', $naturalSort = false, $expanded));
     $dataTable->queueFilter('ReplaceColumnNames');
     $dataTable->queueFilter('ColumnDelete', 'nb_uniq_visitors');
     return $dataTable;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:18,代码来源:API.php

示例4: testArchiveSitesWhenRestrictingToLogin

 /**
  * Test that restricting the number of sites to those viewable to another login
  * works when building an archive query object.
  * 
  * @group        Integration
  */
 public function testArchiveSitesWhenRestrictingToLogin()
 {
     try {
         Archive::build('all', 'day', self::$fixture->dateTime, $segment = false, $_restrictToLogin = 'anotherLogin');
         $this->fail("Restricting sites to invalid login did not return 0 sites.");
     } catch (Exception $ex) {
         // pass
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:15,代码来源:OneVisitorTwoVisitsTest.php

示例5: getDataTable

 /**
  * @param string $name
  * @param int $idSite
  * @param string $period
  * @param string $date
  * @param string $segment
  * @return DataTable
  */
 protected function getDataTable($name, $idSite, $period, $date, $segment)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $archive = Archive::build($idSite, $period, $date, $segment);
     $dataTable = $archive->getDataTable($name);
     $dataTable->queueFilter('ReplaceColumnNames');
     $dataTable->queueFilter('ReplaceSummaryRowLabel');
     return $dataTable;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:17,代码来源:API.php

示例6: getUsers

 /**
  * Get a report of all User Ids.
  *
  * @param int $idSite
  *
  * @param string  $period
  * @param int  $date
  * @param string|bool  $segment
  *
  * @return DataTable
  */
 public function getUsers($idSite, $period, $date, $segment = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $archive = Archive::build($idSite, $period, $date, $segment);
     $dataTable = $archive->getDataTable(Archiver::USERID_ARCHIVE_RECORD);
     $dataTable->queueFilter('ReplaceColumnNames');
     $dataTable->queueFilter('ReplaceSummaryRowLabel');
     return $dataTable;
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:20,代码来源:API.php

示例7: getEvenUnevenTimes

 /**
  * API method that returns number of visits based on hour parity.
  * @param int    $idSite
  * @param string $period
  * @param string $date
  * @param bool|string $segment
  * @return DataTable
  */
 public function getEvenUnevenTimes($idSite, $period, $date, $segment = false)
 {
     $archive = Archive::build($idSite, $period, $date);
     $oddHoursCount = $archive->getNumeric(Archiver::ODD_HOURS_COUNT_RECORD_NAME);
     $evenHoursCount = $archive->getNumeric(Archiver::EVEN_HOURS_COUNT_RECORD_NAME);
     $table = new DataTable();
     $table->setTableSortedBy('times');
     $table->addRowFromArray(array(Row::COLUMNS => array('times' => Piwik::translate('HourParity_Oddhours'), 'nb_visits' => $oddHoursCount)));
     $table->addRowFromArray(array(Row::COLUMNS => array('times' => Piwik::translate('HourParity_Evenhours'), 'nb_visits' => $evenHoursCount)));
     return $table;
 }
开发者ID:MichalKrakiewicz,项目名称:HourParity,代码行数:19,代码来源:API.php

示例8: getProvider

 public function getProvider($idSite, $period, $date, $segment = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $archive = Archive::build($idSite, $period, $date, $segment);
     $dataTable = $archive->getDataTable(Archiver::PROVIDER_RECORD_NAME);
     $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'url', __NAMESPACE__ . '\\getHostnameUrl'));
     $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\\getPrettyProviderName'));
     $dataTable->queueFilter('ReplaceColumnNames');
     $dataTable->queueFilter('ReplaceSummaryRowLabel');
     return $dataTable;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:11,代码来源:API.php

示例9: getPlugin

 public function getPlugin($idSite, $period, $date, $segment = false)
 {
     // fetch all archive data required
     $dataTable = $this->getDataTable(Archiver::PLUGIN_RECORD_NAME, $idSite, $period, $date, $segment);
     $browserVersions = $this->getDataTable(DDArchiver::BROWSER_VERSION_RECORD_NAME, $idSite, $period, $date, $segment);
     $archive = Archive::build($idSite, $period, $date, $segment);
     $visitsSums = $archive->getDataTableFromNumeric('nb_visits');
     // check whether given tables are arrays
     if ($dataTable instanceof DataTable\Map) {
         $dataTableMap = $dataTable->getDataTables();
         $browserVersionsArray = $browserVersions->getDataTables();
         $visitSumsArray = $visitsSums->getDataTables();
     } else {
         $dataTableMap = array($dataTable);
         $browserVersionsArray = array($browserVersions);
         $visitSumsArray = array($visitsSums);
     }
     // walk through the results and calculate the percentage
     foreach ($dataTableMap as $key => $table) {
         // Calculate percentage, but ignore IE users because plugin detection doesn't work on IE
         $ieVisits = 0;
         $browserVersionsToExclude = array('IE;10.0', 'IE;9.0', 'IE;8.0', 'IE;7.0', 'IE;6.0');
         foreach ($browserVersionsToExclude as $browserVersionToExclude) {
             $ieStats = $browserVersionsArray[$key]->getRowFromLabel($browserVersionToExclude);
             if ($ieStats !== false) {
                 $ieVisits += $ieStats->getColumn(Metrics::INDEX_NB_VISITS);
             }
         }
         // get according visitsSum
         $visits = $visitSumsArray[$key];
         if ($visits->getRowsCount() == 0) {
             $visitsSumTotal = 0;
         } else {
             $visitsSumTotal = (double) $visits->getFirstRow()->getColumn('nb_visits');
         }
         $visitsSum = $visitsSumTotal - $ieVisits;
         $extraProcessedMetrics = $table->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME);
         $extraProcessedMetrics[] = new VisitsPercent($visitsSum);
         $table->setMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME, $extraProcessedMetrics);
     }
     $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\\getPluginsLogo'));
     $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'ucfirst'));
     $dataTable->queueFilter('RangeCheck', array('nb_visits_percentage', 0, 1));
     return $dataTable;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:45,代码来源:API.php

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

示例11: test_subtables_willBeSplitIntoChunks

 public function test_subtables_willBeSplitIntoChunks()
 {
     $numSubtablesToGenerate = 1053;
     $blobs = $this->generateDataTableWithManySubtables($numSubtablesToGenerate);
     $this->assertCount($numSubtablesToGenerate + 1, $blobs);
     // +1 for the root table
     $recordName = 'Actions_MyRecord';
     $archiver = $this->createPluginsArchiver();
     $archiver->archiveProcessor->insertBlobRecord($recordName, $blobs);
     $archiver->finalizeArchive();
     // verify they were split into chunks
     $archiveRows = $this->getAllRowsFromArchiveBlobTable('name');
     $expectedArchiveNames = array($recordName, $recordName . '_chunk_0_99', $recordName . '_chunk_1000_1099', $recordName . '_chunk_100_199', $recordName . '_chunk_200_299', $recordName . '_chunk_300_399', $recordName . '_chunk_400_499', $recordName . '_chunk_500_599', $recordName . '_chunk_600_699', $recordName . '_chunk_700_799', $recordName . '_chunk_800_899', $recordName . '_chunk_900_999');
     $this->assertEquals($expectedArchiveNames, array_column($archiveRows, 'name'));
     // verify all have same archiveIds
     $expectedArchiveIds = array_fill(0, count($expectedArchiveNames), $archiveId = '1');
     $this->assertEquals($expectedArchiveIds, array_column($archiveRows, 'idarchive'));
     // verify the subtables were actually splitted into chunks
     foreach ($archiveRows as $row) {
         $value = unserialize(gzuncompress($row['value']));
         $this->assertTrue(is_array($value));
         if ($row['name'] == $recordName) {
             $this->assertCount($numSubtablesToGenerate, $value);
             // 1053 rows
         } elseif ($row['name'] == $recordName . '_chunk_1000_1099') {
             $this->assertCount($numSubtablesToGenerate % Archive\Chunk::NUM_TABLES_IN_CHUNK + 1, $value);
             // 53 subtables
         } elseif ($row['name'] == $recordName . '_chunk_0_99') {
             $this->assertCount(Archive\Chunk::NUM_TABLES_IN_CHUNK - 1, $value);
             // one less as we do not store the root table here
         } else {
             $this->assertCount(Archive\Chunk::NUM_TABLES_IN_CHUNK, $value);
         }
     }
     // should be able to rebuild the datatable
     $archive = Archive::build(1, 'day', $this->date);
     $table = $archive->getDataTable($recordName);
     $this->assertSame(1053, $table->getRowsCount());
     $this->assertSame('Label Test 1', $table->getFirstRow()->getColumn('label'));
     $this->assertSame(1, $table->getFirstRow()->getColumn('nb_visits'));
 }
开发者ID:mgou-net,项目名称:piwik,代码行数:41,代码来源:ChunksTest.php

示例12: getCustomDimension

 /**
  * Fetch a report for the given idDimension. Only reports for active dimensions can be fetched. Requires at least
  * view access.
  *
  * @param int $idDimension
  * @param int $idSite
  * @param string $period
  * @param string $date
  * @param bool|false $segment
  * @param bool|false $expanded
  * @param bool|false $flat
  * @param int|null   $idSubtable
  * @return DataTable|DataTable\Map
  * @throws \Exception
  */
 public function getCustomDimension($idDimension, $idSite, $period, $date, $segment = false, $expanded = false, $flat = false, $idSubtable = null)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $dimension = new Dimension($idDimension, $idSite);
     $dimension->checkActive();
     $record = Archiver::buildRecordNameForCustomDimensionId($idDimension);
     $dataTable = Archive::createDataTableFromArchive($record, $idSite, $period, $date, $segment, $expanded, $flat, $idSubtable);
     if (isset($idSubtable) && $dataTable->getRowsCount()) {
         $parentTable = Archive::createDataTableFromArchive($record, $idSite, $period, $date, $segment);
         foreach ($parentTable->getRows() as $row) {
             if ($row->getIdSubDataTable() == $idSubtable) {
                 $parentValue = $row->getColumn('label');
                 $dataTable->queueFilter('Piwik\\Plugins\\CustomDimensions\\DataTable\\Filter\\AddSubtableSegmentMetadata', array($idDimension, $parentValue));
                 break;
             }
         }
     } else {
         $dataTable->queueFilter('Piwik\\Plugins\\CustomDimensions\\DataTable\\Filter\\AddSegmentMetadata', array($idDimension));
     }
     $dataTable->filter('Piwik\\Plugins\\CustomDimensions\\DataTable\\Filter\\RemoveUserIfNeeded', array($idSite, $period, $date));
     return $dataTable;
 }
开发者ID:ep123,项目名称:plugin-CustomDimensions,代码行数:37,代码来源:API.php

示例13: bannerStats

 private function bannerStats($bannerName, $params)
 {
     $contentPiece = false;
     if (strpos($bannerName, '_') !== false) {
         list($bannerName, $contentPiece) = explode('_', $bannerName);
     }
     $segment = 'contentName==' . $bannerName;
     $recordName = Dimensions::getRecordNameForAction('getContentPieces');
     $subTable = Archive::getDataTableFromArchive($recordName, $params['idSite'], $params['period'], $params['date'], $segment, true);
     //echo '<pre>';
     $bannerTable = new DataTable();
     if (!$contentPiece) {
         foreach ($subTable->getRows() as $row) {
             $ContentPieceId = Db::fetchOne("SELECT idaction FROM piwik_log_action WHERE TYPE = 14 and name = ?", array($row->getColumn('label')));
             $bannerRow = new Row(array(Row::COLUMNS => array('Label' => $row->getColumn('label'), 'Impressions' => $row->getColumn(41), 'Interactions' => $row->getColumn(42), 'Conversion rate' => $this->interactionRate($row->getColumn(41), $row->getColumn(42))), Row::DATATABLE_ASSOCIATED => implode('_', array($bannerName, $ContentPieceId))));
             $bannerTable->addRow($bannerRow);
         }
     } else {
         $orderColumn = str_replace(' ', '_', strtolower($params['filter_sort_column']));
         $orderOrder = in_array($params['filter_sort_order'], array('asc', 'desc')) ? $params['filter_sort_order'] : 'asc';
         $orderLimit = intval($params['filter_limit']);
         $where = '';
         /*
         TODO: filter_pattern is processed by piwik in some way. The results are good with this query, but piwik does some post-processing?
         if (isset($params['filter_pattern'])) {
              $where = 'and piwik_log_action.name like "%' .  $params['filter_pattern'] . '%"';
         }
         */
         $result = Db::fetchAll("\n                    SELECT \n                        trim(substring_index(piwik_log_action.name, '|', 1)) as referrer,\n                        trim(substring_index(piwik_log_action.name, '|', -1)) as target,\n                        sum(IF(idaction_content_interaction is null, 1, 0)) as impressions, \n                        sum(IF(idaction_content_interaction is null, 0, 1)) as interactions,\n                        ((100 / sum(IF(idaction_content_interaction is null, 1, 0))) * sum(IF(idaction_content_interaction is null, 0, 1))) as conversion_rate\n                    FROM piwik_log_link_visit_action \n                    left join piwik_log_action on piwik_log_action.idaction = idaction_content_target\n                    WHERE \n                        idaction_content_name in (SELECT idaction FROM piwik_log_action WHERE name = ?)\n                    and\n                        idaction_content_piece = ?\n                    \n                    {$where}\n\n                    group by piwik_log_action.name\n                    order by {$orderColumn} {$orderOrder}\n                    limit {$orderLimit}\n            ", array($bannerName, $contentPiece));
         foreach ($result as $row) {
             $bannerRow = new Row(array(Row::COLUMNS => array('Referrer' => $row['referrer'], 'Target' => $row['target'], 'Impressions' => $row['impressions'], 'Interactions' => $row['interactions'], 'Conversion rate' => round($row['conversion_rate']) . '%')));
             $bannerTable->addRow($bannerRow);
         }
     }
     return $bannerTable;
 }
开发者ID:ronaldbaltus,项目名称:VPSCashPiwikBannerPlugin,代码行数:36,代码来源:API.php

示例14: getNumberOfDistinctCountries

 public function getNumberOfDistinctCountries($idSite, $period, $date, $segment = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $archive = Archive::build($idSite, $period, $date, $segment);
     return $archive->getDataTableFromNumeric(Archiver::DISTINCT_COUNTRIES_METRIC);
 }
开发者ID:piwik,项目名称:piwik,代码行数:6,代码来源:API.php

示例15: getDataTable

 protected function getDataTable($name, $idSite, $period, $date, $segment, $expanded = false, $idSubtable = null, $secondaryDimension = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $this->checkSecondaryDimension($name, $secondaryDimension);
     $recordName = $this->getRecordNameForAction($name, $secondaryDimension);
     $dataTable = Archive::getDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded, $idSubtable);
     $this->filterDataTable($dataTable);
     return $dataTable;
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:9,代码来源:API.php


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