diff --git a/Classes/Controller/AnalysisController.php b/Classes/Controller/AnalysisController.php index 3cc7653d..1324538d 100644 --- a/Classes/Controller/AnalysisController.php +++ b/Classes/Controller/AnalysisController.php @@ -201,7 +201,6 @@ public function utmAction(FilterDto $filter, string $export = ''): ResponseInter 'utmCampaigns' => $this->utmRepository->findAllCampaigns($filter), 'utmSources' => $this->utmRepository->findAllSources($filter), 'utmMedia' => $this->utmRepository->findAllMedia($filter), - 'utmContent' => $this->utmRepository->findAllContent($filter), 'utmList' => $this->utmRepository->findByFilter($filter), 'utmData' => GeneralUtility::makeInstance(UtmDataProvider::class, $filter), 'utmCampaignData' => GeneralUtility::makeInstance(UtmCampaignDataProvider::class, $filter), diff --git a/Classes/Domain/Model/Transfer/FilterDto.php b/Classes/Domain/Model/Transfer/FilterDto.php index d9142c25..8a440d0b 100644 --- a/Classes/Domain/Model/Transfer/FilterDto.php +++ b/Classes/Domain/Model/Transfer/FilterDto.php @@ -63,6 +63,7 @@ class FilterDto protected int $timePeriodDefault = self::PERIOD_DEFAULT; protected int $timePeriod = self::PERIOD_DEFAULT; protected int $identified = self::IDENTIFIED_ALL; + protected bool $withReferrer = false; /** * Filter by categoryscoring greater then 0 @@ -280,6 +281,22 @@ public function setIdentified(?int $identified): self return $this; } + public function isWithReferrer(): bool + { + return $this->withReferrer; + } + + public function isWithReferrerSet(): bool + { + return $this->isWithReferrer() !== false; + } + + public function setWithReferrer(bool $withReferrer): self + { + $this->withReferrer = $withReferrer; + return $this; + } + /** * Set a timeTo and timeFrom if there is a timeframe given in seconds. E.g. 60 means a starttime 60s ago to now. * @@ -594,6 +611,7 @@ public function isSet(): bool || $this->isTimeToSet() || $this->isTimePeriodSet() || $this->isIdentifiedSet() + || $this->isWithReferrerSet() || $this->isDomainSet() || $this->isCountrySet() || $this->isSiteSet() @@ -611,26 +629,6 @@ public function isTimeFromOrTimeToSet(): bool return $this->isTimeFromSet() || $this->isTimeToSet(); } - /** - * Is only a searchterm given and nothing else in backend filter? - * - * @return bool - */ - protected function isOnlySearchtermGiven(): bool - { - return $this->isSearchtermSet() - && $this->isPidSet() === false - && $this->isScoringSet() === false - && $this->isCategoryScoringSet() === false - && $this->isTimeFromSet() === false - && $this->isTimeToSet() === false - && $this->timePeriod === self::PERIOD_DEFAULT - && $this->identified === self::IDENTIFIED_ALL - && $this->isDomainSet() === false - && $this->isSiteSet() === false - && $this->isCountrySet() === false; - } - /** * Get a start datetime for period filter * diff --git a/Classes/Domain/Repository/UtmRepository.php b/Classes/Domain/Repository/UtmRepository.php index 17442f01..3f9f6d53 100644 --- a/Classes/Domain/Repository/UtmRepository.php +++ b/Classes/Domain/Repository/UtmRepository.php @@ -27,6 +27,7 @@ public function findByFilter(FilterDto $filter): QueryResultInterface $query = $this->createQuery(); $logicalAnd = $this->extendLogicalAndWithFilterConstraintsForCrdate($filter, $query, []); $logicalAnd = $this->extendWithExtendedFilterQuery($query, $logicalAnd, $filter); + $logicalAnd = $this->extendLogicalAndWithFilterConstraintsForIsReferrer($filter, $query, $logicalAnd); $query->matching($query->logicalAnd(...$logicalAnd)); $query->setLimit(750); return $query->execute(); @@ -62,16 +63,6 @@ public function findAllMedia(FilterDto $filter): array return $this->findAllProperties('utm_medium', $filter); } - /** - * @param FilterDto $filter - * @return array - * @throws ExceptionDbal - */ - public function findAllContent(FilterDto $filter): array - { - return $this->findAllProperties('utm_content', $filter); - } - /** * @param string $property * @param FilterDto $filter @@ -112,6 +103,7 @@ public function getNumberOfVisitorsInTimeFrame(DateTime $start, DateTime $end, F $query->lessThanOrEqual('crdate', $end->format('U')), ]; $logicalAnd = $this->extendWithExtendedFilterQuery($query, $logicalAnd, $filter); + $logicalAnd = $this->extendLogicalAndWithFilterConstraintsForIsReferrer($filter, $query, $logicalAnd); $query->matching($query->logicalAnd(...$logicalAnd)); return $query->execute()->count(); } @@ -142,8 +134,8 @@ public function findCombinedByField(string $field, FilterDto $filter): array . $this->extendWhereClauseWithFilterCampaign($filter, 'utm') . $this->extendWhereClauseWithFilterSource($filter, 'utm') . $this->extendWhereClauseWithFilterMedium($filter, 'utm') - . $this->extendWhereClauseWithFilterContent($filter, 'utm') . $this->extendWhereClauseWithFilterSite($filter) + . $this->extendWhereClauseWithFilterIsReferrer($filter, 'utm') . ' group by utm.' . $field . ' order by count desc limit 8'; return $connection->executeQuery($sql)->fetchAllAssociative(); } @@ -187,19 +179,6 @@ protected function extendWhereClauseWithFilterMedium(FilterDto $filter, string $ return $sql; } - protected function extendWhereClauseWithFilterContent(FilterDto $filter, string $table = ''): string - { - $sql = ''; - if ($filter->isUtmContentSet()) { - $field = 'utm_content'; - if ($table !== '') { - $field = $table . '.' . $field; - } - $sql .= ' and ' . $field . '="' . $filter->getUtmContent() . '"'; - } - return $sql; - } - /** * Returns part of a where clause like * ' and site="site 1"' @@ -218,6 +197,19 @@ protected function extendWhereClauseWithFilterSite(FilterDto $filter, string $ta return $sql; } + protected function extendWhereClauseWithFilterIsReferrer(FilterDto $filter, string $table = ''): string + { + $sql = ''; + if ($filter->isWithReferrerSet()) { + $field = 'referrer'; + if ($table !== '') { + $field = $table . '.' . $field; + } + $sql .= ' and ' . $field . ' != \'\''; + } + return $sql; + } + /** * @param QueryInterface $query * @param array $logicalAnd @@ -262,4 +254,15 @@ protected function extendWithExtendedFilterQuery( } return $logicalAnd; } + + protected function extendLogicalAndWithFilterConstraintsForIsReferrer( + FilterDto $filter, + QueryInterface $query, + array $logicalAnd + ): array { + if ($filter->isWithReferrerSet()) { + $logicalAnd[] = $query->logicalNot($query->equals('referrer', '')); + } + return $logicalAnd; + } } diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index 26703c37..c346c085 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -2605,6 +2605,10 @@ Page Identifier (PID) Seitennummer (PID) + + With referrer + Mit Referrer + diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index e5fd99cd..66e047a1 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -1969,6 +1969,9 @@ Page Identifier (PID) + + With referrer + diff --git a/Resources/Private/Partials/Filter/Analysis/Utm.html b/Resources/Private/Partials/Filter/Analysis/Utm.html index f1341fa3..797d3c6e 100644 --- a/Resources/Private/Partials/Filter/Analysis/Utm.html +++ b/Resources/Private/Partials/Filter/Analysis/Utm.html @@ -123,18 +123,18 @@
- - +
+ + +