diff options
author | diosmosis <benaka@piwik.pro> | 2015-03-12 12:26:38 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-03-12 12:26:38 +0300 |
commit | 54bd3f0f18b3ba9edde0823d7f06e0769e5abad7 (patch) | |
tree | 4cc4c26ff9558a8cbc0ccf6afb2cd7498a1a1996 /core/Archive.php | |
parent | 5197b1cd4ddd21e7c2ab4cfe2906dff92ac35734 (diff) | |
parent | 484935ce69c19e94d4b2a95aca33e75b0802abbe (diff) |
Merge branch 'master' into 7181_isolated_archive_purging
Conflicts:
plugins/SitesManager/SitesManager.php
Diffstat (limited to 'core/Archive.php')
-rw-r--r-- | core/Archive.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/core/Archive.php b/core/Archive.php index c95a37ddd3..2bce8c676d 100644 --- a/core/Archive.php +++ b/core/Archive.php @@ -452,6 +452,7 @@ class Archive * @return DataTable|DataTable\Map See {@link getDataTable()} and * {@link getDataTableExpanded()} for more * information + * @deprecated Since Piwik 2.12.0 Use Archive::createDataTableFromArchive() instead */ public static function getDataTableFromArchive($name, $idSite, $period, $date, $segment, $expanded, $idSubtable = null, $depth = null) @@ -474,6 +475,42 @@ class Archive return $dataTable; } + /** + * Helper function that creates an Archive instance and queries for report data using + * query parameter data. API methods can use this method to reduce code redundancy. + * + * @param string $recordName The name of the report to return. + * @param int|string|array $idSite @see {@link build()} + * @param string $period @see {@link build()} + * @param string $date @see {@link build()} + * @param string $segment @see {@link build()} + * @param bool $expanded If true, loads all subtables. See {@link getDataTableExpanded()} + * @param bool $flat If true, loads all subtables and disabled all recursive filters. + * @param int|null $idSubtable See {@link getDataTableExpanded()} + * @param int|null $depth See {@link getDataTableExpanded()} + * @return DataTable|DataTable\Map + */ + public static function createDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded = false, $flat = false, $idSubtable = null, $depth = null) + { + if ($flat && !$idSubtable) { + $expanded = true; + } + + $dataTable = self::getDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded, $idSubtable, $depth); + + $dataTable->queueFilter('ReplaceColumnNames'); + + if ($expanded) { + $dataTable->queueFilterSubtables('ReplaceColumnNames'); + } + + if ($flat) { + $dataTable->disableRecursiveFilters(); + } + + return $dataTable; + } + private function appendIdSubtable($recordName, $id) { return $recordName . "_" . $id; |