TYPO3 CMS  TYPO3_7-6
PageFunctionsController.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 {
37  public $pageinfo;
38 
44  protected $moduleTemplate;
45 
51  public $doc;
52 
58  protected $moduleName = 'web_func';
59 
63  protected $iconFactory;
64 
68  public function __construct()
69  {
70  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
71  $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
72  $this->getLanguageService()->includeLLFile('EXT:lang/locallang_mod_web_func.xlf');
73  $this->MCONF = [
74  'name' => $this->moduleName,
75  ];
76  }
77 
86  public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
87  {
88  $GLOBALS['SOBE'] = $this;
89  $this->init();
90 
91  // Checking for first level external objects
92  $this->checkExtObj();
93 
94  // Checking second level external objects
95  $this->checkSubExtObj();
96  $this->main();
97 
98  $this->moduleTemplate->setContent($this->content);
99 
100  $response->getBody()->write($this->moduleTemplate->renderContent());
101  return $response;
102  }
103 
109  public function main()
110  {
111  // Access check...
112  // The page will show only if there is a valid page and if this page may be viewed by the user
113  $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
114  if ($this->pageinfo) {
115  $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
116  }
117  $access = is_array($this->pageinfo);
118  // We keep this here, in case somebody relies on the old doc being here
119  $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
120  // Main
121  if ($this->id && $access) {
122  // JavaScript
123  $this->moduleTemplate->addJavaScriptCode(
124  'WebFuncInLineJS',
125  'if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';');
126  // Setting up the context sensitive menu:
127  $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu');
128  $this->content .= '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('web_func')) . '" id="PageFunctionsController" method="post"><input type="hidden" name="id" value="' . htmlspecialchars($this->id) . '" />';
129  $vContent = $this->moduleTemplate->getVersionSelector($this->id, true);
130  if ($vContent) {
131  $this->content .= '<div>' . $vContent . '</div>';
132  }
133  $this->extObjContent();
134  // Setting up the buttons and markers for docheader
135  $this->getButtons();
136  $this->generateMenu();
137  $this->content .= '</form>';
138  } else {
139  // If no access or if ID == zero
140  $title = $this->getLanguageService()->getLL('title');
141  $message = $this->getLanguageService()->getLL('clickAPage_content');
142  $view = GeneralUtility::makeInstance(StandaloneView::class);
143  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:func/Resources/Private/Templates/InfoBox.html'));
144  $view->assignMultiple([
145  'title' => $title,
146  'message' => $message,
148  ]);
149  $this->content = $view->render();
150  // Setting up the buttons and markers for docheader
151  $this->getButtons();
152  }
153  }
154 
160  protected function generateMenu()
161  {
162  $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
163  $menu->setIdentifier('WebFuncJumpMenu');
164  foreach ($this->MOD_MENU['function'] as $controller => $title) {
165  $item = $menu
166  ->makeMenuItem()
167  ->setHref(
168  BackendUtility::getModuleUrl(
169  $this->moduleName,
170  [
171  'id' => $this->id,
172  'SET' => [
173  'function' => $controller
174  ]
175  ]
176  )
177  )
178  ->setTitle($title);
179  if ($controller === $this->MOD_SETTINGS['function']) {
180  $item->setActive(true);
181  }
182  $menu->addMenuItem($item);
183  }
184  $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
185  }
186 
193  public function printContent()
194  {
196  echo $this->content;
197  }
198 
202  protected function getButtons()
203  {
204  $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
205  // CSH
206  $cshButton = $buttonBar->makeHelpButton()
207  ->setModuleName('_MOD_web_func')
208  ->setFieldName('');
209  $buttonBar->addButton($cshButton);
210  if ($this->id && is_array($this->pageinfo)) {
211  // View page
212  $viewButton = $buttonBar->makeLinkButton()
213  ->setOnClick(BackendUtility::viewOnClick($this->pageinfo['uid'], '', BackendUtility::BEgetRootLine($this->pageinfo['uid'])))
214  ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage'))
215  ->setIcon($this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL))
216  ->setHref('#');
217  $buttonBar->addButton($viewButton);
218  // Shortcut
219  $shortcutButton = $buttonBar->makeShortcutButton()
220  ->setModuleName($this->moduleName)
221  ->setGetVariables(['id', 'edit_record', 'pointer', 'new_unique_uid', 'search_field', 'search_levels', 'showLimit'])
222  ->setSetVariables(array_keys($this->MOD_MENU));
223  $buttonBar->addButton($shortcutButton);
224  }
225  }
226 
232  protected function getLanguageService()
233  {
234  return $GLOBALS['LANG'];
235  }
236 
242  protected function getBackendUser()
243  {
244  return $GLOBALS['BE_USER'];
245  }
246 }
static readPageAccess($id, $perms_clause)
static BEgetRootLine($uid, $clause='', $workspaceOL=false)
static viewOnClick($pageUid, $backPath='', $rootLine=null, $anchorSection='', $alternativeUrl='', $additionalGetVars='', $switchFocus=true)
static getFileAbsFileName($filename, $onlyRelative=true, $relToTYPO3_mainDir=false)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
mainAction(ServerRequestInterface $request, ResponseInterface $response)