TYPO3 CMS  TYPO3_7-6
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 
60  public function initializeAction()
61  {
62  $this->tableManualRepository = GeneralUtility::makeInstance(TableManualRepository::class);
63  }
64 
71  public function initializeView(ViewInterface $view)
72  {
74  parent::initializeView($view);
75  $this->registerDocheaderButtons();
76  $view->assign('copyright', BackendUtility::TYPO3_copyRightNotice());
77  }
78 
84  public function indexAction()
85  {
86  $this->view->assign('toc', $this->tableManualRepository->getSections(self::TOC_ONLY));
87  }
88 
94  public function allAction()
95  {
96  $this->view->assign('all', $this->tableManualRepository->getSections(self::FULL));
97  }
98 
106  public function detailAction($table = '', $field = '*')
107  {
108  if (empty($table)) {
109  $this->forward('index');
110  }
111 
112  $mainKey = $table;
113  $identifierParts = GeneralUtility::trimExplode('.', $field);
114  // The field is the second one
115  if (count($identifierParts) > 1) {
116  array_shift($field);
117  // There's at least one extra part
118  $extraIdentifierInformation = [];
119  $extraIdentifierInformation[] = array_shift($identifierParts);
120  // If the ds_pointerField contains a comma, it means the choice of FlexForm DS
121  // is determined by 2 parameters. In this case we have an extra identifier part
122  if (strpos($GLOBALS['TCA'][$table]['columns'][$field]['config']['ds_pointerField'], ',') !== false) {
123  $extraIdentifierInformation[] = array_shift($identifierParts);
124  }
125  // The remaining parts make up the FlexForm field name itself (reassembled with dots)
126  $flexFormField = implode('.', $identifierParts);
127  // Assemble a different main key and switch field to use FlexForm field name
128  $mainKey .= '.' . $field;
129  foreach ($extraIdentifierInformation as $extraKey) {
130  $mainKey .= '.' . $extraKey;
131  }
132  $field = $flexFormField;
133  }
134 
135  $this->view->assignMultiple([
136  'table' => $table,
137  'key' => $mainKey,
138  'field' => $field,
139  'manuals' => $field === '*' ? $this->tableManualRepository->getTableManual($mainKey) : [$this->tableManualRepository->getSingleManual($mainKey, $field)],
140  ]);
141  }
142 
148  protected function registerDocheaderButtons()
149  {
151  $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
152  $currentRequest = $this->request;
153  $moduleName = $currentRequest->getPluginName();
154  $getVars = $this->request->getArguments();
155 
156  $mayMakeShortcut = $this->getBackendUser()->mayMakeShortcut();
157 
158  if ($mayMakeShortcut) {
159  $extensionName = $currentRequest->getControllerExtensionName();
160  if (count($getVars) === 0) {
161  $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
162  $getVars = ['id', 'M', $modulePrefix];
163  }
164  $shortcutButton = $buttonBar->makeShortcutButton()
165  ->setModuleName($moduleName)
166  ->setGetVariables($getVars);
167  $buttonBar->addButton($shortcutButton);
168  }
169  if (isset($getVars['action']) && $getVars['action'] !== 'index') {
170  $backButton = $buttonBar->makeLinkButton()
171  ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:back'))
172  ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-up', Icon::SIZE_SMALL))
173  ->setHref(BackendUtility::getModuleUrl($moduleName));
174  $buttonBar->addButton($backButton);
175  }
176  }
177 
183  protected function getBackendUser()
184  {
185  return $GLOBALS['BE_USER'];
186  }
187 
193  protected function getLanguageService()
194  {
195  return $GLOBALS['LANG'];
196  }
197 }
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
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)