ILIAS  release_8 Revision v8.24
ilExcCriteriaGUI Class Reference

Class ilExcCriteriaGUI. More...

+ Collaboration diagram for ilExcCriteriaGUI:

Public Member Functions

 __construct (int $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

ilCtrl $ctrl
 
ilToolbarGUI $toolbar
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
int $cat_id
 
GUIRequest $request
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilExcCriteriaGUI::__construct ( int  $a_cat_id)

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

38 {
39 global $DIC;
40
41 $this->ctrl = $DIC->ctrl();
42 $this->toolbar = $DIC->toolbar();
43 $this->lng = $DIC->language();
44 $this->tpl = $DIC["tpl"];
45 $this->cat_id = $a_cat_id;
46 $this->request = $DIC->exercise()->internal()->gui()->request();
47 }
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

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

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

203 : void
204 {
206 $ilCtrl = $this->ctrl;
207
208 $new_type = $this->request->getCriteriaType();
209 if (!$new_type) {
210 $ilCtrl->redirect($this, "view");
211 }
212
213 $ilCtrl->setParameter($this, "type", $new_type);
214
215 if (!$a_form) {
216 $crit_obj = ilExcCriteria::getInstanceByType($new_type);
217 $a_form = $this->initForm($crit_obj);
218 }
219
220 $tpl->setContent($a_form->getHTML());
221 }
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
@inheritDoc
initForm(ilExcCriteria $a_crit_obj)
ilGlobalTemplateInterface $tpl
static getInstanceByType(string $a_type)
setContent(string $a_html)
Sets content for standard template.

References $ctrl, $tpl, ilExcCriteria\getInstanceByType(), initForm(), ilCtrl\redirect(), and ilGlobalTemplateInterface\setContent().

+ Here is the call graph for this function:

◆ confirmDeletion()

ilExcCriteriaGUI::confirmDeletion ( )
protected

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

112 : void
113 {
114 $ilCtrl = $this->ctrl;
117
118 $ids = $this->request->getCriteriaIds();
119 if (count($ids) == 0) {
120 $this->tpl->setOnScreenMessage('info', $lng->txt("select_one"), true);
121 $ilCtrl->redirect($this, "view");
122 }
123
124 $confirmation_gui = new ilConfirmationGUI();
125 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this, "delete"));
126 $confirmation_gui->setHeaderText($lng->txt("exc_criteria_deletion_confirmation"));
127 $confirmation_gui->setCancel($lng->txt("cancel"), "view");
128 $confirmation_gui->setConfirm($lng->txt("delete"), "delete");
129
130 foreach (ilExcCriteria::getInstancesByParentId($this->cat_id) as $item) {
131 if (in_array($item->getId(), $ids)) {
132 $confirmation_gui->addItem("id[]", $item->getId(), $item->getTitle());
133 }
134 }
135
136 $tpl->setContent($confirmation_gui->getHTML());
137 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstancesByParentId(int $a_parent_id)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.

