TYPO3 CMS  TYPO3_8-7
ConfigureExtensionViewHelper.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 
21 
27 {
31  public function initializeArguments()
32  {
33  parent::initializeArguments();
34  $this->registerArgument('extension', 'array', 'Extension configuration array with extension information', true);
35  $this->registerArgument('forceConfiguration', 'bool', 'If TRUE the content is only returned if a link could be generated', false, true);
36  $this->registerArgument('showDescription', 'bool', 'If TRUE the extension description is also shown in the title attribute', false, false);
37  }
38 
44  public function render()
45  {
46  $extension = $this->arguments['extension'];
47  $forceConfiguration = $this->arguments['forceConfiguration'];
48  $showDescription = $this->arguments['showDescription'];
49 
50  $content = (string)$this->renderChildren();
51  if ($extension['installed'] && file_exists(PATH_site . $extension['siteRelPath'] . 'ext_conf_template.txt')) {
52  $uriBuilder = $this->controllerContext->getUriBuilder();
53  $action = 'showConfigurationForm';
54  $uri = $uriBuilder->reset()->uriFor(
55  $action,
56  ['extension' => ['key' => $extension['key']]],
57  'Configuration'
58  );
59  if ($showDescription) {
60  $title = $extension['description'] . PHP_EOL .
61  LocalizationUtility::translate('extensionList.clickToConfigure', 'extensionmanager');
62  } else {
63  $title = LocalizationUtility::translate('extensionList.configure', 'extensionmanager');
64  }
65  $this->tag->addAttribute('href', $uri);
66  $this->tag->addAttribute('title', $title);
67  $this->tag->setContent($content);
68  $content = $this->tag->render();
69  } elseif ($forceConfiguration) {
70  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
71  $content = '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
72  } else {
73  $content = '<span title="' . htmlspecialchars($extension['description']) . '">' . $content . '</span>';
74  }
75 
76  return $content;
77  }
78 }
static translate($key, $extensionName=null, $arguments=null)
static makeInstance($className,... $constructorArguments)