ILIAS  release_7 Revision v7.30-3-g800a261c036
ilExcCriteriaGUI Class Reference

Class ilExcCriteriaGUI. More...

+ Collaboration diagram for ilExcCriteriaGUI:

Public Member Functions

 __construct ($a_cat_id)
 
 executeCommand ()
 

Protected Member Functions

 view ()
 
 saveOrder ()
 
 confirmDeletion ()
 
 delete ()
 
 initForm (ilExcCriteria $a_crit_obj)
 
 add (ilPropertyFormGUI $a_form=null)
 
 exportForm (ilExcCriteria $a_crit_obj, ilPropertyFormGUI $a_form)
 
 importForm (ilExcCriteria $a_crit_obj)
 
 create ()
 
 getCurrentCritera ()
 
 edit (ilPropertyFormGUI $a_form=null)
 
 update ()
 

Protected Attributes

 $ctrl
 
 $toolbar
 
 $lng
 
 $tpl
 
 $cat_id
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilExcCriteriaGUI::__construct (   $a_cat_id)

Definition at line 36 of file class.ilExcCriteriaGUI.php.

37 {
38 global $DIC;
39
40 $this->ctrl = $DIC->ctrl();
41 $this->toolbar = $DIC->toolbar();
42 $this->lng = $DIC->language();
43 $this->tpl = $DIC["tpl"];
44 $this->cat_id = $a_cat_id;
45 }
global $DIC
Definition: goto.php:24

References $DIC.

Member Function Documentation

◆ add()

ilExcCriteriaGUI::add ( ilPropertyFormGUI  $a_form = null)
protected

Definition at line 200 of file class.ilExcCriteriaGUI.php.

201 {
203 $ilCtrl = $this->ctrl;
204
205 $new_type = trim($_REQUEST["type"]);
206 if (!$new_type) {
207 $ilCtrl->redirect($this, "view");
208 }
209
210 $ilCtrl->setParameter($this, "type", $new_type);
211
212 if (!$a_form) {
213 $crit_obj = ilExcCriteria::getInstanceByType($new_type);
214 $a_form = $this->initForm($crit_obj);
215 }
216
217 $tpl->setContent($a_form->getHTML());
218 }
initForm(ilExcCriteria $a_crit_obj)
static getInstanceByType($a_type)

References $ctrl, $tpl, ilExcCriteria\getInstanceByType(), and initForm().

+ Here is the call graph for this function:

◆ confirmDeletion()

ilExcCriteriaGUI::confirmDeletion ( )
protected

Definition at line 109 of file class.ilExcCriteriaGUI.php.

110 {
111 $ilCtrl = $this->ctrl;
114
115 $ids = $_POST["id"];
116 if (!sizeof($ids)) {
117 ilUtil::sendInfo($lng->txt("select_one"), true);
118 $ilCtrl->redirect($this, "view");
119 }
120
121 $confirmation_gui = new ilConfirmationGUI();
122 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this, "delete"));
123 $confirmation_gui->setHeaderText($lng->txt("exc_criteria_deletion_confirmation"));
124 $confirmation_gui->setCancel($lng->txt("cancel"), "view");
125 $confirmation_gui->setConfirm($lng->txt("delete"), "delete");
126
127 foreach (ilExcCriteria::getInstancesByParentId($this->cat_id) as $item) {
128 if (in_array($item->getId(), $ids)) {
129 $confirmation_gui->addItem("id[]", $item->getId(), $item->getTitle());
130 }
131 }
132
133 $tpl->setContent($confirmation_gui->getHTML());
134 }
$_POST["username"]
Confirmation screen class.
static getInstancesByParentId($a_parent_id)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $_POST, $ctrl, $lng, $tpl, ilExcCriteria\getInstancesByParentId(), and ilUtil\sendInfo().

+ Here is the call graph for this function:

◆ create()

ilExcCriteriaGUI::create ( )
protected

Definition at line 259 of file class.ilExcCriteriaGUI.php.

260 {
261 $ilCtrl = $this->ctrl;
262
263 $new_type = trim($_REQUEST["type"]);
264 if (!$new_type) {
265 $ilCtrl->redirect($this, "view");
266 }
267
268 $crit_obj = ilExcCriteria::getInstanceByType($new_type);
269 $this->importForm($crit_obj);
270 }
importForm(ilExcCriteria $a_crit_obj)

References $ctrl, ilExcCriteria\getInstanceByType(), and importForm().

+ Here is the call graph for this function:

◆ delete()

ilExcCriteriaGUI::delete ( )
protected

Definition at line 136 of file class.ilExcCriteriaGUI.php.

