ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
 $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 428 of file class.ilButton.php.

429 {
430 return $this->button_type;
431 }

References $button_type.

Referenced by render().

+ Here is the caller graph for this function:

◆ getForm()

ilButton::getForm ( )
Returns
string

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

343 {
344 return $this->form;
345 }

References $form.

Referenced by render().

+ Here is the caller graph for this function:

◆ getFormAction()

ilButton::getFormAction ( )
Returns
string

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

315 {
316 return $this->form_action;
317 }

References $form_action.

Referenced by render().

+ Here is the caller graph for this function:

◆ getFormEncType()

ilButton::getFormEncType ( )
Returns
string

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

285 {
287 }

References $form_enc_type.

Referenced by render().

+ Here is the caller graph for this function:

◆ getFormMethod()

ilButton::getFormMethod ( )
Returns
string

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

255 {
256 return $this->form_method;
257 }

References $form_method.

Referenced by render().

+ Here is the caller graph for this function:

◆ getFormTarget()

ilButton::getFormTarget ( )
Returns
string

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

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

References $form_target.

Referenced by render().

+ Here is the caller graph for this function:

◆ getInstance()

static ilButton::getInstance ( )
static
Returns
self

Reimplemented from ilButtonBase.

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

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

References ilButtonBase\TYPE_BUTTON.

◆ getName()

ilButton::getName ( )
Returns
string

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

401 {
402 return $this->name;
403 }

References $name.

Referenced by 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 373 of file class.ilButton.php.

374 {
375 return $this->value;
376 }

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.

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

459 {
460 $this->prepareRender();
461
462 $attr = array();
463 $attr['type'] = $this->getButtonType();
464 $attr['name'] = $this->getName();
465 $attr['value'] = $this->getValue();
466 $attr['form'] = $this->getForm();
467 $attr['formaction'] = $this->getFormAction();
468 $attr['formmethod'] = $this->getFormMethod();
469 $attr['formenctype'] = $this->getFormEncType();
470 $attr['formtarget'] = $this->getFormTarget();
471 $attr['formnovalidate'] = $this->isFormNovalidate() ? var_export($this->isFormNovalidate(), 1) : null;
472
473 if (self::FORM_TARGET_BLANK === $this->getFormTarget()) {
474 $attr['rel'] = 'noopener';
475 }
476
477 return '<button' . $this->renderAttributes(array_filter($attr)) . '>' . $this->getCaption() . '</button>';
478 }
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 438 of file class.ilButton.php.

439 {
440 if(!in_array($button_type, self::getValidButtonTypes()))
441 {
442 throw new InvalidArgumentException(
443 sprintf(
444 "Invalid button type passed, must be one of these: %s",
445 implode(', ', self::getValidButtonTypes())
446 )
447 );
448 }
449
450 $this->button_type = $button_type;
451 return $this;
452 }

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 357 of file class.ilButton.php.

358 {
359 if(!is_string($form))
360 {
361 throw new InvalidArgumentException(
362 sprintf("The form id must be of type 'string'")
363 );
364 }
365
366 $this->form = $form;
367 return $this;
368 }

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 326 of file class.ilButton.php.

327 {
328 if(!is_string($form_action))
329 {
330 throw new InvalidArgumentException(
331 sprintf("The form action must be of type 'string'")
332 );
333 }
334
335 $this->form_action = $form_action;
336 return $this;
337 }

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 295 of file class.ilButton.php.

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

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 265 of file class.ilButton.php.

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

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 {
209 throw new InvalidArgumentException(
210 sprintf("Please pass a value of type 'boolean' to specify whether the form is not to be validated when it is submitted")
211 );
212 }
213
214 $this->form_novalidate = $form_novalidate;
215 return $this;
216 }

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 235 of file class.ilButton.php.

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

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 412 of file class.ilButton.php.

413 {
414 if(!is_string($name))
415 {
416 throw new InvalidArgumentException(
417 sprintf("The name of the button must be of type 'string'")
418 );
419 }
420
421 $this->name = $is_command ? 'cmd[' . $name . ']' : $name;
422 return $this;
423 }

References $name.

◆ setValue()

ilButton::setValue (   $value)

The initial value of the button.

Parameters
string$value
Exceptions
InvalidArgumentException
Returns
self

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

385 {
386 if(!is_string($value))
387 {
388 throw new InvalidArgumentException(
389 sprintf("The initial value of the button must be of type 'string'")
390 );
391 }
392
393 $this->value = $value;
394 return $this;
395 }

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.

◆ 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: