ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilButtonBase Class Reference
+ Inheritance diagram for ilButtonBase:
+ Collaboration diagram for ilButtonBase:

Public Member Functions

 __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 ()
 

Static Public Member Functions

static getInstance ()
 Factory. More...
 

Data Fields

const TYPE_SUBMIT = 1
 
const TYPE_LINK = 2
 
const TYPE_SPLIT = 3
 
const TYPE_BUTTON = 4
 

Protected Member Functions

 __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...
 

Protected Attributes

 $lng
 
 $type
 
 $id
 
 $caption
 
 $caption_is_lng_id
 
 $primary
 
 $omit_prevent_double_submission
 
 $onclick
 
 $acc_key
 
 $disabled
 
 $css = array()
 
 $apply_default_css = true
 

Detailed Description

Definition at line 13 of file class.ilButtonBase.php.

Constructor & Destructor Documentation

◆ __construct()

ilButtonBase::__construct (   $a_type)
protected

Constructor.

Parameters
int$a_type
Returns
self

Definition at line 47 of file class.ilButtonBase.php.

References $a_type, $DIC, and setType().

48  {
49  global $DIC;
50 
51  $this->lng = $DIC->language();
52  $this->setType($a_type);
53  }
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92
setType($a_value)
Set button type.
+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilButtonBase::__clone ( )

Clone instance.

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

References getInstance(), and setId().

59  {
60  $this->setId(null);
61  }
setId($a_value)
Set id.
+ Here is the call graph for this function:

◆ addCSSClass()

ilButtonBase::addCSSClass (   $a_value)

Add CSS class.

Parameters
string$a_value

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

Referenced by ilAssFileUploadFileTableDeleteButton\__construct(), and prepareRender().

253  {
254  $this->css[] = $a_value;
255  }
+ Here is the caller graph for this function:

◆ applyDefaultCss()

ilButtonBase::applyDefaultCss (   $apply_default_css = null)
Parameters
boolean | null$apply_default_css
Returns
boolean|void

Definition at line 355 of file class.ilButtonBase.php.

References $apply_default_css, and render().

Referenced by prepareRender().