References $ctrl, $lng, $tpl, ilExcCriteria\getInstancesByParentId(), ilGlobalTemplateInterface\setContent(), ilGlobalTemplateInterface\setOnScreenMessage(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ create()

ilExcCriteriaGUI::create ( )
protected

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

265 : void
266 {
267 $ilCtrl = $this->ctrl;
268
269 $new_type = $this->request->getCriteriaType();
270 if (!$new_type) {
271 $ilCtrl->redirect($this, "view");
272 }
273
274 $crit_obj = ilExcCriteria::getInstanceByType($new_type);
275 $this->importForm($crit_obj);
276 }
importForm(ilExcCriteria $a_crit_obj)

References ilExcCriteria\getInstanceByType().

+ Here is the call graph for this function:

◆ delete()

ilExcCriteriaGUI::delete ( )
protected

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

139 : void
140 {
141 $ilCtrl = $this->ctrl;
143
144 $ids = $this->request->getCriteriaIds();
145 if (count($ids) == 0) {
146 $ilCtrl->redirect($this, "view");
147 }
148
149 foreach (ilExcCriteria::getInstancesByParentId($this->cat_id) as $item) {
150 if (in_array($item->getId(), $ids)) {
151 $item->delete();
152 }
153 }
154
155 $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
156 $ilCtrl->redirect($this, "view");
157 }

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

+ Here is the call graph for this function:

◆ edit()

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

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

296 : void
297 {
299
300 $crit_obj = $this->getCurrentCritera();
301
302 if (!$a_form) {
303 $a_form = $this->initForm($crit_obj);
304 $this->exportForm($crit_obj, $a_form);
305 }
306
307 $tpl->setContent($a_form->getHTML());
308 }
exportForm(ilExcCriteria $a_crit_obj, ilPropertyFormGUI $a_form)

References $tpl, and ilPropertyFormGUI\getHTML().

+ Here is the call graph for this function:

◆ executeCommand()

ilExcCriteriaGUI::executeCommand ( )

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

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

References $ctrl, and ilCtrl\getNextClass().

+ Here is the call graph for this function:

◆ exportForm()

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

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

226 : void {
227 $a_form->getItemByPostVar("title")->setValue($a_crit_obj->getTitle());
228 $a_form->getItemByPostVar("desc")->setValue($a_crit_obj->getDescription());
229 $a_form->getItemByPostVar("req")->setChecked($a_crit_obj->isRequired());
230
231 $a_crit_obj->exportCustomForm($a_form);
232 }
exportCustomForm(ilPropertyFormGUI $a_form)
getItemByPostVar(string $a_post_var)

◆ getCurrentCritera()

ilExcCriteriaGUI::getCurrentCritera ( )
protected

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

279 {
280 $ilCtrl = $this->ctrl;
281
282 $id = $this->request->getCritId();
283 if ($id) {
285 if ($crit_obj->getParent() == $this->cat_id) {
286 $ilCtrl->setParameter($this, "crit_id", $id);
287 return $crit_obj;
288 }
289 }
290
291 $ilCtrl->redirect($this, "view");
292
293 return null;
294 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceById(int $a_id)

References $id, and ilExcCriteria\getInstanceById().

+ Here is the call graph for this function:

◆ importForm()

ilExcCriteriaGUI::importForm ( ilExcCriteria  $a_crit_obj)
protected

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

236 : void {
237 $ilCtrl = $this->ctrl;
239
240 $is_edit = (bool) $a_crit_obj->getId();
241 $ilCtrl->setParameter($this, "type", $this->request->getCriteriaType());
242 $form = $this->initForm($a_crit_obj);
243 if ($form->checkInput()) {
244 $a_crit_obj->setTitle($form->getInput("title"));
245 $a_crit_obj->setDescription($form->getInput("desc"));
246 $a_crit_obj->setRequired($form->getInput("req"));
247
248 $a_crit_obj->importCustomForm($form);
249
250 if (!$is_edit) {
251 $a_crit_obj->setParent($this->cat_id);
252 $a_crit_obj->save();
253 } else {
254 $a_crit_obj->update();
255 }
256
257 $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
258 $ilCtrl->redirect($this, "view");
259 }
260
261 $form->setValuesByPost();
262 $this->{$is_edit ? "edit" : "add"}($form);
263 }
setRequired(bool $a_value)
setTitle(?string $a_value)
importCustomForm(ilPropertyFormGUI $a_form)
setDescription(?string $a_value)
setParent(?int $a_value)

◆ initForm()

ilExcCriteriaGUI::initForm ( ilExcCriteria  $a_crit_obj)
protected

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

165 {
166 $ilCtrl = $this->ctrl;
168
169 $form = new ilPropertyFormGUI();
170
171 $is_edit = (bool) $a_crit_obj->getId();
172 if (!$is_edit) {
173 $form->setFormAction($ilCtrl->getFormAction($this, "create"));
174 $form->setTitle($lng->txt("exc_criteria_create_form"));
175 $form->addCommandButton("create", $lng->txt("create"));
176 } else {
177 $form->setFormAction($ilCtrl->getFormAction($this, "update"));
178 $form->setTitle($lng->txt("exc_criteria_update_form"));
179 $form->addCommandButton("update", $lng->txt("save"));
180 }
181
182 $form->addCommandButton("view", $lng->txt("cancel"));
183
184 $type = new ilNonEditableValueGUI($lng->txt("type"));
185 $type->setValue($a_crit_obj->getTranslatedType());
186 $form->addItem($type);
187
188 $title = new ilTextInputGUI($lng->txt("title"), "title");
189 $title->setRequired(true);
190 $form->addItem($title);
191
192 $desc = new ilTextAreaInputGUI($lng->txt("description"), "desc");
193 $form->addItem($desc);
194
195 $req = new ilCheckboxInputGUI($lng->txt("required_field"), "req");
196 $form->addItem($req);
197
198 $a_crit_obj->initCustomForm($form);
199
200 return $form;
201 }
This class represents a checkbox property in a property form.
initCustomForm(ilPropertyFormGUI $a_form)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
catch(\Exception $e) $req
Definition: xapiproxy.php:93
$type

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

Referenced by add().

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

◆ saveOrder()

ilExcCriteriaGUI::saveOrder ( )
protected

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

90 : void
91 {
92 $ilCtrl = $this->ctrl;
94
95 $all_cat = ilExcCriteria::getInstancesByParentId($this->cat_id);
96
97 $pos = 0;
98 $req_positions = $this->request->getPositions();
99 asort($req_positions);
100 foreach (array_keys($req_positions) as $id) {
101 if (array_key_exists($id, $all_cat)) {
102 $pos += 10;
103 $all_cat[$id]->setPosition($pos);
104 $all_cat[$id]->update();
105 }
106 }
107
108 $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
109 $ilCtrl->redirect($this, "view");
110 }

References $ctrl, $id, $lng, ilExcCriteria\getInstancesByParentId(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ update()

ilExcCriteriaGUI::update ( )
protected

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

310 : void
311 {
312 $crit_obj = $this->getCurrentCritera();
313 $this->importForm($crit_obj);
314 }

◆ view()

ilExcCriteriaGUI::view ( )
protected

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

68 : void
69 {
70 $ilToolbar = $this->toolbar;
71 $ilCtrl = $this->ctrl;
74
75 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "add"));
76
77 $types = new ilSelectInputGUI($lng->txt("type"), "type");
78 $types->setOptions(ilExcCriteria::getTypesMap());
79 $ilToolbar->addStickyItem($types);
80
82 $button->setCaption("exc_add_criteria");
83 $button->setCommand("add");
84 $ilToolbar->addStickyItem($button);
85
86 $tbl = new ilExcCriteriaTableGUI($this, "view", $this->cat_id);
87 $tpl->setContent($tbl->getHTML());
88 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.

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

+ Here is the call graph for this function:

Field Documentation

◆ $cat_id

int ilExcCriteriaGUI::$cat_id
protected

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

◆ $ctrl

ilCtrl ilExcCriteriaGUI::$ctrl
protected

◆ $lng

ilLanguage ilExcCriteriaGUI::$lng
protected

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

Referenced by confirmDeletion(), delete(), initForm(), saveOrder(), and view().

◆ $request

GUIRequest ilExcCriteriaGUI::$request
protected

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

◆ $toolbar

ilToolbarGUI ilExcCriteriaGUI::$toolbar
protected

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

Referenced by view().

◆ $tpl

ilGlobalTemplateInterface ilExcCriteriaGUI::$tpl
protected

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

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


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