TYPO3 CMS  TYPO3_7-6
ContextHelpAjaxController.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 
23 
28 {
36  public function getHelpAction(ServerRequestInterface $request, ResponseInterface $response)
37  {
38  $params = isset($request->getParsedBody()['params']) ? $request->getParsedBody()['params'] : $request->getQueryParams()['params'];
39  if ($params['action'] === 'getContextHelp') {
40  $result = $this->getContextHelp($params['table'], $params['field']);
41  $response->getBody()->write(json_encode([
42  'title' => $result['title'],
43  'content' => $result['description'],
44  'link' => $result['moreInfo']
45  ]));
46  }
47  return $response;
48  }
49 
57  protected function getContextHelp($table, $field)
58  {
59  $helpTextArray = BackendUtility::helpTextArray($table, $field);
61  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
62  $moreIcon = $helpTextArray['moreInfo'] ? $iconFactory->getIcon('actions-view-go-forward', Icon::SIZE_SMALL)->render() : '';
63  return [
64  'title' => $helpTextArray['title'],
65  'description' => '<p class="t3-help-short' . ($moreIcon ? ' tipIsLinked' : '') . '">' . $helpTextArray['description'] . $moreIcon . '</p>',
66  'id' => $table . '.' . $field,
67  'moreInfo' => $helpTextArray['moreInfo']
68  ];
69  }
70 }
getHelpAction(ServerRequestInterface $request, ResponseInterface $response)