TYPO3  7.6
DownloadExtensionViewHelper.php
Go to the documentation of this file.
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 
18 
24 {
28  protected $tagName = 'form';
29 
34 
38  public function injectConfigurationUtility(\TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility $configurationUtility)
39  {
40  $this->configurationUtility = $configurationUtility;
41  }
42 
49  public function render(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension)
50  {
51  $installPaths = \TYPO3\CMS\Extensionmanager\Domain\Model\Extension::returnAllowedInstallPaths();
52  if (empty($installPaths)) {
53  return '';
54  }
55  $pathSelector = '<ul class="is-hidden">';
56  foreach ($installPaths as $installPathType => $installPath) {
57  $pathSelector .= '<li>
58  <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"' : '') . '/>
59  <label for="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '">' . htmlspecialchars($installPathType) . '</label>
60  </li>';
61  }
62  $pathSelector .= '</ul>';
63  $uriBuilder = $this->controllerContext->getUriBuilder();
64  $action = 'checkDependencies';
65  $uriBuilder->reset();
66  $uriBuilder->setFormat('json');
67  $uri = $uriBuilder->uriFor($action, array(
68  'extension' => (int)$extension->getUid()
69  ), 'Download');
70  $this->tag->addAttribute('data-href', $uri);
71 
72  $automaticInstallation = $this->configurationUtility->getCurrentConfiguration('extensionmanager')['automaticInstallation']['value'];
73  $labelKeySuffix = $automaticInstallation ? '' : '.downloadOnly';
74  $label = '
75  <div class="btn-group">
76  <button
77  title="' . LocalizationUtility::translate('extensionList.downloadViewHelper.submit' . $labelKeySuffix, 'extensionmanager') . '"
78  type="submit"
79  class="btn btn-default"
80  value="' . LocalizationUtility::translate('extensionList.downloadViewHelper.submit' . $labelKeySuffix, 'extensionmanager') . '"
81  >
82  <span class="t3-icon fa fa-cloud-download"></span>
83  </button>
84  </div>';
85 
86  $this->tag->setContent($label . $pathSelector);
87  $this->tag->addAttribute('class', 'download');
88  return '<div id="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadFromTer" class="downloadFromTer">' . $this->tag->render() . '</div>';
89  }
90 }