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