‪TYPO3CMS  10.4
InputButton.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
38 {
44  protected ‪$name = '';
45 
51  protected ‪$value = '';
52 
58  protected ‪$form = '';
59 
65  public function ‪getName()
66  {
67  return ‪$this->name;
68  }
69 
77  public function ‪setName(‪$name)
78  {
79  $this->name = ‪$name;
80  return $this;
81  }
82 
88  public function ‪getValue()
89  {
90  return ‪$this->value;
91  }
92 
100  public function ‪setValue(‪$value)
101  {
102  $this->value = ‪$value;
103  return $this;
104  }
105 
109  public function ‪getForm()
110  {
111  return ‪$this->form;
112  }
113 
119  public function ‪setForm(‪$form)
120  {
121  $this->form = ‪$form;
122  return $this;
123  }
124 
130  public function ‪isValid()
131  {
132  if (
133  trim($this->‪getName()) !== ''
134  && trim($this->‪getValue()) !== ''
135  && trim($this->‪getTitle()) !== ''
136  && $this->‪getType() === self::class
137  && $this->‪getIcon() !== null
138  ) {
139  return true;
140  }
141  return false;
142  }
143 
149  public function ‪render()
150  {
151  $attributes = [
152  'name' => $this->‪getName(),
153  'class' => 'btn btn-default btn-sm ' . $this->‪getClasses(),
154  'value' => $this->‪getValue(),
155  'title' => $this->‪getTitle(),
156  'form' => trim($this->‪getForm())
157  ];
158  if ($this->‪isDisabled()) {
159  $attributes['disabled'] = 'disabled';
160  }
161  $labelText = '';
162  if ($this->showLabelText) {
163  $labelText = ' ' . ‪$this->title;
164  }
165  foreach ($this->dataAttributes as $attributeName => $attributeValue) {
166  $attributes['data-' . $attributeName] = $attributeValue;
167  }
168  $attributesString = '';
169  foreach ($attributes as $key => ‪$value) {
170  if (‪$value !== '') {
171  $attributesString .= ' ' . htmlspecialchars($key) . '="' . htmlspecialchars(‪$value) . '"';
172  }
173  }
174  return '<button' . $attributesString . '>'
175  . $this->‪getIcon()->‪render() . htmlspecialchars($labelText)
176  . '</button>';
177  }
178 
184  public function ‪__toString()
185  {
186  return $this->‪render();
187  }
188 }
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\render
‪string render()
Definition: InputButton.php:146
‪TYPO3\CMS\Backend\Template\Components\Buttons\AbstractButton\getType
‪string getType()
Definition: AbstractButton.php:82
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\$form
‪string $form
Definition: InputButton.php:55
‪TYPO3\CMS\Backend\Template\Components\Buttons\AbstractButton\getIcon
‪Icon getIcon()
Definition: AbstractButton.php:72
‪TYPO3\CMS\Core\Imaging\Icon\render
‪string render($alternativeMarkupIdentifier=null)
Definition: Icon.php:232
‪TYPO3\CMS\Backend\Template\Components\Buttons\AbstractButton
Definition: AbstractButton.php:25
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\getValue
‪string getValue()
Definition: InputButton.php:85
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\__toString
‪string __toString()
Definition: InputButton.php:181
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\setName
‪InputButton setName($name)
Definition: InputButton.php:74
‪TYPO3\CMS\Backend\Template\Components\AbstractControl\getClasses
‪string getClasses()
Definition: AbstractControl.php:54
‪TYPO3\CMS\Backend\Template\Components\Buttons\AbstractButton\isDisabled
‪bool isDisabled()
Definition: AbstractButton.php:105
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\setValue
‪InputButton setValue($value)
Definition: InputButton.php:97
‪TYPO3\CMS\Backend\Template\Components\AbstractControl\$title
‪string $title
Definition: AbstractControl.php:33
‪TYPO3\CMS\Backend\Template\Components\AbstractControl\getTitle
‪string getTitle()
Definition: AbstractControl.php:64
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\setForm
‪InputButton setForm($form)
Definition: InputButton.php:116
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\$value
‪string $value
Definition: InputButton.php:49
‪TYPO3\CMS\Backend\Template\Components\Buttons
Definition: AbstractButton.php:16
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton
Definition: InputButton.php:38
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\$name
‪string $name
Definition: InputButton.php:43
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\getForm
‪string getForm()
Definition: InputButton.php:106
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\getName
‪string getName()
Definition: InputButton.php:62
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\isValid
‪bool isValid()
Definition: InputButton.php:127