ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilConfirmationGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("Services/Table/classes/class.ilTableGUI.php");
6 
16 {
20  protected $lng;
21 
22  private $hidden_item = array();
23  private $item = array();
24  private $use_images = false;
25  private $buttons = array();
26  private $form_name;
27 
32  public function __construct()
33  {
34  global $DIC;
35 
36  $this->lng = $DIC->language();
37  }
38 
39  final public function setFormAction($a_form_action)
40  {
41  $this->form_action = $a_form_action;
42  }
43 
44  final public function getFormAction()
45  {
46  return $this->form_action;
47  }
48 
54  public function setHeaderText($a_headertext)
55  {
56  $this->headertext = $a_headertext;
57  }
58 
64  public function getHeaderText()
65  {
66  return $this->headertext;
67  }
68 
75  final public function addButton($a_txt, $a_cmd)
76  {
77  $this->buttons[] = array(
78  "txt" => $a_txt, "cmd" => $a_cmd);
79  }
80 
87  final public function setCancel($a_txt, $a_cmd, $a_id = "")
88  {
89  $this->cancel_txt = $a_txt;
90  $this->cancel_cmd = $a_cmd;
91  $this->cancel_id = $a_id;
92  }
93 
100  final public function setConfirm($a_txt, $a_cmd, $a_id = "")
101  {
102  $this->confirm_txt = $a_txt;
103  $this->confirm_cmd = $a_cmd;
104  $this->confirm_id = $a_id;
105  }
106 
115  public function addItem(
116  $a_post_var,
117  $a_id,
118  $a_text,
119  $a_img = "",
120  $a_alt = ""
121  ) {
122  $this->item[] = array("var" => $a_post_var, "id" => $a_id,
123  "text" => $a_text, "img" => $a_img, "alt" => $a_alt);
124  if ($a_img != "") {
125  $this->use_images = true;
126  }
127  }
128 
135  public function addHiddenItem($a_post_var, $a_value)
136  {
137  $this->hidden_item[] = array("var" => $a_post_var, "value" => $a_value);
138  }
139 
145  final public function getHTML()
146  {
147  $lng = $this->lng;
148 
150 
151  include_once("./Services/Utilities/classes/class.ilConfirmationTableGUI.php");
152 
153  // delete/handle items
154  if (count($this->item) > 0) {
155  $ctab = new ilConfirmationTableGUI($this->use_images);
156  $ctab->setData($this->item);
157 
158  // other buttons
159  foreach ($this->buttons as $b) {
160  $ctab->addCommandButton($b["cmd"], $b["txt"]);
161  }
162  $ctab->addCommandButton($this->confirm_cmd, $this->confirm_txt);
163  $ctab->addCommandButton($this->cancel_cmd, $this->cancel_txt);
164  $ctab->setFormAction($this->getFormAction());
165  foreach ($this->hidden_item as $hidden_item) {
166  $ctab->addHiddenInput($hidden_item["var"], $hidden_item["value"]);
167  }
168 
169  if ($this->form_name) {
170  $ctab->setFormName($this->form_name);
171  }
172 
173  return $ctab->getHTML();
174  } else { // simple version, just ask for confirmation
175  $tb = new ilToolbarGUI();
176  $tb->setPreventDoubleSubmission(true);
177  $tb->setFormAction($this->getFormAction());
178  if ($this->hidden_item) {
179  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
180  foreach ($this->hidden_item as $hidden_item) {
181  $hiddenInput = new ilHiddenInputGUI($hidden_item['var']);
182  $hiddenInput->setValue($hidden_item['value']);
183  $tb->addInputItem($hiddenInput);
184  }
185  }
186  require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
187  $confirm = ilSubmitButton::getInstance();
188  $confirm->setCommand($this->confirm_cmd);
189  $confirm->setCaption($this->confirm_txt, false);
190  $confirm->setId($this->confirm_id);
191 
192  $cancel = ilSubmitButton::getInstance();
193  $cancel->setCommand($this->cancel_cmd);
194  $cancel->setCaption($this->cancel_txt, false);
195  $cancel->setId($this->cancel_id);
196 
197  $tb->addStickyItem($confirm);
198  $tb->addStickyItem($cancel);
199 
200  return $tb->getHTML();
201  }
202  }
203 
209  public function setFormName($a_name)
210  {
211  $this->form_name = $a_name;
212  }
213 }
addHiddenItem($a_post_var, $a_value)
Add hidden item.
global $DIC
Definition: saml.php:7
addButton($a_txt, $a_cmd)
Set cancel button command and text.
setFormAction($a_form_action)
getHeaderText()
Get Set header text.
setConfirm($a_txt, $a_cmd, $a_id="")
Set confirmation button command and text.
This class represents a hidden form property in a property form.
getHTML()
Get confirmation screen HTML.
setFormName($a_name)
Set form name.
setCancel($a_txt, $a_cmd, $a_id="")
Set cancel button command and text.
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
setHeaderText($a_headertext)
Set Set header text.
addItem( $a_post_var, $a_id, $a_text, $a_img="", $a_alt="")
Add row item.
Confirmation screen class.