ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilConfirmationGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("Services/Table/classes/class.ilTableGUI.php");
25 
35 {
36  private $hidden_item = array();
37  private $item = array();
38  private $use_images = false;
39 
44  public function __construct()
45  {
46  }
47 
48  final public function setFormAction($a_form_action)
49  {
50  $this->form_action = $a_form_action;
51  }
52 
53  final public function getFormAction()
54  {
55  return $this->form_action;
56  }
57 
63  function setHeaderText($a_headertext)
64  {
65  $this->headertext = $a_headertext;
66  }
67 
73  function getHeaderText()
74  {
75  return $this->headertext;
76  }
77 
84  final public function setCancel($a_txt, $a_cmd)
85  {
86  $this->cancel_txt = $a_txt;
87  $this->cancel_cmd = $a_cmd;
88  }
89 
96  final public function setConfirm($a_txt, $a_cmd)
97  {
98  $this->confirm_txt = $a_txt;
99  $this->confirm_cmd = $a_cmd;
100  }
101 
110  public function addItem($a_post_var, $a_id, $a_text, $a_img = "")
111  {
112  $this->item[] = array("var" => $a_post_var, "id" => $a_id,
113  "text" => $a_text, "img" => $a_img);
114  if ($a_img != "")
115  {
116  $this->use_images = true;
117  }
118  }
119 
126  public function addHiddenItem($a_post_var, $a_value)
127  {
128  $this->hidden_item[] = array("var" => $a_post_var, "value" => $a_value);
129  }
130 
136  final public function getHTML()
137  {
138  global $lng;
139 
140  $tpl = new ilTemplate("tpl.confirmation.html", true, true, "Services/Utilities");
141 
142  // cancel/confirm buttons
143  $tpl->setCurrentBlock("cmd");
144  $tpl->setVariable("TXT_CMD", $this->confirm_txt);
145  $tpl->setVariable("CMD", $this->confirm_cmd);
146  $tpl->parseCurrentBlock();
147  $tpl->setCurrentBlock("cmd");
148  $tpl->setVariable("TXT_CMD", $this->cancel_txt);
149  $tpl->setVariable("CMD", $this->cancel_cmd);
150  $tpl->parseCurrentBlock();
151 
152  // output items
153  foreach ($this->item as $item)
154  {
155  if ($this->use_images)
156  {
157  if ($item["img"] != "")
158  {
159  $tpl->setCurrentBlock("img_cell");
160  $tpl->setVariable("IMG_ITEM", $item["img"]);
161  $tpl->parseCurrentBlock();
162  }
163  else
164  {
165  $tpl->touchBlock("blank_cell");
166  }
167  }
168  $tpl->setCurrentBlock("item_row");
169  $this->fillRowColor($tpl);
170  $tpl->setVariable("TXT_ITEM", $item["text"]);
171  $tpl->setVariable("VAR_ITEM", $item["var"]);
172  $tpl->setVariable("ID", $item["id"]);
173  $tpl->parseCurrentBlock();
174  }
175 
176  foreach ($this->hidden_item as $hidden_item)
177  {
178  $tpl->setCurrentBlock("hidden_item_row");
179  $tpl->setVariable("VAR_HIDDEN_VAR", $hidden_item["var"]);
180  $tpl->setVariable("VAR_HIDDEN_VALUE", $hidden_item["value"]);
181  $tpl->parseCurrentBlock();
182  }
183 
184  $tpl->setVariable("FORMACTION", $this->getFormAction());
185  $tpl->setVariable("TXT_HEADER", $this->getHeaderText());
186 
187  if ($this->use_images)
188  {
189  $tpl->setVariable("COL_SPAN", 2);
190  }
191  else
192  {
193  $tpl->setVariable("COL_SPAN", 1);
194  }
195 
196  return $tpl->get();
197  }
198 
199  final protected function fillRowColor(&$a_tpl, $a_placeholder = "CSS_ROW")
200  {
201  $this->css_row = ($this->css_row != "tblrow1")
202  ? "tblrow1"
203  : "tblrow2";
204  $a_tpl->setVariable($a_placeholder, $this->css_row);
205  }
206 
207 }
208 ?>