ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilButton Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilButton:
+ Collaboration diagram for ilButton:

Public Member Functions

 isFormNovalidate ()
 
 setFormNovalidate (bool $form_novalidate)
 If the button is a submit button, this Boolean attribute specifies that the form is not to be validated when it is submitted. More...
 
 getFormTarget ()
 
 setFormTarget (string $form_target)
 If the button is a submit button, this attribute is a name or keyword indicating where to display the response that is received after submitting the form. More...
 
 getFormMethod ()
 
 setFormMethod (string $form_method)
 If the button is a submit button, this attribute specifies the HTTP method that the browser uses to submit the form. More...
 
 getFormEncType ()
 
 setFormEncType (string $form_enc_type)
 If this attribute is specified, it overrides the enctype attribute of the button's form owner. More...
 
 getFormAction ()
 
 setFormAction (string $form_action)
 The URI of a program that processes the information submitted by the button. More...
 
 getForm ()
 
 setForm (string $form)
 The form element that the button is associated with (its form owner). More...
 
 getValue ()
 
 setValue (string $value)
 The initial value of the button. More...
 
 getName ()
 
 setName (string $name, bool $is_command=true)
 The name of the button, which is submitted with the form data. More...
 
 getButtonType ()
 
 setButtonType (string $button_type)
 
 render ()
 
- Public Member Functions inherited from ilButtonBase
 __clone ()
 
 getType ()
 
 setId (?string $a_value)
 
 getId ()
 
 setCaption (string $a_value, bool $a_is_lng_id=true)
 
 getCaption (bool $a_translate=true)
 
 setPrimary (bool $a_value)
 
 isPrimary ()
 
 setOmitPreventDoubleSubmission (bool $a_value)
 Toggle double submission prevention status. More...
 
 getOmitPreventDoubleSubmission ()
 
 setOnClick (string $a_value)
 
 getOnClick ()
 
 setDisabled (bool $a_value)
 
 isDisabled ()
 
 addCSSClass (string $a_value)
 
 getCSSClasses ()
 
 applyDefaultCss (?bool $apply_default_css=null)
 
 render ()
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 

Static Public Member Functions

static getInstance ()
 
static getValidFormTargets ()
 
static getValidFormMethods ()
 
static getValidFormEncTypes ()
 
static getValidButtonTypes ()
 
- Static Public Member Functions inherited from ilButtonBase
static getInstance ()
 

Data Fields

const BUTTON_TYPE_BUTTON = 'button'
 The button has no default behavior. More...
 
const BUTTON_TYPE_SUBMIT = 'submit'
 The button submits the form data to the server. More...
 
const BUTTON_TYPE_RESET = 'reset'
 The button resets all the controls to their initial values. More...
 
const FORM_ENC_TYPE_APPLICATION = 'application/x-www-form-urlencoded'
 The default value if the attribute is not specified. More...
 
const FORM_ENC_TYPE_MULTI_PART = 'multipart/form-data'
 Use this value if you are using an <input> element with the type attribute set to file. More...
 
const FORM_ENC_TYPE_PLAIN = 'text/plain'
 
const FORM_METHOD_POST = 'POST'
 
const FORM_METHOD_GET = 'GET'
 
const FORM_TARGET_SELF = '_self'
 Load the response into the same browsing context as the current one. More...
 
const FORM_TARGET_BLANK = '_blank'
 Load the response into a new unnamed browsing context. More...
 
const FORM_TARGET_PARENT = '_parent'
 Load the response into the parent browsing context of the current one. More...
 
const FORM_TARGET_TOP = '_top'
 Load the response into the top-level browsing context (that is, the browsing context that is an ancestor of the current one, and has no parent). More...
 
- Data Fields inherited from ilButtonBase
const TYPE_SUBMIT = 1
 
const TYPE_LINK = 2
 
const TYPE_SPLIT = 3
 
const TYPE_BUTTON = 4
 

Protected Attributes

string $button_type = self::BUTTON_TYPE_SUBMIT
 
string $name = null
 
string $value = null
 
string $form = null
 
string $form_action = null
 
string $form_enc_type = null
 
string $form_method = null
 
string $form_target = null
 
