[TASK] Split action buttons into two groups
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / UpdateScriptViewHelper.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 update script link
21 *
22 * @author Francois Suter <francois.suter@typo3.org>
23 * @internal
24 */
25 class UpdateScriptViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper {
26
27 /**
28 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
29 * @inject
30 */
31 protected $objectManager;
32
33 /**
34 * @var string
35 */
36 protected $tagName = 'a';
37
38 /**
39 * Renders a link to the update script screen if the extension has one
40 *
41 * @param string $extensionKey Extension key
42 * @return string The rendered a tag
43 */
44 public function render($extensionKey) {
45 $tag = '';
46
47 // If the "class.ext_update.php" file exists, build link to the update script screen
48 /** @var $updateScriptUtility \TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility */
49 $updateScriptUtility = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility::class);
50 if ($updateScriptUtility->checkUpdateScriptExists($extensionKey)) {
51 $uriBuilder = $this->controllerContext->getUriBuilder();
52 $action = 'show';
53 $uri = $uriBuilder->reset()->uriFor(
54 $action,
55 array('extensionKey' => $extensionKey),
56 'UpdateScript'
57 );
58 $this->tag->addAttribute('href', $uri);
59 $this->tag->addAttribute('title', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.update.script', 'extensionmanager'));
60 $this->tag->setContent(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('extensions-extensionmanager-update-script'));
61 $tag = $this->tag->render();
62 } else {
63 return '<span class="btn btn-default disabled">' . IconUtility::getSpriteIcon('empty-empty') . '</span>';
64 }
65 return $tag;
66 }
67
68 }