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:
authorThomas Steur <thomas.steur@gmail.com>2015-07-29 18:50:19 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-07-29 18:50:19 +0300
commit79e71e3491829a2c1a2da309b15228caeb6a4a2e (patch)
tree17f2a021e881734591dd5192e4a310abb2c0b53c /plugins/Referrers
parent08fa53b99fa94ad51112288487c6bcb950474dfa (diff)
refs #7983 Row Evolution at Referrer Reports shows 0 visitors on subdatatables
Diffstat (limited to 'plugins/Referrers')
-rw-r--r--plugins/Referrers/API.php44
-rw-r--r--plugins/Referrers/DataTable/Filter/SetGetReferrerTypeSubtables.php87
2 files changed, 88 insertions, 43 deletions
diff --git a/plugins/Referrers/API.php b/plugins/Referrers/API.php
index 6475bbea07..d1c08ac20c 100644
--- a/plugins/Referrers/API.php
+++ b/plugins/Referrers/API.php
@@ -104,10 +104,7 @@ class API extends \Piwik\Plugin\API
}
// set subtable IDs for each row to the label (which holds the int referrer type)
- // NOTE: not yet possible to do this w/ DataTable\Map instances
- if (!($dataTable instanceof DataTable\Map)) {
- $this->setGetReferrerTypeSubtables($dataTable, $idSite, $period, $date, $segment, $expanded);
- }
+ $dataTable->filter('Piwik\Plugins\Referrers\DataTable\Filter\SetGetReferrerTypeSubtables', array($idSite, $period, $date, $segment, $expanded));
// set referrer type column to readable value
$dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getReferrerTypeLabel'));
@@ -483,45 +480,6 @@ class API extends \Piwik\Plugin\API
}
/**
- * Utility function that sets the subtables for the getReferrerType report.
- *
- * If we're not getting an expanded datatable, the subtable ID is set to each parent
- * row's referrer type (stored in the label for the getReferrerType report).
- *
- * If we are getting an expanded datatable, the datatable for the row's referrer
- * type is loaded and attached to the appropriate row in the getReferrerType report.
- *
- * @param DataTable $dataTable
- * @param string $idSite
- * @param string $period
- * @param string $date
- * @param string $segment
- * @param bool $expanded
- */
- private function setGetReferrerTypeSubtables($dataTable, $idSite, $period, $date, $segment, $expanded)
- {
- foreach ($dataTable->getRows() as $row) {
- $typeReferrer = $row->getColumn('label');
- if ($typeReferrer != Common::REFERRER_TYPE_DIRECT_ENTRY) {
- if (!$expanded) // if we don't want the expanded datatable, then don't do any extra queries
- {
- $row->setNonLoadedSubtableId($typeReferrer);
- } else // otherwise, we have to get the othe datatables
- {
- $subtable = $this->getReferrerType($idSite, $period, $date, $segment, $type = false,
- $idSubtable = $typeReferrer);
-
- if ($expanded) {
- $subtable->applyQueuedFilters();
- }
-
- $row->setSubtable($subtable);
- }
- }
- }
- }
-
- /**
* @param int $idSite
* @param string $period
* @param string $date
diff --git a/plugins/Referrers/DataTable/Filter/SetGetReferrerTypeSubtables.php b/plugins/Referrers/DataTable/Filter/SetGetReferrerTypeSubtables.php
new file mode 100644
index 0000000000..5d487299d9
--- /dev/null
+++ b/plugins/Referrers/DataTable/Filter/SetGetReferrerTypeSubtables.php
@@ -0,0 +1,87 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\Referrers\DataTable\Filter;
+
+use Piwik\Common;
+use Piwik\DataTable\Row;
+use Piwik\DataTable;
+use Piwik\Plugins\Referrers\API;
+
+/**
+ * Utility function that sets the subtables for the getReferrerType report.
+ *
+ * If we're not getting an expanded datatable, the subtable ID is set to each parent
+ * row's referrer type (stored in the label for the getReferrerType report).
+ *
+ * If we are getting an expanded datatable, the datatable for the row's referrer
+ * type is loaded and attached to the appropriate row in the getReferrerType report.
+ */
+class SetGetReferrerTypeSubtables extends DataTable\BaseFilter
+{
+ /** @var int */
+ private $idSite;
+
+ /** @var string */
+ private $period;
+
+ /** @var string */
+ private $date;
+
+ /** @var string */
+ private $segment;
+
+ /** @var bool */
+ private $expanded;
+
+ /**
+ * Constructor.
+ *
+ * @param DataTable $table The table to eventually filter.
+ * @param int $idSite
+ * @param string $period
+ * @param string $date
+ * @param string $segment
+ * @param bool $expanded
+ */
+ public function __construct($table, $idSite, $period, $date, $segment, $expanded)
+ {
+ parent::__construct($table);
+ $this->idSite = $idSite;
+ $this->period = $period;
+ $this->date = $date;
+ $this->segment = $segment;
+ $this->expanded = $expanded;
+ }
+
+ public function filter($table)
+ {
+ foreach ($table->getRows() as $row) {
+ $typeReferrer = $row->getColumn('label');
+
+ if ($typeReferrer != Common::REFERRER_TYPE_DIRECT_ENTRY) {
+ if (!$this->expanded) // if we don't want the expanded datatable, then don't do any extra queries
+ {
+ $row->setNonLoadedSubtableId($typeReferrer);
+ } else // otherwise, we have to get the othe datatables
+ {
+ $subtable = API::getInstance()->getReferrerType(
+ $this->idSite, $this->period, $this->date, $this->segment, $type = false, $idSubtable = $typeReferrer
+ );
+
+ if ($this->expanded) {
+ $subtable->applyQueuedFilters();
+ }
+
+ $row->setSubtable($subtable);
+ }
+ }
+ }
+
+ }
+} \ No newline at end of file