|
13 | 13 | use In2code\Lux\Domain\DataProvider\LanguagesNewsDataProvider; |
14 | 14 | use In2code\Lux\Domain\DataProvider\LinkclickDataProvider; |
15 | 15 | use In2code\Lux\Domain\DataProvider\NewsvisistsDataProvider; |
| 16 | +use In2code\Lux\Domain\DataProvider\PagevisistsBySourceDataProvider; |
16 | 17 | use In2code\Lux\Domain\DataProvider\PagevisistsDataProvider; |
17 | 18 | use In2code\Lux\Domain\DataProvider\ReferrerAmountDataProvider; |
| 19 | +use In2code\Lux\Domain\DataProvider\ReferrerCategoryDataProvider; |
18 | 20 | use In2code\Lux\Domain\DataProvider\SearchDataProvider; |
19 | 21 | use In2code\Lux\Domain\DataProvider\SocialMediaDataProvider; |
20 | 22 | use In2code\Lux\Domain\DataProvider\UtmCampaignDataProvider; |
|
25 | 27 | use In2code\Lux\Domain\Model\News; |
26 | 28 | use In2code\Lux\Domain\Model\Page; |
27 | 29 | use In2code\Lux\Domain\Model\Transfer\FilterDto; |
| 30 | +use In2code\Lux\Domain\Service\Referrer\SourceHelper; |
28 | 31 | use In2code\Lux\Exception\ArgumentsException; |
29 | 32 | use In2code\Lux\Exception\AuthenticationException; |
30 | 33 | use In2code\Lux\Utility\BackendUtility; |
@@ -225,6 +228,54 @@ public function utmCsvAction(FilterDto $filter): ResponseInterface |
225 | 228 | return $this->csvResponse(); |
226 | 229 | } |
227 | 230 |
|
| 231 | + /** |
| 232 | + * @return void |
| 233 | + * @throws NoSuchArgumentException |
| 234 | + */ |
| 235 | + public function initializeSourcesAction(): void |
| 236 | + { |
| 237 | + $this->setFilter(); |
| 238 | + } |
| 239 | + |
| 240 | + /** |
| 241 | + * Sources with referrers |
| 242 | + * |
| 243 | + * @param FilterDto $filter |
| 244 | + * @param string $export |
| 245 | + * @return ResponseInterface |
| 246 | + * @throws ExceptionDbal |
| 247 | + */ |
| 248 | + public function sourcesAction(FilterDto $filter, string $export = ''): ResponseInterface |
| 249 | + { |
| 250 | + if ($export === 'csv') { |
| 251 | + return (new ForwardResponse('sourcesCsv'))->withArguments(['filter' => $filter]); |
| 252 | + } |
| 253 | + |
| 254 | + $values = [ |
| 255 | + 'filter' => $filter, |
| 256 | + 'referrers' => $this->pagevisitsRepository->getReferrers($filter), |
| 257 | + 'sourceCategories' => GeneralUtility::makeInstance(SourceHelper::class)->getAllKeys(), |
| 258 | + 'categoryData' => GeneralUtility::makeInstance(ReferrerCategoryDataProvider::class, $filter), |
| 259 | + ]; |
| 260 | + $this->moduleTemplate->assignMultiple($values); |
| 261 | + |
| 262 | + $this->addDocumentHeaderForCurrentController(); |
| 263 | + return $this->defaultRendering(); |
| 264 | + } |
| 265 | + |
| 266 | + /** |
| 267 | + * @param FilterDto $filter |
| 268 | + * @return ResponseInterface |
| 269 | + * @throws ExceptionDbal |
| 270 | + */ |
| 271 | + public function sourcesCsvAction(FilterDto $filter): ResponseInterface |
| 272 | + { |
| 273 | + $this->view->assignMultiple([ |
| 274 | + 'referrers' => $this->pagevisitsRepository->getReferrers($filter), |
| 275 | + ]); |
| 276 | + return $this->csvResponse(); |
| 277 | + } |
| 278 | + |
228 | 279 | /** |
229 | 280 | * @return void |
230 | 281 | * @throws NoSuchArgumentException |
@@ -443,6 +494,31 @@ public function detailSearchAction(string $searchterm): ResponseInterface |
443 | 494 | return $this->defaultRendering(); |
444 | 495 | } |
445 | 496 |
|
| 497 | + /** |
| 498 | + * @param string $referrerDomain |
| 499 | + * @return ResponseInterface |
| 500 | + * @throws ArgumentsException |
| 501 | + * @throws ExceptionDbal |
| 502 | + */ |
| 503 | + public function detailSourceAction(string $referrerDomain): ResponseInterface |
| 504 | + { |
| 505 | + $filter = BackendUtility::getFilterFromSession( |
| 506 | + 'sources', |
| 507 | + $this->getControllerName(), |
| 508 | + ['searchterm' => $referrerDomain, 'limit' => 100] |
| 509 | + ); |
| 510 | + $this->moduleTemplate->assignMultiple([ |
| 511 | + 'filter' => $filter, |
| 512 | + 'referrerDomain' => $referrerDomain, |
| 513 | + 'pagevisits' => $this->pagevisitsRepository->findByReferrerDomain($filter), |
| 514 | +// 'searchData' => GeneralUtility::makeInstance(SearchDataProvider::class, $filter), |
| 515 | +// 'searches' => $this->searchRepository->findByFilter($filter), |
| 516 | + ]); |
| 517 | + |
| 518 | + $this->addDocumentHeaderForCurrentController(); |
| 519 | + return $this->defaultRendering(); |
| 520 | + } |
| 521 | + |
446 | 522 | /** |
447 | 523 | * AJAX action to show a detail view coming from contentAction |
448 | 524 | * |
@@ -475,6 +551,39 @@ public function detailAjaxPage(ServerRequestInterface $request): ResponseInterfa |
475 | 551 | return $response; |
476 | 552 | } |
477 | 553 |
|
| 554 | + /** |
| 555 | + * AJAX action to show a detail view coming from sourceAction |
| 556 | + * |
| 557 | + * @param ServerRequestInterface $request |
| 558 | + * @return ResponseInterface |
| 559 | + * @noinspection PhpUnused |
| 560 | + * @throws ExceptionDbal |
| 561 | + * @throws ArgumentsException |
| 562 | + */ |
| 563 | + public function detailAjaxSource(ServerRequestInterface $request): ResponseInterface |
| 564 | + { |
| 565 | + $filter = BackendUtility::getFilterFromSession( |
| 566 | + 'sources', |
| 567 | + 'Analysis', |
| 568 | + ['searchterm' => (string)$request->getQueryParams()['referrerDomain'], 'limit' => 10] |
| 569 | + ); |
| 570 | + $standaloneView = ObjectUtility::getStandaloneView(); |
| 571 | + $standaloneView->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName( |
| 572 | + 'EXT:lux/Resources/Private/Templates/Analysis/SourcesDetailAjax.html' |
| 573 | + )); |
| 574 | + $standaloneView->setPartialRootPaths(['EXT:lux/Resources/Private/Partials/']); |
| 575 | + $standaloneView->assignMultiple([ |
| 576 | + 'filter' => $filter, |
| 577 | + 'pagevisits' => $this->pagevisitsRepository->findByReferrerDomain($filter), |
| 578 | + 'pagevisitsBySourceData' => GeneralUtility::makeInstance(PagevisistsBySourceDataProvider::class, $filter), |
| 579 | + ]); |
| 580 | + $response = GeneralUtility::makeInstance(JsonResponse::class); |
| 581 | + /** @var StreamInterface $stream */ |
| 582 | + $stream = $response->getBody(); |
| 583 | + $stream->write(json_encode(['html' => $standaloneView->render()])); |
| 584 | + return $response; |
| 585 | + } |
| 586 | + |
478 | 587 | /** |
479 | 588 | * AJAX action to show a detail view for news |
480 | 589 | * |
@@ -627,7 +736,7 @@ protected function addDocumentHeaderForCurrentController(): void |
627 | 736 | if ($this->searchRepository->isTableFilled()) { |
628 | 737 | $actions[] = 'search'; |
629 | 738 | } |
630 | | - $actions = array_merge($actions, ['utm', 'linkListener']); |
| 739 | + $actions = array_merge($actions, ['utm', 'sources', 'linkListener']); |
631 | 740 | $menuConfiguration = []; |
632 | 741 | foreach ($actions as $action) { |
633 | 742 | $menuConfiguration[] = [ |
|
0 commit comments