ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
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

 $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 42 of file class.ilButtonBase.php.

References $a_type, and setType().

43  {
44  $this->setType($a_type);
45  }
$a_type
Definition: workflow.php:93
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 50 of file class.ilButtonBase.php.

References getInstance(), and setId().

51  {
52  $this->setId(null);
53  }
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 245 of file class.ilButtonBase.php.

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

246  {
247  $this->css[] = $a_value;
248  }
+ 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 357 of file class.ilButtonBase.php.

References $apply_default_css, and render().

Referenced by prepareRender().

358  {
359  if(null === $apply_default_css)
360  {
362  }
363 
364  $this->apply_default_css = $apply_default_css;
365  }
+ 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 270 of file class.ilButtonBase.php.

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

Referenced by renderAttributes().

271  {
272  $css = array_unique($this->getCSSClasses());
273 
274  if($this->isPrimary())
275  {
276  $css[] = "btn-primary";
277  }
278  if($this->getOmitPreventDoubleSubmission())
279  {
280  $css[] = "omitPreventDoubleSubmission";
281  }
282 
283  return implode(" ", $css);
284  }
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 215 of file class.ilButtonBase.php.

References $acc_key.

Referenced by renderAttributes().

216  {
217  return $this->acc_key;
218  }
+ 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 125 of file class.ilButtonBase.php.

References $caption, and $lng.

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

126  {
127  global $lng;
128 
130 
131  if($this->caption_is_lng_id &&
132  (bool)$a_translate)
133  {
134  $caption = $lng->txt($caption);
135  }
136 
137  return $caption;
138  }
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ getCSSClasses()

ilButtonBase::getCSSClasses ( )

Get CSS class(es)

Returns
array

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

References $css.

Referenced by gatherCssClasses().

256  {
257  return $this->css;
258  }
+ Here is the caller graph for this function:

◆ getId()

ilButtonBase::getId ( )

Get id.

Returns
string

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

References $id.

Referenced by renderAttributes().

103  {
104  return $this->id;
105  }
+ 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 175 of file class.ilButtonBase.php.

References $omit_prevent_double_submission.

Referenced by gatherCssClasses().

176  {
178  }
+ Here is the caller graph for this function:

◆ getOnClick()

ilButtonBase::getOnClick ( )

Get onclick.

Returns
string

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

References $onclick.

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

196  {
197  return $this->onclick;
198  }
+ Here is the caller graph for this function:

◆ getToolbarHTML()

ilButtonBase::getToolbarHTML ( )
Returns
string

Implements ilToolbarItem.

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

References render().

379  {
380  return $this->render();
381  }
render()
Render HTML.
+ Here is the call graph for this function:

◆ getType()

ilButtonBase::getType ( )

Get button type.

Returns
int

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

References $type.

83  {
84  return $this->type;
85  }

◆ isDisabled()

ilButtonBase::isDisabled ( )

Get disabled status.

Returns
bool

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

References $disabled.

Referenced by renderAttributes().

236  {
237  return $this->disabled;
238  }
+ Here is the caller graph for this function:

◆ isPrimary()

ilButtonBase::isPrimary ( )

Get primary status.

Returns
bool

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

References $primary.

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

156  {
157  return $this->primary;
158  }
+ Here is the caller graph for this function:

◆ prepareRender()

ilButtonBase::prepareRender ( )
protected

Prepare render.

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

References addCSSClass(), and applyDefaultCss().

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

345  {
346  if($this->applyDefaultCss())
347  {
348  $this->addCSSClass("btn");
349  $this->addCSSClass("btn-default");
350  }
351  }
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 315 of file class.ilButtonBase.php.

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

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

