[TASK] Show Bootstrap Tooltips in Extension Manager
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / ConfigureExtensionViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
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 use TYPO3\CMS\Core\Imaging\Icon;
18 use TYPO3\CMS\Core\Imaging\IconFactory;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
21
22 /**
23 * View helper for configure extension link
24 * @internal
25 */
26 class ConfigureExtensionViewHelper extends Link\ActionViewHelper
27 {
28 /**
29 * Renders a configure extension link if the extension has configuration options
30 *
31 * @param array $extension Extension configuration array with extension information
32 * @param bool $forceConfiguration If TRUE the content is only returned if a link could be generated
33 * @param bool $showDescription If TRUE the extension description is also shown in the title attribute
34 * @return string the rendered tag or child nodes content
35 */
36 public function render($extension, $forceConfiguration = true, $showDescription = false)
37 {
38 $content = (string)$this->renderChildren();
39 if ($extension['installed'] && file_exists(PATH_site . $extension['siteRelPath'] . 'ext_conf_template.txt')) {
40 $uriBuilder = $this->controllerContext->getUriBuilder();
41 $action = 'showConfigurationForm';
42 $uri = $uriBuilder->reset()->uriFor(
43 $action,
44 array('extension' => array('key' => $extension['key'])),
45 'Configuration'
46 );
47 if ($showDescription) {
48 $title = $extension['description'] . PHP_EOL .
49 LocalizationUtility::translate('extensionList.clickToConfigure', 'extensionmanager');
50 } else {
51 $title = LocalizationUtility::translate('extensionList.configure', 'extensionmanager');
52 }
53 $this->tag->addAttribute('href', $uri);
54 $this->tag->addAttribute('title', $title);
55 $this->tag->setContent($content);
56 $content = $this->tag->render();
57 } elseif ($forceConfiguration) {
58 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
59 $content = '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
60 } else {
61 $content = '<span title="' . htmlspecialchars($extension['description']) . '">' . $content . '</span>';
62 }
63
64 return $content;
65 }
66 }