ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 38 of file class.ilExcCriteriaGUI.php.

References $DIC.

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

Member Function Documentation

◆ add()

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

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

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

208  {
209  $tpl = $this->tpl;
211 
212  $new_type = trim($_REQUEST["type"]);
213  if (!$new_type) {
214  $ilCtrl->redirect($this, "view");
215  }
216 
217  $ilCtrl->setParameter($this, "type", $new_type);
218 
219  if (!$a_form) {
220  $crit_obj = ilExcCriteria::getInstanceByType($new_type);
221  $a_form = $this->initForm($crit_obj);
222  }
223 
224  $tpl->setContent($a_form->getHTML());
225  }
static getInstanceByType($a_type)
global $ilCtrl
Definition: ilias.php:18
initForm(ilExcCriteria $a_crit_obj)
+ Here is the call graph for this function:

◆ confirmDeletion()

ilExcCriteriaGUI::confirmDeletion ( )
protected

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

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

115  {
117  $lng = $this->lng;
118  $tpl = $this->tpl;
119 
120  $ids = $_POST["id"];
121  if (!sizeof($ids)) {
122  ilUtil::sendInfo($lng->txt("select_one"), true);
123  $ilCtrl->redirect($this, "view");
124  }
125 
126  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
127  $confirmation_gui = new ilConfirmationGUI();
128  $confirmation_gui->setFormAction($ilCtrl->getFormAction($this, "delete"));
129  $confirmation_gui->setHeaderText($lng->txt("exc_criteria_deletion_confirmation"));
130  $confirmation_gui->setCancel($lng->txt("cancel"), "view");
131  $confirmation_gui->setConfirm($lng->txt("delete"), "delete");
132 
133  foreach (ilExcCriteria::getInstancesByParentId($this->cat_id) as $item) {
134  if (in_array($item->getId(), $ids)) {
135  $confirmation_gui->addItem("id[]", $item->getId(), $item->getTitle());
136  }
137  }
138 
139  $tpl->setContent($confirmation_gui->getHTML());
140  }
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getInstancesByParentId($a_parent_id)
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ create()

ilExcCriteriaGUI::create ( )
protected

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

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

267  {
269 
270  $new_type = trim($_REQUEST["type"]);
271  if (!$new_type) {
272  $ilCtrl->redirect($this, "view");
273  }
274 
275  $crit_obj = ilExcCriteria::getInstanceByType($new_type);
276  $this->importForm($crit_obj);
277  }
static getInstanceByType($a_type)
global $ilCtrl
Definition: ilias.php:18
importForm(ilExcCriteria $a_crit_obj)
+ Here is the call graph for this function:

◆ delete()

ilExcCriteriaGUI::delete ( )
protected

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

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

143  {
145  $lng = $this->lng;
146 
147  $ids = $_POST["id"];
148  if (!sizeof($ids)) {
149  $ilCtrl->redirect($this, "view");
150  }
151 
152  foreach (ilExcCriteria::getInstancesByParentId($this->cat_id) as $item) {
153  if (in_array($item->getId(), $ids)) {
154  $item->delete();
155  }
156  }
157 
158  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
159  $ilCtrl->redirect($this, "view");
160  }
global $ilCtrl
Definition: ilias.php:18
static getInstancesByParentId($a_parent_id)
$_POST["username"]
+ Here is the call graph for this function:

◆ edit()

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

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

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

296  {
297  $tpl = $this->tpl;
298 
299  $crit_obj = $this->getCurrentCritera();
300 
301  if (!$a_form) {
302  $a_form = $this->initForm($crit_obj);
303  $this->exportForm($crit_obj, $a_form);
304  }
305 
306  $tpl->setContent($a_form->getHTML());
307  }
exportForm(ilExcCriteria $a_crit_obj, ilPropertyFormGUI $a_form)
initForm(ilExcCriteria $a_crit_obj)
+ Here is the call graph for this function:

◆ executeCommand()

ilExcCriteriaGUI::executeCommand ( )

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

References $ctrl, and $ilCtrl.

50  {
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  }
global $ilCtrl
Definition: ilias.php:18

◆ exportForm()

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

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

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

Referenced by edit().

