b5ae30e57a4cd5795e263a2a559f41e954ed8a17
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / DownloadExtensionDataViewHelper.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\Backend\Utility\IconUtility;
18
19 /**
20 * view helper for displaying a download extension data link
21 * @internal
22 */
23 class DownloadExtensionDataViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper {
24
25 /**
26 * @var string
27 */
28 protected $tagName = 'a';
29
30 /**
31 * Renders an install link
32 *
33 * @param array $extension
34 * @return string the rendered a tag
35 */
36 public function render($extension) {
37 $filePrefix = PATH_site . $extension['siteRelPath'];
38 if (!file_exists(($filePrefix . 'ext_tables.sql')) && !file_exists(($filePrefix . 'ext_tables_static+adt.sql'))) {
39 return '<span class="btn btn-default disabled">' . IconUtility::getSpriteIcon('empty-empty') . '</span>';
40 }
41 $uriBuilder = $this->controllerContext->getUriBuilder();
42 $uriBuilder->reset();
43 $uri = $uriBuilder->uriFor('downloadExtensionData', array(
44 'extension' => $extension['key']
45 ), 'Action');
46 $this->tag->addAttribute('href', $uri);
47 $cssClass = 'downloadExtensionData btn btn-default';
48 $this->tag->addAttribute('class', $cssClass);
49 $this->tag->addAttribute('title', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.downloadsql', 'extensionmanager'));
50 $this->tag->setContent(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-system-extension-sqldump'));
51 return $this->tag->render();
52 }
53
54 }