ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

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

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
+ 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.

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

203  : void
204  {
205  $tpl = $this->tpl;
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)
static getInstanceByType(string $a_type)
setContent(string $a_html)
Sets content for standard template.
initForm(ilExcCriteria $a_crit_obj)
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:

◆ confirmDeletion()

ilExcCriteriaGUI::confirmDeletion ( )
protected

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

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

112  : void
113  {
114  $ilCtrl = $this->ctrl;
115  $lng = $this->lng;
116  $tpl = $this->tpl;
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  }
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.
static getInstancesByParentId(int $a_parent_id)
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ create()

ilExcCriteriaGUI::create ( )
protected

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

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

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  }
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
static getInstanceByType(string $a_type)
importForm(ilExcCriteria $a_crit_obj)
+ Here is the call graph for this function:

◆ delete()

ilExcCriteriaGUI::delete ( )
protected

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

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

139  : void
140  {
141  $ilCtrl = $this->ctrl;
142  $lng = $this->lng;
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  }
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...
static getInstancesByParentId(int $a_parent_id)
+ 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.

References $tpl, exportForm(), getCurrentCritera(), initForm(), and ilGlobalTemplateInterface\setContent().

296  : void
297  {
298  $tpl = $this->tpl;
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  }
setContent(string $a_html)
Sets content for standard template.
exportForm(ilExcCriteria $a_crit_obj, ilPropertyFormGUI $a_form)
initForm(ilExcCriteria $a_crit_obj)
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:

◆ executeCommand()

ilExcCriteriaGUI::executeCommand ( )

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

References $ctrl, and ilCtrl\getNextClass().

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)
+ 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.

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

Referenced by edit().

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  }
getItemByPostVar(string $a_post_var)
exportCustomForm(ilPropertyFormGUI $a_form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentCritera()

ilExcCriteriaGUI::getCurrentCritera ( )
protected

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

References $cat_id, $ctrl, $id, and ilExcCriteria\getInstanceById().

Referenced by edit(), and update().

278  : ?ilExcCriteria
279  {
280  $ilCtrl = $this->ctrl;
281 
282  $id = $this->request->getCritId();
283  if ($id) {
284  $crit_obj = ilExcCriteria::getInstanceById($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  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getInstanceById(int $a_id)
+ 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 234 of file class.ilExcCriteriaGUI.php.

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

Referenced by create(), and update().

236  : void {
237  $ilCtrl = $this->ctrl;
238  $lng = $this->lng;
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  }
setDescription(?string $a_value)
setRequired(bool $a_value)
importCustomForm(ilPropertyFormGUI $a_form)
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...
setTitle(?string $a_value)
initForm(ilExcCriteria $a_crit_obj)
setParent(?int $a_value)
+ 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 164 of file class.ilExcCriteriaGUI.php.

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

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

165  {
166  $ilCtrl = $this->ctrl;
167  $lng = $this->lng;
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  }
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...
$type
This class represents a checkbox property in a property form.
catch(\Exception $e) $req
Definition: xapiproxy.php:93
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
initCustomForm(ilPropertyFormGUI $a_form)
+ 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.

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

90  : void
91  {
92  $ilCtrl = $this->ctrl;
93  $lng = $this->lng;
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  }
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...
static getInstancesByParentId(int $a_parent_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ update()

ilExcCriteriaGUI::update ( )
protected

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

References getCurrentCritera(), and importForm().

310  : void
311  {
312  $crit_obj = $this->getCurrentCritera();
313  $this->importForm($crit_obj);
314  }
importForm(ilExcCriteria $a_crit_obj)
+ Here is the call graph for this function:

◆ view()

ilExcCriteriaGUI::view ( )
protected

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

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

68  : void
69  {
70  $ilToolbar = $this->toolbar;
71  $ilCtrl = $this->ctrl;
72  $lng = $this->lng;
73  $tpl = $this->tpl;
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 
81  $button = ilSubmitButton::getInstance();
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  }
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...
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ 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.

Referenced by getCurrentCritera().

◆ $ctrl

ilCtrl ilExcCriteriaGUI::$ctrl
protected

◆ $lng

ilLanguage ilExcCriteriaGUI::$lng
protected

◆ $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(), edit(), and view().


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