‪TYPO3CMS  ‪main
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 
19 
40 {
46  protected ‪$name = '';
47 
53  protected ‪$value = '';
54 
60  protected ‪$form = '';
61 
67  public function ‪getName()
68  {
69  return ‪$this->name;
70  }
71 
79  public function ‪setName(‪$name)
80  {
81  $this->name = ‪$name;
82  return $this;
83  }
84 
90  public function ‪getValue()
91  {
92  return ‪$this->value;
93  }
94 
102  public function ‪setValue(‪$value)
103  {
104  $this->value = ‪$value;
105  return $this;
106  }
107 
111  public function ‪getForm()
112  {
113  return ‪$this->form;
114  }
115 
121  public function ‪setForm(‪$form)
122  {
123  $this->form = ‪$form;
124  return $this;
125  }
126 
132  public function ‪isValid()
133  {
134  if (
135  trim($this->‪getName()) !== ''
136  && trim($this->‪getValue()) !== ''
137  && trim($this->‪getTitle()) !== ''
138  && $this->‪getType() === self::class
139  && $this->‪getIcon() !== null
140  ) {
141  return true;
142  }
143  return false;
144  }
145 
151  public function ‪render()
152  {
153  $attributes = [
154  'name' => $this->‪getName(),
155  'class' => 'btn btn-sm btn-default ' . $this->‪getClasses(),
156  'value' => $this->‪getValue(),
157  'title' => $this->‪getTitle(),
158  'form' => trim($this->‪getForm()),
159  ];
160  if ($this->‪isDisabled()) {
161  $attributes['disabled'] = 'disabled';
162  }
163  $labelText = '';
164  if ($this->showLabelText) {
165  $labelText = ' ' . ‪$this->title;
166  }
167  foreach ($this->dataAttributes as $attributeName => $attributeValue) {
168  $attributes['data-' . $attributeName] = $attributeValue;
169  }
170  $attributesString = GeneralUtility::implodeAttributes($attributes, true);
171 
172  return '<button ' . $attributesString . '>'
173  . $this->‪getIcon()->‪render() . htmlspecialchars($labelText)
174  . '</button>';
175  }
176 
180  public function ‪__toString(): string
181  {
182  return $this->‪render();
183  }
184 }
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\render
‪string render()
Definition: InputButton.php:148
‪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:57
‪TYPO3\CMS\Backend\Template\Components\Buttons\AbstractButton\getIcon
‪Icon getIcon()
Definition: AbstractButton.php:72
‪TYPO3\CMS\Core\Imaging\Icon\render
‪render(?string $alternativeMarkupIdentifier=null)
Definition: Icon.php:237
‪TYPO3\CMS\Backend\Template\Components\Buttons\AbstractButton
Definition: AbstractButton.php:25
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\getValue
‪string getValue()
Definition: InputButton.php:87
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\setName
‪InputButton setName($name)
Definition: InputButton.php:76
‪TYPO3\CMS\Backend\Template\Components\AbstractControl\getClasses
‪string getClasses()
Definition: AbstractControl.php:47
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\setValue
‪InputButton setValue($value)
Definition: InputButton.php:99
‪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:57
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\setForm
‪InputButton setForm($form)
Definition: InputButton.php:118
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\$value
‪string $value
Definition: InputButton.php:51
‪TYPO3\CMS\Backend\Template\Components\Buttons
Definition: AbstractButton.php:16
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton
Definition: InputButton.php:40
‪TYPO3\CMS\Backend\Template\Components\Buttons\AbstractButton\isDisabled
‪isDisabled()
Definition: AbstractButton.php:103
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\$name
‪string $name
Definition: InputButton.php:45
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\getForm
‪string getForm()
Definition: InputButton.php:108
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\__toString
‪__toString()
Definition: InputButton.php:177
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\getName
‪string getName()
Definition: InputButton.php:64
‪TYPO3\CMS\Backend\Template\Components\Buttons\InputButton\isValid
‪bool isValid()
Definition: InputButton.php:129