|
|
@@ -2,12 +2,11 @@
|
|
|
|
|
|
namespace Opentalent\OtTemplating\Controller;
|
|
|
|
|
|
-use Opentalent\OtCore\Page\OtPageRepository;
|
|
|
+use Opentalent\OtCore\Controller\SelectedSiteController;
|
|
|
use Opentalent\OtCore\Cache\OtCacheManager;
|
|
|
use Opentalent\OtTemplating\Templating\TemplateRepository;
|
|
|
use PDO;
|
|
|
use TYPO3\CMS\Core\Database\ConnectionPool;
|
|
|
-use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
|
|
|
/**
|
|
|
@@ -15,34 +14,22 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
*
|
|
|
* @author olivier.massot
|
|
|
*/
|
|
|
-class OtCustomizerController extends ActionController {
|
|
|
+class OtCustomizerController extends SelectedSiteController {
|
|
|
|
|
|
/**
|
|
|
* Index action (default action)
|
|
|
* Displays the customizer page on the backend
|
|
|
*/
|
|
|
public function indexAction() {
|
|
|
-
|
|
|
- // Get the current root page's uid
|
|
|
- $rootPageUid = $this->getCurrentRootPageUid();
|
|
|
-
|
|
|
- // If the current page is not a root page or a subpage of one, abort
|
|
|
- $pageSelected = ($rootPageUid !== null);
|
|
|
- $this->view->assign('pageSelected', (int)$pageSelected);
|
|
|
- if (!$pageSelected) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- $this->view->assign('rootPage', $rootPageUid);
|
|
|
+ $this->view->assign('rootPage', $this->currentRootUid);
|
|
|
$this->view->assign('templates', TemplateRepository::templates);
|
|
|
|
|
|
$templateRepository = GeneralUtility::makeInstance(TemplateRepository::class);
|
|
|
- $this->view->assign('currentTemplate', $templateRepository->getCurrentTemplate());
|
|
|
- $this->view->assign('preferences', $templateRepository->getTemplatePreferences());
|
|
|
+ $this->view->assign('currentTemplate', $templateRepository->getTemplate($this->currentRootUid));
|
|
|
+ $this->view->assign('preferences', $templateRepository->getTemplatePreferences($this->currentRootUid));
|
|
|
|
|
|
$args = $this->request->getArguments();
|
|
|
$this->view->assign('preferencesUpdated', $args['preferencesUpdated']);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -52,16 +39,13 @@ class OtCustomizerController extends ActionController {
|
|
|
public function selectTemplateAction() {
|
|
|
$templateKey = $this->request->getArgument('template_key');
|
|
|
|
|
|
- // Get the current root page's uid
|
|
|
- $rootPageUid = $this->getCurrentRootPageUid();
|
|
|
-
|
|
|
// applies the change in the database
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
|
|
|
$queryBuilder->update('pages')
|
|
|
->where(
|
|
|
$queryBuilder->expr()->eq(
|
|
|
'uid',
|
|
|
- $queryBuilder->createNamedParameter($rootPageUid, PDO::PARAM_INT)
|
|
|
+ $queryBuilder->createNamedParameter($this->currentRootUid, PDO::PARAM_INT)
|
|
|
)
|
|
|
)
|
|
|
->set('tx_opentalent_template', $templateKey)
|
|
|
@@ -69,7 +53,7 @@ class OtCustomizerController extends ActionController {
|
|
|
;
|
|
|
|
|
|
// Clear the site's cache
|
|
|
- OtCacheManager::clearSiteCache($rootPageUid);
|
|
|
+ OtCacheManager::clearSiteCache($this->currentRootUid);
|
|
|
|
|
|
$this->forward('index');
|
|
|
}
|
|
|
@@ -89,16 +73,13 @@ class OtCustomizerController extends ActionController {
|
|
|
$prefs['displayCarousel'] = $args['displayCarousel'];
|
|
|
}
|
|
|
|
|
|
- // Get the current root page's uid
|
|
|
- $rootPageUid = $this->getCurrentRootPageUid();
|
|
|
-
|
|
|
// applies the change in the database
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
|
|
|
$queryBuilder->update('pages')
|
|
|
->where(
|
|
|
$queryBuilder->expr()->eq(
|
|
|
'uid',
|
|
|
- $queryBuilder->createNamedParameter($rootPageUid, PDO::PARAM_INT)
|
|
|
+ $queryBuilder->createNamedParameter($this->currentRootUid, PDO::PARAM_INT)
|
|
|
)
|
|
|
)
|
|
|
->set('tx_opentalent_template_preferences', json_encode($prefs))
|
|
|
@@ -106,7 +87,7 @@ class OtCustomizerController extends ActionController {
|
|
|
;
|
|
|
|
|
|
// Clear the site's cache
|
|
|
- OtCacheManager::clearSiteCache($rootPageUid);
|
|
|
+ OtCacheManager::clearSiteCache($this->currentRootUid);
|
|
|
|
|
|
$this->forward(
|
|
|
'index',
|
|
|
@@ -115,34 +96,4 @@ class OtCustomizerController extends ActionController {
|
|
|
['preferencesUpdated'=>'1']
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * Return the uid of the root page of the currently selected
|
|
|
- * site, or null if no site's page is selected
|
|
|
- *
|
|
|
- * @return int | null
|
|
|
- */
|
|
|
- protected function getCurrentRootPageUid() {
|
|
|
- // Get the current page uid
|
|
|
- $pageId = (int) GeneralUtility::_GP('id');
|
|
|
-
|
|
|
- // Get the root page of the site
|
|
|
- $otPageRepository = GeneralUtility::makeInstance(OtPageRepository::class);
|
|
|
- $rootPage = $otPageRepository->getRootPageFor($pageId);
|
|
|
-
|
|
|
- if (!$rootPage['uid'] > 0) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- return (int)$rootPage['uid'];
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Gets the backend user
|
|
|
- *
|
|
|
- * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
|
|
|
- */
|
|
|
- protected function getBackendUser() {
|
|
|
- return $GLOBALS['BE_USER'];
|
|
|
- }
|
|
|
}
|