137 {
138 $ilCtrl = $this->ctrl;
140
141 $ids = $_POST["id"];
142 if (!sizeof($ids)) {
143 $ilCtrl->redirect($this, "view");
144 }
145
146 foreach (ilExcCriteria::getInstancesByParentId($this->cat_id) as $item) {
147 if (in_array($item->getId(), $ids)) {
148 $item->delete();
149 }
150 }
151
152 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
153 $ilCtrl->redirect($this, "view");
154 }

References $_POST, $ctrl, $lng, and ilExcCriteria\getInstancesByParentId().

+ Here is the call graph for this function:

◆ edit()

ilExcCriteriaGUI::edit ( ilPropertyFormGUI  $a_form = null)
protected

Definition at line 288 of file class.ilExcCriteriaGUI.php.

289 {
291
292 $crit_obj = $this->getCurrentCritera();
293
294 if (!$a_form) {
295 $a_form = $this->initForm($crit_obj);
296 $this->exportForm($crit_obj, $a_form);
297 }
298
299 $tpl->setContent($a_form->getHTML());
300 }
exportForm(ilExcCriteria $a_crit_obj, ilPropertyFormGUI $a_form)

References $tpl, exportForm(), getCurrentCritera(), and initForm().

+ Here is the call graph for this function:

◆ executeCommand()

ilExcCriteriaGUI::executeCommand ( )

Definition at line 47 of file class.ilExcCriteriaGUI.php.

48 {
49 $ilCtrl = $this->ctrl;
50
51 $next_class = $ilCtrl->getNextClass($this);
52 $cmd = $ilCtrl->getCmd("view");
53
54 switch ($next_class) {
55 default:
56 $this->$cmd();
57 break;
58 }
59 }

References $ctrl.

◆ exportForm()

ilExcCriteriaGUI::exportForm ( ilExcCriteria  $a_crit_obj,
ilPropertyFormGUI  $a_form 
)
protected

Definition at line 220 of file class.ilExcCriteriaGUI.php.

221 {
222 $a_form->getItemByPostVar("title")->setValue($a_crit_obj->getTitle());
223 $a_form->getItemByPostVar("desc")->setValue($a_crit_obj->getDescription());
224 $a_form->getItemByPostVar("req")->setChecked($a_crit_obj->isRequired());
225
226 $a_crit_obj->exportCustomForm($a_form);
227 }
exportCustomForm(ilPropertyFormGUI $a_form)
getItemByPostVar($a_post_var)
Get Item by POST variable.

References ilExcCriteria\exportCustomForm(), ilExcCriteria\getDescription(), ilPropertyFormGUI\getItemByPostVar(), ilExcCriteria\getTitle(), and ilExcCriteria\isRequired().

Referenced by edit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentCritera()

ilExcCriteriaGUI::getCurrentCritera ( )
protected

Definition at line 272 of file class.ilExcCriteriaGUI.php.

273 {
274 $ilCtrl = $this->ctrl;
275
276 $id = (int) $_REQUEST["crit_id"];
277 if ($id) {
278 $crit_obj = ilExcCriteria::getInstanceById($id);
279 if ($crit_obj->getParent() == $this->cat_id) {
280 $ilCtrl->setParameter($this, "crit_id", $id);
281 return $crit_obj;
282 }
283 }
284
285 $ilCtrl->redirect($this, "view");
286 }
static getInstanceById($a_id)

References $ctrl, and ilExcCriteria\getInstanceById().

