[TASK] Make show_rechis.php mod.php dispatched
[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 text file 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 use TYPO3\CMS\Core\Utility\GeneralUtility;
31
32 /**
33 * Review controller.
34 *
35 * @author Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
36 */
37 class ReviewController extends \TYPO3\CMS\Workspaces\Controller\AbstractController {
38
39 /**
40 * Renders the review module user dependent with all workspaces.
41 * The module will show all records of one workspace.
42 *
43 * @return void
44 */
45 public function indexAction() {
46 $wsService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService');
47 $this->view->assign('showGrid', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
48 $this->view->assign('showAllWorkspaceTab', TRUE);
49 $this->view->assign('pageUid', GeneralUtility::_GP('id'));
50 $this->view->assign('showLegend', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
51 $wsList = $wsService->getAvailableWorkspaces();
52 $activeWorkspace = $GLOBALS['BE_USER']->workspace;
53 $performWorkspaceSwitch = FALSE;
54 // Only admins see multiple tabs, we decided to use it this
55 // way for usability reasons. Regular users might be confused
56 // by switching workspaces with the tabs in a module.
57 if (!$GLOBALS['BE_USER']->isAdmin()) {
58 $wsCur = array($activeWorkspace => TRUE);
59 $wsList = array_intersect_key($wsList, $wsCur);
60 } else {
61 if (strlen(GeneralUtility::_GP('workspace'))) {
62 $switchWs = (int)GeneralUtility::_GP('workspace');
63 if (in_array($switchWs, array_keys($wsList)) && $activeWorkspace != $switchWs) {
64 $activeWorkspace = $switchWs;
65 $GLOBALS['BE_USER']->setWorkspace($activeWorkspace);
66 $performWorkspaceSwitch = TRUE;
67 \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree');
68 } elseif ($switchWs == \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES) {
69 $this->redirect('fullIndex');
70 }
71 }
72 }
73 $this->pageRenderer->addInlineSetting('Workspaces', 'isLiveWorkspace', $GLOBALS['BE_USER']->workspace == 0 ? TRUE : FALSE);
74 $this->view->assign('performWorkspaceSwitch', $performWorkspaceSwitch);
75 $this->view->assign('workspaceList', $wsList);
76 $this->view->assign('activeWorkspaceUid', $activeWorkspace);
77 $this->view->assign('activeWorkspaceTitle', \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($activeWorkspace));
78 $this->view->assign('showPreviewLink', $wsService->canCreatePreviewLink(GeneralUtility::_GP('id'), $activeWorkspace));
79 $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', $activeWorkspace);
80 }
81
82 /**
83 * Renders the review module user dependent.
84 * The module will show all records of all workspaces.
85 *
86 * @return void
87 */
88 public function fullIndexAction() {
89 $wsService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService');
90 $wsList = $wsService->getAvailableWorkspaces();
91
92 if (!$GLOBALS['BE_USER']->isAdmin()) {
93 $activeWorkspace = $GLOBALS['BE_USER']->workspace;
94 $wsCur = array($activeWorkspace => TRUE);
95 $wsList = array_intersect_key($wsList, $wsCur);
96 }
97
98 $this->view->assign('pageUid', GeneralUtility::_GP('id'));
99 $this->view->assign('showGrid', TRUE);
100 $this->view->assign('showLegend', TRUE);
101 $this->view->assign('showAllWorkspaceTab', TRUE);
102 $this->view->assign('workspaceList', $wsList);
103 $this->view->assign('activeWorkspaceUid', \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES);
104 $this->view->assign('showPreviewLink', FALSE);
105 $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES);
106 // set flag for javascript
107 $this->pageRenderer->addInlineSetting('Workspaces', 'allView', '1');
108 }
109
110 /**
111 * Renders the review module for a single page. This is used within the
112 * workspace-preview frame.
113 *
114 * @return void
115 */
116 public function singleIndexAction() {
117 $wsService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService');
118 $wsList = $wsService->getAvailableWorkspaces();
119 $activeWorkspace = $GLOBALS['BE_USER']->workspace;
120 $wsCur = array($activeWorkspace => TRUE);
121 $wsList = array_intersect_key($wsList, $wsCur);
122 $this->view->assign('pageUid', GeneralUtility::_GP('id'));
123 $this->view->assign('showGrid', TRUE);
124 $this->view->assign('showAllWorkspaceTab', FALSE);
125 $this->view->assign('workspaceList', $wsList);
126 $this->view->assign('backendDomain', GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'));
127 $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
128 }
129
130 /**
131 * Initializes the controller before invoking an action method.
132 *
133 * @return void
134 */
135 protected function initializeAction() {
136 parent::initializeAction();
137 $this->template->setExtDirectStateProvider();
138 if (\TYPO3\CMS\Workspaces\Service\WorkspaceService::isOldStyleWorkspaceUsed()) {
139 $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);
140 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
141 $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
142 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
143 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
144 $defaultFlashMessageQueue->enqueue($flashMessage);
145 }
146 $this->pageRenderer->loadExtJS();
147 $this->pageRenderer->enableExtJSQuickTips();
148 $states = $GLOBALS['BE_USER']->uc['moduleData']['Workspaces']['States'];
149 $this->pageRenderer->addInlineSetting('Workspaces', 'States', $states);
150 // Load JavaScript:
151 $this->pageRenderer->addExtDirectCode(array(
152 'TYPO3.Workspaces'
153 ));
154 $this->pageRenderer->addJsFile($this->backPath . 'sysext/backend/Resources/Public/JavaScript/flashmessages.js');
155 $this->pageRenderer->addJsFile($this->backPath . 'js/extjs/ux/Ext.grid.RowExpander.js');
156 $this->pageRenderer->addJsFile($this->backPath . 'js/extjs/ux/Ext.app.SearchField.js');
157 $this->pageRenderer->addJsFile($this->backPath . 'js/extjs/ux/Ext.ux.FitToParent.js');
158 $resourcePath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('workspaces') . 'Resources/Public/JavaScript/';
159
160 // @todo Integrate additional stylesheet resources
161 $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/GridFilters.css');
162 $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/RangeMenu.css');
163
164 $filters = array(
165 $resourcePath. 'gridfilters/menu/RangeMenu.js',
166 $resourcePath. 'gridfilters/menu/ListMenu.js',
167 $resourcePath .'gridfilters/GridFilters.js',
168 $resourcePath . 'gridfilters/filter/Filter.js',
169 $resourcePath . 'gridfilters/filter/StringFilter.js',
170 $resourcePath . 'gridfilters/filter/DateFilter.js',
171 $resourcePath . 'gridfilters/filter/ListFilter.js',
172 $resourcePath . 'gridfilters/filter/NumericFilter.js',
173 $resourcePath . 'gridfilters/filter/BooleanFilter.js',
174 $resourcePath . 'gridfilters/filter/BooleanFilter.js',
175 );
176
177 $custom = $this->getAdditionalResourceService()->getJavaScriptResources();
178
179 $resources = array(
180 $resourcePath . 'Store/mainstore.js',
181 $resourcePath . 'configuration.js',
182 $resourcePath . 'helpers.js',
183 $resourcePath . 'actions.js',
184 $resourcePath . 'component.js',
185 $resourcePath . 'toolbar.js',
186 $resourcePath . 'grid.js',
187 $resourcePath . 'workspaces.js'
188 );
189
190 $javaScriptFiles = array_merge($filters, $custom, $resources);
191
192 foreach ($javaScriptFiles as $javaScriptFile) {
193 $this->pageRenderer->addJsFile($javaScriptFile);
194 }
195 $this->pageRenderer->addInlineSetting('RecordHistory', 'moduleUrl', \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('record_history'));
196 }
197
198 }