OtStatsController.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Opentalent\OtStats\Controller;
  3. use Opentalent\OtStats\Settings\StatsSettingsRepository;
  4. use Opentalent\OtCore\Page\OtPageRepository;
  5. use TYPO3\CMS\Core\Utility\GeneralUtility;
  6. use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
  7. /**
  8. * Controller for the OtStats backend submodule
  9. *
  10. * @author olivier.massot
  11. */
  12. class OtStatsController extends ActionController {
  13. /**
  14. * Index action (default action)
  15. * Displays the customizer page on the backend
  16. */
  17. public function indexAction() {
  18. // Get the selected page uid
  19. $pageId = (int) GeneralUtility::_GP('id');
  20. // Get the root page of the site
  21. $otPageRepository = GeneralUtility::makeInstance(OtPageRepository::class);
  22. $rootPage = $otPageRepository->getRootPageFor($pageId);
  23. $rootPageUid = (int)($rootPage['uid'] ?? 0);
  24. // If the current page is not a root page or a subpage of one, abort
  25. $pageSelected = ($rootPageUid !== null);
  26. $this->view->assign('pageSelected', (int)$pageSelected);
  27. if (!$pageSelected) {
  28. return;
  29. }
  30. $this->view->assign('rootPage', $rootPageUid);
  31. $statsSettingsRepository = GeneralUtility::makeInstance(StatsSettingsRepository::class);
  32. $matomoId = $statsSettingsRepository->getMatomoSiteId($rootPageUid);
  33. $statsActivated = ($matomoId !== null);
  34. $this->view->assign('statsActivated', (int)$statsActivated);
  35. if (!$statsActivated) {
  36. return;
  37. }
  38. $this->view->assign('matomoSiteId', (int)$matomoId);
  39. }
  40. /**
  41. * Creates a matomo site record if none exists and
  42. * save its id
  43. */
  44. public function enableStatsAction() {
  45. }
  46. /**
  47. * Disable the stats monitoring
  48. */
  49. public function disableStatsAction() {
  50. }
  51. }