Referenced by edit(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importForm()

ilExcCriteriaGUI::importForm ( ilExcCriteria  $a_crit_obj)
protected

Definition at line 229 of file class.ilExcCriteriaGUI.php.

230 {
231 $ilCtrl = $this->ctrl;
233
234 $is_edit = (bool) $a_crit_obj->getId();
235
236 $form = $this->initForm($a_crit_obj);
237 if ($form->checkInput()) {
238 $a_crit_obj->setTitle($form->getInput("title"));
239 $a_crit_obj->setDescription($form->getInput("desc"));
240 $a_crit_obj->setRequired($form->getInput("req"));
241
242 $a_crit_obj->importCustomForm($form);
243
244 if (!$is_edit) {
245 $a_crit_obj->setParent($this->cat_id);
246 $a_crit_obj->save();
247 } else {
248 $a_crit_obj->update();
249 }
250
251 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
252 $ilCtrl->redirect($this, "view");
253 }
254
255 $form->setValuesByPost();
256 $this->{$is_edit ? "edit" : "add"}($form);
257 }
importCustomForm(ilPropertyFormGUI $a_form)

References $ctrl, $lng, ilExcCriteria\getId(), ilExcCriteria\importCustomForm(), initForm(), ilExcCriteria\save(), ilExcCriteria\setDescription(), ilExcCriteria\setParent(), ilExcCriteria\setRequired(), ilExcCriteria\setTitle(), and ilExcCriteria\update().

Referenced by create(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilExcCriteriaGUI::initForm ( ilExcCriteria  $a_crit_obj)
protected

Definition at line 161 of file class.ilExcCriteriaGUI.php.

162 {
163 $ilCtrl = $this->ctrl;
165
166 $form = new ilPropertyFormGUI();
167
168 $is_edit = (bool) $a_crit_obj->getId();
169 if (!$is_edit) {
170 $form->setFormAction($ilCtrl->getFormAction($this, "create"));
171 $form->setTitle($lng->txt("exc_criteria_create_form"));
172 $form->addCommandButton("create", $lng->txt("create"));
173 } else {
174 $form->setFormAction($ilCtrl->getFormAction($this, "update"));
175 $form->setTitle($lng->txt("exc_criteria_update_form"));
176 $form->addCommandButton("update", $lng->txt("save"));
177 }
178
179 $form->addCommandButton("view", $lng->txt("cancel"));
180
181 $type = new ilNonEditableValueGUI($lng->txt("type"));
182 $type->setValue($a_crit_obj->getTranslatedType());
183 $form->addItem($type);
184
185 $title = new ilTextInputGUI($lng->txt("title"), "title");
186 $title->setRequired(true);
187 $form->addItem($title);
188
189 $desc = new ilTextAreaInputGUI($lng->txt("description"), "desc");
190 $form->addItem($desc);
191
192 $req = new ilCheckboxInputGUI($lng->txt("required_field"), "req");
193 $form->addItem($req);
194
195 $a_crit_obj->initCustomForm($form);
196
197 return $form;
198 }
This class represents a checkbox property in a property form.
initCustomForm(ilPropertyFormGUI $a_form)
This class represents a non editable value in a property form.
This class represents a property form user interface.
This class represents a text area property in a property form.
This class represents a text property in a property form.
$type

References $ctrl, $lng, XapiProxy\$req, $type, ilExcCriteria\getId(), ilExcCriteria\getTranslatedType(), and ilExcCriteria\initCustomForm().

Referenced by add(), edit(), and importForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveOrder()

ilExcCriteriaGUI::saveOrder ( )
protected

Definition at line 88 of file class.ilExcCriteriaGUI.php.

89 {
90 $ilCtrl = $this->ctrl;
92
93 $all_cat = ilExcCriteria::getInstancesByParentId($this->cat_id);
94
95 $pos = 0;
96 asort($_POST["pos"]);
97 foreach (array_keys($_POST["pos"]) as $id) {
98 if (array_key_exists($id, $all_cat)) {
99 $pos += 10;
100 $all_cat[$id]->setPosition($pos);
101 $all_cat[$id]->update();
102 }
103 }
104
105 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
106 $ilCtrl->redirect($this, "view");
107 }

References $_POST, $ctrl, $lng, and ilExcCriteria\getInstancesByParentId().

+ Here is the call graph for this function:

◆ update()

ilExcCriteriaGUI::update ( )
protected

Definition at line 302 of file class.ilExcCriteriaGUI.php.

303 {
304 $crit_obj = $this->getCurrentCritera();
305 $this->importForm($crit_obj);
306 }

References getCurrentCritera(), and importForm().

+ Here is the call graph for this function:

◆ view()

ilExcCriteriaGUI::view ( )
protected

Definition at line 66 of file class.ilExcCriteriaGUI.php.

67 {
68 $ilToolbar = $this->toolbar;
69 $ilCtrl = $this->ctrl;
72
73 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "add"));
74
75 $types = new ilSelectInputGUI($lng->txt("type"), "type");
76 $types->setOptions(ilExcCriteria::getTypesMap());
77 $ilToolbar->addStickyItem($types);
78
80 $button->setCaption("exc_add_criteria");
81 $button->setCommand("add");
82 $ilToolbar->addStickyItem($button);
83
84 $tbl = new ilExcCriteriaTableGUI($this, "view", $this->cat_id);
85 $tpl->setContent($tbl->getHTML());
86 }
Class ilExcCriteriaTableGUI.
This class represents a selection list property in a property form.
static getInstance()
Factory.

References $ctrl, $lng, $toolbar, $tpl, ilSubmitButton\getInstance(), and ilExcCriteria\getTypesMap().

+ Here is the call graph for this function:

Field Documentation

◆ $cat_id

ilExcCriteriaGUI::$cat_id
protected

Definition at line 34 of file class.ilExcCriteriaGUI.php.

◆ $ctrl

ilExcCriteriaGUI::$ctrl
protected

◆ $lng

ilExcCriteriaGUI::$lng
protected

◆ $toolbar

ilExcCriteriaGUI::$toolbar
protected

Definition at line 22 of file class.ilExcCriteriaGUI.php.

Referenced by view().

◆ $tpl

ilExcCriteriaGUI::$tpl
protected

Definition at line 32 of file class.ilExcCriteriaGUI.php.

Referenced by add(), confirmDeletion(), edit(), and view().


The documentation for this class was generated from the following file: