ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
5require_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->setPreventDoubleSubmission(true);
170 $tb->setFormAction($this->getFormAction());
171 if($this->hidden_item)
172 {
173 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
174 foreach($this->hidden_item as $hidden_item)
175 {
176 $hiddenInput = new ilHiddenInputGUI($hidden_item['var']);
177 $hiddenInput->setValue($hidden_item['value']);
178 $tb->addInputItem($hiddenInput);
179 }
180 }
181 require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
182 $confirm = ilSubmitButton::getInstance();
183 $confirm->setCommand($this->confirm_cmd);
184 $confirm->setCaption($this->confirm_txt, false);
185
186 $cancel = ilSubmitButton::getInstance();
187 $cancel->setCommand($this->cancel_cmd);
188 $cancel->setCaption($this->cancel_txt, false);
189
190 $tb->addStickyItem($confirm);
191 $tb->addStickyItem($cancel);
192
193 return $tb->getHTML();
194 }
195 }
196
202 function setFormName($a_name)
203 {
204 $this->form_name = $a_name;
205 }
206}
207?>
Confirmation screen class.
addButton($a_txt, $a_cmd)
Set cancel button command and text.
setFormAction($a_form_action)
setCancel($a_txt, $a_cmd)
Set cancel button command and text.
getHeaderText()
Get Set header text.
setHeaderText($a_headertext)
Set Set header text.
addHiddenItem($a_post_var, $a_value)
Add hidden item.
setConfirm($a_txt, $a_cmd)
Set confirmation button command and text.
setFormName($a_name)
Set form name.
addItem($a_post_var, $a_id, $a_text, $a_img="", $a_alt="")
Add row item.
getHTML()
Get confirmation screen HTML.
This class represents a hidden form property in a property form.
static getInstance()
Factory.
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
global $lng
Definition: privfeed.php:40