TYPO3 CMS  TYPO3_6-2
ReviewController.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
32  public function indexAction() {
33  $wsService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService');
34  $this->view->assign('showGrid', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
35  $this->view->assign('showAllWorkspaceTab', TRUE);
36  $this->view->assign('pageUid', GeneralUtility::_GP('id'));
37  $this->view->assign('showLegend', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
38  $wsList = $wsService->getAvailableWorkspaces();
39  $activeWorkspace = $GLOBALS['BE_USER']->workspace;
40  $performWorkspaceSwitch = FALSE;
41  // Only admins see multiple tabs, we decided to use it this
42  // way for usability reasons. Regular users might be confused
43  // by switching workspaces with the tabs in a module.
44  if (!$GLOBALS['BE_USER']->isAdmin()) {
45  $wsCur = array($activeWorkspace => TRUE);
46  $wsList = array_intersect_key($wsList, $wsCur);
47  } else {
48  if (strlen(GeneralUtility::_GP('workspace'))) {
49  $switchWs = (int)GeneralUtility::_GP('workspace');
50  if (in_array($switchWs, array_keys($wsList)) && $activeWorkspace != $switchWs) {
51  $activeWorkspace = $switchWs;
52  $GLOBALS['BE_USER']->setWorkspace($activeWorkspace);
53  $performWorkspaceSwitch = TRUE;
55  } elseif ($switchWs == \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES) {
56  $this->redirect('fullIndex');
57  }
58  }
59  }
60  $this->pageRenderer->addInlineSetting('Workspaces', 'isLiveWorkspace', (int)$GLOBALS['BE_USER']->workspace === 0 ? TRUE : FALSE);
61  $this->pageRenderer->addInlineSetting('Workspaces', 'workspaceTabs', $this->prepareWorkspaceTabs($wsList, $activeWorkspace));
62  $this->pageRenderer->addInlineSetting('Workspaces', 'activeWorkspaceId', $activeWorkspace);
63  $this->pageRenderer->addInlineSetting('Workspaces', 'PATH_typo3', GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . TYPO3_mainDir);
64  $this->view->assign('performWorkspaceSwitch', $performWorkspaceSwitch);
65  $this->view->assign('workspaceList', $wsList);
66  $this->view->assign('activeWorkspaceUid', $activeWorkspace);
67  $this->view->assign('activeWorkspaceTitle', \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($activeWorkspace));
68  $this->view->assign('showPreviewLink', $wsService->canCreatePreviewLink(GeneralUtility::_GP('id'), $activeWorkspace));
69  $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', $activeWorkspace);
70  }
71 
78  public function fullIndexAction() {
79  $wsService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService');
80  $wsList = $wsService->getAvailableWorkspaces();
81 
82  if (!$GLOBALS['BE_USER']->isAdmin()) {
83  $activeWorkspace = $GLOBALS['BE_USER']->workspace;
84  $wsCur = array($activeWorkspace => TRUE);
85  $wsList = array_intersect_key($wsList, $wsCur);
86  }
87 
88  $this->pageRenderer->addInlineSetting('Workspaces', 'workspaceTabs', $this->prepareWorkspaceTabs($wsList, \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES));
89  $this->pageRenderer->addInlineSetting('Workspaces', 'activeWorkspaceId', \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES);
90  $this->pageRenderer->addInlineSetting('Workspaces', 'PATH_typo3', GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . TYPO3_mainDir);
91  $this->view->assign('pageUid', GeneralUtility::_GP('id'));
92  $this->view->assign('showGrid', TRUE);
93  $this->view->assign('showLegend', TRUE);
94  $this->view->assign('showAllWorkspaceTab', TRUE);
95  $this->view->assign('workspaceList', $wsList);
96  $this->view->assign('activeWorkspaceUid', \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES);
97  $this->view->assign('showPreviewLink', FALSE);
98  $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES);
99  // set flag for javascript
100  $this->pageRenderer->addInlineSetting('Workspaces', 'allView', '1');
101  }
102 
109  public function singleIndexAction() {
110  $wsService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService');
111  $wsList = $wsService->getAvailableWorkspaces();
112  $activeWorkspace = $GLOBALS['BE_USER']->workspace;
113  $wsCur = array($activeWorkspace => TRUE);
114  $wsList = array_intersect_key($wsList, $wsCur);
115  $backendDomain = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
116  $this->view->assign('pageUid', GeneralUtility::_GP('id'));
117  $this->view->assign('showGrid', TRUE);
118  $this->view->assign('showAllWorkspaceTab', FALSE);
119  $this->view->assign('workspaceList', $wsList);
120  $this->view->assign('backendDomain', $backendDomain);
121  // Setting the document.domain early before JavScript
122  // libraries are loaded, try to access top frame reference
123  // and possibly run into some CORS issue
124  $this->pageRenderer->addJsInlineCode(
125  'backendDomain',
126  'document.domain = ' . GeneralUtility::quoteJSvalue($backendDomain) . ';'
127  );
128  $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
129  }
130 
136  protected function initializeAction() {
137  parent::initializeAction();
138  $this->template->setExtDirectStateProvider();
139  if (\TYPO3\CMS\Workspaces\Service\WorkspaceService::isOldStyleWorkspaceUsed()) {
140  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:warning.oldStyleWorkspaceInUser'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING);
142  $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
144  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
145  $defaultFlashMessageQueue->enqueue($flashMessage);
146  }
147  $this->pageRenderer->loadExtJS();
148  $this->pageRenderer->enableExtJSQuickTips();
149  $states = $GLOBALS['BE_USER']->uc['moduleData']['Workspaces']['States'];
150  $this->pageRenderer->addInlineSetting('Workspaces', 'States', $states);
151  // Load JavaScript:
152  $this->pageRenderer->addExtDirectCode(array(
153  'TYPO3.Workspaces'
154  ));
155  $this->pageRenderer->addJsFile($this->backPath . 'sysext/backend/Resources/Public/JavaScript/flashmessages.js');
156  $this->pageRenderer->addJsFile($this->backPath . 'js/extjs/ux/Ext.grid.RowExpander.js');
157  $this->pageRenderer->addJsFile($this->backPath . 'js/extjs/ux/Ext.app.SearchField.js');
158  $this->pageRenderer->addJsFile($this->backPath . 'js/extjs/ux/Ext.ux.FitToParent.js');
159  $resourcePath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('workspaces') . 'Resources/Public/JavaScript/';
160 
161  // @todo Integrate additional stylesheet resources
162  $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/GridFilters.css');
163  $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/RangeMenu.css');
164 
165  $filters = array(
166  $resourcePath. 'gridfilters/menu/RangeMenu.js',
167  $resourcePath. 'gridfilters/menu/ListMenu.js',
168  $resourcePath .'gridfilters/GridFilters.js',
169  $resourcePath . 'gridfilters/filter/Filter.js',
170  $resourcePath . 'gridfilters/filter/StringFilter.js',
171  $resourcePath . 'gridfilters/filter/DateFilter.js',
172  $resourcePath . 'gridfilters/filter/ListFilter.js',
173  $resourcePath . 'gridfilters/filter/NumericFilter.js',
174  $resourcePath . 'gridfilters/filter/BooleanFilter.js',
175  $resourcePath . 'gridfilters/filter/BooleanFilter.js',
176  );
177 
178  $custom = $this->getAdditionalResourceService()->getJavaScriptResources();
179 
180  $resources = array(
181  $resourcePath . 'Component/RowDetailTemplate.js',
182  $resourcePath . 'Component/RowExpander.js',
183  $resourcePath . 'Component/TabPanel.js',
184  $resourcePath . 'Store/mainstore.js',
185  $resourcePath . 'configuration.js',
186  $resourcePath . 'helpers.js',
187  $resourcePath . 'actions.js',
188  $resourcePath . 'component.js',
189  $resourcePath . 'toolbar.js',
190  $resourcePath . 'grid.js',
191  $resourcePath . 'workspaces.js'
192  );
193 
194  $javaScriptFiles = array_merge($filters, $custom, $resources);
195 
196  foreach ($javaScriptFiles as $javaScriptFile) {
197  $this->pageRenderer->addJsFile($javaScriptFile);
198  }
199  $this->pageRenderer->addInlineSetting('RecordHistory', 'moduleUrl', \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('record_history'));
200  }
201 
209  protected function prepareWorkspaceTabs(array $workspaceList, $activeWorkspace) {
210  $tabs = array();
211 
212  if ($activeWorkspace !== \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES) {
213  $tabs[] = array(
214  'title' => $workspaceList[$activeWorkspace],
215  'itemId' => 'workspace-' . $activeWorkspace,
216  'workspaceId' => $activeWorkspace,
217  'triggerUrl' => $this->getModuleUri($activeWorkspace),
218  );
219  }
220 
221  $tabs[] = array(
222  'title' => 'All workspaces',
223  'itemId' => 'workspace-' . \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES,
224  'workspaceId' => \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES,
225  'triggerUrl' => $this->getModuleUri(\TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES),
226  );
227 
228  foreach ($workspaceList as $workspaceId => $workspaceTitle) {
229  if ($workspaceId === $activeWorkspace) {
230  continue;
231  }
232  $tabs[] = array(
233  'title' => $workspaceTitle,
234  'itemId' => 'workspace-' . $workspaceId,
235  'workspaceId' => $workspaceId,
236  'triggerUrl' => $this->getModuleUri($workspaceId),
237  );
238  }
239 
240  return $tabs;
241  }
242 
249  protected function getModuleUri($workspaceId) {
250  $parameters = array(
251  'id' => (int)$this->pageId,
252  'workspace' => (int)$workspaceId,
253  );
254  // The "all workspaces" tab is handled in fullIndexAction
255  // which is required as additional GET parameter in the URI then
256  if ($workspaceId === \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES) {
257  $this->uriBuilder->reset()->uriFor('fullIndex');
258  $parameters = array_merge($parameters, $this->uriBuilder->getArguments());
259  }
260  return \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_WorkspacesWorkspaces', $parameters);
261  }
262 
263 }
$parameters
Definition: FileDumpEID.php:15
prepareWorkspaceTabs(array $workspaceList, $activeWorkspace)
static getModuleUrl($moduleName, $urlParameters=array(), $backPathOverride=FALSE, $returnAbsoluteUrl=FALSE)
redirect($actionName, $controllerName=NULL, $extensionName=NULL, array $arguments=NULL, $pageUid=NULL, $delay=0, $statusCode=303)
static setUpdateSignal($set='', $params='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]