diff options
Diffstat (limited to 'plugins/UserCountry/API.php')
-rw-r--r-- | plugins/UserCountry/API.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/plugins/UserCountry/API.php b/plugins/UserCountry/API.php index c4e12b550a..76acdbb8f1 100644 --- a/plugins/UserCountry/API.php +++ b/plugins/UserCountry/API.php @@ -32,6 +32,26 @@ class API extends \Piwik\Plugin\API { $dataTable = $this->getDataTable(Archiver::COUNTRY_RECORD_NAME, $idSite, $period, $date, $segment); + $dataTables = [$dataTable]; + + if ($dataTable instanceof DataTable\Map) { + $dataTables = $dataTable->getDataTables(); + } + + foreach ($dataTables as $dt) { + if ($dt->getRowFromLabel('ti')) { + $dt->filter('GroupBy', array( + 'label', + function ($label) { + if ($label == 'ti') { + return 'cn'; + } + return $label; + } + )); + } + } + // apply filter on the whole datatable in order the inline search to work (searches are done on "beautiful" label) $dataTable->filter('AddSegmentValue'); $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'code')); @@ -75,6 +95,27 @@ class API extends \Piwik\Plugin\API $separator = Archiver::LOCATION_SEPARATOR; $unk = Visit::UNKNOWN_CODE; + // show visits tracked as Tibet as region of China + $dataTables = [$dataTable]; + + if ($dataTable instanceof DataTable\Map) { + $dataTables = $dataTable->getDataTables(); + } + + foreach ($dataTables as $dt) { + if ($dt->getRowFromLabel('1|ti')) { + $dt->filter('GroupBy', array( + 'label', + function ($label) { + if ($label == '1|ti') { + return '14|cn'; + } + return $label; + } + )); + } + } + // split the label and put the elements into the 'region' and 'country' metadata fields $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'region', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 0, $unk))); |