228  {
229  $a_form->getItemByPostVar("title")->setValue($a_crit_obj->getTitle());
230  $a_form->getItemByPostVar("desc")->setValue($a_crit_obj->getDescription());
231  $a_form->getItemByPostVar("req")->setChecked($a_crit_obj->isRequired());
232 
233  $a_crit_obj->exportCustomForm($a_form);
234  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
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 279 of file class.ilExcCriteriaGUI.php.

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

Referenced by edit(), and update().

280  {
282 
283  $id = (int) $_REQUEST["crit_id"];
284  if ($id) {
285  $crit_obj = ilExcCriteria::getInstanceById($id);
286  if ($crit_obj->getParent() == $this->cat_id) {
287  $ilCtrl->setParameter($this, "crit_id", $id);
288  return $crit_obj;
289  }
290  }
291 
292  $ilCtrl->redirect($this, "view");
293  }
static getInstanceById($a_id)
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
+ 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 236 of file class.ilExcCriteriaGUI.php.

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

Referenced by create(), and update().

237  {
239  $lng = $this->lng;
240 
241  $is_edit = (bool) $a_crit_obj->getId();
242 
243  $form = $this->initForm($a_crit_obj);
244  if ($form->checkInput()) {
245  $a_crit_obj->setTitle($form->getInput("title"));
246  $a_crit_obj->setDescription($form->getInput("desc"));
247  $a_crit_obj->setRequired($form->getInput("req"));
248 
249  $a_crit_obj->importCustomForm($form);
250 
251  if (!$is_edit) {
252  $a_crit_obj->setParent($this->cat_id);
253  $a_crit_obj->save();
254  } else {
255  $a_crit_obj->update();
256  }
257 
258  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
259  $ilCtrl->redirect($this, "view");
260  }
261 
262  $form->setValuesByPost();
263  $this->{$is_edit ? "edit" : "add"}($form);
264  }
importCustomForm(ilPropertyFormGUI $a_form)
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
initForm(ilExcCriteria $a_crit_obj)
+ 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 167 of file class.ilExcCriteriaGUI.php.

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

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

168  {
170  $lng = $this->lng;
171 
172  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
173  $form = new ilPropertyFormGUI();
174 
175  $is_edit = (bool) $a_crit_obj->getId();
176  if (!$is_edit) {
177  $form->setFormAction($ilCtrl->getFormAction($this, "create"));
178  $form->setTitle($lng->txt("exc_criteria_create_form"));
179  $form->addCommandButton("create", $lng->txt("create"));
180  } else {
181  $form->setFormAction($ilCtrl->getFormAction($this, "update"));
182  $form->setTitle($lng->txt("exc_criteria_update_form"));
183  $form->addCommandButton("update", $lng->txt("save"));
184  }
185 
186  $form->addCommandButton("view", $lng->txt("cancel"));
187 
188  $type = new ilNonEditableValueGUI($lng->txt("type"));
189  $type->setValue($a_crit_obj->getTranslatedType());
190  $form->addItem($type);
191 
192  $title = new ilTextInputGUI($lng->txt("title"), "title");
193  $title->setRequired(true);
194  $form->addItem($title);
195 
196  $desc = new ilTextAreaInputGUI($lng->txt("description"), "desc");
197  $form->addItem($desc);
198 
199  $req = new ilCheckboxInputGUI($lng->txt("required_field"), "req");
200  $form->addItem($req);
201 
202  $a_crit_obj->initCustomForm($form);
203 
204  return $form;
205  }
This class represents a property form user interface.
$type
This class represents a checkbox property in a property form.
$req
Definition: getUserInfo.php:20
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
This class represents a text property in a property form.
This class represents a non editable value in a property form.
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 93 of file class.ilExcCriteriaGUI.php.

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

94  {
96  $lng = $this->lng;
97 
98  $all_cat = ilExcCriteria::getInstancesByParentId($this->cat_id);
99 
100  $pos = 0;
101  asort($_POST["pos"]);
102  foreach (array_keys($_POST["pos"]) as $id) {
103  if (array_key_exists($id, $all_cat)) {
104  $pos += 10;
105  $all_cat[$id]->setPosition($pos);
106  $all_cat[$id]->update();
107  }
108  }
109 
110  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
111  $ilCtrl->redirect($this, "view");
112  }
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
static getInstancesByParentId($a_parent_id)
$_POST["username"]
+ Here is the call graph for this function:

◆ update()

ilExcCriteriaGUI::update ( )
protected

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

References getCurrentCritera(), and importForm().

310  {
311  $crit_obj = $this->getCurrentCritera();
312  $this->importForm($crit_obj);
313  }
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, $ilCtrl, $lng, $tbl, $toolbar, $tpl, ilSubmitButton\getInstance(), ilExcCriteria\getTypesMap(), and ilSelectInputGUI\setOptions().

69  {
70  $ilToolbar = $this->toolbar;
72  $lng = $this->lng;
73  $tpl = $this->tpl;
74 
75  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "add"));
76 
77  include_once "Services/Form/classes/class.ilSelectInputGUI.php";
78  $types = new ilSelectInputGUI($lng->txt("type"), "type");
80  $ilToolbar->addStickyItem($types);
81 
82  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
83  $button = ilSubmitButton::getInstance();
84  $button->setCaption("exc_add_criteria");
85  $button->setCommand("add");
86  $ilToolbar->addStickyItem($button);
87 
88  include_once "Modules/Exercise/classes/class.ilExcCriteriaTableGUI.php";
89  $tbl = new ilExcCriteriaTableGUI($this, "view", $this->cat_id);
90  $tpl->setContent($tbl->getHTML());
91  }
This class represents a selection list property in a property form.
$tbl
Definition: example_048.php:81
global $ilCtrl
Definition: ilias.php:18
setOptions($a_options)
Set Options.
Class ilExcCriteriaTableGUI.
+ Here is the call graph for this function:

Field Documentation

◆ $cat_id

ilExcCriteriaGUI::$cat_id
protected

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

Referenced by getCurrentCritera().

◆ $ctrl

ilExcCriteriaGUI::$ctrl
protected

◆ $lng

ilExcCriteriaGUI::$lng
protected

◆ $toolbar

ilExcCriteriaGUI::$toolbar
protected

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

Referenced by view().

◆ $tpl

ilExcCriteriaGUI::$tpl
protected

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

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


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