ILIAS  release_7 Revision v7.30-3-g800a261c036
ilButton Class Reference
+ Inheritance diagram for ilButton:
+ Collaboration diagram for ilButton:

Public Member Functions

 isFormNovalidate ()
 
 setFormNovalidate ($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 ($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 ($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 ($form_enc_type)
 If this attribute is specified, it overrides the enctype attribute of the button's form owner. More...
 
 getFormAction ()
 
 setFormAction ($form_action)
 The URI of a program that processes the information submitted by the button. More...
 
 getForm ()
 
 setForm ($form)
 The form element that the button is associated with (its form owner). More...
 
 getValue ()
 
 setValue ($value)
 The initial value of the button. More...
 
 getName ()
 
 setName ($name, $is_command=true)
 The name of the button, which is submitted with the form data. More...
 
 getButtonType ()
 
 setButtonType ($button_type)
 
 render ()
 Render HTML. More...
 
- Public Member Functions inherited from ilButtonBase
 __clone ()
 Clone instance. More...
 
 getType ()
 Get button type. More...
 
 setId ($a_value)
 Set id. More...
 
 getId ()
 Get id. More...
 
 setCaption ($a_value, $a_is_lng_id=true)
 Set caption. More...
 
 getCaption ($a_translate=true)
 Get caption. More...
 
 setPrimary ($a_value)
 Toggle primary status. More...
 
 isPrimary ()
 Get primary status. More...
 
 setOmitPreventDoubleSubmission ($a_value)
 Toggle double submission prevention status. More...
 
 getOmitPreventDoubleSubmission ()
 Get double submission prevention status. More...
 
 setOnClick ($a_value)
 Set onclick. More...
 
 getOnClick ()
 Get onclick. More...
 
 setAccessKey ($a_value)
 Set access key. More...
 
 getAccessKey ()
 Get access key. More...
 
 setDisabled ($a_value)
 Toggle disabled status. More...
 
 isDisabled ()
 Get disabled status. More...
 
 addCSSClass ($a_value)
 Add CSS class. More...
 
 getCSSClasses ()
 Get CSS class(es) More...
 
 applyDefaultCss ($apply_default_css=null)
 
 render ()
 Render HTML. More...
 
 getToolbarHTML ()
 
 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 getInstance ()
 Factory. More...
 

Data Fields

const BUTTON_TYPE_BUTTON = 'button'
 
const BUTTON_TYPE_SUBMIT = 'submit'
 
const BUTTON_TYPE_RESET = 'reset'
 
const FORM_ENC_TYPE_APPLICATION = 'application/x-www-form-urlencoded'
 
const FORM_ENC_TYPE_MULTI_PART = 'multipart/form-data'
 
const FORM_ENC_TYPE_PLAIN = 'text/plain'
 
const FORM_METHOD_POST = 'POST'
 
const FORM_METHOD_GET = 'GET'
 
const FORM_TARGET_SELF = '_self'
 
const FORM_TARGET_BLANK = '_blank'
 
const FORM_TARGET_PARENT = '_parent'
 
const FORM_TARGET_TOP = '_top'
 
- Data Fields inherited from ilButtonBase
const TYPE_SUBMIT = 1
 
const TYPE_LINK = 2
 
const TYPE_SPLIT = 3
 
const TYPE_BUTTON = 4
 

Protected Attributes

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

Additional Inherited Members

- Protected Member Functions inherited from ilButtonBase
 __construct ($a_type)
 Constructor. More...
 
 setType ($a_value)
 Set button type. More...
 
 gatherCssClasses ()
 Gather all active CSS classes. More...
 
 renderAttributesHelper (array $a_attr)
 Render HTML node attributes. More...
 
 renderAttributes (array $a_additional_attr=null)
 Render current HTML attributes. More...
 
 prepareRender ()
 Prepare render. More...
 

Detailed Description

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

Member Function Documentation

◆ getButtonType()

ilButton::getButtonType ( )
Returns
string

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

421 {
422 return $this->button_type;
423 }

References $button_type.

Referenced by render().

+ Here is the caller graph for this function:

◆ getForm()

ilButton::getForm ( )
Returns
string

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

338 {
339 return $this->form;
340 }

References $form.

Referenced by render().

+ Here is the caller graph for this function:

◆ getFormAction()

ilButton::getFormAction ( )
Returns
string

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

311 {
312 return $this->form_action;
313 }

References $form_action.

Referenced by render().

+ Here is the caller graph for this function:

◆ getFormEncType()

ilButton::getFormEncType ( )
Returns
string

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

282 {
284 }

References $form_enc_type.

Referenced by render().

+ Here is the caller graph for this function:

◆ getFormMethod()

ilButton::getFormMethod ( )
Returns
string

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

253 {
254 return $this->form_method;
255 }

References $form_method.

Referenced by render().

+ Here is the caller graph for this function:

◆ getFormTarget()

ilButton::getFormTarget ( )
Returns
string

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

221 {
222 return $this->form_target;
223 }

References $form_target.

Referenced by render().

+ Here is the caller graph for this function:

◆ getInstance()

static ilButton::getInstance ( )
static
Returns
self

Reimplemented from ilButtonBase.

Reimplemented in ilJsLinkButton.

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

138 {
139 return new self(self::TYPE_BUTTON);
140 }

References ilButtonBase\TYPE_BUTTON.

Referenced by ilMailFormGUI\showForm(), ilMarkSchemaGUI\showMarkSchema(), and ilContainerGUI\showPasswordInstructionObject().

+ Here is the caller graph for this function:

◆ getName()

ilButton::getName ( )
Returns
string

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

394 {
395 return $this->name;
396 }

References $name.

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

+ Here is the caller graph for this function:

◆ getValidButtonTypes()

static ilButton::getValidButtonTypes ( )
static
Returns
array()

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

182 {
183 return array(
184 self::BUTTON_TYPE_SUBMIT,
185 self::BUTTON_TYPE_BUTTON,
186 self::BUTTON_TYPE_RESET
187 );
188 }

◆ getValidFormEncTypes()

static ilButton::getValidFormEncTypes ( )
static
Returns
array()

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

170 {
171 return array(
172 self::FORM_ENC_TYPE_APPLICATION,
173 self::FORM_ENC_TYPE_MULTI_PART,
174 self::FORM_ENC_TYPE_PLAIN
175 );
176 }

◆ getValidFormMethods()

static ilButton::getValidFormMethods ( )
static
Returns
array()

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

159 {
160 return array(
161 self::FORM_METHOD_POST,
162 self::FORM_METHOD_GET
163 );
164 }

◆ getValidFormTargets()

static ilButton::getValidFormTargets ( )
static
Returns
array()

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

146 {
147 return array(
148 self::FORM_TARGET_BLANK,
149 self::FORM_TARGET_PARENT,
150 self::FORM_TARGET_SELF,
151 self::FORM_TARGET_TOP
152 );
153 }

◆ getValue()

ilButton::getValue ( )
Returns
string

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

368 {
369 return $this->value;
370 }

References $value.

Referenced by render().

+ Here is the caller graph for this function:

◆ isFormNovalidate()

ilButton::isFormNovalidate ( )
Returns
boolean

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

194 {
196 }

References $form_novalidate.

Referenced by render().

+ Here is the caller graph for this function:

◆ render()

ilButton::render ( )

Render HTML.

Returns
string

Reimplemented from ilButtonBase.

Reimplemented in ilJsLinkButton.

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

450 {
451 $this->prepareRender();
452
453 $attr = array();
454 $attr['type'] = $this->getButtonType();
455 $attr['name'] = $this->getName();
456 $attr['value'] = $this->getValue();
457 $attr['form'] = $this->getForm();
458 $attr['formaction'] = $this->getFormAction();
459 $attr['formmethod'] = $this->getFormMethod();
460 $attr['formenctype'] = $this->getFormEncType();
461 $attr['formtarget'] = $this->getFormTarget();
462 $attr['formnovalidate'] = $this->isFormNovalidate() ? var_export($this->isFormNovalidate(), 1) : null;
463
464 if (self::FORM_TARGET_BLANK === $this->getFormTarget()) {
465 $attr['rel'] = 'noopener';
466 }
467
468 return '<button' . $this->renderAttributes(array_filter($attr)) . '>' . $this->getCaption() . '</button>';
469 }
renderAttributes(array $a_additional_attr=null)
Render current HTML attributes.
prepareRender()
Prepare render.
getCaption($a_translate=true)
Get caption.

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

+ Here is the call graph for this function:

◆ setButtonType()

ilButton::setButtonType (   $button_type)
Parameters
string$button_type
Exceptions
InvalidArgumentException
Returns
self

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

431 {
432 if (!in_array($button_type, self::getValidButtonTypes())) {
433 throw new InvalidArgumentException(
434 sprintf(
435 "Invalid button type passed, must be one of these: %s",
436 implode(', ', self::getValidButtonTypes())
437 )
438 );
439 }
440
441 $this->button_type = $button_type;
442 return $this;
443 }

References $button_type.

◆ setForm()

ilButton::setForm (   $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.

Parameters
string
Exceptions
InvalidArgumentException
Returns
self

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

353 {
354 if (!is_string($form)) {
355 throw new InvalidArgumentException(
356 sprintf("The form id must be of type 'string'")
357 );
358 }
359
360 $this->form = $form;
361 return $this;
362 }

References $form.

◆ setFormAction()

ilButton::setFormAction (   $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.

Parameters
string$form_action
Exceptions
InvalidArgumentException
Returns
self

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

323 {
324 if (!is_string($form_action)) {
325 throw new InvalidArgumentException(
326 sprintf("The form action must be of type 'string'")
327 );
328 }
329
330 $this->form_action = $form_action;
331 return $this;
332 }

References $form_action.

◆ setFormEncType()

ilButton::setFormEncType (   $form_enc_type)

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

Parameters
string$form_enc_type
Exceptions
InvalidArgumentException
Returns
self

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

293 {
294 if (!in_array($form_enc_type, self::getValidFormEncTypes())) {
295 throw new InvalidArgumentException(
296 sprintf(
297 "Invalid form enc type passed, must be one of these: %s",
298 implode(', ', self::getValidFormEncTypes())
299 )
300 );
301 }
302
303 $this->form_enc_type = $form_enc_type;
304 return $this;
305 }

References $form_enc_type.

◆ setFormMethod()

ilButton::setFormMethod (   $form_method)

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

Parameters
string$form_method
Exceptions
InvalidArgumentException
Returns
self

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

264 {
265 if (!in_array($form_method, self::getValidFormMethods())) {
266 throw new InvalidArgumentException(
267 sprintf(
268 "Invalid form method passed, must be one of these: %s",
269 implode(', ', self::getValidFormMethods())
270 )
271 );
272 }
273
274 $this->form_method = $form_method;
275 return $this;
276 }

References $form_method.

◆ setFormNovalidate()

ilButton::setFormNovalidate (   $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.

Parameters
boolean$form_novalidate
Exceptions
InvalidArgumentException
Returns
self

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

206 {
207 if (!is_bool($form_novalidate)) {
208 throw new InvalidArgumentException(
209 sprintf("Please pass a value of type 'boolean' to specify whether the form is not to be validated when it is submitted")
210 );
211 }
212
213 $this->form_novalidate = $form_novalidate;
214 return $this;
215 }

References $form_novalidate.

◆ setFormTarget()

ilButton::setFormTarget (   $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.

Parameters
string$form_target
Exceptions
InvalidArgumentException
Returns
self

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

235 {
236 if (!in_array($form_target, self::getValidFormTargets())) {
237 throw new InvalidArgumentException(
238 sprintf(
239 "Invalid form target passed, must be one of these: %s",
240 implode(', ', self::getValidFormTargets())
241 )
242 );
243 }
244
245 $this->form_target = $form_target;
246 return $this;
247 }

References $form_target.

◆ setName()

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

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

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

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

406 {
407 if (!is_string($name)) {
408 throw new InvalidArgumentException(
409 sprintf("The name of the button must be of type 'string'")
410 );
411 }
412
413 $this->name = $is_command ? 'cmd[' . $name . ']' : $name;
414 return $this;
415 }

References $name.

◆ setValue()

ilButton::setValue (   $value)

The initial value of the button.

Parameters
string$value
Exceptions
InvalidArgumentException
Returns
self

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

379 {
380 if (!is_string($value)) {
381 throw new InvalidArgumentException(
382 sprintf("The initial value of the button must be of type 'string'")
383 );
384 }
385
386 $this->value = $value;
387 return $this;
388 }

References $value.

Field Documentation

◆ $button_type

ilButton::$button_type = self::BUTTON_TYPE_SUBMIT
protected

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

Referenced by getButtonType(), and setButtonType().

◆ $form

ilButton::$form = null
protected

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

Referenced by getForm(), and setForm().

◆ $form_action

ilButton::$form_action = null
protected

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

Referenced by getFormAction(), and setFormAction().

◆ $form_enc_type

ilButton::$form_enc_type = null
protected

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

Referenced by getFormEncType(), and setFormEncType().

◆ $form_method

ilButton::$form_method = null
protected

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

Referenced by getFormMethod(), and setFormMethod().

◆ $form_novalidate

ilButton::$form_novalidate = null
protected

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

Referenced by isFormNovalidate(), and setFormNovalidate().

◆ $form_target

ilButton::$form_target = null
protected

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

Referenced by getFormTarget(), and setFormTarget().

◆ $name

ilButton::$name = null
protected

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

Referenced by getName(), and setName().

◆ $value

ilButton::$value = null
protected

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

Referenced by getValue(), and setValue().

◆ BUTTON_TYPE_BUTTON

const ilButton::BUTTON_TYPE_BUTTON = 'button'

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

◆ BUTTON_TYPE_RESET

const ilButton::BUTTON_TYPE_RESET = 'reset'

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

◆ BUTTON_TYPE_SUBMIT

const ilButton::BUTTON_TYPE_SUBMIT = 'submit'

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

Referenced by ilMailFormGUI\showForm(), and ilMarkSchemaGUI\showMarkSchema().

◆ FORM_ENC_TYPE_APPLICATION

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

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

◆ FORM_ENC_TYPE_MULTI_PART

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

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

◆ FORM_ENC_TYPE_PLAIN

const ilButton::FORM_ENC_TYPE_PLAIN = 'text/plain'

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

◆ FORM_METHOD_GET

const ilButton::FORM_METHOD_GET = 'GET'

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

◆ FORM_METHOD_POST

const ilButton::FORM_METHOD_POST = 'POST'

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

◆ FORM_TARGET_BLANK

const ilButton::FORM_TARGET_BLANK = '_blank'

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

Referenced by ilTestSubmissionReviewGUI\buildToolbar().

◆ FORM_TARGET_PARENT

const ilButton::FORM_TARGET_PARENT = '_parent'

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

◆ FORM_TARGET_SELF

const ilButton::FORM_TARGET_SELF = '_self'

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

◆ FORM_TARGET_TOP

const ilButton::FORM_TARGET_TOP = '_top'

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


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