bool $form_novalidate = false
 
- Protected Attributes inherited from ilButtonBase
ilLanguage $lng
 
int $type = 0
 
string $id = ""
 
string $caption = ""
 
bool $caption_is_lng_id = false
 
bool $primary = false
 
bool $omit_prevent_double_submission = false
 
string $onclick = ""
 
int $acc_key = 0
 
bool $disabled = false
 
array $css = array()
 
bool $apply_default_css = true
 

Additional Inherited Members

- Protected Member Functions inherited from ilButtonBase
 __construct (int $a_type)
 
 setType (int $a_value)
 
 gatherCssClasses ()
 
 renderAttributesHelper (array $a_attr)
 
 renderAttributes (?array $a_additional_attr=null)
 Render current HTML attributes. More...
 
 prepareRender ()
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Description: <button> (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button) by Mozilla Contributors is licensed under CC-BY-SA 2.5.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Deprecated:
9 Use KS Buttons instead

Definition at line 24 of file class.ilButton.php.

Member Function Documentation

◆ getButtonType()

ilButton::getButtonType ( )

Definition at line 319 of file class.ilButton.php.

References $button_type.

Referenced by render().

319  : string
320  {
321  return $this->button_type;
322  }
string $button_type
+ Here is the caller graph for this function:

◆ getForm()

ilButton::getForm ( )

Definition at line 251 of file class.ilButton.php.

References ILIAS\Repository\form().

Referenced by render().

251  : string
252  {
253  return $this->form ?? '';
254  }
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFormAction()

ilButton::getFormAction ( )

Definition at line 229 of file class.ilButton.php.

References $form_action.

Referenced by render().

229  : ?string
230  {
231  return $this->form_action;
232  }
string $form_action
+ Here is the caller graph for this function:

◆ getFormEncType()

ilButton::getFormEncType ( )

Definition at line 205 of file class.ilButton.php.

References $form_enc_type.

Referenced by render().

205  : ?string
206  {
207  return $this->form_enc_type;
208  }
string $form_enc_type
+ Here is the caller graph for this function:

◆ getFormMethod()

ilButton::getFormMethod ( )

Definition at line 181 of file class.ilButton.php.

References $form_method.

Referenced by render().

181  : ?string
182  {
183  return $this->form_method;
184  }
string $form_method
+ Here is the caller graph for this function:

◆ getFormTarget()

ilButton::getFormTarget ( )

Definition at line 154 of file class.ilButton.php.

References $form_target.

Referenced by render().

154  : ?string
155  {
156  return $this->form_target;
157  }
string $form_target
+ Here is the caller graph for this function:

◆ getInstance()

static ilButton::getInstance ( )
static

Definition at line 91 of file class.ilButton.php.

91  : self
92  {
93  return new self(self::TYPE_BUTTON);
94  }

◆ getName()

ilButton::getName ( )

Definition at line 297 of file class.ilButton.php.

References $name.

Referenced by ilJsLinkButton\render(), and render().

297  : ?string
298  {
299  return $this->name;
300  }
string $name
+ Here is the caller graph for this function:

◆ getValidButtonTypes()

static ilButton::getValidButtonTypes ( )
static

Definition at line 123 of file class.ilButton.php.

123  : array
124  {
125  return array(
126  self::BUTTON_TYPE_SUBMIT,
127  self::BUTTON_TYPE_BUTTON,
128  self::BUTTON_TYPE_RESET
129  );
130  }

◆ getValidFormEncTypes()

static ilButton::getValidFormEncTypes ( )
static

Definition at line 114 of file class.ilButton.php.

114  : array
115  {
116  return array(
117  self::FORM_ENC_TYPE_APPLICATION,
118  self::FORM_ENC_TYPE_MULTI_PART,
119  self::FORM_ENC_TYPE_PLAIN
120  );
121  }

◆ getValidFormMethods()

static ilButton::getValidFormMethods ( )
static

Definition at line 106 of file class.ilButton.php.

106  : array
107  {
108  return array(
109  self::FORM_METHOD_POST,
110  self::FORM_METHOD_GET
111  );
112  }

◆ getValidFormTargets()

static ilButton::getValidFormTargets ( )
static

