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:
authormattab <matthieu.aubry@gmail.com>2013-04-20 13:02:35 +0400
committermattab <matthieu.aubry@gmail.com>2013-04-20 13:02:36 +0400
commit35f975accb45152dd669e0009237eed3dc6ada2b (patch)
tree8a0a82519a8a3502ae18c31ae3db7bf2d148af55 /core/DataTable/Filter/ColumnDelete.php
parent6575c1f85e6d4276cbce2d8a22535c6d499cb8ce (diff)
Fixes #3904:
* new segment 'siteSearchKeyword' Fixes #3903, #3905: * adding few fields in the Live API output to accomodate getSuggestedValuesForSegment * renamed other fields for consistency with segment names Fixes #3906: * new API: getSuggestedValuesForSegment which returns top suggested values for a particular segment. It uses the Live.getLastVisitsDetails API to fetch the most recently used values, and will show the most used values first * Adding tests for everything. The test case actually generates data for all segments so that VisitsSummary.get returns some data for each of the 47 segments being tested returns some data. How it works: * generate extended data in fixture * Tests (1) call getSuggestedValuesForSegment for each segment, check there is some data returned for each segment * get the first suggested value from the list, * Tests (2) call VisitsSummary.get with this segment value, eg. countryCode==ru. * I worked this way for all 47 segments until all tests had some data ==> now we know that all segments have been tested and that the auto suggest works for all segments. TDD FTW!
Diffstat (limited to 'core/DataTable/Filter/ColumnDelete.php')
-rw-r--r--core/DataTable/Filter/ColumnDelete.php22
1 files changed, 20 insertions, 2 deletions
diff --git a/core/DataTable/Filter/ColumnDelete.php b/core/DataTable/Filter/ColumnDelete.php
index 3ac3f5b244..709d56a02e 100644
--- a/core/DataTable/Filter/ColumnDelete.php
+++ b/core/DataTable/Filter/ColumnDelete.php
@@ -34,6 +34,14 @@ class Piwik_DataTable_Filter_ColumnDelete extends Piwik_DataTable_Filter
private $columnsToKeep;
/**
+ * Hack: when specifying "showColumns", sometimes we'd like to also keep columns that "look" like a given column,
+ * without manually specifying all these columns (which may not be possible if column names are generated dynamically)
+ *
+ * Column will be kept, if they match any name in the $columnsToKeep, or if they look like anyColumnToKeep__anythingHere
+ */
+ const APPEND_TO_COLUMN_NAME_TO_KEEP = '__';
+
+ /**
* Delete the column, only if the value was zero
*
* @var bool
@@ -101,8 +109,18 @@ class Piwik_DataTable_Filter_ColumnDelete extends Piwik_DataTable_Filter
if (!empty($this->columnsToKeep)) {
foreach ($table->getRows() as $row) {
foreach ($row->getColumns() as $name => $value) {
- // label cannot be removed via whitelisting
- if ($name != 'label' && !isset($this->columnsToKeep[$name])) {
+
+ $keep = false;
+ // @see self::APPEND_TO_COLUMN_NAME_TO_KEEP
+ foreach($this->columnsToKeep as $nameKeep => $true) {
+ if(strpos($name, $nameKeep . self::APPEND_TO_COLUMN_NAME_TO_KEEP) === 0) {
+ $keep = true;
+ }
+ }
+
+ if (!$keep
+ && $name != 'label' // label cannot be removed via whitelisting
+ && !isset($this->columnsToKeep[$name])) {
$row->deleteColumn($name);
}
}