TYPO3  7.6
BackendUtilityHook.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Workspaces\Hook;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
23 {
29  public static function getInstance()
30  {
31  return GeneralUtility::makeInstance(__CLASS__);
32  }
33 
47  public function preProcess(&$pageUid, $backPath, $rootLine, $anchorSection, &$viewScript, $additionalGetVars, $switchFocus)
48  {
49  if ($GLOBALS['BE_USER']->workspace !== 0) {
50  $viewScript = $this->getWorkspaceService()->generateWorkspaceSplittedPreviewLink($pageUid);
51  }
52  }
53 
59  protected function getWorkspaceService()
60  {
61  return GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\WorkspaceService::class);
62  }
63 
72  public function makeEditForm_accessCheck($params, &$form)
73  {
74  if ($GLOBALS['BE_USER']->workspace !== 0 && $GLOBALS['TCA'][$params['table']]['ctrl']['versioningWS']) {
75  $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($params['table'], $params['uid']);
76  if (abs($record['t3ver_stage']) > \TYPO3\CMS\Workspaces\Service\StagesService::STAGE_EDIT_ID) {
77  $stages = GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\StagesService::class);
78  $stageName = $stages->getStageTitle($record['t3ver_stage']);
79  $editingName = $stages->getStageTitle(\TYPO3\CMS\Workspaces\Service\StagesService::STAGE_EDIT_ID);
80  $message = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:info.elementAlreadyModified');
81  $flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, sprintf($message, $stageName, $editingName), '', \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, true);
83  $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
85  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
86  $defaultFlashMessageQueue->enqueue($flashMessage);
87  }
88  }
89  return $params['hasAccess'];
90  }
91 }