[TASK] Replace static calls to FlashMessageQueue to the new service
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Classes / Controller / ReviewController.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2010-2013 Steffen Ritter (steffen@typo3.org)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Review controller.
31 *
32 * @author Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
33 */
34 class ReviewController extends \TYPO3\CMS\Workspaces\Controller\AbstractController {
35
36 /**
37 * Renders the review module user dependent with all workspaces.
38 * The module will show all records of one workspace.
39 *
40 * @return void
41 */
42 public function indexAction() {
43 $wsService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService');
44 $this->view->assign('showGrid', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
45 $this->view->assign('showAllWorkspaceTab', $GLOBALS['BE_USER']->isAdmin());
46 $this->view->assign('pageUid', \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'));
47 $this->view->assign('showLegend', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
48 $wsList = $wsService->getAvailableWorkspaces();
49 $activeWorkspace = $GLOBALS['BE_USER']->workspace;
50 $performWorkspaceSwitch = FALSE;
51 // Only admins see multiple tabs, we decided to use it this
52 // way for usability reasons. Regular users might be confused
53 // by switching workspaces with the tabs in a module.
54 if (!$GLOBALS['BE_USER']->isAdmin()) {
55 $wsCur = array($activeWorkspace => TRUE);
56 $wsList = array_intersect_key($wsList, $wsCur);
57 } else {
58 if (strlen(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('workspace'))) {
59 $switchWs = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('workspace');
60 if (in_array($switchWs, array_keys($wsList)) && $activeWorkspace != $switchWs) {
61 $activeWorkspace = $switchWs;
62 $GLOBALS['BE_USER']->setWorkspace($activeWorkspace);
63 $performWorkspaceSwitch = TRUE;
64 \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree');
65 } elseif ($switchWs == \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES) {
66 $this->redirect('fullIndex');
67 }
68 }
69 }
70 $this->pageRenderer->addInlineSetting('Workspaces', 'isLiveWorkspace', $GLOBALS['BE_USER']->workspace == 0 ? TRUE : FALSE);
71 $this->view->assign('performWorkspaceSwitch', $performWorkspaceSwitch);
72 $this->view->assign('workspaceList', $wsList);
73 $this->view->assign('activeWorkspaceUid', $activeWorkspace);
74 $this->view->assign('activeWorkspaceTitle', \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($activeWorkspace));
75 $this->view->assign('showPreviewLink', $wsService->canCreatePreviewLink(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'), $activeWorkspace));
76 $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', $activeWorkspace);
77 }
78
79 /**
80 * Renders the review module for admins.
81 * The module will show all records of all workspaces.
82 *
83 * @return void
84 */
85 public function fullIndexAction() {
86 if (!$GLOBALS['BE_USER']->isAdmin()) {
87 $this->redirect('index');
88 } else {
89 $wsService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService');
90 $this->view->assign('pageUid', \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'));
91 $this->view->assign('showGrid', TRUE);
92 $this->view->assign('showLegend', TRUE);
93 $this->view->assign('showAllWorkspaceTab', $GLOBALS['BE_USER']->isAdmin());
94 $this->view->assign('workspaceList', $wsService->getAvailableWorkspaces());
95 $this->view->assign('activeWorkspaceUid', \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES);
96 $this->view->assign('showPreviewLink', FALSE);
97 $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES);
98 // set flag for javascript
99 $this->pageRenderer->addInlineSetting('Workspaces', 'allView', '1');
100 }
101 }
102
103 /**
104 * Renders the review module for a single page. This is used within the
105 * workspace-preview frame.
106 *
107 * @return void
108 */
109 public function singleIndexAction() {
110 $wsService = \TYPO3\CMS\Core\Utility\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 $this->view->assign('pageUid', \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'));
116 $this->view->assign('showGrid', TRUE);
117 $this->view->assign('showAllWorkspaceTab', FALSE);
118 $this->view->assign('workspaceList', $wsList);
119 $this->view->assign('backendDomain', \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'));
120 $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
121 }
122
123 /**
124 * Initializes the controller before invoking an action method.
125 *
126 * @return void
127 */
128 protected function initializeAction() {
129 parent::initializeAction();
130 $this->template->setExtDirectStateProvider();
131 if (\TYPO3\CMS\Workspaces\Service\WorkspaceService::isOldStyleWorkspaceUsed()) {
132 $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:warning.oldStyleWorkspaceInUser'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING);
133 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
134 $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
135 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
136 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
137 $defaultFlashMessageQueue->enqueue($flashMessage);
138 }
139 $this->pageRenderer->loadExtJS();
140 $this->pageRenderer->enableExtJSQuickTips();
141 $states = $GLOBALS['BE_USER']->uc['moduleData']['Workspaces']['States'];
142 $this->pageRenderer->addInlineSetting('Workspaces', 'States', $states);
143 // Load JavaScript:
144 $this->pageRenderer->addExtDirectCode(array(
145 'TYPO3.Workspaces'
146 ));
147 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
148 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.grid.RowExpander.js');
149 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.app.SearchField.js');
150 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
151 $resourcePath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('workspaces') . 'Resources/Public/JavaScript/';
152 $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/GridFilters.css');
153 $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/RangeMenu.css');
154 $jsFiles = array(
155 'gridfilters/menu/RangeMenu.js',
156 'gridfilters/menu/ListMenu.js',
157 'gridfilters/GridFilters.js',
158 'gridfilters/filter/Filter.js',
159 'gridfilters/filter/StringFilter.js',
160 'gridfilters/filter/DateFilter.js',
161 'gridfilters/filter/ListFilter.js',
162 'gridfilters/filter/NumericFilter.js',
163 'gridfilters/filter/BooleanFilter.js',
164 'gridfilters/filter/BooleanFilter.js',
165 'Store/mainstore.js',
166 'configuration.js',
167 'helpers.js',
168 'actions.js',
169 'component.js',
170 'toolbar.js',
171 'grid.js',
172 'workspaces.js'
173 );
174 foreach ($jsFiles as $jsFile) {
175 $this->pageRenderer->addJsFile($resourcePath . $jsFile);
176 }
177 }
178
179 }
180
181
182 ?>