PHP Class Piwik\Plugins\API\ProcessedReport

Show file Open project: piwik/piwik Class Usage Examples

Public Methods

Method Description
__construct ( ReportsProvider $reportsProvider )
getMetadata ( $idSite, $apiModule, $apiAction, $apiParameters = [], $language = false, $period = false, $date = false, $hideMetricsDoc = false, $showSubtableReports = false ) Loads reports metadata, then return the requested one, matching optional API parameters.
getPrettyValue ( Piwik\Metrics\Formatter $formatter, integer $idSite, string $columnName, mixed $value ) : string Prettifies a metric value based on the column name.
getProcessedReport ( $idSite, $period, $date, $apiModule, $apiAction, $segment = false, $apiParameters = false, $idGoal = false, $language = false, $showTimer = true, $hideMetricsDoc = false, $idSubtable = false, $showRawMetrics = false, $formatMetrics = null, $idDimension = false )
getReportMetadata ( integer $idSite, boolean | string $period = false, boolean | Date $date = false, boolean $hideMetricsDoc = false, boolean $showSubtableReports = false ) : array Triggers a hook to ask plugins for available Reports.
getReportMetadataByUniqueId ( $idSite, $apiMethodUniqueId )
isValidMetricForReport ( string $metric, integer $idSite, string $apiMethodUniqueId ) : boolean Verfies whether the given metric belongs to the given report.
isValidReportForSite ( integer $idSite, string $apiMethodUniqueId ) : boolean Verfies whether the given report exists for the given site.
sortReports ( array $a, array $b ) : integer API metadata are sorted by category/name, with a little tweak to replicate the standard Piwik category ordering
translateMetric ( string $metric, integer $idSite, string $apiMethodUniqueId ) : null | string Translates the given metric in case the report exists and in case the metric acutally belongs to the report.

Private Methods

Method Description
aggregateReportTotalValues ( $simpleDataTable, $totals )
buildReportMetadataCacheKey ( $idSite, $period, $date, $hideMetricsDoc, $showSubtableReports )
getColumnsToKeep ( )
getColumnsToRemove ( )
getImplodedArray ( $v ) : string
handleSimpleDataTable ( integer $idSite, Piwik\DataTable\Simple $simpleDataTable, array $metadataColumns, boolean $hasDimension, boolean $returnRawMetrics = false, boolean | null $formatMetrics = null ) : array Enhance $simpleDataTable using metadata :
handleTableReport ( integer $idSite, Piwik\DataTable\Map | Piwik\DataTable\Simple $dataTable, array &$reportMetadata, boolean $showRawMetrics = false, boolean | null $formatMetrics = null ) : array Enhance a $dataTable using metadata :
hideShowMetrics ( array $columns, array $emptyColumns = [] ) : array Removes column names from an array based on the values in the hideColumns, showColumns query parameters. This is a hack that provides the ColumnDelete filter functionality in processed reports.
hideShowMetricsWithParams ( $columns, $columnsToRemove, $columnsToKeep, $emptyColumns = [] )
removeEmptyColumns ( &$columns, &$reportMetadata, $dataTable ) Removes metrics from the list of columns and the report meta data if they are marked empty in the data table meta data.

Method Details

__construct() public method

public __construct ( ReportsProvider $reportsProvider )
$reportsProvider Piwik\Plugin\ReportsProvider

getMetadata() public method

Loads reports metadata, then return the requested one, matching optional API parameters.
public getMetadata ( $idSite, $apiModule, $apiAction, $apiParameters = [], $language = false, $period = false, $date = false, $hideMetricsDoc = false, $showSubtableReports = false )

getPrettyValue() public static method

Prettifies a metric value based on the column name.
public static getPrettyValue ( Piwik\Metrics\Formatter $formatter, integer $idSite, string $columnName, mixed $value ) : string
$formatter Piwik\Metrics\Formatter
$idSite integer The ID of the site the metric is for (used if the column value is an amount of money).
$columnName string The metric name.
$value mixed The metric value.
return string

getProcessedReport() public method

public getProcessedReport ( $idSite, $period, $date, $apiModule, $apiAction, $segment = false, $apiParameters = false, $idGoal = false, $language = false, $showTimer = true, $hideMetricsDoc = false, $idSubtable = false, $showRawMetrics = false, $formatMetrics = null, $idDimension = false )

getReportMetadata() public method

Returns metadata information about each report (category, name, dimension, metrics, etc.)
public getReportMetadata ( integer $idSite, boolean | string $period = false, boolean | Date $date = false, boolean $hideMetricsDoc = false, boolean $showSubtableReports = false ) : array
$idSite integer
$period boolean | string
$date boolean | Piwik\Date
$hideMetricsDoc boolean
$showSubtableReports boolean
return array

getReportMetadataByUniqueId() public method

public getReportMetadataByUniqueId ( $idSite, $apiMethodUniqueId )

isValidMetricForReport() public method

Verfies whether the given metric belongs to the given report.
public isValidMetricForReport ( string $metric, integer $idSite, string $apiMethodUniqueId ) : boolean
$metric string For example 'nb_visits'
$idSite integer
$apiMethodUniqueId string For example 'MultiSites_getAll'
return boolean

isValidReportForSite() public method

Verfies whether the given report exists for the given site.
public isValidReportForSite ( integer $idSite, string $apiMethodUniqueId ) : boolean
$idSite integer
$apiMethodUniqueId string For example 'MultiSites_getAll'
return boolean

sortReports() public method

API metadata are sorted by category/name, with a little tweak to replicate the standard Piwik category ordering
public sortReports ( array $a, array $b ) : integer
$a array
$b array
return integer

translateMetric() public method

Translates the given metric in case the report exists and in case the metric acutally belongs to the report.
public translateMetric ( string $metric, integer $idSite, string $apiMethodUniqueId ) : null | string
$metric string For example 'nb_visits'
$idSite integer
$apiMethodUniqueId string For example 'MultiSites_getAll'
return null | string