1
|
<?php
|
2
|
namespace TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons;
|
3
|
|
4
|
/* *
|
5
|
* This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
|
6
|
* *
|
7
|
* It is free software; you can redistribute it and/or modify it under *
|
8
|
* the terms of the GNU Lesser General Public License, either version 3 *
|
9
|
* of the License, or (at your option) any later version. *
|
10
|
* *
|
11
|
* *
|
12
|
* This script is distributed in the hope that it will be useful, but *
|
13
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
|
14
|
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
|
15
|
* General Public License for more details. *
|
16
|
* *
|
17
|
* You should have received a copy of the GNU Lesser General Public *
|
18
|
* License along with the script. *
|
19
|
* If not, see http://www.gnu.org/licenses/lgpl.html *
|
20
|
* *
|
21
|
* The TYPO3 project - inspiring people to share! *
|
22
|
* */
|
23
|
/**
|
24
|
* View helper which returns button with icon
|
25
|
* Note: This view helper is experimental!
|
26
|
*
|
27
|
* = Examples =
|
28
|
*
|
29
|
* <code title="Default">
|
30
|
* <f:be.buttons.submitIcon />
|
31
|
* </code>
|
32
|
* <output>
|
33
|
* An icon button as known from the TYPO3 backend, skinned and linked with the submit action of the current form.
|
34
|
* Note: By default the "close" icon is used as image
|
35
|
* </output>
|
36
|
*
|
37
|
* <code title="Default">
|
38
|
* <f:be.buttons.submitIcon icon="actions-document-save" title="Save Foo" name="savedoc" />
|
39
|
* </code>
|
40
|
* <output>
|
41
|
* This time, the actions-document-save icon is used, and the submit button has "savedoc" name.
|
42
|
* </output>
|
43
|
*/
|
44
|
class SubmitIconViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper {
|
45
|
|
46
|
/**
|
47
|
* @var string
|
48
|
*/
|
49
|
protected $tagName = 'input';
|
50
|
|
51
|
/**
|
52
|
* Initialize the arguments.
|
53
|
*
|
54
|
* @return void
|
55
|
* @api
|
56
|
*/
|
57
|
public function initializeArguments() {
|
58
|
parent::initializeArguments();
|
59
|
$this->registerArgument('icon', 'string', 'Icon to be used. See self::allowedIcons for a list of allowed icon names', false, 'actions-document-close');
|
60
|
$this->registerTagAttribute('src', 'string', 'Image source', false, 'clear.gif');
|
61
|
$this->registerUniversalTagAttributes();
|
62
|
}
|
63
|
|
64
|
/**
|
65
|
* Renders an icon link as known from the TYPO3 backend
|
66
|
*
|
67
|
* @return string the rendered icon link
|
68
|
*/
|
69
|
public function render() {
|
70
|
$name = $this->getName();
|
71
|
$this->registerFieldNameForFormTokenGeneration($name);
|
72
|
|
73
|
$this->tag->addAttribute('type', 'image');
|
74
|
$this->tag->addAttribute('name', $name);
|
75
|
$this->tag->addAttribute('class', 'c-inputButton');
|
76
|
|
77
|
return \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon($this->arguments['icon'], array('title' => $this->arguments['title'], 'html' => $this->tag->render()));
|
78
|
}
|
79
|
}
|
80
|
|
81
|
?>
|