[TASK] Re-work/simplify copyright header in PHP files - Part 9
[Packages/TYPO3.CMS.git] / typo3 / sysext / context_help / Classes / ExtDirect / ContextHelpDataProvider.php
1 <?php
2 namespace TYPO3\CMS\ContextHelp\ExtDirect;
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 /**
18 * ExtDirect DataProvider for ContextHelp
19 *
20 * @author Steffen Kamper <steffen@typo3.org>
21 */
22 class ContextHelpDataProvider {
23
24 /**
25 * Fetch the context help for the given table/field parameters
26 *
27 * @param string $table Table identifier
28 * @param string $field Field identifier
29 * @return array complete Help information
30 */
31 public function getContextHelp($table, $field) {
32 $helpTextArray = \TYPO3\CMS\Backend\Utility\BackendUtility::helpTextArray($table, $field);
33 $moreIcon = $helpTextArray['moreInfo'] ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-go-forward') : '';
34 return array(
35 'title' => $helpTextArray['title'],
36 'description' => '<p class="t3-help-short' . ($moreIcon ? ' tipIsLinked' : '') . '">' . $helpTextArray['description'] . $moreIcon . '</p>',
37 'id' => $table . '.' . $field,
38 'moreInfo' => $helpTextArray['moreInfo']
39 );
40 }
41
42 /**
43 * Fetch the context help for the given table
44 *
45 * @param string $table Table identifier
46 * @return array Complete help information
47 */
48 public function getTableContextHelp($table) {
49 $output = array();
50 if (!isset($GLOBALS['TCA_DESCR'][$table]['columns'])) {
51 $GLOBALS['LANG']->loadSingleTableDescription($table);
52 }
53 if (is_array($GLOBALS['TCA_DESCR'][$table]) && is_array($GLOBALS['TCA_DESCR'][$table]['columns'])) {
54 $arrow = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-go-forward');
55 foreach ($GLOBALS['TCA_DESCR'][$table]['columns'] as $field => $data) {
56 $output[$field] = array(
57 'description' => NULL,
58 'title' => NULL,
59 'moreInfo' => FALSE,
60 'id' => $table . '.' . $field
61 );
62 // Add alternative title, if defined
63 if ($data['alttitle']) {
64 $output[$field]['title'] = $data['alttitle'];
65 }
66 // If we have more information to show
67 if ($data['image_descr'] || $data['seeAlso'] || $data['details'] || $data['syntax']) {
68 $output[$field]['moreInfo'] = TRUE;
69 }
70 // Add description
71 if ($data['description']) {
72 $output[$field]['description'] = $data['description'] . ($output[$field]['moreInfo'] ? $arrow : '');
73 }
74 }
75 }
76 return $output;
77 }
78
79 }