08d7886e56161fee17798435c93189fd8bd7d5f8
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / ConfigureExtensionViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012-2013 Susanne Moog, <typo3@susannemoog.de>
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 for configure extension link
31 *
32 * @author Susanne Moog <typo3@susannemoog.de>
33 */
34 class ConfigureExtensionViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper {
35
36 /**
37 * @var string
38 */
39 protected $tagName = 'a';
40
41 /**
42 * Renders a configure extension link if the extension has configuration options
43 *
44 * @param array $extension Extension configuration array with extension information
45 * @param boolean $forceConfiguration If TRUE the content is only returned if a link could be generated
46 * @param boolean $showDescription If TRUE the extension description is also shown in the title attribute
47 * @return string the rendered tag or child nodes content
48 */
49 public function render($extension, $forceConfiguration = TRUE, $showDescription = FALSE) {
50 $content = (string)$this->renderChildren();
51 if ($extension['installed'] && file_exists(PATH_site . $extension['siteRelPath'] . 'ext_conf_template.txt')) {
52 $uriBuilder = $this->controllerContext->getUriBuilder();
53 $action = 'showConfigurationForm';
54 $uri = $uriBuilder->reset()->uriFor(
55 $action,
56 array('extension' => array('key' => $extension['key'])),
57 'Configuration'
58 );
59 if ($showDescription) {
60 $title = $extension['description'] . PHP_EOL .
61 \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.clickToConfigure', 'extensionmanager');
62
63 } else {
64 $title = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.configure', 'extensionmanager');
65 }
66 $this->tag->addAttribute('href', $uri);
67 $this->tag->addAttribute('title', $title);
68 $this->tag->setContent($content);
69 $content = $this->tag->render();
70 } elseif ($forceConfiguration) {
71 $content = '';
72 }
73
74 return $content;
75 }
76
77 }