356  {
357  if (null === $apply_default_css) {
359  }
360 
361  $this->apply_default_css = $apply_default_css;
362  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gatherCssClasses()

ilButtonBase::gatherCssClasses ( )
protected

Gather all active CSS classes.

Returns
string

Definition at line 277 of file class.ilButtonBase.php.

References $css, getCSSClasses(), getOmitPreventDoubleSubmission(), and isPrimary().

Referenced by renderAttributes().

278  {
279  $css = array_unique($this->getCSSClasses());
280 
281  if ($this->isPrimary()) {
282  $css[] = "btn-primary";
283  }
284  if ($this->getOmitPreventDoubleSubmission()) {
285  $css[] = "omitPreventDoubleSubmission";
286  }
287 
288  return implode(" ", $css);
289  }
isPrimary()
Get primary status.
getOmitPreventDoubleSubmission()
Get double submission prevention status.
getCSSClasses()
Get CSS class(es)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAccessKey()

ilButtonBase::getAccessKey ( )

Get access key.

Returns
string

Definition at line 222 of file class.ilButtonBase.php.

References $acc_key.

Referenced by renderAttributes().

223  {
224  return $this->acc_key;
225  }
+ Here is the caller graph for this function:

◆ getCaption()

ilButtonBase::getCaption (   $a_translate = true)

Get caption.

Parameters
bool$a_translate
Returns
string

Definition at line 133 of file class.ilButtonBase.php.

References $caption, and $lng.

Referenced by ilSubmitButton\render(), ilButton\render(), ilJsLinkButton\renderCaption(), ilImageLinkButton\renderCaption(), and ilLinkButton\renderCaption().

134  {
135  $lng = $this->lng;
136 
138 
139  if ($this->caption_is_lng_id &&
140  (bool) $a_translate) {
141  $caption = $lng->txt($caption);
142  }
143 
144  return $caption;
145  }
+ Here is the caller graph for this function:

◆ getCSSClasses()

ilButtonBase::getCSSClasses ( )

Get CSS class(es)

Returns
array

Definition at line 262 of file class.ilButtonBase.php.

References $css.

Referenced by gatherCssClasses().

263  {
264  return $this->css;
265  }
+ Here is the caller graph for this function:

◆ getId()

ilButtonBase::getId ( )

Get id.

Returns
string

Definition at line 110 of file class.ilButtonBase.php.

References $id.

Referenced by renderAttributes().

111  {
112  return $this->id;
113  }
+ Here is the caller graph for this function:

◆ getInstance()

static ilButtonBase::getInstance ( )
staticabstract

Factory.

Returns
self

Referenced by __clone().

+ Here is the caller graph for this function:

◆ getOmitPreventDoubleSubmission()

ilButtonBase::getOmitPreventDoubleSubmission ( )

Get double submission prevention status.

Returns
bool

Definition at line 182 of file class.ilButtonBase.php.

References $omit_prevent_double_submission.

Referenced by gatherCssClasses().

183  {
185  }
+ Here is the caller graph for this function:

◆ getOnClick()

ilButtonBase::getOnClick ( )

Get onclick.

Returns
string

Definition at line 202 of file class.ilButtonBase.php.

References $onclick.

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

203  {
204  return $this->onclick;
205  }
+ Here is the caller graph for this function:

◆ getToolbarHTML()

ilButtonBase::getToolbarHTML ( )
Returns
string

Implements ilToolbarItem.

Definition at line 375 of file class.ilButtonBase.php.

References render().

376  {
377  return $this->render();
378  }
render()
Render HTML.
+ Here is the call graph for this function:

◆ getType()

ilButtonBase::getType ( )

Get button type.

Returns
int

Definition at line 90 of file class.ilButtonBase.php.

References $type.

91  {
92  return $this->type;
93  }

◆ isDisabled()

ilButtonBase::isDisabled ( )

Get disabled status.

Returns
bool

Definition at line 242 of file class.ilButtonBase.php.

References $disabled.

Referenced by renderAttributes().

243  {
244  return $this->disabled;
245  }
+ Here is the caller graph for this function:

◆ isPrimary()

ilButtonBase::isPrimary ( )

Get primary status.

Returns
bool

Definition at line 162 of file class.ilButtonBase.php.

References $primary.

Referenced by ilToolbarGUI\addButtonInstance(), gatherCssClasses(), and ilSplitButtonGUI\render().

163  {
164  return $this->primary;
165  }
+ Here is the caller graph for this function:

◆ prepareRender()

ilButtonBase::prepareRender ( )
protected

Prepare render.

Definition at line 343 of file class.ilButtonBase.php.

References addCSSClass(), and applyDefaultCss().

Referenced by ilJsLinkButton\render(), ilSubmitButton\render(), ilTestPlayerNavButton\render(), ilLinkButton\render(), and ilButton\render().

344  {
345  if ($this->applyDefaultCss()) {
346  $this->addCSSClass("btn");
347  $this->addCSSClass("btn-default");
348  }
349  }
addCSSClass($a_value)
Add CSS class.
applyDefaultCss($apply_default_css=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilButtonBase::render ( )
abstract

Render HTML.

Returns
string

Referenced by applyDefaultCss(), and getToolbarHTML().

+ Here is the caller graph for this function:

◆ renderAttributes()

ilButtonBase::renderAttributes ( array  $a_additional_attr = null)
protected

Render current HTML attributes.

Parameters
array$a_additional_attr
Returns
string

Definition at line 317 of file class.ilButtonBase.php.

References gatherCssClasses(), getAccessKey(), getId(), ilAccessKey\getKey(), getOnClick(), isDisabled(), and renderAttributesHelper().

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

318  {
319  $attr = array();
320  $attr["id"] = $this->getId();
321  $attr["class"] = $this->gatherCssClasses();
322  $attr["onclick"] = $this->getOnClick();
323 
324  if ($this->getAccessKey()) {
325  include_once("./Services/Accessibility/classes/class.ilAccessKey.php");
326  $attr["accesskey"] = ilAccessKey::getKey($this->getAccessKey());
327  }
328 
329  if ($this->isDisabled()) {
330  $attr["disabled"] = "disabled";
331  }
332 
333  if (sizeof($a_additional_attr)) {
334  $attr = array_merge($attr, $a_additional_attr);
335  }
336 
337  return $this->renderAttributesHelper($attr);
338  }
renderAttributesHelper(array $a_attr)
Render HTML node attributes.
getOnClick()
Get onclick.
static getKey($a_func_id, $lang_key="0", $a_ignore_default=false)
Get single access key.
isDisabled()
Get disabled status.
getAccessKey()
Get access key.
gatherCssClasses()
Gather all active CSS classes.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderAttributesHelper()

ilButtonBase::renderAttributesHelper ( array  $a_attr)
protected

Render HTML node attributes.

Returns
string

Definition at line 296 of file class.ilButtonBase.php.

References $id, and $res.

Referenced by ilDclLinkButton\render(), renderAttributes(), and ilImageLinkButton\renderCaption().

297  {
298  $res = array();
299 
300  foreach ($a_attr as $id => $value) {
301  if (trim($value)) {
302  $res[] = strtolower(trim($id)) . '="' . $value . '"';
303  }
304  }
305 
306  if (sizeof($res)) {
307  return " " . implode(" ", $res);
308  }
309  }
foreach($_POST as $key=> $value) $res
+ Here is the caller graph for this function:

◆ setAccessKey()

ilButtonBase::setAccessKey (   $a_value)

Set access key.

Parameters
string$a_value

Definition at line 212 of file class.ilButtonBase.php.

213  {
214  $this->acc_key = trim($a_value);
215  }

◆ setCaption()

ilButtonBase::setCaption (   $a_value,
  $a_is_lng_id = true 
)

Set caption.

Parameters
string$a_value
bool$a_is_lng_id

Definition at line 121 of file class.ilButtonBase.php.

Referenced by ilAssFileUploadFileTableReuseButton\__construct(), and ilAssFileUploadFileTableDeleteButton\__construct().

122  {
123  $this->caption = $a_value;
124  $this->caption_is_lng_id = (bool) $a_is_lng_id;
125  }
+ Here is the caller graph for this function:

◆ setDisabled()

ilButtonBase::setDisabled (   $a_value)

Toggle disabled status.

Parameters
bool$a_value

Definition at line 232 of file class.ilButtonBase.php.

233  {
234  $this->disabled = (bool) $a_value;
235  }

◆ setId()

ilButtonBase::setId (   $a_value)

Set id.

Parameters
string$a_value

Definition at line 100 of file class.ilButtonBase.php.

Referenced by __clone().

101  {
102  $this->id = $a_value;
103  }
+ Here is the caller graph for this function:

◆ setOmitPreventDoubleSubmission()

ilButtonBase::setOmitPreventDoubleSubmission (   $a_value)

Toggle double submission prevention status.

Parameters
bool$a_value

Definition at line 172 of file class.ilButtonBase.php.

173  {
174  $this->omit_prevent_double_submission = (bool) $a_value;
175  }

◆ setOnClick()

ilButtonBase::setOnClick (   $a_value)

Set onclick.

Parameters
string$a_value

Definition at line 192 of file class.ilButtonBase.php.

193  {
194  $this->onclick = trim($a_value);
195  }

◆ setPrimary()

ilButtonBase::setPrimary (   $a_value)

Toggle primary status.

Parameters
bool$a_value

Definition at line 152 of file class.ilButtonBase.php.

153  {
154  $this->primary = (bool) $a_value;
155  }

◆ setType()

ilButtonBase::setType (   $a_value)
protected

Set button type.

Parameters
int$a_value

Definition at line 80 of file class.ilButtonBase.php.

Referenced by __construct().

81  {
82  $this->type = (int) $a_value;
83  }
+ Here is the caller graph for this function:

Field Documentation

◆ $acc_key

ilButtonBase::$acc_key
protected

Definition at line 27 of file class.ilButtonBase.php.

Referenced by getAccessKey().

◆ $apply_default_css

ilButtonBase::$apply_default_css = true
protected

Definition at line 34 of file class.ilButtonBase.php.

Referenced by applyDefaultCss().

◆ $caption

ilButtonBase::$caption
protected

Definition at line 22 of file class.ilButtonBase.php.

Referenced by getCaption(), and ilTestPlayerNavButton\renderCaption().

◆ $caption_is_lng_id

ilButtonBase::$caption_is_lng_id
protected

Definition at line 23 of file class.ilButtonBase.php.

◆ $css

ilButtonBase::$css = array()
protected

Definition at line 29 of file class.ilButtonBase.php.

Referenced by gatherCssClasses(), and getCSSClasses().

◆ $disabled

ilButtonBase::$disabled
protected

Definition at line 28 of file class.ilButtonBase.php.

Referenced by isDisabled().

◆ $id

ilButtonBase::$id
protected

Definition at line 21 of file class.ilButtonBase.php.

Referenced by getId(), and renderAttributesHelper().

◆ $lng

ilButtonBase::$lng
protected

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

Referenced by getCaption().

◆ $omit_prevent_double_submission

ilButtonBase::$omit_prevent_double_submission
protected

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

Referenced by getOmitPreventDoubleSubmission().

◆ $onclick

ilButtonBase::$onclick
protected

Definition at line 26 of file class.ilButtonBase.php.

Referenced by getOnClick().

◆ $primary

ilButtonBase::$primary
protected

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

Referenced by isPrimary().

◆ $type

◆ TYPE_BUTTON

const ilButtonBase::TYPE_BUTTON = 4

Definition at line 39 of file class.ilButtonBase.php.

◆ TYPE_LINK

const ilButtonBase::TYPE_LINK = 2

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

◆ TYPE_SPLIT

const ilButtonBase::TYPE_SPLIT = 3

Definition at line 38 of file class.ilButtonBase.php.

◆ TYPE_SUBMIT

const ilButtonBase::TYPE_SUBMIT = 1

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


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