ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilButtonBase Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilButtonBase:
+ Collaboration diagram for ilButtonBase:

Public Member Functions

 __clone ()
 
 getType ()
 
 setId (?string $a_value)
 
 getId ()
 
 setCaption (string $a_value, bool $a_is_lng_id=true)
 
 getCaption (bool $a_translate=true)
 
 setPrimary (bool $a_value)
 
 isPrimary ()
 
 setOmitPreventDoubleSubmission (bool $a_value)
 Toggle double submission prevention status. More...
 
 getOmitPreventDoubleSubmission ()
 
 setOnClick (string $a_value)
 
 getOnClick ()
 
 setDisabled (bool $a_value)
 
 isDisabled ()
 
 addCSSClass (string $a_value)
 
 getCSSClasses ()
 
 applyDefaultCss (?bool $apply_default_css=null)
 
 render ()
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 

Static Public Member Functions

static getInstance ()
 

Data Fields

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

Protected Member Functions

 __construct (int $a_type)
 
 setType (int $a_value)
 
 gatherCssClasses ()
 
 renderAttributesHelper (array $a_attr)
 
 renderAttributes (?array $a_additional_attr=null)
 Render current HTML attributes. More...
 
 prepareRender ()
 

Protected Attributes

ilLanguage $lng
 
int $type = 0
 
string $id = ""
 
string $caption = ""
 
bool $caption_is_lng_id = false
 
bool $primary = false
 
bool $omit_prevent_double_submission = false
 
string $onclick = ""
 
int $acc_key = 0
 
bool $disabled = false
 
array $css = array()
 
bool $apply_default_css = true
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Button GUI

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Deprecated:
with ILIAS 12. Use KS Buttons instead

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

Constructor & Destructor Documentation

◆ __construct()

ilButtonBase::__construct ( int  $a_type)
protected

Reimplemented in ilSplitButtonGUI.

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

46 {
47 global $DIC;
48
49 $this->lng = $DIC->language();
50 $this->setType($a_type);
51 }
setType(int $a_value)
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\lng(), and setType().

+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilButtonBase::__clone ( )

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

54 {
55 $this->setId(null);
56 }
setId(?string $a_value)

References setId().

+ Here is the call graph for this function:

◆ addCSSClass()

ilButtonBase::addCSSClass ( string  $a_value)

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

147 : void
148 {
149 $this->css[] = $a_value;
150 }

Referenced by prepareRender().

+ Here is the caller graph for this function:

◆ applyDefaultCss()

ilButtonBase::applyDefaultCss ( ?bool  $apply_default_css = null)

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

221 : ?bool
222 {
223 if (null === $apply_default_css) {
225 }
226
227 $this->apply_default_css = $apply_default_css;
228 return false;
229 }

References $apply_default_css.

Referenced by prepareRender().

+ Here is the caller graph for this function:

◆ gatherCssClasses()

ilButtonBase::gatherCssClasses ( )
protected

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

162 : string
163 {
164 $css = array_unique($this->getCSSClasses());
165
166 if ($this->isPrimary()) {
167 $css[] = "btn-primary";
168 }
169 if ($this->getOmitPreventDoubleSubmission()) {
170 $css[] = "omitPreventDoubleSubmission";
171 }
172
173 return implode(" ", $css);
174 }

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

Referenced by renderAttributes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCaption()

ilButtonBase::getCaption ( bool  $a_translate = true)

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

