TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
InfoModuleController.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Info\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 use Psr\Http\Message\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
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 
88  public function main()
89  {
90  // We leave this here because of dependencies to submodules
91  $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
92 
93  // The page will show only if there is a valid page and if this page
94  // may be viewed by the user
95  $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
96  if ($this->pageinfo) {
97  $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
98  }
99  $access = is_array($this->pageinfo);
100  if ($this->id && $access || $this->backendUser->user['admin'] && !$this->id) {
101  if ($this->backendUser->user['admin'] && !$this->id) {
102  $this->pageinfo = ['title' => '[root-level]', 'uid' => 0, 'pid' => 0];
103  }
104  // JavaScript
105  $this->moduleTemplate->addJavaScriptCode(
106  'WebFuncInLineJS',
107  'if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';
108  function jumpToUrl(URL) {
109  window.location.href = URL;
110  return false;
111  }
112  '
113  );
114  // Setting up the context sensitive menu:
115  $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu');
116 
117  $this->view = $this->getFluidTemplateObject();
118  $this->view->assign('moduleName', BackendUtility::getModuleUrl($this->moduleName));
119  $this->view->assign('versionSelector', $this->moduleTemplate->getVersionSelector($this->id, 1));
120  $this->view->assign('functionMenuModuleContent', $this->getExtObjContent());
121  // Setting up the buttons and markers for docheader
122  $this->getButtons();
123  $this->generateMenu();
124  $this->content .= $this->view->render();
125  } else {
126  // If no access or if ID == zero
127  $this->content = $this->moduleTemplate->header($this->languageService->getLL('title'));
128  }
129  }
130 
139  public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
140  {
141  $GLOBALS['SOBE'] = $this;
142  $this->init();
143 
144  // Checking for first level external objects
145  $this->checkExtObj();
146 
147  // Checking second level external objects
148  $this->checkSubExtObj();
149  $this->main();
150 
151  $this->moduleTemplate->setContent($this->content);
152  $response->getBody()->write($this->moduleTemplate->renderContent());
153  return $response;
154  }
155 
159  protected function getButtons()
160  {
161  $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
162  // View page
163  $viewButton = $buttonBar->makeLinkButton()
164  ->setHref('#')
165  ->setOnClick(BackendUtility::viewOnClick(
166  $this->pageinfo['uid'],
167  '',
168  BackendUtility::BEgetRootLine($this->pageinfo['uid'])
169  ))
170  ->setTitle($this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage'))
171  ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-view', Icon::SIZE_SMALL));
172  $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 1);
173  // Shortcut
174  $shortCutButton = $buttonBar->makeShortcutButton()
175  ->setModuleName($this->moduleName)
176  ->setDisplayName($this->MOD_MENU['function'][$this->MOD_SETTINGS['function']])
177  ->setGetVariables([
178  'M',
179  'id',
180  'edit_record',
181  'pointer',
182  'new_unique_uid',
183  'search_field',
184  'search_levels',
185  'showLimit'
186  ])
187  ->setSetVariables(array_keys($this->MOD_MENU));
188  $buttonBar->addButton($shortCutButton, ButtonBar::BUTTON_POSITION_RIGHT);
189  }
190 
194  protected function generateMenu()
195  {
196  $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
197  $menu->setIdentifier('WebInfoJumpMenu');
198  foreach ($this->MOD_MENU['function'] as $controller => $title) {
199  $item = $menu
200  ->makeMenuItem()
201  ->setHref(
202  BackendUtility::getModuleUrl(
203  $this->moduleName,
204  [
205  'id' => $this->id,
206  'SET' => [
207  'function' => $controller
208  ]
209  ]
210  )
211  )
212  ->setTitle($title);
213  if ($controller === $this->MOD_SETTINGS['function']) {
214  $item->setActive(true);
215  }
216  $menu->addMenuItem($item);
217  }
218  $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
219  }
220 
227  public function getModuleTemplate()
228  {
229  return $this->moduleTemplate;
230  }
231 
237  protected function getFluidTemplateObject()
238  {
240  $view = GeneralUtility::makeInstance(StandaloneView::class);
241  $view->setLayoutRootPaths([GeneralUtility::getFileAbsFileName('EXT:info/Resources/Private/Layouts')]);
242  $view->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:info/Resources/Private/Partials')]);
243  $view->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:info/Resources/Private/Templates')]);
244 
245  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:info/Resources/Private/Templates/Main.html'));
246 
247  $view->getRequest()->setControllerExtensionName('info');
248  return $view;
249  }
250 }
static viewOnClick($pageUid, $backPath= '', $rootLine=null, $anchorSection= '', $alternativeUrl= '', $additionalGetVars= '', $switchFocus=true)
static BEgetRootLine($uid, $clause= '', $workspaceOL=false)
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)
static getFileAbsFileName($filename, $_=null, $_2=null)
mainAction(ServerRequestInterface $request, ResponseInterface $response)