ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Repository\Button\ButtonAdapterGUI Class Reference
+ Collaboration diagram for ILIAS\Repository\Button\ButtonAdapterGUI:

Public Member Functions

 __construct (string $caption, string $cmd)
 
 submit ()
 
 primary ()
 
 onClick (string $on_click)
 
 disabled (bool $disabled)
 
 toToolbar (bool $sticky=false, ?\ilToolbarGUI $toolbar=null)
 
 render ()
 

Protected Member Functions

 getSubmitButton ()
 
 getStandardButton ()
 
 getStdPrimaryButton ()
 
 getButton ()
 

Protected Attributes

const TYPE_STD = 0
 
const TYPE_SUBMIT = 1
 
const TYPE_STD_PRIMARY = 2
 
bool $is_primary = false
 
string $on_click = ""
 
int $type
 
Button $button
 
ilToolbarGUI $toolbar
 
ILIAS DI UIServices $ui
 
string $caption = ""
 
string $cmd = ""
 
bool $disabled = false
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Repository\Button\ButtonAdapterGUI::__construct ( string  $caption,
string  $cmd 
)

Member Function Documentation

◆ disabled()

ILIAS\Repository\Button\ButtonAdapterGUI::disabled ( bool  $disabled)

Definition at line 81 of file class.ButtonAdapterGUI.php.

81 : self
82 {
83 $this->disabled = $disabled;
84 return $this;
85 }

References ILIAS\Repository\Button\ButtonAdapterGUI\$disabled, and ILIAS\Repository\Button\ButtonAdapterGUI\disabled().

Referenced by ILIAS\Repository\Button\ButtonAdapterGUI\disabled(), and ILIAS\Repository\Button\ButtonAdapterGUI\getButton().

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

◆ getButton()

ILIAS\Repository\Button\ButtonAdapterGUI::getButton ( )
protected

Definition at line 130 of file class.ButtonAdapterGUI.php.

