ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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, $a_id = "")
80 {
81 $this->cancel_txt = $a_txt;
82 $this->cancel_cmd = $a_cmd;
83 $this->cancel_id = $a_id;
84 }
85
92 final public function setConfirm($a_txt, $a_cmd, $a_id = "")
93 {
94 $this->confirm_txt = $a_txt;
95 $this->confirm_cmd = $a_cmd;
96 $this->confirm_id = $a_id;
97 }
98
107 public function addItem($a_post_var, $a_id, $a_text, $a_img = "",
108 $a_alt = "")
109 {
110 $this->item[] = array("var" => $a_post_var, "id" => $a_id,
111 "text" => $a_text, "img" => $a_img, "alt" => $a_alt);
112 if ($a_img != "")
113 {
114 $this->use_images = true;
115 }
116 }
117
124 public function addHiddenItem($a_post_var, $a_value)
125 {
126 $this->hidden_item[] = array("var" => $a_post_var, "value" => $a_value);
127 }
128
134 final public function getHTML()
135 {
136 global $lng;
137
139
140 include_once("./Services/Utilities/classes/class.ilConfirmationTableGUI.php");
141
142 // delete/handle items
143 if (count($this->item) > 0)
144 {
145 $ctab = new ilConfirmationTableGUI($this->use_images);
146 $ctab->setData($this->item);
147
148 // other buttons
149 foreach ($this->buttons as $b)
150 {
151 $ctab->addCommandButton($b["cmd"], $b["txt"]);
152 }
153 $ctab->addCommandButton($this->confirm_cmd, $this->confirm_txt);
154 $ctab->addCommandButton($this->cancel_cmd, $this->cancel_txt);
155 $ctab->setFormAction($this->getFormAction());
156 foreach ($this->hidden_item as $hidden_item)
157 {
158 $ctab->addHiddenInput($hidden_item["var"], $hidden_item["value"]);
159 }
160
161 if($this->form_name)
162 {
163 $ctab->setFormName($this->form_name);
164 }
165
166 return $ctab->getHTML();
167 }
168 else // simple version, just ask for confirmation
169 {
170 $tb = new ilToolbarGUI();
171 $tb->setPreventDoubleSubmission(true);
172 $tb->setFormAction($this->getFormAction());
173 if($this->hidden_item)
174 {
175 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
176 foreach($this->hidden_item as $hidden_item)
177 {
178 $hiddenInput = new ilHiddenInputGUI($hidden_item['var']);
179 $hiddenInput->setValue($hidden_item['value']);
180 $tb->addInputItem($hiddenInput);
181 }
182 }
183 require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
184 $confirm = ilSubmitButton::getInstance();
185 $confirm->setCommand($this->confirm_cmd);
186 $confirm->setCaption($this->confirm_txt, false);
187 $confirm->setId($this->confirm_id);
188
189 $cancel = ilSubmitButton::getInstance();
190 $cancel->setCommand($this->cancel_cmd);
191 $cancel->setCaption($this->cancel_txt, false);
192 $cancel->setId($this->cancel_id);
193
194 $tb->addStickyItem($confirm);
195 $tb->addStickyItem($cancel);
196
197 return $tb->getHTML();
198 }
199 }
200
206 function setFormName($a_name)
207 {
208 $this->form_name = $a_name;
209 }
210}
211?>
An exception for terminatinating execution or to throw for unit testing.
Confirmation screen class.
setConfirm($a_txt, $a_cmd, $a_id="")
Set confirmation button command and text.
addButton($a_txt, $a_cmd)
Set cancel button command and text.
setFormAction($a_form_action)
setCancel($a_txt, $a_cmd, $a_id="")
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.
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:17