Definition at line 96 of file class.ilButton.php.

96  : array
97  {
98  return array(
99  self::FORM_TARGET_BLANK,
100  self::FORM_TARGET_PARENT,
101  self::FORM_TARGET_SELF,
102  self::FORM_TARGET_TOP
103  );
104  }

◆ getValue()

ilButton::getValue ( )

Definition at line 276 of file class.ilButton.php.

References $value.

Referenced by render().

276  : ?string
277  {
278  return $this->value;
279  }
string $value
+ Here is the caller graph for this function:

◆ isFormNovalidate()

ilButton::isFormNovalidate ( )

Definition at line 132 of file class.ilButton.php.

References $form_novalidate.

Referenced by render().

132  : ?bool
133  {
134  return $this->form_novalidate;
135  }
bool $form_novalidate
+ Here is the caller graph for this function:

◆ render()

ilButton::render ( )

Definition at line 342 of file class.ilButton.php.

References getButtonType(), ilButtonBase\getCaption(), getForm(), getFormAction(), getFormEncType(), getFormMethod(), getFormTarget(), getName(), getValue(), isFormNovalidate(), null, ilButtonBase\prepareRender(), and ilButtonBase\renderAttributes().

342  : string
343  {
344  $this->prepareRender();
345 
346  $attr = [];
347  $attr['type'] = $this->getButtonType() ?? '';
348  $attr['name'] = $this->getName() ?? '';
349  $attr['value'] = $this->getValue() ?? '';
350  $attr['form'] = $this->getForm() ?? '';
351  $attr['formaction'] = $this->getFormAction() ?? '';
352  $attr['formmethod'] = $this->getFormMethod() ?? '';
353  $attr['formenctype'] = $this->getFormEncType() ?? '';
354  $attr['formtarget'] = $this->getFormTarget() ?? '';
355  $attr['formnovalidate'] = $this->isFormNovalidate() ? var_export($this->isFormNovalidate(), 1) : null;
356 
357  if (self::FORM_TARGET_BLANK === $this->getFormTarget()) {
358  $attr['rel'] = 'noopener';
359  }
360 
361  return '<button' . $this->renderAttributes(array_filter($attr)) . '>' . $this->getCaption() . '</button>';
362  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
renderAttributes(?array $a_additional_attr=null)
Render current HTML attributes.
getCaption(bool $a_translate=true)
+ Here is the call graph for this function:

◆ setButtonType()

ilButton::setButtonType ( string  $button_type)
Exceptions
InvalidArgumentException

Definition at line 327 of file class.ilButton.php.

References $button_type.

327  : self
328  {
329  if (!in_array($button_type, self::getValidButtonTypes())) {
330  throw new InvalidArgumentException(
331  sprintf(
332  "Invalid button type passed, must be one of these: %s",
333  implode(', ', self::getValidButtonTypes())
334  )
335  );
336  }
337 
338  $this->button_type = $button_type;
339  return $this;
340  }
string $button_type

◆ setForm()

ilButton::setForm ( string  $form)

The form element that the button is associated with (its form owner).

The value of the attribute must be the id attribute of a <form> element in the same document. If this attribute is not specified, the <button> element must be a descendant of a form element. This attribute enables you to place <button> elements anywhere within a document, not just as descendants of their <form> elements.

Exceptions
InvalidArgumentException

Definition at line 264 of file class.ilButton.php.

References $form, and ILIAS\Repository\form().

264  : self
265  {
266  if (!is_string($form)) {
267  throw new InvalidArgumentException(
268  "The form id must be of type 'string'"
269  );
270  }
271 
272  $this->form = $form;
273  return $this;
274  }
string $form
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:

◆ setFormAction()

ilButton::setFormAction ( string  $form_action)

The URI of a program that processes the information submitted by the button.

If specified, it overrides the action attribute of the button's form owner.

Exceptions
InvalidArgumentException

Definition at line 239 of file class.ilButton.php.

References $form_action.

239  : self
240  {
241  if (!is_string($form_action)) {
242  throw new InvalidArgumentException(
243  "The form action must be of type 'string'"
244  );
245  }
246 
247  $this->form_action = $form_action;
248  return $this;
249  }
string $form_action

◆ setFormEncType()

ilButton::setFormEncType ( string  $form_enc_type)

If this attribute is specified, it overrides the enctype attribute of the button's form owner.

Exceptions
InvalidArgumentException

Definition at line 214 of file class.ilButton.php.

References $form_enc_type.

214  : self
215  {
216  if (!in_array($form_enc_type, self::getValidFormEncTypes())) {
217  throw new InvalidArgumentException(
218  sprintf(
219  "Invalid form enc type passed, must be one of these: %s",
220  implode(', ', self::getValidFormEncTypes())
221  )
222  );
223  }
224 
225  $this->form_enc_type = $form_enc_type;
226  return $this;
227  }
string $form_enc_type

◆ setFormMethod()

ilButton::setFormMethod ( string  $form_method)

If the button is a submit button, this attribute specifies the HTTP method that the browser uses to submit the form.

Exceptions
InvalidArgumentException

Definition at line 190 of file class.ilButton.php.

References $form_method.

190  : self
191  {
192  if (!in_array($form_method, self::getValidFormMethods())) {
193  throw new InvalidArgumentException(
194  sprintf(
195  "Invalid form method passed, must be one of these: %s",
196  implode(', ', self::getValidFormMethods())
197  )
198  );
199  }
200 
201  $this->form_method = $form_method;
202  return $this;
203  }
string $form_method

◆ setFormNovalidate()

ilButton::setFormNovalidate ( bool  $form_novalidate)

If the button is a submit button, this Boolean attribute specifies that the form is not to be validated when it is submitted.

If this attribute is specified, it overrides the novalidate attribute of the button's form owner.

Exceptions
InvalidArgumentException

Definition at line 142 of file class.ilButton.php.

References $form_novalidate.

142  : self
143  {
144  if (!is_bool($form_novalidate)) {
145  throw new InvalidArgumentException(
146  "Please pass a value of type 'boolean' to specify whether the form is not to be validated when it is submitted"
147  );
148  }
149 
150  $this->form_novalidate = $form_novalidate;
151  return $this;
152  }
bool $form_novalidate

◆ setFormTarget()

ilButton::setFormTarget ( string  $form_target)

If the button is a submit button, this attribute is a name or keyword indicating where to display the response that is received after submitting the form.

This is a name of, or keyword for, a browsing context (for example, tab, window, or inline frame). If this attribute is specified, it overrides the target attribute of the button's form owner.

Exceptions
InvalidArgumentException

Definition at line 166 of file class.ilButton.php.

References $form_target.

166  : self
167  {
168  if (!in_array($form_target, self::getValidFormTargets())) {
169  throw new InvalidArgumentException(
170  sprintf(
171  "Invalid form target passed, must be one of these: %s",
172  implode(', ', self::getValidFormTargets())
173  )
174  );
175  }
176 
177  $this->form_target = $form_target;
178  return $this;
179  }
string $form_target

◆ setName()

ilButton::setName ( string  $name,
bool  $is_command = true 
)

The name of the button, which is submitted with the form data.

Parameters
bool$is_commandif true, a cmd[] is wrapped around the passed name
Exceptions
InvalidArgumentException

Definition at line 307 of file class.ilButton.php.

References $name.

307  : self
308  {
309  if (!is_string($name)) {
310  throw new InvalidArgumentException(
311  "The name of the button must be of type 'string'"
312  );
313  }
314 
315  $this->name = $is_command ? 'cmd[' . $name . ']' : $name;
316  return $this;
317  }
string $name

◆ setValue()

ilButton::setValue ( string  $value)

The initial value of the button.

Exceptions
InvalidArgumentException

Definition at line 285 of file class.ilButton.php.

References $value.

285  : self
286  {
287  if (!is_string($value)) {
288  throw new InvalidArgumentException(
289  "The initial value of the button must be of type 'string'"
290  );
291  }
292 
293  $this->value = $value;
294  return $this;
295  }
string $value

Field Documentation

◆ $button_type

string ilButton::$button_type = self::BUTTON_TYPE_SUBMIT
protected

Definition at line 81 of file class.ilButton.php.

Referenced by getButtonType(), and setButtonType().

◆ $form

string ilButton::$form = null
protected

Definition at line 84 of file class.ilButton.php.

Referenced by setForm().

◆ $form_action

string ilButton::$form_action = null
protected

Definition at line 85 of file class.ilButton.php.

Referenced by getFormAction(), and setFormAction().

◆ $form_enc_type

string ilButton::$form_enc_type = null
protected

Definition at line 86 of file class.ilButton.php.

Referenced by getFormEncType(), and setFormEncType().

◆ $form_method

string ilButton::$form_method = null
protected

Definition at line 87 of file class.ilButton.php.

Referenced by getFormMethod(), and setFormMethod().

◆ $form_novalidate

bool ilButton::$form_novalidate = false
protected

Definition at line 89 of file class.ilButton.php.

Referenced by isFormNovalidate(), and setFormNovalidate().

◆ $form_target

string ilButton::$form_target = null
protected

Definition at line 88 of file class.ilButton.php.

Referenced by getFormTarget(), and setFormTarget().

◆ $name

string ilButton::$name = null
protected

Definition at line 82 of file class.ilButton.php.

Referenced by getName(), and setName().

◆ $value

string ilButton::$value = null
protected

Definition at line 83 of file class.ilButton.php.

Referenced by getValue(), and setValue().

◆ BUTTON_TYPE_BUTTON

const ilButton::BUTTON_TYPE_BUTTON = 'button'

The button has no default behavior.

It can have client-side scripts associated with the element's events, which are triggered when the events occur.

Definition at line 30 of file class.ilButton.php.

◆ BUTTON_TYPE_RESET

const ilButton::BUTTON_TYPE_RESET = 'reset'

The button resets all the controls to their initial values.

Definition at line 41 of file class.ilButton.php.

◆ BUTTON_TYPE_SUBMIT

const ilButton::BUTTON_TYPE_SUBMIT = 'submit'

The button submits the form data to the server.

This is the default if the attribute is not specified, or if the attribute is dynamically changed to an empty or invalid value.

Definition at line 36 of file class.ilButton.php.

◆ FORM_ENC_TYPE_APPLICATION

const ilButton::FORM_ENC_TYPE_APPLICATION = 'application/x-www-form-urlencoded'

The default value if the attribute is not specified.

Definition at line 46 of file class.ilButton.php.

◆ FORM_ENC_TYPE_MULTI_PART

const ilButton::FORM_ENC_TYPE_MULTI_PART = 'multipart/form-data'

Use this value if you are using an <input> element with the type attribute set to file.

Definition at line 51 of file class.ilButton.php.

◆ FORM_ENC_TYPE_PLAIN

const ilButton::FORM_ENC_TYPE_PLAIN = 'text/plain'

Definition at line 53 of file class.ilButton.php.

◆ FORM_METHOD_GET

const ilButton::FORM_METHOD_GET = 'GET'

Definition at line 55 of file class.ilButton.php.

◆ FORM_METHOD_POST

const ilButton::FORM_METHOD_POST = 'POST'

Definition at line 54 of file class.ilButton.php.

◆ FORM_TARGET_BLANK

const ilButton::FORM_TARGET_BLANK = '_blank'

Load the response into a new unnamed browsing context.

Definition at line 66 of file class.ilButton.php.

◆ FORM_TARGET_PARENT

const ilButton::FORM_TARGET_PARENT = '_parent'

Load the response into the parent browsing context of the current one.

If there is no parent, this option behaves the same way as self::FORM_TARGET_SELF.

Definition at line 72 of file class.ilButton.php.

◆ FORM_TARGET_SELF

const ilButton::FORM_TARGET_SELF = '_self'

Load the response into the same browsing context as the current one.

This value is the default if the attribute is not specified.

Definition at line 61 of file class.ilButton.php.

◆ FORM_TARGET_TOP

const ilButton::FORM_TARGET_TOP = '_top'

Load the response into the top-level browsing context (that is, the browsing context that is an ancestor of the current one, and has no parent).

If there is no parent, this option behaves the same way as self::FORM_TARGET_SELF.

Definition at line 79 of file class.ilButton.php.


The documentation for this class was generated from the following file: