TYPO3 CMS  TYPO3_8-7
RecyclerModuleController.php
Go to the documentation of this file.
1 <?php
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 
23 
28 {
32  protected $relativePath;
33 
37  public $perms_clause;
38 
42  protected $pageRecord = [];
43 
47  protected $isAccessibleForCurrentUser = false;
48 
52  protected $allowDelete = false;
53 
57  protected $recordsPageLimit = 50;
58 
62  protected $id;
63 
67  protected $view;
68 
74  protected $defaultViewObjectName = BackendTemplateView::class;
75 
79  public function initializeAction()
80  {
81  $this->id = (int)GeneralUtility::_GP('id');
82  $backendUser = $this->getBackendUser();
83  $this->perms_clause = $backendUser->getPagePermsClause(1);
84  $this->pageRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->perms_clause);
85  $this->isAccessibleForCurrentUser = $this->id && is_array($this->pageRecord) || !$this->id && $this->getBackendUser()->isAdmin();
86 
87  // don't access in workspace
88  if ($backendUser->workspace !== 0) {
89  $this->isAccessibleForCurrentUser = false;
90  }
91 
92  // read configuration
93  $modTS = $backendUser->getTSConfig('mod.recycler');
94  if ($this->getBackendUser()->isAdmin()) {
95  $this->allowDelete = true;
96  } else {
97  $this->allowDelete = (bool)$modTS['properties']['allowDelete'];
98  }
99 
100  if (isset($modTS['properties']['recordsPageLimit']) && (int)$modTS['properties']['recordsPageLimit'] > 0) {
101  $this->recordsPageLimit = (int)$modTS['properties']['recordsPageLimit'];
102  }
103  }
104 
110  public function initializeView(ViewInterface $view)
111  {
113  parent::initializeView($view);
114  $this->registerDocheaderButtons();
115  $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
116  }
117 
121  public function indexAction()
122  {
123  // Integrate dynamic JavaScript such as configuration or lables:
124  $jsConfiguration = $this->getJavaScriptConfiguration();
125  $this->view->getModuleTemplate()->getPageRenderer()->addInlineSettingArray('Recycler', $jsConfiguration);
126  $this->view->getModuleTemplate()->getPageRenderer()->addInlineLanguageLabelFile('EXT:recycler/Resources/Private/Language/locallang.xlf');
127  if ($this->isAccessibleForCurrentUser) {
128  $this->view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($this->pageRecord);
129  }
130 
131  $this->view->assign('title', $this->getLanguageService()->getLL('title'));
132  $this->view->assign('allowDelete', $this->allowDelete);
133  }
134 
140  protected function registerDocheaderButtons()
141  {
143  $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
144  $currentRequest = $this->request;
145  $moduleName = $currentRequest->getPluginName();
146  $getVars = $this->request->getArguments();
147 
148  $extensionName = $currentRequest->getControllerExtensionName();
149  if (count($getVars) === 0) {
150  $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
151  $getVars = ['id', 'M', $modulePrefix];
152  }
153  $shortcutButton = $buttonBar->makeShortcutButton()
154  ->setModuleName($moduleName)
155  ->setGetVariables($getVars);
156  $buttonBar->addButton($shortcutButton);
157 
158  $reloadButton = $buttonBar->makeLinkButton()
159  ->setHref('#')
160  ->setDataAttributes(['action' => 'reload'])
161  ->setTitle($this->getLanguageService()->sL('LLL:EXT:recycler/Resources/Private/Language/locallang.xlf:button.reload'))
162  ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-refresh', Icon::SIZE_SMALL));
163  $buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT);
164  }
165 
171  protected function getJavaScriptConfiguration()
172  {
173  $configuration = [
174  'pagingSize' => $this->recordsPageLimit,
175  'showDepthMenu' => 1,
176  'startUid' => (int)GeneralUtility::_GP('id'),
177  'isSSL' => GeneralUtility::getIndpEnv('TYPO3_SSL'),
178  'deleteDisable' => !$this->allowDelete,
179  'depthSelection' => $this->getDataFromSession('depthSelection', 0),
180  'tableSelection' => $this->getDataFromSession('tableSelection', ''),
181  'States' => $this->getBackendUser()->uc['moduleData']['web_recycler']['States']
182  ];
183  return $configuration;
184  }
185 
193  protected function getDataFromSession($identifier, $default = null)
194  {
195  $sessionData = &$this->getBackendUser()->uc['tx_recycler'];
196  if (isset($sessionData[$identifier]) && $sessionData[$identifier]) {
197  $data = $sessionData[$identifier];
198  } else {
199  $data = $default;
200  }
201  return $data;
202  }
203 
209  protected function getBackendUser()
210  {
211  return $GLOBALS['BE_USER'];
212  }
213 
219  protected function getDocumentTemplate()
220  {
221  return $GLOBALS['TBE_TEMPLATE'];
222  }
223 
229  protected function getLanguageService()
230  {
231  return $GLOBALS['LANG'];
232  }
233 }
static readPageAccess($id, $perms_clause)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']