131 {
132 switch ($this->type) {
134 $button = $this->getSubmitButton();
135 break;
136
138 $button = $this->getStdPrimaryButton();
139 break;
140
141 default:
142 $button = $this->getStandardButton();
143 break;
144 }
145 if ($this->on_click !== "") {
146 $click = $this->on_click;
147 $button = $button->withOnLoadCode(function ($id) use ($click) {
148 $code = <<<EOT
149(function() {
150 const el = document.getElementById('$id').addEventListener('click', () => { $click });
151}());
152EOT;
153 return $code;
154 });
155 }
156
157 if ($this->disabled) {
159 }
160
161 return $button;
162 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This describes commonalities between standard and primary buttons.
Definition: Button.php:34
withUnavailableAction(bool $flag=true)
Get a button like this, but action should be unavailable atm.

References ILIAS\Repository\Button\ButtonAdapterGUI\$button, $id, ILIAS\Repository\Button\ButtonAdapterGUI\$on_click, ILIAS\Repository\Button\ButtonAdapterGUI\disabled(), ILIAS\Repository\Button\ButtonAdapterGUI\getStandardButton(), ILIAS\Repository\Button\ButtonAdapterGUI\getStdPrimaryButton(), ILIAS\Repository\Button\ButtonAdapterGUI\getSubmitButton(), ILIAS\Repository\Button\ButtonAdapterGUI\TYPE_STD_PRIMARY, ILIAS\Repository\Button\ButtonAdapterGUI\TYPE_SUBMIT, ILIAS\UI\Component\JavaScriptBindable\withOnLoadCode(), and ILIAS\UI\Component\Button\Button\withUnavailableAction().

Referenced by ILIAS\Repository\Button\ButtonAdapterGUI\render(), and ILIAS\Repository\Button\ButtonAdapterGUI\toToolbar().

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

◆ getStandardButton()

ILIAS\Repository\Button\ButtonAdapterGUI::getStandardButton ( )
protected

Definition at line 114 of file class.ButtonAdapterGUI.php.

115 {
116 return $this->ui->factory()->button()->standard(
117 $this->caption,
118 $this->cmd
119 );
120 }

References ILIAS\Repository\ui().

Referenced by ILIAS\Repository\Button\ButtonAdapterGUI\getButton().

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

◆ getStdPrimaryButton()

ILIAS\Repository\Button\ButtonAdapterGUI::getStdPrimaryButton ( )
protected

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

123 {
124 return $this->ui->factory()->button()->primary(
125 $this->caption,
126 $this->cmd
127 );
128 }

References ILIAS\Repository\ui().

Referenced by ILIAS\Repository\Button\ButtonAdapterGUI\getButton().

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

◆ getSubmitButton()

ILIAS\Repository\Button\ButtonAdapterGUI::getSubmitButton ( )
protected

Definition at line 87 of file class.ButtonAdapterGUI.php.

88 {
90 if ($this->is_primary) {
91 $b = $this->ui->factory()->button()->primary(
92 $this->caption,
93 ""
94 );
95 } else {
96 $b = $this->ui->factory()->button()->standard(
97 $this->caption,
98 ""
99 );
100 }
101 $b = $b->withOnLoadCode(function ($id) use ($cmd) {
102 $code = <<<EOT
103(function() {
104 const el = document.getElementById('$id');
105 el.name = "cmd[$cmd]";
106 el.type = "submit";
107}());
108EOT;
109 return $code;
110 });
111 return $b;
112 }

References Vendor\Package\$b, ILIAS\Repository\Button\ButtonAdapterGUI\$cmd, $id, and ILIAS\Repository\ui().

Referenced by ILIAS\Repository\Button\ButtonAdapterGUI\getButton().

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

◆ onClick()

ILIAS\Repository\Button\ButtonAdapterGUI::onClick ( string  $on_click)

Definition at line 75 of file class.ButtonAdapterGUI.php.

75 : self
76 {
77 $this->on_click = $on_click;
78 return $this;
79 }

References ILIAS\Repository\Button\ButtonAdapterGUI\$on_click.

◆ primary()

ILIAS\Repository\Button\ButtonAdapterGUI::primary ( )

Definition at line 68 of file class.ButtonAdapterGUI.php.

68 : self
69 {
70 $this->type = self::TYPE_STD_PRIMARY;
71 $this->is_primary = true;
72 return $this;
73 }

References ILIAS\Repository\Button\ButtonAdapterGUI\TYPE_STD_PRIMARY.

◆ render()

ILIAS\Repository\Button\ButtonAdapterGUI::render ( )

Definition at line 177 of file class.ButtonAdapterGUI.php.

177 : string
178 {
179 return $this->ui->renderer()->render($this->getButton());
180 }

References ILIAS\Repository\Button\ButtonAdapterGUI\getButton(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ submit()

ILIAS\Repository\Button\ButtonAdapterGUI::submit ( )

Definition at line 62 of file class.ButtonAdapterGUI.php.

62 : self
63 {
64 $this->type = self::TYPE_SUBMIT;
65 return $this;
66 }

References ILIAS\Repository\Button\ButtonAdapterGUI\TYPE_SUBMIT.

◆ toToolbar()

ILIAS\Repository\Button\ButtonAdapterGUI::toToolbar ( bool  $sticky = false,
?\ilToolbarGUI  $toolbar = null 
)

Definition at line 164 of file class.ButtonAdapterGUI.php.

164 : void
165 {
166 $button = $this->getButton();
167 if (is_null($toolbar)) {
169 }
170 if ($sticky) {
172 } else {
174 }
175 }
addComponent(\ILIAS\UI\Component\Component $a_comp)
addStickyItem( $a_item, bool $a_output_label=false)
Add a sticky item.

References ILIAS\Repository\Button\ButtonAdapterGUI\$button, ILIAS\Repository\Button\ButtonAdapterGUI\$toolbar, ilToolbarGUI\addComponent(), ilToolbarGUI\addStickyItem(), and ILIAS\Repository\Button\ButtonAdapterGUI\getButton().

+ Here is the call graph for this function:

Field Documentation

◆ $button

Button ILIAS\Repository\Button\ButtonAdapterGUI::$button
protected

◆ $caption

string ILIAS\Repository\Button\ButtonAdapterGUI::$caption = ""
protected

◆ $cmd

string ILIAS\Repository\Button\ButtonAdapterGUI::$cmd = ""
protected

◆ $disabled

bool ILIAS\Repository\Button\ButtonAdapterGUI::$disabled = false
protected

◆ $is_primary

bool ILIAS\Repository\Button\ButtonAdapterGUI::$is_primary = false
protected

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

◆ $on_click

string ILIAS\Repository\Button\ButtonAdapterGUI::$on_click = ""
protected

◆ $toolbar

ilToolbarGUI ILIAS\Repository\Button\ButtonAdapterGUI::$toolbar
protected

◆ $type

int ILIAS\Repository\Button\ButtonAdapterGUI::$type
protected

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

◆ $ui

ILIAS DI UIServices ILIAS\Repository\Button\ButtonAdapterGUI::$ui
protected

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

◆ TYPE_STD

const ILIAS\Repository\Button\ButtonAdapterGUI::TYPE_STD = 0
protected

◆ TYPE_STD_PRIMARY

const ILIAS\Repository\Button\ButtonAdapterGUI::TYPE_STD_PRIMARY = 2
protected

◆ TYPE_SUBMIT

const ILIAS\Repository\Button\ButtonAdapterGUI::TYPE_SUBMIT = 1
protected

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