OtCustomizerController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace Opentalent\OtTemplating\Controller;
  3. use Opentalent\OtTemplating\Utilities\OtPageRepository;
  4. use TYPO3\CMS\Core\Page\PageRenderer;
  5. use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
  6. use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
  7. use TYPO3\CMS\Core\Utility\GeneralUtility;
  8. /**
  9. * Controller for the OtCustomizer backend submodule
  10. *
  11. * @author olivier.massot
  12. */
  13. class OtCustomizerController extends ActionController {
  14. CONST themes = [
  15. 'classic' => [
  16. 'name' => 'Classique',
  17. 'description' => 'Le thème classique',
  18. 'picture' => 'EXT:ot_templating/Resources/Public/media/theme_classic.png'
  19. ],
  20. 'modern' => [
  21. 'name' => 'Moderne',
  22. 'description' => 'Le thème 2020 pour votre site',
  23. 'picture' => 'EXT:ot_templating/Resources/Public/media/theme_modern.png'
  24. ]
  25. ];
  26. /**
  27. *
  28. * @var int
  29. */
  30. protected $pageRootId;
  31. public function __construct() {
  32. $this->pageRootId = (int) GeneralUtility::_GP('id');
  33. }
  34. /**
  35. * Index action
  36. */
  37. public function indexAction() {
  38. // Get the current page
  39. $pageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
  40. $pageId = (int) GeneralUtility::_GP('id');
  41. $page = $pageRepository->getPage($pageId);
  42. // Get the root page of the site
  43. $pageRepository = new OtPageRepository();
  44. $rootPage = $pageRepository->getRootPageFor($pageId);
  45. // If the current page is not a root page or a subpage of one, abort
  46. $pageSelected = ($rootPage['uid'] > 0);
  47. $this->view->assign('pageSelected', (int)$pageSelected);
  48. if (!$pageSelected) {
  49. return;
  50. }
  51. $this->view->assign('rootPage', $rootPage);
  52. $this->view->assign('themes', self::themes);
  53. }
  54. /**
  55. * Gets the backend user
  56. *
  57. * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
  58. */
  59. protected function getBackendUser() {
  60. return $GLOBALS['BE_USER'];
  61. }
  62. }