316  {
317  $attr = array();
318  $attr["id"] = $this->getId();
319  $attr["class"] = $this->gatherCssClasses();
320  $attr["onclick"] = $this->getOnClick();
321 
322  if($this->getAccessKey())
323  {
324  include_once("./Services/Accessibility/classes/class.ilAccessKey.php");
325  $attr["accesskey"] = ilAccessKey::getKey($this->getAccessKey());
326  }
327 
328  if($this->isDisabled())
329  {
330  $attr["disabled"] = "disabled";
331  }
332 
333  if(sizeof($a_additional_attr))
334  {
335  $attr = array_merge($attr, $a_additional_attr);
336  }
337 
338  return $this->renderAttributesHelper($attr);
339  }
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.
Create styles array
The data for the language used.
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 291 of file class.ilButtonBase.php.

References $id, $res, and array.

Referenced by renderAttributes().

292  {
293  $res = array();
294 
295  foreach($a_attr as $id => $value)
296  {
297  if(trim($value))
298  {
299  $res[] = strtolower(trim($id)).'="'.$value.'"';
300  }
301  }
302 
303  if(sizeof($res))
304  {
305  return " ".implode(" ", $res);
306  }
307  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ setAccessKey()

ilButtonBase::setAccessKey (   $a_value)

Set access key.

Parameters
string$a_value

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

206  {
207  $this->acc_key = trim($a_value);
208  }

◆ setCaption()

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

Set caption.

Parameters
string$a_value
bool$a_is_lng_id

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

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

114  {
115  $this->caption = $a_value;
116  $this->caption_is_lng_id = (bool)$a_is_lng_id;
117  }
+ Here is the caller graph for this function:

◆ setDisabled()

ilButtonBase::setDisabled (   $a_value)

Toggle disabled status.

Parameters
bool$a_value

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

226  {
227  $this->disabled = (bool)$a_value;
228  }

◆ setId()

ilButtonBase::setId (   $a_value)

Set id.

Parameters
string$a_value

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

Referenced by __clone().

93  {
94  $this->id = $a_value;
95  }
+ 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 165 of file class.ilButtonBase.php.

166  {
167  $this->omit_prevent_double_submission = (bool)$a_value;
168  }

◆ setOnClick()

ilButtonBase::setOnClick (   $a_value)

Set onclick.

Parameters
string$a_value

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

186  {
187  $this->onclick = trim($a_value);
188  }

◆ setPrimary()

ilButtonBase::setPrimary (   $a_value)

Toggle primary status.

Parameters
bool$a_value

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

146  {
147  $this->primary = (bool)$a_value;
148  }

◆ setType()

ilButtonBase::setType (   $a_value)
protected

Set button type.

Parameters
int$a_value

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

Referenced by __construct().

73  {
74  $this->type = (int)$a_value;
75  }
+ Here is the caller graph for this function:

Field Documentation

◆ $acc_key

ilButtonBase::$acc_key
protected

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

Referenced by getAccessKey().

◆ $apply_default_css

ilButtonBase::$apply_default_css = true
protected

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

Referenced by applyDefaultCss().

◆ $caption

ilButtonBase::$caption
protected

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

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

◆ $caption_is_lng_id

ilButtonBase::$caption_is_lng_id
protected

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

◆ $css

ilButtonBase::$css = array()
protected

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

Referenced by gatherCssClasses(), and getCSSClasses().

◆ $disabled

ilButtonBase::$disabled
protected

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

Referenced by isDisabled().

◆ $id

ilButtonBase::$id
protected

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

Referenced by getId(), and renderAttributesHelper().

◆ $omit_prevent_double_submission

ilButtonBase::$omit_prevent_double_submission
protected

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

Referenced by getOmitPreventDoubleSubmission().

◆ $onclick

ilButtonBase::$onclick
protected

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

Referenced by getOnClick().

◆ $primary

ilButtonBase::$primary
protected

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

Referenced by isPrimary().

◆ $type

◆ TYPE_BUTTON

const ilButtonBase::TYPE_BUTTON = 4

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

◆ TYPE_LINK

const ilButtonBase::TYPE_LINK = 2

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

◆ TYPE_SPLIT

const ilButtonBase::TYPE_SPLIT = 3

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

◆ TYPE_SUBMIT

const ilButtonBase::TYPE_SUBMIT = 1

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


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