90 : string
91 {
93
95
96 if ($this->caption_is_lng_id &&
97 $a_translate) {
99 }
100
101 return $caption;
102 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...

References $caption, $lng, and ilLanguage\txt().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCSSClasses()

ilButtonBase::getCSSClasses ( )

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

152 : array
153 {
154 return $this->css;
155 }

References $css.

Referenced by gatherCssClasses().

+ Here is the caller graph for this function:

◆ getId()

ilButtonBase::getId ( )

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

79 : ?string
80 {
81 return $this->id;
82 }

References $id.

Referenced by renderAttributes().

+ Here is the caller graph for this function:

◆ getInstance()

static ilButtonBase::getInstance ( )
staticabstract

◆ getOmitPreventDoubleSubmission()

ilButtonBase::getOmitPreventDoubleSubmission ( )

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

122 : bool
123 {
125 }
bool $omit_prevent_double_submission

References $omit_prevent_double_submission.

Referenced by gatherCssClasses().

+ Here is the caller graph for this function:

◆ getOnClick()

ilButtonBase::getOnClick ( )

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

132 : string
133 {
134 return $this->onclick;
135 }

References $onclick.

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

+ Here is the caller graph for this function:

◆ getToolbarHTML()

ilButtonBase::getToolbarHTML ( )

Get input item HTML to be inserted into ilToolbarGUI.

Implements ilToolbarItem.

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

233 : string
234 {
235 return $this->render();
236 }

References render().

+ Here is the call graph for this function:

◆ getType()

ilButtonBase::getType ( )

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

69 : int
70 {
71 return $this->type;
72 }

References $type.

◆ isDisabled()

ilButtonBase::isDisabled ( )

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

142 : bool
143 {
144 return $this->disabled;
145 }

References $disabled.

Referenced by renderAttributes().

+ Here is the caller graph for this function:

◆ isPrimary()

ilButtonBase::isPrimary ( )

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

109 : bool
110 {
111 return $this->primary;
112 }

References $primary.

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

+ Here is the caller graph for this function:

◆ prepareRender()

ilButtonBase::prepareRender ( )
protected

Reimplemented in ilImageLinkButton.

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

213 : void
214 {
215 if ($this->applyDefaultCss()) {
216 $this->addCSSClass("btn");
217 $this->addCSSClass("btn-default");
218 }
219 }
applyDefaultCss(?bool $apply_default_css=null)
addCSSClass(string $a_value)

References addCSSClass(), and applyDefaultCss().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilButtonBase::render ( )
abstract

Reimplemented in ilButton, ilJsLinkButton, ilLinkButton, ilSubmitButton, and ilSplitButtonGUI.

Referenced by getToolbarHTML().

+ Here is the caller graph for this function:

◆ renderAttributes()

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

Render current HTML attributes.

Reimplemented in ilLinkButton.

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

195 : string
196 {
197 $attr = array();
198 $attr["id"] = $this->getId();
199 $attr["class"] = $this->gatherCssClasses();
200 $attr["onclick"] = $this->getOnClick();
201
202 if ($this->isDisabled()) {
203 $attr["disabled"] = "disabled";
204 }
205
206 if (count($a_additional_attr)) {
207 $attr = array_merge($attr, $a_additional_attr);
208 }
209
210 return $this->renderAttributesHelper($attr);
211 }
renderAttributesHelper(array $a_attr)

References gatherCssClasses(), getId(), getOnClick(), isDisabled(), and renderAttributesHelper().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderAttributesHelper()

ilButtonBase::renderAttributesHelper ( array  $a_attr)
protected

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

176 : string
177 {
178 $res = array();
179
180 foreach ($a_attr as $id => $value) {
181 if (trim((string) $value)) {
182 $res[] = strtolower(trim($id)) . '="' . $value . '"';
183 }
184 }
185
186 if (count($res)) {
187 return " " . implode(" ", $res);
188 }
189 return "";
190 }
$res
Definition: ltiservices.php:69

References $id, and $res.

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

+ Here is the caller graph for this function:

◆ setCaption()

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

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

84 : void
85 {
86 $this->caption = $a_value;
87 $this->caption_is_lng_id = $a_is_lng_id;
88 }

◆ setDisabled()

ilButtonBase::setDisabled ( bool  $a_value)

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

137 : void
138 {
139 $this->disabled = $a_value;
140 }

References ILIAS\UI\examples\Input\Field\Checkbox\disabled().

+ Here is the call graph for this function:

◆ setId()

ilButtonBase::setId ( ?string  $a_value)

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

74 : void
75 {
76 $this->id = $a_value;
77 }

Referenced by __clone().

+ Here is the caller graph for this function:

◆ setOmitPreventDoubleSubmission()

ilButtonBase::setOmitPreventDoubleSubmission ( bool  $a_value)

Toggle double submission prevention status.

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

117 : void
118 {
119 $this->omit_prevent_double_submission = $a_value;
120 }

◆ setOnClick()

ilButtonBase::setOnClick ( string  $a_value)

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

127 : void
128 {
129 $this->onclick = trim($a_value);
130 }

◆ setPrimary()

ilButtonBase::setPrimary ( bool  $a_value)

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

104 : void
105 {
106 $this->primary = $a_value;
107 }

◆ setType()

ilButtonBase::setType ( int  $a_value)
protected

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

64 : void
65 {
66 $this->type = $a_value;
67 }

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $acc_key

int ilButtonBase::$acc_key = 0
protected

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

◆ $apply_default_css

bool ilButtonBase::$apply_default_css = true
protected

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

Referenced by applyDefaultCss().

◆ $caption

string ilButtonBase::$caption = ""
protected

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

Referenced by getCaption().

◆ $caption_is_lng_id

bool ilButtonBase::$caption_is_lng_id = false
protected

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

◆ $css

array ilButtonBase::$css = array()
protected

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

Referenced by gatherCssClasses(), and getCSSClasses().

◆ $disabled

bool ilButtonBase::$disabled = false
protected

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

Referenced by isDisabled().

◆ $id

string ilButtonBase::$id = ""
protected

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

Referenced by getId(), and renderAttributesHelper().

◆ $lng

ilLanguage ilButtonBase::$lng
protected

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

Referenced by getCaption().

◆ $omit_prevent_double_submission

bool ilButtonBase::$omit_prevent_double_submission = false
protected

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

Referenced by getOmitPreventDoubleSubmission().

◆ $onclick

string ilButtonBase::$onclick = ""
protected

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

Referenced by getOnClick().

◆ $primary

bool ilButtonBase::$primary = false
protected

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

Referenced by isPrimary().

◆ $type

int ilButtonBase::$type = 0
protected

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

Referenced by getType().

◆ TYPE_BUTTON

const ilButtonBase::TYPE_BUTTON = 4

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

Referenced by ilButton\getInstance().

◆ TYPE_LINK

const ilButtonBase::TYPE_LINK = 2

◆ TYPE_SPLIT

const ilButtonBase::TYPE_SPLIT = 3

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

Referenced by ilSplitButtonGUI\getInstance().

◆ TYPE_SUBMIT

const ilButtonBase::TYPE_SUBMIT = 1

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

Referenced by ilSubmitButton\getInstance().


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