ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 {
17  private $hidden_item = array();
18  private $item = array();
19  private $use_images = false;
20  private $buttons = array();
21  private $form_name;
22 
27  public function __construct()
28  {
29  }
30 
31  final public function setFormAction($a_form_action)
32  {
33  $this->form_action = $a_form_action;
34  }
35 
36  final public function getFormAction()
37  {
38  return $this->form_action;
39  }
40 
46  function setHeaderText($a_headertext)
47  {
48  $this->headertext = $a_headertext;
49  }
50 
56  function getHeaderText()
57  {
58  return $this->headertext;
59  }
60 
67  final public function addButton($a_txt, $a_cmd)
68  {
69  $this->buttons[] = array(
70  "txt" => $a_txt, "cmd" => $a_cmd);
71  }
72 
79  final public function setCancel($a_txt, $a_cmd)
80  {
81  $this->cancel_txt = $a_txt;
82  $this->cancel_cmd = $a_cmd;
83  }
84 
91  final public function setConfirm($a_txt, $a_cmd)
92  {
93  $this->confirm_txt = $a_txt;
94  $this->confirm_cmd = $a_cmd;
95  }
96 
105  public function addItem($a_post_var, $a_id, $a_text, $a_img = "",
106  $a_alt = "")
107  {
108  $this->item[] = array("var" => $a_post_var, "id" => $a_id,
109  "text" => $a_text, "img" => $a_img, "alt" => $a_alt);
110  if ($a_img != "")
111  {
112  $this->use_images = true;
113  }
114  }
115 
122  public function addHiddenItem($a_post_var, $a_value)
123  {
124  $this->hidden_item[] = array("var" => $a_post_var, "value" => $a_value);
125  }
126 
132  final public function getHTML()
133  {
134  global $lng;
135 
137 
138  include_once("./Services/Utilities/classes/class.ilConfirmationTableGUI.php");
139 
140  // delete/handle items
141  if (count($this->item) > 0)
142  {
143  $ctab = new ilConfirmationTableGUI($this->use_images);
144  $ctab->setData($this->item);
145 
146  // other buttons
147  foreach ($this->buttons as $b)
148  {
149  $ctab->addCommandButton($b["cmd"], $b["txt"]);
150  }
151  $ctab->addCommandButton($this->confirm_cmd, $this->confirm_txt);
152  $ctab->addCommandButton($this->cancel_cmd, $this->cancel_txt);
153  $ctab->setFormAction($this->getFormAction());
154  foreach ($this->hidden_item as $hidden_item)
155  {
156  $ctab->addHiddenInput($hidden_item["var"], $hidden_item["value"]);
157  }
158 
159  if($this->form_name)
160  {
161  $ctab->setFormName($this->form_name);
162  }
163 
164  return $ctab->getHTML();
165  }
166  else // simple version, just ask for confirmation
167  {
168  $tb = new ilToolbarGUI();
169  $tb->setFormAction($this->getFormAction());
170  if($this->hidden_item)
171  {
172  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
173  foreach($this->hidden_item as $hidden_item)
174  {
175  $hiddenInput = new ilHiddenInputGUI($hidden_item['var']);
176  $hiddenInput->setValue($hidden_item['value']);
177  $tb->addInputItem($hiddenInput);
178  }
179  }
180  $tb->addFormButton($this->confirm_txt, $this->confirm_cmd);
181  $tb->addFormButton($this->cancel_txt, $this->cancel_cmd);
182  return $tb->getHTML();
183  }
184  }
185 
191  function setFormName($a_name)
192  {
193  $this->form_name = $a_name;
194  }
195 }
196 ?>