ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilExcCriteriaCatalogueGUI Class Reference

Class ilExcCriteriaCatalogueGUI. More...

+ Collaboration diagram for ilExcCriteriaCatalogueGUI:

Public Member Functions

 __construct (ilObjExercise $a_exc_obj)
 
 executeCommand ()
 

Protected Member Functions

 view ()
 
 saveOrder ()
 
 confirmDeletion ()
 
 delete ()
 
 initForm (ilExcCriteriaCatalogue $a_cat_obj=null)
 
 add (ilPropertyFormGUI $a_form=null)
 
 exportForm (ilExcCriteriaCatalogue $a_cat_obj, ilPropertyFormGUI $a_form)
 
 importForm (ilExcCriteriaCatalogue $a_cat_obj=null)
 
 create ()
 
 getCurrentCatalogue ()
 
 edit (ilPropertyFormGUI $a_form=null)
 
 update ()
 

Protected Attributes

 $ctrl
 
 $tabs
 
 $lng
 
 $toolbar
 
 $tpl
 
 $exc_obj
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilExcCriteriaCatalogueGUI::__construct ( ilObjExercise  $a_exc_obj)

Definition at line 43 of file class.ilExcCriteriaCatalogueGUI.php.

References $DIC.

44  {
45  global $DIC;
46 
47  $this->ctrl = $DIC->ctrl();
48  $this->tabs = $DIC->tabs();
49  $this->lng = $DIC->language();
50  $this->toolbar = $DIC->toolbar();
51  $this->tpl = $DIC["tpl"];
52  $this->exc_obj = $a_exc_obj;
53  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ add()

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

Definition at line 204 of file class.ilExcCriteriaCatalogueGUI.php.

References $tpl, and initForm().

205  {
206  $tpl = $this->tpl;
207 
208  if (!$a_form) {
209  $a_form = $this->initForm();
210  }
211 
212  $tpl->setContent($a_form->getHTML());
213  }
initForm(ilExcCriteriaCatalogue $a_cat_obj=null)
+ Here is the call graph for this function:

◆ confirmDeletion()

ilExcCriteriaCatalogueGUI::confirmDeletion ( )
protected

Definition at line 123 of file class.ilExcCriteriaCatalogueGUI.php.

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

124  {
126  $lng = $this->lng;
127  $tpl = $this->tpl;
128 
129  $ids = $_POST["id"];
130  if (!sizeof($ids)) {
131  ilUtil::sendInfo($lng->txt("select_one"), true);
132  $ilCtrl->redirect($this, "view");
133  }
134 
135  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
136  $confirmation_gui = new ilConfirmationGUI();
137  $confirmation_gui->setFormAction($ilCtrl->getFormAction($this, "delete"));
138  $confirmation_gui->setHeaderText($lng->txt("exc_criteria_catalogue_deletion_confirmation"));
139  $confirmation_gui->setCancel($lng->txt("cancel"), "view");
140  $confirmation_gui->setConfirm($lng->txt("delete"), "delete");
141 
142  foreach (ilExcCriteriaCatalogue::getInstancesByParentId($this->exc_obj->getId()) as $item) {
143  if (in_array($item->getId(), $ids)) {
144  $confirmation_gui->addItem("id[]", $item->getId(), $item->getTitle());
145  }
146  }
147 
148  $tpl->setContent($confirmation_gui->getHTML());
149  }
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()

ilExcCriteriaCatalogueGUI::create ( )
protected

Definition at line 250 of file class.ilExcCriteriaCatalogueGUI.php.

References importForm().

251  {
252  $this->importForm();
253  }
importForm(ilExcCriteriaCatalogue $a_cat_obj=null)
+ Here is the call graph for this function:

◆ delete()

ilExcCriteriaCatalogueGUI::delete ( )
protected

Definition at line 151 of file class.ilExcCriteriaCatalogueGUI.php.

References $_POST, $ctrl, $ilCtrl, $lng, ilExcCriteriaCatalogue\getInstancesByParentId(), and ilUtil\sendSuccess().

152  {
154  $lng = $this->lng;
155 
156  $ids = $_POST["id"];
157  if (!sizeof($ids)) {
158  $ilCtrl->redirect($this, "view");
159  }
160 
161  foreach (ilExcCriteriaCatalogue::getInstancesByParentId($this->exc_obj->getId()) as $item) {
162  if (in_array($item->getId(), $ids)) {
163  $item->delete();
164  }
165  }
166 
167  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
168  $ilCtrl->redirect($this, "view");
169  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
static getInstancesByParentId($a_parent_id)
$_POST["username"]
+ Here is the call graph for this function:

◆ edit()

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

Definition at line 271 of file class.ilExcCriteriaCatalogueGUI.php.

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

272  {
273  $tpl = $this->tpl;
274 
275  $cat_obj = $this->getCurrentCatalogue();
276 
277  if (!$a_form) {
278  $a_form = $this->initForm($cat_obj);
279  $this->exportForm($cat_obj, $a_form);
280  }
281 
282  $tpl->setContent($a_form->getHTML());
283  }
initForm(ilExcCriteriaCatalogue $a_cat_obj=null)
exportForm(ilExcCriteriaCatalogue $a_cat_obj, ilPropertyFormGUI $a_form)
+ Here is the call graph for this function:

◆ executeCommand()

ilExcCriteriaCatalogueGUI::executeCommand ( )

Definition at line 55 of file class.ilExcCriteriaCatalogueGUI.php.

References $ctrl, $ilCtrl, $lng, and $tabs.

56  {
58  $ilTabs = $this->tabs;
59  $lng = $this->lng;
60 
61  $next_class = $ilCtrl->getNextClass($this);
62  $cmd = $ilCtrl->getCmd("view");
63 
64  switch ($next_class) {
65  case "ilexccriteriagui":
66  $ilTabs->clearTargets();
67  $ilTabs->setBackTarget($lng->txt("back"), $ilCtrl->getLinkTarget($this, ""));
68  $ilCtrl->saveParameter($this, "cat_id");
69  include_once "Modules/Exercise/classes/class.ilExcCriteriaGUI.php";
70  $crit_gui = new ilExcCriteriaGUI($_REQUEST["cat_id"]);
71  $ilCtrl->forwardCommand($crit_gui);
72  break;
73 
74  default:
75  $this->$cmd();
76  break;
77  }
78  }
global $ilCtrl
Definition: ilias.php:18
Class ilExcCriteriaGUI.

◆ exportForm()

ilExcCriteriaCatalogueGUI::exportForm ( ilExcCriteriaCatalogue  $a_cat_obj,
ilPropertyFormGUI  $a_form 
)
protected

Definition at line 215 of file class.ilExcCriteriaCatalogueGUI.php.

References ilPropertyFormGUI\getItemByPostVar(), and ilExcCriteriaCatalogue\getTitle().

Referenced by edit().

216  {
217  $a_form->getItemByPostVar("title")->setValue($a_cat_obj->getTitle());
218  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentCatalogue()

ilExcCriteriaCatalogueGUI::getCurrentCatalogue ( )
protected

Definition at line 255 of file class.ilExcCriteriaCatalogueGUI.php.

References $ctrl, $id, and $ilCtrl.

Referenced by edit(), and update().

256  {
258 
259  $id = (int) $_REQUEST["cat_id"];
260  if ($id) {
261  $cat_obj = new ilExcCriteriaCatalogue($id);
262  if ($cat_obj->getParent() == $this->exc_obj->getId()) {
263  $ilCtrl->setParameter($this, "cat_id", $id);
264  return $cat_obj;
265  }
266  }
267 
268  $ilCtrl->redirect($this, "view");
269  }
Class ilExcCriteriaCatalogue.
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
+ Here is the caller graph for this function:

◆ importForm()

ilExcCriteriaCatalogueGUI::importForm ( ilExcCriteriaCatalogue  $a_cat_obj = null)
protected

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

References $ctrl, $form, $ilCtrl, $lng, initForm(), and ilUtil\sendSuccess().

Referenced by create(), and update().

221  {
223  $lng = $this->lng;
224 
225  $is_edit = ($a_cat_obj !== null);
226 
227  $form = $this->initForm($a_cat_obj);
228  if ($form->checkInput()) {
229  if (!$is_edit) {
230  $a_cat_obj = new ilExcCriteriaCatalogue();
231  $a_cat_obj->setParent($this->exc_obj->getId());
232  }
233 
234  $a_cat_obj->setTitle($form->getInput("title"));
235 
236  if (!$is_edit) {
237  $a_cat_obj->save();
238  } else {
239  $a_cat_obj->update();
240  }
241 
242  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
243  $ilCtrl->redirect($this, "view");
244  }
245 
246  $form->setValuesByPost();
247  $this->{$is_edit ? "edit" : "add"}($form);
248  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
Class ilExcCriteriaCatalogue.
initForm(ilExcCriteriaCatalogue $a_cat_obj=null)
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilExcCriteriaCatalogueGUI::initForm ( ilExcCriteriaCatalogue  $a_cat_obj = null)
protected

Definition at line 176 of file class.ilExcCriteriaCatalogueGUI.php.

References $ctrl, $form, $ilCtrl, $lng, and $title.

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

177  {
179  $lng = $this->lng;
180 
181  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
182  $form = new ilPropertyFormGUI();
183 
184  $is_edit = ($a_cat_obj !== null);
185  if (!$is_edit) {
186  $form->setFormAction($ilCtrl->getFormAction($this, "create"));
187  $form->setTitle($lng->txt("exc_criteria_catalogue_create_form"));
188  $form->addCommandButton("create", $lng->txt("create"));
189  } else {
190  $form->setFormAction($ilCtrl->getFormAction($this, "update"));
191  $form->setTitle($lng->txt("exc_criteria_catalogue_update_form"));
192  $form->addCommandButton("update", $lng->txt("save"));
193  }
194 
195  $form->addCommandButton("view", $lng->txt("cancel"));
196 
197  $title = new ilTextInputGUI($lng->txt("title"), "title");
198  $title->setRequired(true);
199  $form->addItem($title);
200 
201  return $form;
202  }
This class represents a property form user interface.
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
This class represents a text property in a property form.
+ Here is the caller graph for this function:

◆ saveOrder()

ilExcCriteriaCatalogueGUI::saveOrder ( )
protected

Definition at line 102 of file class.ilExcCriteriaCatalogueGUI.php.

References $_POST, $ctrl, $id, $ilCtrl, $lng, ilExcCriteriaCatalogue\getInstancesByParentId(), and ilUtil\sendSuccess().

103  {
105  $lng = $this->lng;
106 
107  $all_cat = ilExcCriteriaCatalogue::getInstancesByParentId($this->exc_obj->getId());
108 
109  $pos = 0;
110  asort($_POST["pos"]);
111  foreach (array_keys($_POST["pos"]) as $id) {
112  if (array_key_exists($id, $all_cat)) {
113  $pos += 10;
114  $all_cat[$id]->setPosition($pos);
115  $all_cat[$id]->update();
116  }
117  }
118 
119  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
120  $ilCtrl->redirect($this, "view");
121  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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()

ilExcCriteriaCatalogueGUI::update ( )
protected

Definition at line 285 of file class.ilExcCriteriaCatalogueGUI.php.

References getCurrentCatalogue(), and importForm().

286  {
287  $cat_obj = $this->getCurrentCatalogue();
288  $this->importForm($cat_obj);
289  }
importForm(ilExcCriteriaCatalogue $a_cat_obj=null)
+ Here is the call graph for this function:

◆ view()

ilExcCriteriaCatalogueGUI::view ( )
protected

Definition at line 85 of file class.ilExcCriteriaCatalogueGUI.php.

References $ctrl, $ilCtrl, $lng, $tbl, $toolbar, and $tpl.

86  {
87  $ilToolbar = $this->toolbar;
89  $lng = $this->lng;
90  $tpl = $this->tpl;
91 
92  $ilToolbar->addButton(
93  $lng->txt("exc_add_criteria_catalogue"),
94  $ilCtrl->getLinkTarget($this, "add")
95  );
96 
97  include_once "Modules/Exercise/classes/class.ilExcCriteriaCatalogueTableGUI.php";
98  $tbl = new ilExcCriteriaCatalogueTableGUI($this, "view", $this->exc_obj->getId());
99  $tpl->setContent($tbl->getHTML());
100  }
$tbl
Definition: example_048.php:81
global $ilCtrl
Definition: ilias.php:18
Class ilExcCriteriaCatalogueTableGUI.

Field Documentation

◆ $ctrl

ilExcCriteriaCatalogueGUI::$ctrl
protected

◆ $exc_obj

ilExcCriteriaCatalogueGUI::$exc_obj
protected

Definition at line 41 of file class.ilExcCriteriaCatalogueGUI.php.

◆ $lng

ilExcCriteriaCatalogueGUI::$lng
protected

◆ $tabs

ilExcCriteriaCatalogueGUI::$tabs
protected

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

Referenced by executeCommand().

◆ $toolbar

ilExcCriteriaCatalogueGUI::$toolbar
protected

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

Referenced by view().

◆ $tpl

ilExcCriteriaCatalogueGUI::$tpl
protected

Definition at line 39 of file class.ilExcCriteriaCatalogueGUI.php.

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


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