ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilButton Class Reference
+ Inheritance diagram for ilButton:
+ Collaboration diagram for ilButton:

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...
 
 render ()
 Render HTML. More...
 

Static Public Member Functions

static getInstance ()
 Factory. More...
 

Data Fields

const TYPE_SUBMIT = 1
 
const TYPE_LINK = 2
 

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

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilButton::__construct (   $a_type)
protected

Constructor.

Parameters
int$a_type
Returns
self

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

References setType().

34  {
35  $this->setType($a_type);
36  }
setType($a_value)
Set button type.
+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilButton::__clone ( )

Clone instance.

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

References getInstance(), and setId().

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

◆ addCSSClass()

ilButton::addCSSClass (   $a_value)

Add CSS class.

Parameters
string$a_value

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

Referenced by prepareRender().

237  {
238  $this->css[] = $a_value;
239  }
+ Here is the caller graph for this function:

◆ gatherCssClasses()

ilButton::gatherCssClasses ( )
protected

Gather all active CSS classes.

Returns
string

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

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

Referenced by renderAttributes().

262  {
263  $css = array_unique($this->getCSSClasses());
264 
265  if($this->isPrimary())
266  {
267  $css[] = "btn-primary";
268  }
269  if($this->getOmitPreventDoubleSubmission())
270  {
271  $css[] = "omitPreventDoubleSubmission";
272  }
273 
274  return implode(" ", $css);
275  }
getOmitPreventDoubleSubmission()
Get double submission prevention status.
getCSSClasses()
Get CSS class(es)
isPrimary()
Get primary status.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAccessKey()

ilButton::getAccessKey ( )

Get access key.

Returns
string

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

References $acc_key.

Referenced by renderAttributes().

207  {
208  return $this->acc_key;
209  }
+ Here is the caller graph for this function:

◆ getCaption()

ilButton::getCaption (   $a_translate = true)

Get caption.

Parameters
bool$a_translate
Returns
string

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

References $caption, and $lng.

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

117  {
118  global $lng;
119 
121 
122  if($this->caption_is_lng_id &&
123  (bool)$a_translate)
124  {
125  $caption = $lng->txt($caption);
126  }
127 
128  return $caption;
129  }
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ getCSSClasses()

ilButton::getCSSClasses ( )

Get CSS class(es)

Returns
array

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

References $css.

Referenced by gatherCssClasses().

247  {
248  return $this->css;
249  }
+ Here is the caller graph for this function:

◆ getId()

ilButton::getId ( )

Get id.

Returns
string

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

References $id.

Referenced by renderAttributes().

94  {
95  return $this->id;
96  }
+ Here is the caller graph for this function:

◆ getInstance()

static ilButton::getInstance ( )
staticabstract

Factory.

Returns
self

Referenced by __clone().

+ Here is the caller graph for this function:

◆ getOmitPreventDoubleSubmission()

ilButton::getOmitPreventDoubleSubmission ( )

Get double submission prevention status.

Returns
bool

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

References $omit_prevent_double_submission.

Referenced by gatherCssClasses().

167  {
169  }
$omit_prevent_double_submission
+ Here is the caller graph for this function:

◆ getOnClick()

ilButton::getOnClick ( )

Get onclick.

Returns
string

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

References $onclick.

Referenced by renderAttributes().

187  {
188  return $this->onclick;
189  }
+ Here is the caller graph for this function:

◆ getType()

ilButton::getType ( )

Get button type.

Returns
int

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

References $type.

74  {
75  return $this->type;
76  }

◆ isDisabled()

ilButton::isDisabled ( )

Get disabled status.

Returns
bool

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

References $disabled.

Referenced by renderAttributes().

227  {
228  return $this->disabled;
229  }
+ Here is the caller graph for this function:

◆ isPrimary()

ilButton::isPrimary ( )

Get primary status.

Returns
bool

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

References $primary.

Referenced by gatherCssClasses().

147  {
148  return $this->primary;
149  }
+ Here is the caller graph for this function:

◆ prepareRender()

