[TASK] Split action buttons into two groups
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / DownloadExtensionViewHelper.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\Extbase\Utility\LocalizationUtility;
18
19 /**
20 * view helper
21 *
22 * @author Susanne Moog <susanne.moog@typo3.org>
23 * @internal
24 */
25 class DownloadExtensionViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper {
26
27 /**
28 * @var string
29 */
30 protected $tagName = 'form';
31
32 /**
33 * Renders a download link
34 *
35 * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
36 * @return string the rendered a tag
37 */
38 public function render(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) {
39 $installPaths = \TYPO3\CMS\Extensionmanager\Domain\Model\Extension::returnAllowedInstallPaths();
40 $pathSelector = '<ul class="is-hidden">';
41 foreach ($installPaths as $installPathType => $installPath) {
42 $pathSelector .= '<li>
43 <input type="radio" id="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '" name="' . htmlspecialchars($this->getFieldNamePrefix('downloadPath')) . '[downloadPath]" class="downloadPath" value="' . htmlspecialchars($installPathType) . '"' . ($installPathType == 'Local' ? ' checked="checked"' : '') . '/>
44 <label for="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '">' . htmlspecialchars($installPathType) . '</label>
45 </li>';
46 }
47 $pathSelector .= '</ul>';
48 $uriBuilder = $this->controllerContext->getUriBuilder();
49 $action = 'checkDependencies';
50 $uriBuilder->reset();
51 $uriBuilder->setFormat('json');
52 $uri = $uriBuilder->uriFor($action, array(
53 'extension' => (int)$extension->getUid()
54 ), 'Download');
55 $this->tag->addAttribute('data-href', $uri);
56
57 // @TODO Clean-up
58 $iconClasses = 'btn btn-default fa fa-cloud-download';
59 $label = '<div class="btn-group"><button title="' . LocalizationUtility::translate('extensionList.downloadViewHelper.submit', 'extensionmanager') .
60 '" type="submit" class="' . $iconClasses . '" value="' .
61 LocalizationUtility::translate('extensionList.downloadViewHelper.submit', 'extensionmanager') . '" /></div>';
62
63 $this->tag->setContent($label . $pathSelector);
64 $this->tag->addAttribute('class', 'download');
65 return '<div id="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadFromTer" class="downloadFromTer">' . $this->tag->render() . '</div>';
66 }
67
68 }