ILIAS  release_4-3 Revision
 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 
127  public function addHiddenItem($a_post_var, $a_value)
128  {
129  $this->hidden_item[] = array("var" => $a_post_var, "value" => $a_value);
130  }
131 
137  final public function getHTML()
138  {
139  global $lng;
140 
142 
143  include_once("./Services/Utilities/classes/class.ilConfirmationTableGUI.php");
144 
145  // delete/handle items
146  if (count($this->item) > 0)
147  {
148  $ctab = new ilConfirmationTableGUI($this->use_images);
149  $ctab->setData($this->item);
150 
151  // other buttons
152  foreach ($this->buttons as $b)
153  {
154  $ctab->addCommandButton($b["cmd"], $b["txt"]);
155  }
156  $ctab->addCommandButton($this->confirm_cmd, $this->confirm_txt);
157  $ctab->addCommandButton($this->cancel_cmd, $this->cancel_txt);
158  $ctab->setFormAction($this->getFormAction());
159  foreach ($this->hidden_item as $hidden_item)
160  {
161  $ctab->addHiddenInput($hidden_item["var"], $hidden_item["value"]);
162  }
163 
164  if($this->form_name)
165  {
166  $ctab->setFormName($this->form_name);
167  }
168 
169  return $ctab->getHTML();
170  }
171  else // simple version, just ask for confirmation
172  {
173  $tb = new ilToolbarGUI();
174  $tb->setFormAction($this->getFormAction());
175  $tb->addFormButton($this->confirm_txt, $this->confirm_cmd);
176  $tb->addFormButton($this->cancel_txt, $this->cancel_cmd);
177  return $tb->getHTML();
178  }
179  }
180 
186  function setFormName($a_name)
187  {
188  $this->form_name = $a_name;
189  }
190 }
191 ?>