[BUGFIX] Show loading spinner when Updating TER list on search module
[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 * view helper
18 *
19 * @author Susanne Moog <susanne.moog@typo3.org>
20 */
21 class DownloadExtensionViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper {
22
23 /**
24 * @var string
25 */
26 protected $tagName = 'form';
27
28 /**
29 * Renders a download link
30 *
31 * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
32 * @return string the rendered a tag
33 */
34 public function render(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) {
35 $installPaths = \TYPO3\CMS\Extensionmanager\Domain\Model\Extension::returnAllowedInstallPaths();
36 $pathSelector = '<ul class="is-hidden">';
37 foreach ($installPaths as $installPathType => $installPath) {
38 $pathSelector .= '<li>
39 <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"' : '') . '/>
40 <label for="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '">' . htmlspecialchars($installPathType) . '</label>
41 </li>';
42 }
43 $pathSelector .= '</ul>';
44 $uriBuilder = $this->controllerContext->getUriBuilder();
45 $action = 'checkDependencies';
46 $uriBuilder->reset();
47 $uriBuilder->setFormat('json');
48 $uri = $uriBuilder->uriFor($action, array(
49 'extension' => (int)$extension->getUid()
50 ), 'Download');
51 $this->tag->addAttribute('data-href', $uri);
52
53 // @TODO Clean-up
54 $iconClasses = "t3-icon t3-icon-actions t3-icon-system-extension-import";
55 $label = '<input title="' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.downloadViewHelper.submit', 'extensionmanager') . '" type="submit" class="' . $iconClasses . '" value="' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.downloadViewHelper.submit', 'extensionmanager') . '">';
56
57 $this->tag->setContent($label . $pathSelector);
58 $this->tag->addAttribute('class', 'download');
59 return '<div id="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadFromTer" class="downloadFromTer">' . $this->tag->render() . '</div>';
60 }
61
62 }