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


PHP Piwik\Metrics类代码示例

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


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

示例1: render

 /**
  * @see ViewDataTable::main()
  * @return mixed
  */
 public function render()
 {
     $view = new View('@CoreVisualizations/_dataTableViz_sparklines.twig');
     $columnsList = array();
     if ($this->config->hasSparklineMetrics()) {
         foreach ($this->config->getSparklineMetrics() as $cols) {
             $columns = $cols['columns'];
             if (!is_array($columns)) {
                 $columns = array($columns);
             }
             $columnsList = array_merge($columns, $columnsList);
         }
     }
     $view->allMetricsDocumentation = Metrics::getDefaultMetricsDocumentation();
     $this->requestConfig->request_parameters_to_modify['columns'] = $columnsList;
     $this->requestConfig->request_parameters_to_modify['format_metrics'] = '1';
     if (!empty($this->requestConfig->apiMethodToRequestDataTable)) {
         $this->fetchConfiguredSparklines();
     }
     $view->sparklines = $this->config->getSortedSparklines();
     $view->isWidget = Common::getRequestVar('widget', 0, 'int');
     $view->titleAttributes = $this->config->title_attributes;
     $view->footerMessage = $this->config->show_footer_message;
     $view->areSparklinesLinkable = $this->config->areSparklinesLinkable();
     $view->title = '';
     if ($this->config->show_title) {
         $view->title = $this->config->title;
     }
     return $view->render();
 }
开发者ID:piwik,项目名称:piwik,代码行数:34,代码来源:Sparklines.php

示例2: testGetUnit

 /**
  * @dataProvider getUnitColumns
  * @group Core
  */
 public function testGetUnit($column, $expected)
 {
     Site::setSites(array(1 => array('name' => 'TestSite', 'currency' => 'EUR')));
     FakeAccess::$superUser = true;
     $actual = Metrics::getUnit($column, 1);
     $this->assertEquals($expected, $actual);
 }
开发者ID:mgou-net,项目名称:piwik,代码行数:11,代码来源:MetricsTest.php

