[TASK] Re-work/simplify copyright header in PHP files - Part 9
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Classes / Controller / AbstractController.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Controller;
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
17 /**
18 * Abstract action controller.
19 *
20 * @author Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
21 */
22 class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
23
24 /**
25 * @var string Key of the extension this controller belongs to
26 */
27 protected $extensionName = 'Workspaces';
28
29 /**
30 * @var \TYPO3\CMS\Core\Page\PageRenderer
31 */
32 protected $pageRenderer;
33
34 /**
35 * @var integer
36 */
37 protected $pageId;
38
39 /**
40 * Initializes the controller before invoking an action method.
41 *
42 * @return void
43 */
44 protected function initializeAction() {
45 // @todo Evaluate how the intval() call can be used with Extbase validators/filters
46 $this->pageId = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
47 $icons = array(
48 'language' => \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconClasses('flags-multiple'),
49 'integrity' => \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconClasses('status-dialog-information'),
50 'success' => \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconClasses('status-dialog-ok'),
51 'info' => \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconClasses('status-dialog-information'),
52 'warning' => \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconClasses('status-dialog-warning'),
53 'error' => \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconClasses('status-dialog-error')
54 );
55 $this->pageRenderer->addInlineSetting('Workspaces', 'icons', $icons);
56 $this->pageRenderer->addInlineSetting('Workspaces', 'id', $this->pageId);
57 $this->pageRenderer->addInlineSetting('Workspaces', 'depth', $this->pageId === 0 ? 999 : 1);
58 $this->pageRenderer->addInlineSetting('Workspaces', 'language', $this->getLanguageSelection());
59 $this->pageRenderer->addCssFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('workspaces') . 'Resources/Public/StyleSheet/module.css');
60 $this->pageRenderer->addInlineLanguageLabelArray(array(
61 'title' => $GLOBALS['LANG']->getLL('title'),
62 'path' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.path'),
63 'table' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.table'),
64 'depth' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_perm.xlf:Depth'),
65 'depth_0' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_0'),
66 'depth_1' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_1'),
67 'depth_2' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_2'),
68 'depth_3' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_3'),
69 'depth_4' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_4'),
70 'depth_infi' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_infi')
71 ));
72 $this->pageRenderer->addInlineLanguageLabelFile('EXT:workspaces/Resources/Private/Language/locallang.xlf');
73 $this->assignExtensionSettings();
74 }
75
76 /**
77 * Assigns additional Workspace settings to TYPO3.settings.Workspaces.extension
78 *
79 * @return void
80 */
81 protected function assignExtensionSettings() {
82 $extension = array(
83 'AdditionalColumn' => array(
84 'Definition' => array(),
85 'Handler' => array(),
86 ),
87 );
88
89 $extension['AdditionalColumn']['Definition'] = $this->getAdditionalColumnService()->getDefinition();
90 $extension['AdditionalColumn']['Handler'] = $this->getAdditionalColumnService()->getHandler();
91 $this->pageRenderer->addInlineSetting('Workspaces', 'extension', $extension);
92 }
93
94 /**
95 * Processes a general request. The result can be returned by altering the given response.
96 *
97 * @param \TYPO3\CMS\Extbase\Mvc\RequestInterface $request The request object
98 * @param \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response The response, modified by this handler
99 * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException if the controller doesn't support the current request type
100 * @return void
101 */
102 public function processRequest(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response) {
103 $this->template = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
104 $this->pageRenderer = $this->template->getPageRenderer();
105 $GLOBALS['SOBE'] = new \stdClass();
106 $GLOBALS['SOBE']->doc = $this->template;
107 parent::processRequest($request, $response);
108 $pageHeader = $this->template->startpage($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:module.title'));
109 $pageEnd = $this->template->endPage();
110 $response->setContent($pageHeader . $response->getContent() . $pageEnd);
111 }
112
113 /**
114 * Gets the selected language.
115 *
116 * @return string
117 */
118 protected function getLanguageSelection() {
119 $language = 'all';
120 $backendUser = $this->getBackendUser();
121 if (isset($backendUser->uc['moduleData']['Workspaces'][$backendUser->workspace]['language'])) {
122 $language = $backendUser->uc['moduleData']['Workspaces'][$backendUser->workspace]['language'];
123 }
124 return $language;
125 }
126
127 /**
128 * @return \TYPO3\CMS\Workspaces\Service\AdditionalColumnService
129 */
130 protected function getAdditionalColumnService() {
131 return $this->objectManager->get('TYPO3\\CMS\\Workspaces\\Service\\AdditionalColumnService');
132 }
133
134 /**
135 * @return \TYPO3\CMS\Workspaces\Service\AdditionalResourceService
136 */
137 protected function getAdditionalResourceService() {
138 return $this->objectManager->get('TYPO3\\CMS\\Workspaces\\Service\\AdditionalResourceService');
139 }
140
141 /**
142 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
143 */
144 protected function getBackendUser() {
145 return $GLOBALS['BE_USER'];
146 }
147
148 }