60cf25115b3142000a8bada0b24d1ea802e387a0
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / UpdateScriptViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Francois Suter, <francois.suter@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 /**
31 * View helper for update script link
32 *
33 * @author Francois Suter <francois.suter@typo3.org>
34 */
35 class UpdateScriptViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper {
36
37 /**
38 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
39 * @inject
40 */
41 protected $objectManager;
42
43 /**
44 * @var string
45 */
46 protected $tagName = 'a';
47
48 /**
49 * Renders a link to the update script screen if the extension has one
50 *
51 * @param string $extensionKey Extension key
52 * @return string The rendered a tag
53 */
54 public function render($extensionKey) {
55 $tag = '';
56
57 // If the "class.ext_update.php" file exists, build link to the update script screen
58 /** @var $updateScriptUtility \TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility */
59 $updateScriptUtility = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\UpdateScriptUtility');
60 if ($updateScriptUtility->checkUpdateScriptExists($extensionKey)) {
61 $uriBuilder = $this->controllerContext->getUriBuilder();
62 $action = 'show';
63 $uri = $uriBuilder->reset()->uriFor(
64 $action,
65 array('extensionKey' => $extensionKey),
66 'UpdateScript'
67 );
68 $this->tag->addAttribute('href', $uri);
69 $this->tag->addAttribute('title', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.update.script', 'extensionmanager'));
70 $this->tag->setContent(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('extensions-extensionmanager-update-script'));
71 $tag = $this->tag->render();
72 }
73 return $tag;
74 }
75
76 }