示例3: renderSidebar

 /** Render the area left of the iframe */
 public function renderSidebar()
 {
     $idSite = Common::getRequestVar('idSite');
     $period = Common::getRequestVar('period');
     $date = Common::getRequestVar('date');
     $currentUrl = Common::getRequestVar('currentUrl');
     $currentUrl = Common::unsanitizeInputValue($currentUrl);
     $normalizedCurrentUrl = PageUrl::excludeQueryParametersFromUrl($currentUrl, $idSite);
     $normalizedCurrentUrl = Common::unsanitizeInputValue($normalizedCurrentUrl);
     // load the appropriate row of the page urls report using the label filter
     ArchivingHelper::reloadConfig();
     $path = ArchivingHelper::getActionExplodedNames($normalizedCurrentUrl, Action::TYPE_PAGE_URL);
     $path = array_map('urlencode', $path);
     $label = implode('>', $path);
     $request = new Request('method=Actions.getPageUrls' . '&idSite=' . urlencode($idSite) . '&date=' . urlencode($date) . '&period=' . urlencode($period) . '&label=' . urlencode($label) . '&format=original' . '&format_metrics=0');
     $dataTable = $request->process();
     $formatter = new Metrics\Formatter\Html();
     $data = array();
     if ($dataTable->getRowsCount() > 0) {
         $row = $dataTable->getFirstRow();
         $translations = Metrics::getDefaultMetricTranslations();
         $showMetrics = array('nb_hits', 'nb_visits', 'nb_users', 'nb_uniq_visitors', 'bounce_rate', 'exit_rate', 'avg_time_on_page');
         foreach ($showMetrics as $metric) {
             $value = $row->getColumn($metric);
             if ($value === false) {
                 // skip unique visitors for period != day
                 continue;
             }
             if ($metric == 'bounce_rate' || $metric == 'exit_rate') {
                 $value = $formatter->getPrettyPercentFromQuotient($value);
             } else {
                 if ($metric == 'avg_time_on_page') {
                     $value = $formatter->getPrettyTimeFromSeconds($value, $displayAsSentence = true);
                 }
             }
             $data[] = array('name' => $translations[$metric], 'value' => $value);
         }
     }
     // generate page url string
     foreach ($path as &$part) {
         $part = preg_replace(';^/;', '', urldecode($part));
     }
     $page = '/' . implode('/', $path);
     $page = preg_replace(';/index$;', '/', $page);
     if ($page == '/') {
         $page = '/index';
     }
     // render template
     $view = new View('@Overlay/renderSidebar');
     $view->data = $data;
     $view->location = $page;
     $view->normalizedUrl = $normalizedCurrentUrl;
     $view->label = $label;
     $view->idSite = $idSite;
     $view->period = $period;
     $view->date = $date;
     $this->outputCORSHeaders();
     return $view->render();
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:60,代码来源:Controller.php

示例4: compute

 public function compute(Row $row)
 {
     $mappingFromNameToIdGoal = Metrics::getMappingFromNameToIdGoal();
     $goalMetrics = $this->getGoalMetrics($row);
     $goalRevenue = $this->getMetric($goalMetrics, 'revenue', $mappingFromNameToIdGoal);
     $conversions = $this->getMetric($goalMetrics, 'nb_conversions', $mappingFromNameToIdGoal);
     return Piwik::getQuotientSafe($goalRevenue, $conversions, GoalManager::REVENUE_PRECISION);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:8,代码来源:AverageOrderRevenue.php

示例5: testGetUnit

 /**
  * @dataProvider getUnitColumns
  * @group Core
  */
 public function testGetUnit($column, $expected)
 {
     \Piwik\Site::setSites(array(1 => array('name' => 'TestSite', 'currency' => 'EUR')));
     $pseudoMockAccess = new FakeAccess();
     FakeAccess::$superUser = true;
     Access::setSingletonInstance($pseudoMockAccess);
     $actual = Metrics::getUnit($column, 1);
     $this->assertEquals($expected, $actual);
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:13,代码来源:MetricsTest.php

示例6: configureView

 public function configureView(ViewDataTable $view)
 {
     $view->requestConfig->filter_sort_column = 'label';
     $view->requestConfig->filter_sort_order = 'asc';
     $view->requestConfig->filter_limit = 15;
     $view->config->addTranslations(array('label' => Piwik::translate('VisitorInterest_VisitNum'), 'nb_visits_percentage' => Metrics::getPercentVisitColumn()));
     $view->config->columns_to_display = array('label', 'nb_visits', 'nb_visits_percentage');
     $view->config->show_exclude_low_population = false;
     $view->config->enable_sort = false;
     $view->config->show_offset_information = false;
     $view->config->show_pagination_control = false;
     $view->config->show_limit_control = false;
     $view->config->show_search = false;
     $view->config->show_table_all_columns = false;
     $view->config->show_all_views_icons = false;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:16,代码来源:GetNumberOfVisitsByVisitCount.php

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

示例8: compute

 public function compute(Row $row)
 {
     $mappingFromNameToIdGoal = Metrics::getMappingFromNameToIdGoal();
     $goals = $this->getMetric($row, 'goals') ?: array();
     $revenue = 0;
     foreach ($goals as $goalId => $goalMetrics) {
         if ($goalId == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART) {
             continue;
         }
         if ($goalId >= GoalManager::IDGOAL_ORDER || $goalId == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
             $revenue += (int) $this->getMetric($goalMetrics, 'revenue', $mappingFromNameToIdGoal);
         }
     }
     if ($revenue == 0) {
         $revenue = (int) $this->getMetric($row, 'revenue');
     }
     $nbVisits = (int) $this->getMetric($row, 'nb_visits');
     $conversions = (int) $this->getMetric($row, 'nb_conversions');
     // If no visit for this metric, but some conversions, we still want to display some kind of "revenue per visit"
     // even though it will actually be in this edge case "Revenue per conversion"
     return Piwik::getQuotientSafe($revenue, $nbVisits == 0 ? $conversions : $nbVisits, GoalManager::REVENUE_PRECISION);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:22,代码来源:RevenuePerVisit.php

示例9: manipulateDataTable

 /**
  * Adds ratio metrics if possible.
  *
  * @param  DataTable $dataTable
  * @return DataTable
  */
 protected function manipulateDataTable($dataTable)
 {
     if (!empty($this->report) && !$this->report->getDimension() && !$this->isAllMetricsReport()) {
         // we currently do not calculate the total value for reports having no dimension
         return $dataTable;
     }
     $this->totals = array();
     $firstLevelTable = $this->makeSureToWorkOnFirstLevelDataTable($dataTable);
     $metricsToCalculate = Metrics::getMetricIdsToProcessReportTotal();
     $metricNames = array();
     foreach ($metricsToCalculate as $metricId) {
         $metricNames[$metricId] = Metrics::getReadableColumnName($metricId);
     }
     foreach ($firstLevelTable->getRows() as $row) {
         $columns = $row->getColumns();
         foreach ($metricNames as $metricId => $metricName) {
             $this->sumColumnValueToTotal($columns, $metricId, $metricName);
         }
     }
     $dataTable->setMetadata('totals', $this->totals);
     return $dataTable;
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:28,代码来源:ReportTotalsCalculator.php

示例10: selectColumnToExclude

 /**
  * Sets the column to be used for Excluding low population
  *
  * @param DataTable\Row $row
  * @return int
  */
 private function selectColumnToExclude($columnToFilter, $row)
 {
     if ($row->hasColumn($columnToFilter)) {
         return $columnToFilter;
     }
     // filter_excludelowpop=nb_visits but the column name is still Metrics::INDEX_NB_VISITS in the table
     $columnIdToName = Metrics::getMappingFromNameToId();
     if (isset($columnIdToName[$columnToFilter])) {
         $column = $columnIdToName[$columnToFilter];
         if ($row->hasColumn($column)) {
             return $column;
         }
     }
     return $columnToFilter;
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:21,代码来源:ExcludeLowPopulation.php

示例11: aggregateMultipleVisitsMetrics

 protected function aggregateMultipleVisitsMetrics()
 {
     $toSum = Metrics::getVisitsMetricNames();
     $metrics = $this->archiveProcessor->aggregateNumericMetrics($toSum);
     return $metrics;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:6,代码来源:PluginsArchiver.php

示例12: handleTableReport

 /**
  * Enhance a $dataTable using metadata :
  *
  * - remove metrics based on $reportMetadata['metrics']
  * - add 0 valued metrics if $dataTable doesn't provide all $reportMetadata['metrics']
  * - format metric values to a 'human readable' format
  * - extract row metadata to a separate Simple|Set : $rowsMetadata
  * - translate metric names to a separate array : $columns
  *
  * @param int $idSite enables monetary value formatting based on site currency
  * @param \Piwik\DataTable\Map|\Piwik\DataTable\Simple $dataTable
  * @param array $reportMetadata
  * @param bool $showRawMetrics
  * @param bool|null $formatMetrics
  * @return array Simple|Set $newReport with human readable format & array $columns list of translated column names & Simple|Set $rowsMetadata
  */
 private function handleTableReport($idSite, $dataTable, &$reportMetadata, $showRawMetrics = false, $formatMetrics = null)
 {
     $hasDimension = isset($reportMetadata['dimension']);
     $columns = @$reportMetadata['metrics'] ?: array();
     if ($hasDimension) {
         $columns = array_merge(array('label' => $reportMetadata['dimension']), $columns);
     }
     if (isset($reportMetadata['processedMetrics']) && is_array($reportMetadata['processedMetrics'])) {
         $processedMetricsAdded = Metrics::getDefaultProcessedMetrics();
         foreach ($reportMetadata['processedMetrics'] as $processedMetricId => $processedMetricTranslation) {
             // this processed metric can be displayed for this report
             if ($processedMetricTranslation && $processedMetricId !== $processedMetricTranslation) {
                 $columns[$processedMetricId] = $processedMetricTranslation;
             } elseif (isset($processedMetricsAdded[$processedMetricId])) {
                 // for instance in case 'nb_visits' => 'nb_visits' we will translate it
                 $columns[$processedMetricId] = $processedMetricsAdded[$processedMetricId];
             }
         }
     }
     // Display the global Goal metrics
     if (isset($reportMetadata['metricsGoal'])) {
         $metricsGoalDisplay = array('revenue');
         // Add processed metrics to be displayed for this report
         foreach ($metricsGoalDisplay as $goalMetricId) {
             if (isset($reportMetadata['metricsGoal'][$goalMetricId])) {
                 $columns[$goalMetricId] = $reportMetadata['metricsGoal'][$goalMetricId];
             }
         }
     }
     $columns = $this->hideShowMetrics($columns);
     $totals = array();
     // $dataTable is an instance of Set when multiple periods requested
     if ($dataTable instanceof DataTable\Map) {
         // Need a new Set to store the 'human readable' values
         $newReport = new DataTable\Map();
         $newReport->setKeyName("prettyDate");
         // Need a new Set to store report metadata
         $rowsMetadata = new DataTable\Map();
         $rowsMetadata->setKeyName("prettyDate");
         // Process each Simple entry
         foreach ($dataTable->getDataTables() as $simpleDataTable) {
             $this->removeEmptyColumns($columns, $reportMetadata, $simpleDataTable);
             list($enhancedSimpleDataTable, $rowMetadata) = $this->handleSimpleDataTable($idSite, $simpleDataTable, $columns, $hasDimension, $showRawMetrics, $formatMetrics);
             $enhancedSimpleDataTable->setAllTableMetadata($simpleDataTable->getAllTableMetadata());
             $period = $simpleDataTable->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getLocalizedLongString();
             $newReport->addTable($enhancedSimpleDataTable, $period);
             $rowsMetadata->addTable($rowMetadata, $period);
             $totals = $this->aggregateReportTotalValues($simpleDataTable, $totals);
         }
     } else {
         $this->removeEmptyColumns($columns, $reportMetadata, $dataTable);
         list($newReport, $rowsMetadata) = $this->handleSimpleDataTable($idSite, $dataTable, $columns, $hasDimension, $showRawMetrics, $formatMetrics);
         $totals = $this->aggregateReportTotalValues($dataTable, $totals);
     }
     return array($newReport, $columns, $rowsMetadata, $totals);
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:72,代码来源:ProcessedReport.php

示例13: deriveUnitsFromRequestedColumnNames

 private function deriveUnitsFromRequestedColumnNames()
 {
     $idSite = Common::getRequestVar('idSite', null, 'int');
     $units = array();
     foreach ($this->properties['columns_to_display'] as $columnName) {
         $derivedUnit = Metrics::getUnit($columnName, $idSite);
         $units[$columnName] = empty($derivedUnit) ? false : $derivedUnit;
     }
     return $units;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:10,代码来源:JqplotDataGenerator.php

示例14: __construct

 /**
  * Constructor.
  */
 public function __construct()
 {
     $this->export_limit = \Piwik\Config::getInstance()->General['API_datatable_default_limit'];
     $this->translations = array_merge(Metrics::getDefaultMetrics(), Metrics::getDefaultProcessedMetrics());
     $this->show_title = (bool) Common::getRequestVar('showtitle', 0, 'int');
 }
开发者ID:piwik,项目名称:piwik,代码行数:9,代码来源:Config.php

示例15: getMetricTranslations

 private function getMetricTranslations($metricsToTranslate)
 {
     $translations = Metrics::getDefaultMetricTranslations();
     $metrics = array();
     foreach ($metricsToTranslate as $metric) {
         if ($metric instanceof Metric) {
             $metricName = $metric->getName();
             $translation = $metric->getTranslatedName();
         } else {
             $metricName = $metric;
             $translation = @$translations[$metric];
         }
         $metrics[$metricName] = $translation ?: $metricName;
     }
     return $metrics;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:16,代码来源:Report.php


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