Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2014-09-21 02:34:52 +0400
committerdiosmosis <benaka@piwik.pro>2014-09-21 03:02:41 +0400
commit96895068207ec39e0c110307a0d2f987970752e5 (patch)
tree677966c4c99e910116351e05756921f9696400f7 /core/DataTable/Filter/PivotByDimension.php
parent33cc6c77bc789a6d957272b1fec4a15a7d6ffb2b (diff)
Refs #6078, prepend numeral index to each column in pivotted datatable.
Diffstat (limited to 'core/DataTable/Filter/PivotByDimension.php')
-rw-r--r--core/DataTable/Filter/PivotByDimension.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/core/DataTable/Filter/PivotByDimension.php b/core/DataTable/Filter/PivotByDimension.php
index ba4f0220f6..fd176f8cf5 100644
--- a/core/DataTable/Filter/PivotByDimension.php
+++ b/core/DataTable/Filter/PivotByDimension.php
@@ -215,7 +215,7 @@ class PivotByDimension extends BaseFilter
$others = Piwik::translate('General_Others');
$defaultRow = $this->getPivotTableDefaultRowFromColumnSummary($columnSet, $others);
- Log::debug("PivotByDimension::%s: processed pivoted columns: %s", __FUNCTION__, $defaultRow);
+ Log::debug("PivotByDimension::%s: un-prepended default row: %s", __FUNCTION__, $defaultRow);
// post process pivoted datatable
foreach ($table->getRows() as $row) {
@@ -238,6 +238,18 @@ class PivotByDimension extends BaseFilter
$table->clearQueuedFilters(); // TODO: shouldn't clear queued filters, but we can't wait for them to be run
// since generic filters are run before them. remove after refactoring
// processed metrics.
+
+ // prepend numerals to columns in a queued filter (this way, disable_queued_filters can be used
+ // to get machine readable data from the API if needed)
+ $prependedColumnNames = $this->getOrderedColumnsWithPrependedNumerals($defaultRow, $others);
+
+ Log::debug("PivotByDimension::%s: prepended column name mapping: %s", __FUNCTION__, $prependedColumnNames);
+
+ $table->queueFilter(function (DataTable $table) use ($prependedColumnNames) {
+ foreach ($table->getRows() as $row) {
+ $row->setColumns(array_combine($prependedColumnNames, $row->getColumns()));
+ }
+ });
}
/**
@@ -445,6 +457,27 @@ class PivotByDimension extends BaseFilter
return $columnSet;
}
+ private function getOrderedColumnsWithPrependedNumerals($defaultRow, $othersRowLabel)
+ {
+ $result = array();
+
+ $currentIndex = 1;
+ foreach ($defaultRow as $columnName => $ignore) {
+ if ($columnName == $othersRowLabel
+ || $columnName == 'label'
+ ) {
+ $result[] = $columnName;
+ } else {
+ $modifiedColumnName = $currentIndex . '.&nbsp;' . $columnName;
+ $result[] = $modifiedColumnName;
+
+ ++$currentIndex;
+ }
+ }
+
+ return $result;
+ }
+
/**
* Returns true if pivoting by subtable is supported for a report. Will return true if the report
* has a subtable dimension and if the subtable dimension is different than the report's dimension.