ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilConfirmationGUI 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 ilConfirmationGUI:
+ Collaboration diagram for ilConfirmationGUI:

Public Member Functions

 setFormAction (string $a_form_action)
 
 getFormAction ()
 
 setHeaderText (string $a_headertext)
 
 getHeaderText ()
 
 setFormName (string $a_name)
 
 addButton (string $a_txt, string $a_cmd)
 
 setCancel (string $a_txt, string $a_cmd, string $a_id='')
 
 setConfirm (string $a_txt, string $a_cmd, string $a_id='')
 
 addItem (string $a_post_var, string $a_id, string $a_text, string $a_img='', string $a_alt='')
 
 addHiddenItem (string $a_post_var, string $a_value)
 
 getHTML ()
 

Protected Attributes

ilLanguage $lng
 
string $form_action = ''
 
string $headertext = ''
 
string $cancel_txt = ''
 
string $cancel_cmd = ''
 
string $cancel_id = ''
 
string $confirm_txt = ''
 
string $confirm_cmd = ''
 
string $confirm_id = ''
 

Private Attributes

array $hidden_item = []
 
array $item = []
 
array $buttons = []
 
bool $use_images = false
 
string $form_name = ''
 
ilGlobalTemplateInterface $main_tpl
 

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 Confirmation screen class.

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

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

Member Function Documentation

◆ addButton()

ilConfirmationGUI::addButton ( string  $a_txt,
string  $a_cmd 
)
final

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

79  : void
80  {
81  $this->buttons[] = [
82  'txt' => $a_txt,
83  'cmd' => $a_cmd
84  ];
85  }

◆ addHiddenItem()

◆ addItem()

ilConfirmationGUI::addItem ( string  $a_post_var,
string  $a_id,
string  $a_text,
string  $a_img = '',
string  $a_alt = '' 
)

Definition at line 107 of file class.ilConfirmationGUI.php.

113  : void {
114  $this->item[] = [
115  'var' => $a_post_var,
116  'id' => $a_id,
117  'text' => $a_text,
118  'img' => $a_img,
119  'alt' => $a_alt
120  ];
121 
122  if ($a_img !== '') {
123  $this->use_images = true;
124  }
125  }

◆ getFormAction()

ilConfirmationGUI::getFormAction ( )
final

Definition at line 59 of file class.ilConfirmationGUI.php.

References $form_action.

Referenced by getHTML().

59  : string
60  {
61  return $this->form_action;
62  }
+ Here is the caller graph for this function:

◆ getHeaderText()

ilConfirmationGUI::getHeaderText ( )

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

References $headertext.

Referenced by getHTML().

69  : string
70  {
71  return $this->headertext;
72  }
+ Here is the caller graph for this function:

◆ getHTML()

ilConfirmationGUI::getHTML ( )
final

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

References Vendor\Package\$b, getFormAction(), getHeaderText(), and ilSubmitButton\getInstance().

