[TASK] Split action buttons into two groups
[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\Backend\Utility\IconUtility;
18
19 /**
20 * View helper for configure extension link
21 *
22 * @author Susanne Moog <typo3@susannemoog.de>
23 * @internal
24 */
25 class ConfigureExtensionViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper {
26
27 /**
28 * @var string
29 */
30 protected $tagName = 'a';
31
32 /**
33 * Renders a configure extension link if the extension has configuration options
34 *
35 * @param array $extension Extension configuration array with extension information
36 * @param bool $forceConfiguration If TRUE the content is only returned if a link could be generated
37 * @param bool $showDescription If TRUE the extension description is also shown in the title attribute
38 * @return string the rendered tag or child nodes content
39 */
40 public function render($extension, $forceConfiguration = TRUE, $showDescription = FALSE) {
41 $content = (string)$this->renderChildren();
42 if ($extension['installed'] && file_exists(PATH_site . $extension['siteRelPath'] . 'ext_conf_template.txt')) {
43 $uriBuilder = $this->controllerContext->getUriBuilder();
44 $action = 'showConfigurationForm';
45 $uri = $uriBuilder->reset()->uriFor(
46 $action,
47 array('extension' => array('key' => $extension['key'])),
48 'Configuration'
49 );
50 if ($showDescription) {
51 $title = $extension['description'] . PHP_EOL .
52 \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.clickToConfigure', 'extensionmanager');
53
54 } else {
55 $title = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.configure', 'extensionmanager');
56 }
57 $this->tag->addAttribute('href', $uri);
58 $this->tag->addAttribute('title', $title);
59 $this->tag->setContent($content);
60 $content = $this->tag->render();
61 } elseif ($forceConfiguration) {
62 $content = '<span class="btn btn-default disabled">' . IconUtility::getSpriteIcon('empty-empty') . '</span>';
63 }
64
65 return $content;
66 }
67
68 }