diff options
author | diosmosis <benaka@piwik.pro> | 2014-09-18 07:40:38 +0400 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2014-09-18 07:40:38 +0400 |
commit | 41fabcb3488f00f5840dc2c231519488322b1837 (patch) | |
tree | 32021d167f45a4047e0195841fbb4fba8eed167f /core/ViewDataTable | |
parent | aafb07c75b86b7905da1d7525e2800c8dbad2cde (diff) |
Adding new PivotByDimension DataTable filter that can pivot a report by (almost) any dimension. The filter can pivot reports by their subtable dimension and can also pivot by other dimensions (by using segments).
Notes:
- in the UI, only pivoting by subtable is supported
- change to CSV DataTable renderer so column names w/ commas & quotes can appear in text
- change to XML DataTable renderer so column names w/ invalid XML characters can be rendered (bit of an iffy change, XML format needs an overhaul I think)
- includes new config option 'pivot_by_filter_enable_fetch_by_segment'
- includes additions to component metadata classes (ie, Report/Dimension)
Diffstat (limited to 'core/ViewDataTable')
-rw-r--r-- | core/ViewDataTable/Config.php | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/core/ViewDataTable/Config.php b/core/ViewDataTable/Config.php index 093f28b254..0389c213fb 100644 --- a/core/ViewDataTable/Config.php +++ b/core/ViewDataTable/Config.php @@ -9,7 +9,9 @@ namespace Piwik\ViewDataTable; use Piwik\API\Request as ApiRequest; +use Piwik\DataTable\Filter\PivotByDimension; use Piwik\Metrics; +use Piwik\Plugin\Report; use Piwik\Plugins\API\API; /** @@ -83,7 +85,8 @@ class Config * The list of ViewDataTable properties that are 'Client Side Properties'. */ public $clientSideProperties = array( - 'show_limit_control' + 'show_limit_control', + 'pivot_by_dimension' ); /** @@ -93,6 +96,7 @@ class Config 'show_goals', 'show_exclude_low_population', 'show_flatten_table', + 'show_pivot_by_subtable', 'show_table', 'show_table_all_columns', 'show_footer', @@ -185,6 +189,18 @@ class Config public $show_flatten_table = true; /** + * Whether to show the 'Pivot by subtable' option (visible in the popup that displays after clicking + * the 'cog' icon). + */ + public $show_pivot_by_subtable; + + /** + * The ID of the dimension to pivot by when the 'pivot by subtable' option is clicked. Defaults + * to the subtable dimension of the report being displayed. + */ + public $pivot_by_dimension; + + /** * Controls whether the footer icon that allows users to switch to the 'normal' DataTable view * is shown. */ @@ -447,6 +463,7 @@ class Config $this->report_id = $controllerName . '.' . $controllerAction; $this->loadDocumentation(); + $this->setShouldShowPivotBySubtable(); } /** Load documentation from the API */ @@ -635,4 +652,19 @@ class Config $this->addTranslation($key, $translation); } } + + private function setShouldShowPivotBySubtable() + { + $report = Report::factory($this->controllerName, $this->controllerAction); + + if (empty($report)) { + $this->show_pivot_by_subtable = false; + $this->pivot_by_dimension = false; + } else { + $this->show_pivot_by_subtable = PivotByDimension::isPivotingReportBySubtableSupported($report); + + $subtableDimension = $report->getSubtableDimension(); + $this->pivot_by_dimension = $subtableDimension ? $subtableDimension->getId() : false; + } + } } |