4 include_once(
"./Services/Rating/classes/class.ilRatingCategory.php");
20 function __construct($a_parent_id, $a_export_callback = null, $a_export_subobj_title = null)
24 $this->parent_id = (int)$a_parent_id;
25 $this->export_callback = $a_export_callback;
26 $this->export_subobj_title = $a_export_subobj_title;
28 $lng->loadLanguageModule(
"rating");
35 $this->cat_id = $cat->getId();
47 $next_class = $ilCtrl->getNextClass($this);
48 $cmd = $ilCtrl->getCmd(
"listCategories");
62 $ilToolbar->addButton($lng->txt(
"rating_add_category"),
63 $ilCtrl->getLinkTarget($this,
"add"));
65 $ilToolbar->addSeparator();
67 $ilToolbar->addButton($lng->txt(
"export"),
68 $ilCtrl->getLinkTarget($this,
"export"));
70 include_once
"Services/Rating/classes/class.ilRatingCategoryTableGUI.php";
72 $tpl->setContent($table->getHTML());
80 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
82 $form->setTarget(
"_top");
83 $form->setFormAction($ilCtrl->getFormAction($this,
"save"));
84 $form->setTitle($lng->txt(
"rating_category_".($a_id ?
"edit" :
"create")));
90 $ti->setRequired(
true);
101 $form->addCommandButton(
"save", $lng->txt(
"rating_category_add"));
106 $ti->setValue($cat->getTitle());
107 $ta->setValue($cat->getDescription());
109 $form->addCommandButton(
"update", $lng->txt(
"rating_category_update"));
111 $form->addCommandButton(
"listCategories", $lng->txt(
"cancel"));
116 protected function add($a_form = null)
125 $tpl->setContent($a_form->getHTML());
133 if($form->checkInput())
135 include_once
"Services/Rating/classes/class.ilRatingCategory.php";
137 $cat->setParentId($this->parent_id);
138 $cat->setTitle($form->getInput(
"title"));
139 $cat->setDescription($form->getInput(
"desc"));
143 $ilCtrl->redirect($this,
"listCategories");
146 $form->setValuesByPost();
150 protected function edit($a_form = null)
154 $ilCtrl->setParameter($this,
"cat_id", $this->cat_id);
161 $tpl->setContent($a_form->getHTML());
169 if($form->checkInput())
171 include_once
"Services/Rating/classes/class.ilRatingCategory.php";
173 $cat->setTitle($form->getInput(
"title"));
174 $cat->setDescription($form->getInput(
"desc"));
178 $ilCtrl->redirect($this,
"listCategories");
181 $form->setValuesByPost();
193 foreach($order as $id => $pos)
199 $cat->setPosition($cnt);
205 $ilCtrl->redirect($this,
"listCategories");
217 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
219 $cgui->setHeaderText($lng->txt(
"rating_category_delete_sure").
"<br/>".
220 $lng->txt(
"info_delete_warning_no_trash"));
222 $cgui->setFormAction($ilCtrl->getFormAction($this));
223 $cgui->setCancel($lng->txt(
"cancel"),
"listCategories");
224 $cgui->setConfirm($lng->txt(
"confirm"),
"delete");
227 $cgui->addItem(
"cat_id", $this->cat_id, $cat->getTitle());
229 $tpl->setContent($cgui->getHTML());
232 protected function delete()
249 $cat->setPosition($cnt);
253 $ilCtrl->redirect($this,
"listCategories");
261 include_once
"./Services/Excel/classes/class.ilExcelUtils.php";
262 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
269 $active[$item[
"id"]] = $item[
"title"];
273 $workbook = $adapter->getWorkbook();
274 $worksheet = $workbook->addWorksheet();
280 $worksheet->write(
$row, 0, $this->export_subobj_title.
" (".$lng->txt(
"id").
")");
281 $worksheet->write(
$row, 1, $this->export_subobj_title);
282 $worksheet->write(
$row, 2, $lng->txt(
"rating_export_category").
" (".$lng->txt(
"id").
")");
283 $worksheet->write(
$row, 3, $lng->txt(
"rating_export_category"));
284 $worksheet->write(
$row, 4, $lng->txt(
"rating_export_date"));
285 $worksheet->write(
$row, 5, $lng->txt(
"rating_export_rating"));
292 $sub_obj_title = $item[
"sub_obj_type"];
293 if($this->export_callback)
295 $sub_obj_title = call_user_func($this->export_callback, $item[
"sub_obj_id"], $item[
"sub_obj_type"]);
298 $worksheet->write(
$row, 0, $item[
"sub_obj_id"]);
299 $worksheet->write(
$row, 1, $sub_obj_title);
300 $worksheet->write(
$row, 2, $item[
"category_id"]);
301 $worksheet->write(
$row, 3, $active[$item[
"category_id"]]);
302 $worksheet->write(
$row, 4, date(
"Y-m-d H:i:s", $item[
"tstamp"]));
303 $worksheet->write(
$row, 5, $item[
"rating"]);