Project

General

Profile

Feature #49477 ยป SubmitIconViewHelper.php

PHP source - Charles Brunet, 2013-06-27 22:32

 
<?php
namespace TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons;

/* *
* This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
* *
* It is free software; you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License, either version 3 *
* of the License, or (at your option) any later version. *
* *
* *
* This script is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
* General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with the script. *
* If not, see http://www.gnu.org/licenses/lgpl.html *
* *
* The TYPO3 project - inspiring people to share! *
* */
/**
* View helper which returns button with icon
* Note: This view helper is experimental!
*
* = Examples =
*
* <code title="Default">
* <f:be.buttons.submitIcon />
* </code>
* <output>
* An icon button as known from the TYPO3 backend, skinned and linked with the submit action of the current form.
* Note: By default the "close" icon is used as image
* </output>
*
* <code title="Default">
* <f:be.buttons.submitIcon icon="actions-document-save" title="Save Foo" name="savedoc" />
* </code>
* <output>
* This time, the actions-document-save icon is used, and the submit button has "savedoc" name.
* </output>
*/
class SubmitIconViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper {

/**
* @var string
*/
protected $tagName = 'input';
/**
* Initialize the arguments.
*
* @return void
* @api
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('icon', 'string', 'Icon to be used. See self::allowedIcons for a list of allowed icon names', false, 'actions-document-close');
$this->registerTagAttribute('src', 'string', 'Image source', false, 'clear.gif');
$this->registerUniversalTagAttributes();
}
/**
* Renders an icon link as known from the TYPO3 backend
*
* @return string the rendered icon link
*/
public function render() {
$name = $this->getName();
$this->registerFieldNameForFormTokenGeneration($name);
$this->tag->addAttribute('type', 'image');
$this->tag->addAttribute('name', $name);
$this->tag->addAttribute('class', 'c-inputButton');
return \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon($this->arguments['icon'], array('title' => $this->arguments['title'], 'html' => $this->tag->render()));
}
}

?>
    (1-1/1)