[ 'name' => 'Classique', 'description' => "Le thème classique, simple et complet. C'est le thème par défaut.", 'picture' => 'EXT:ot_templating/Resources/Public/media/theme_classic.png' ], 'Modern' => [ 'name' => 'Moderne', 'description' => '[Nouveauté 2020] Un thème moderne et intuitif.', 'picture' => 'EXT:ot_templating/Resources/Public/media/theme_modern.png' ] ]; CONST defaultTemplate = 'Classic'; CONST defaultPreferences = [ 'themeColor' => 'lightblue', 'displayCarousel' => '1' ]; /** * Returns the root page of the given page, * or the page itself if the given page is * already the rootpage of the site * * @param $pageUid * * @return array */ public function getRootPageFor($pageUid) { $pageService = GeneralUtility::makeInstance(ObjectManager::class)->get(PageService::class); $rootLine = $pageService->getRootLine($pageUid); for (end($rootLine); key($rootLine)!==null; prev($rootLine)){ $page = current($rootLine); if ($page['is_siteroot'] == 1) { return $page; } } return []; } /** * Recursively returns all the subpages of the given page * * @param $pageUid * @return array */ public function getAllSubpagesForPage($pageUid) { $subpages = []; $stack = $this->getSubpagesForPages( [$pageUid], '*', 'sorting', '', false ); foreach ($stack as $page) { $subpages[] = $page; $children = $this->getAllSubpagesForPage($page['uid']); if (!empty($children)) { $subpages = array_merge($subpages, $children); } } return $subpages; } /** * Returns the current site template's name * @return string */ public function getCurrentTemplate() { $rootPageUid = $this->getCurrentSiteRootPageId(); if (!($rootPageUid >= 0)) { // throw new \RuntimeException('Can not find any root page'); return self::defaultTemplate; } $rootPage = $this->getPage($rootPageUid); $templateName = $rootPage['tx_opentalent_template']; if ($templateName==='') { return self::defaultTemplate; } return $templateName; } /** * Returns the current site template's name * @return array */ public function getTemplatePreferences() { $rootPageUid = $this->getCurrentSiteRootPageId(); if (!($rootPageUid >= 0)) { return []; } $rootPage = $this->getPage($rootPageUid); $templatePreferences = $rootPage['tx_opentalent_template_preferences']; if ($templatePreferences==='') { return self::defaultPreferences; } return json_decode($templatePreferences, true); } /** * Returns the typo3 site matching the current request * */ public function getCurrentSite() { $request = $GLOBALS['TYPO3_REQUEST']; $site = $request->getAttribute('site'); return GeneralUtility::makeInstance(SiteFinder::class) ->getSiteByIdentifier($site->getIdentifier()); } /** * */ public function getCurrentSiteRootPageId() { $site = $this->getCurrentSite(); return $site->getRootPageId(); } /** * */ public function getCurrentSiteRootPageUri() { $site = $this->getCurrentSite(); return $site->getBase(); } /** * */ public function getCurrentSiteRootPage() { $uid = $this->getCurrentSiteRootPageUri(); return $this->getPage($uid); } }