TYPO3 CMS  TYPO3_8-7
InfoModuleController.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 
26 
32 {
36  public $pageinfo;
37 
41  protected $backendUser;
42 
46  protected $languageService;
47 
53  protected $moduleName = 'web_info';
54 
60  protected $moduleTemplate;
61 
65  protected $view;
66 
70  public function __construct()
71  {
72  $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
73  $this->languageService = $GLOBALS['LANG'];
74  $this->languageService->includeLLFile('EXT:lang/Resources/Private/Language/locallang_mod_web_info.xlf');
75 
76  $this->backendUser = $GLOBALS['BE_USER'];
77 
78  $this->MCONF = [
79  'name' => $this->moduleName,
80  ];
81  }
82 
86  public function main()
87  {
88  // We leave this here because of dependencies to submodules
89  $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
90 
91  // The page will show only if there is a valid page and if this page
92  // may be viewed by the user
93  $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
94  if ($this->pageinfo) {
95  $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
96  }
97  $access = is_array($this->pageinfo);
98  if ($this->id && $access || $this->backendUser->user['admin'] && !$this->id) {
99  if ($this->backendUser->user['admin'] && !$this->id) {
100  $this->pageinfo = ['title' => '[root-level]', 'uid' => 0, 'pid' => 0];
101  }
102  // JavaScript
103  $this->moduleTemplate->addJavaScriptCode(
104  'WebFuncInLineJS',
105  'if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';
106  function jumpToUrl(URL) {
107  window.location.href = URL;
108  return false;
109  }
110  '
111  );
112  // Setting up the context sensitive menu:
113  $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
114 
115  $this->view = $this->getFluidTemplateObject();
116  $this->view->assign('moduleName', BackendUtility::getModuleUrl($this->moduleName));
117  $this->view->assign('versionSelector', $this->moduleTemplate->getVersionSelector($this->id, 1));
118  $this->view->assign('functionMenuModuleContent', $this->getExtObjContent());
119  // Setting up the buttons and markers for docheader
120  $this->getButtons();
121  $this->generateMenu();
122  $this->content .= $this->view->render();
123  } else {
124  // If no access or if ID == zero
125  $this->content = $this->moduleTemplate->header($this->languageService->getLL('title'));
126  }
127  }
128 
137  public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
138  {
139  $GLOBALS['SOBE'] = $this;
140  $this->init();
141 
142  // Checking for first level external objects
143  $this->checkExtObj();
144 
145  // Checking second level external objects
146  $this->checkSubExtObj();
147  $this->main();
148 
149  $this->moduleTemplate->setContent($this->content);
150  $response->getBody()->write($this->moduleTemplate->renderContent());
151  return $response;
152  }
153 
157  protected function getButtons()
158  {
159  $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
160  // View page
161  $viewButton = $buttonBar->makeLinkButton()
162  ->setHref('#')
163  ->setOnClick(BackendUtility::viewOnClick(
164  $this->pageinfo['uid'],
165  '',
166  BackendUtility::BEgetRootLine($this->pageinfo['uid'])
167  ))
168  ->setTitle($this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage'))
169  ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-view', Icon::SIZE_SMALL));
170  $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 1);
171  // Shortcut
172  $shortCutButton = $buttonBar->makeShortcutButton()
173  ->setModuleName($this->moduleName)
174  ->setDisplayName($this->MOD_MENU['function'][$this->MOD_SETTINGS['function']])
175  ->setGetVariables([
176  'M',
177  'id',
178  'edit_record',
179  'pointer',
180  'new_unique_uid',
181  'search_field',
182  'search_levels',
183  'showLimit'
184  ])
185  ->setSetVariables(array_keys($this->MOD_MENU));
186  $buttonBar->addButton($shortCutButton, ButtonBar::BUTTON_POSITION_RIGHT);
187 
188  // CSH
189  $cshButton = $buttonBar->makeHelpButton()
190  ->setModuleName('xMOD_csh_corebe')
191  ->setFieldName('pagetree_overview');
192  $buttonBar->addButton($cshButton);
193  }
194 
198  protected function generateMenu()
199  {
200  $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
201  $menu->setIdentifier('WebInfoJumpMenu');
202  foreach ($this->MOD_MENU['function'] as $controller => $title) {
203  $item = $menu
204  ->makeMenuItem()
205  ->setHref(
206  BackendUtility::getModuleUrl(
207  $this->moduleName,
208  [
209  'id' => $this->id,
210  'SET' => [
211  'function' => $controller
212  ]
213  ]
214  )
215  )
216  ->setTitle($title);
217  if ($controller === $this->MOD_SETTINGS['function']) {
218  $item->setActive(true);
219  }
220  $menu->addMenuItem($item);
221  }
222  $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
223  }
224 
231  public function getModuleTemplate()
232  {
233  return $this->moduleTemplate;
234  }
235 
241  protected function getFluidTemplateObject()
242  {
244  $view = GeneralUtility::makeInstance(StandaloneView::class);
245  $view->setLayoutRootPaths([GeneralUtility::getFileAbsFileName('EXT:info/Resources/Private/Layouts')]);
246  $view->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:info/Resources/Private/Partials')]);
247  $view->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:info/Resources/Private/Templates')]);
248 
249  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:info/Resources/Private/Templates/Main.html'));
250 
251  $view->getRequest()->setControllerExtensionName('info');
252  return $view;
253  }
254 }
static readPageAccess($id, $perms_clause)
static viewOnClick( $pageUid, $backPath='', $rootLine=null, $anchorSection='', $alternativeUrl='', $additionalGetVars='', $switchFocus=true)
static BEgetRootLine($uid, $clause='', $workspaceOL=false)
static getFileAbsFileName($filename, $_=null, $_2=null)
mainAction(ServerRequestInterface $request, ResponseInterface $response)
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']