137  : string
138  {
139  if ($this->headertext === '') {
140  throw new RuntimeException('Please provide a header text before rendering the confirmation dialogue');
141  }
142 
143  if ($this->form_action === '') {
144  throw new RuntimeException('Please provide a form action before rendering the confirmation dialogue');
145  }
146 
147  if ($this->confirm_txt === '' || $this->confirm_cmd === '') {
148  throw new RuntimeException('Please provide a confirmation button label and command before rendering the confirmation dialogue');
149  }
150 
151  if ($this->cancel_txt === '' || $this->cancel_cmd === '') {
152  throw new RuntimeException('Please provide a cancel button label and command before rendering the confirmation dialogue');
153  }
154 
155  $this->main_tpl->setOnScreenMessage('question', $this->getHeaderText());
156 
157  // delete/handle items
158  if (count($this->item) > 0) {
159  $ctab = new ilConfirmationTableGUI($this->use_images);
160  $ctab->setData($this->item);
161 
162  foreach ($this->buttons as $b) {
163  $ctab->addCommandButton($b["cmd"], $b["txt"]);
164  }
165  $ctab->addCommandButton($this->confirm_cmd, $this->confirm_txt);
166  $ctab->addCommandButton($this->cancel_cmd, $this->cancel_txt);
167  $ctab->setFormAction($this->getFormAction());
168  foreach ($this->hidden_item as $hidden_item) {
169  $ctab->addHiddenInput($hidden_item["var"], $hidden_item["value"]);
170  }
171 
172  if ($this->form_name !== '') {
173  $ctab->setFormName($this->form_name);
174  }
175 
176  return $ctab->getHTML();
177  }
178 
179  // simple version, just ask for confirmation
180  $tb = new ilToolbarGUI();
181  $tb->setPreventDoubleSubmission(true);
182  $tb->setFormAction($this->getFormAction());
183  if ($this->hidden_item) {
184  foreach ($this->hidden_item as $hidden_item) {
185  $hiddenInput = new ilHiddenInputGUI($hidden_item['var']);
186  $hiddenInput->setValue($hidden_item['value']);
187  $tb->addInputItem($hiddenInput);
188  }
189  }
190  $confirm = ilSubmitButton::getInstance();
191  $confirm->setCommand($this->confirm_cmd);
192  $confirm->setCaption($this->confirm_txt, false);
193  $confirm->setId($this->confirm_id);
194 
195  $cancel = ilSubmitButton::getInstance();
196  $cancel->setCommand($this->cancel_cmd);
197  $cancel->setCaption($this->cancel_txt, false);
198 
199  if ($this->cancel_id !== '') {
200  $cancel->setId($this->cancel_id);
201  }
202 
203  $tb->addStickyItem($confirm);
204  $tb->addStickyItem($cancel);
205 
206  return $tb->getHTML();
207  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ setCancel()

ilConfirmationGUI::setCancel ( string  $a_txt,
string  $a_cmd,
string  $a_id = '' 
)
final

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

Referenced by ilTestPassDeletionConfirmationGUI\build(), and ilTestAnswerOptionalQuestionsConfirmationGUI\build().

91  : void {
92  $this->cancel_txt = $a_txt;
93  $this->cancel_cmd = $a_cmd;
94  $this->cancel_id = $a_id;
95  }
+ Here is the caller graph for this function:

◆ setConfirm()

ilConfirmationGUI::setConfirm ( string  $a_txt,
string  $a_cmd,
string  $a_id = '' 
)
final

Definition at line 97 of file class.ilConfirmationGUI.php.

Referenced by ilTestPassDeletionConfirmationGUI\build(), and ilTestAnswerOptionalQuestionsConfirmationGUI\build().

101  : void {
102  $this->confirm_txt = $a_txt;
103  $this->confirm_cmd = $a_cmd;
104  $this->confirm_id = $a_id;
105  }
+ Here is the caller graph for this function:

◆ setFormAction()

ilConfirmationGUI::setFormAction ( string  $a_form_action)
final

Definition at line 54 of file class.ilConfirmationGUI.php.

Referenced by ilTestPassDeletionConfirmationGUI\__construct().

54  : void
55  {
56  $this->form_action = $a_form_action;
57  }
+ Here is the caller graph for this function:

◆ setFormName()

ilConfirmationGUI::setFormName ( string  $a_name)

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

74  : void
75  {
76  $this->form_name = $a_name;
77  }

◆ setHeaderText()

ilConfirmationGUI::setHeaderText ( string  $a_headertext)

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

Referenced by ilTestPassDeletionConfirmationGUI\build(), ilTestAnswerOptionalQuestionsConfirmationGUI\build(), and ilTestSettingsChangeConfirmationGUI\build().

64  : void
65  {
66  $this->headertext = $a_headertext;
67  }
+ Here is the caller graph for this function:

Field Documentation

◆ $buttons

array ilConfirmationGUI::$buttons = []
private

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

◆ $cancel_cmd

string ilConfirmationGUI::$cancel_cmd = ''
protected

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

◆ $cancel_id

string ilConfirmationGUI::$cancel_id = ''
protected

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

◆ $cancel_txt

string ilConfirmationGUI::$cancel_txt = ''
protected

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

◆ $confirm_cmd

string ilConfirmationGUI::$confirm_cmd = ''
protected

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

◆ $confirm_id

string ilConfirmationGUI::$confirm_id = ''
protected

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

◆ $confirm_txt

string ilConfirmationGUI::$confirm_txt = ''
protected

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

◆ $form_action

string ilConfirmationGUI::$form_action = ''
protected

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

Referenced by getFormAction().

◆ $form_name

string ilConfirmationGUI::$form_name = ''
private

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

◆ $headertext

string ilConfirmationGUI::$headertext = ''
protected

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

Referenced by getHeaderText().

◆ $hidden_item

array ilConfirmationGUI::$hidden_item = []
private

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

◆ $item

array ilConfirmationGUI::$item = []
private

◆ $lng

◆ $main_tpl

ilGlobalTemplateInterface ilConfirmationGUI::$main_tpl
private

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

◆ $use_images

bool ilConfirmationGUI::$use_images = false
private

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


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