ilButton::prepareRender ( )
protected

Prepare render.

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

References addCSSClass(), and render().

Referenced by ilSubmitButton\render(), and ilLinkButton\render().

336  {
337  $this->addCSSClass("btn");
338  $this->addCSSClass("btn-default");
339  }
addCSSClass($a_value)
Add CSS class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilButton::render ( )
abstract

Render HTML.

Returns
string

Referenced by prepareRender().

+ Here is the caller graph for this function:

◆ renderAttributes()

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

Render current HTML attributes.

Parameters
array$a_additional_attr
Returns
string

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

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

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

◆ renderAttributesHelper()

ilButton::renderAttributesHelper ( array  $a_attr)
protected

Render HTML node attributes.

Returns
string

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

References $id, and $res.

Referenced by renderAttributes().

283  {
284  $res = array();
285 
286  foreach($a_attr as $id => $value)
287  {
288  if(trim($value))
289  {
290  $res[] = strtolower(trim($id)).'="'.$value.'"';
291  }
292  }
293 
294  if(sizeof($res))
295  {
296  return " ".implode(" ", $res);
297  }
298  }
+ Here is the caller graph for this function:

◆ setAccessKey()

ilButton::setAccessKey (   $a_value)

Set access key.

Parameters
string$a_value

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

197  {
198  $this->acc_key = trim($a_value);
199  }

◆ setCaption()

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

Set caption.

Parameters
string$a_value
bool$a_is_lng_id

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

105  {
106  $this->caption = $a_value;
107  $this->caption_is_lng_id = (bool)$a_is_lng_id;
108  }

◆ setDisabled()

ilButton::setDisabled (   $a_value)

Toggle disabled status.

Parameters
bool$a_value

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

217  {
218  $this->disabled = (bool)$a_value;
219  }

◆ setId()

ilButton::setId (   $a_value)

Set id.

Parameters
string$a_value

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

Referenced by __clone().

84  {
85  $this->id = $a_value;
86  }
+ Here is the caller graph for this function:

◆ setOmitPreventDoubleSubmission()

ilButton::setOmitPreventDoubleSubmission (   $a_value)

Toggle double submission prevention status.

Parameters
bool$a_value

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

157  {
158  $this->omit_prevent_double_submission = (bool)$a_value;
159  }

◆ setOnClick()

ilButton::setOnClick (   $a_value)

Set onclick.

Parameters
string$a_value

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

177  {
178  $this->onclick = trim($a_value);
179  }

◆ setPrimary()

ilButton::setPrimary (   $a_value)

Toggle primary status.

Parameters
bool$a_value

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

137  {
138  $this->primary = (bool)$a_value;
139  }

◆ setType()

ilButton::setType (   $a_value)
protected

Set button type.

Parameters
int$a_value

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

Referenced by __construct().

64  {
65  $this->type = (int)$a_value;
66  }
+ Here is the caller graph for this function:

Field Documentation

◆ $acc_key

ilButton::$acc_key
protected

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

Referenced by getAccessKey().

◆ $caption

ilButton::$caption
protected

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

Referenced by getCaption().

◆ $caption_is_lng_id

ilButton::$caption_is_lng_id
protected

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

◆ $css

ilButton::$css = array()
protected

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

Referenced by gatherCssClasses(), and getCSSClasses().

◆ $disabled

ilButton::$disabled
protected

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

Referenced by isDisabled().

◆ $id

ilButton::$id
protected

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

Referenced by getId(), and renderAttributesHelper().

◆ $omit_prevent_double_submission

ilButton::$omit_prevent_double_submission
protected

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

Referenced by getOmitPreventDoubleSubmission().

◆ $onclick

ilButton::$onclick
protected

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

Referenced by getOnClick().

◆ $primary

ilButton::$primary
protected

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

Referenced by isPrimary().

◆ $type

ilButton::$type
protected

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

Referenced by getType().

◆ TYPE_LINK

const ilButton::TYPE_LINK = 2

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

◆ TYPE_SUBMIT

const ilButton::TYPE_SUBMIT = 1

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


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