f468b6e629465e734c385ec1f0e2e3a69a76f268
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / DownloadExtensionViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012-2013 Susanne Moog <susanne.moog@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the text file GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * view helper
31 *
32 * @author Susanne Moog <susanne.moog@typo3.org>
33 */
34 class DownloadExtensionViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper {
35
36 /**
37 * @var string
38 */
39 protected $tagName = 'form';
40
41 /**
42 * Renders a download link
43 *
44 * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
45 * @return string the rendered a tag
46 */
47 public function render(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) {
48 $installPaths = \TYPO3\CMS\Extensionmanager\Domain\Model\Extension::returnAllowedInstallPaths();
49 $pathSelector = '<ul class="is-hidden">';
50 foreach ($installPaths as $installPathType => $installPath) {
51 $pathSelector .= '<li>
52 <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"' : '') . '/>
53 <label for="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '">' . htmlspecialchars($installPathType) . '</label>
54 </li>';
55 }
56 $pathSelector .= '</ul>';
57 $uriBuilder = $this->controllerContext->getUriBuilder();
58 $action = 'checkDependencies';
59 $uriBuilder->reset();
60 $uriBuilder->setFormat('json');
61 $uri = $uriBuilder->uriFor($action, array(
62 'extension' => (int)$extension->getUid()
63 ), 'Download');
64 $this->tag->addAttribute('href', $uri);
65
66 // @TODO Clean-up
67 $iconClasses = "t3-icon t3-icon-actions t3-icon-system-extension-import";
68 $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') . '">';
69
70 $this->tag->setContent($label . $pathSelector);
71 $this->tag->addAttribute('class', 'download');
72 return '<div id="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadFromTer" class="downloadFromTer">' . $this->tag->render() . '</div>';
73 }
74
75 }