TYPO3 CMS  TYPO3_8-7
HelpController.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 
27 
32 {
36  const FULL = 0;
37 
41  const TOC_ONLY = 1;
42 
47 
53  protected $defaultViewObjectName = BackendTemplateView::class;
54 
58  public function initializeAction()
59  {
60  $this->tableManualRepository = GeneralUtility::makeInstance(TableManualRepository::class);
61  }
62 
68  public function initializeView(ViewInterface $view)
69  {
71  parent::initializeView($view);
72  $this->registerDocheaderButtons();
73  $view->assign('copyright', BackendUtility::TYPO3_copyRightNotice());
74  }
75 
79  public function indexAction()
80  {
81  $this->view->assign('toc', $this->tableManualRepository->getSections(self::TOC_ONLY));
82  }
83 
87  public function allAction()
88  {
89  $this->view->assign('all', $this->tableManualRepository->getSections(self::FULL));
90  }
91 
98  public function detailAction($table = '', $field = '*')
99  {
100  if (empty($table)) {
101  $this->forward('index');
102  }
103 
104  $mainKey = $table;
105  $identifierParts = GeneralUtility::trimExplode('.', $field);
106  // The field is the second one
107  if (count($identifierParts) > 1) {
108  array_shift($field);
109  // There's at least one extra part
110  $extraIdentifierInformation = [];
111  $extraIdentifierInformation[] = array_shift($identifierParts);
112  // If the ds_pointerField contains a comma, it means the choice of FlexForm DS
113  // is determined by 2 parameters. In this case we have an extra identifier part
114  if (strpos($GLOBALS['TCA'][$table]['columns'][$field]['config']['ds_pointerField'], ',') !== false) {
115  $extraIdentifierInformation[] = array_shift($identifierParts);
116  }
117  // The remaining parts make up the FlexForm field name itself (reassembled with dots)
118  $flexFormField = implode('.', $identifierParts);
119  // Assemble a different main key and switch field to use FlexForm field name
120  $mainKey .= '.' . $field;
121  foreach ($extraIdentifierInformation as $extraKey) {
122  $mainKey .= '.' . $extraKey;
123  }
124  $field = $flexFormField;
125  }
126 
127  $this->view->assignMultiple([
128  'table' => $table,
129  'key' => $mainKey,
130  'field' => $field,
131  'manuals' => $field === '*' ? $this->tableManualRepository->getTableManual($mainKey) : [$this->tableManualRepository->getSingleManual($mainKey, $field)],
132  ]);
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  $mayMakeShortcut = $this->getBackendUser()->mayMakeShortcut();
149 
150  if ($mayMakeShortcut) {
151  $extensionName = $currentRequest->getControllerExtensionName();
152  if (count($getVars) === 0) {
153  $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
154  $getVars = ['id', 'M', $modulePrefix];
155  }
156  $shortcutButton = $buttonBar->makeShortcutButton()
157  ->setModuleName($moduleName)
158  ->setGetVariables($getVars);
159  $buttonBar->addButton($shortcutButton);
160  }
161  if (isset($getVars['action']) && $getVars['action'] !== 'index') {
162  $backButton = $buttonBar->makeLinkButton()
163  ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:back'))
164  ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-up', Icon::SIZE_SMALL))
165  ->setHref(BackendUtility::getModuleUrl($moduleName));
166  $buttonBar->addButton($backButton);
167  }
168  }
169 
175  protected function getBackendUser()
176  {
177  return $GLOBALS['BE_USER'];
178  }
179 
185  protected function getLanguageService()
186  {
187  return $GLOBALS['LANG'];
188  }
189 }
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
forward($actionName, $controllerName=null, $extensionName=null, array $arguments=null)