ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilRatingCategoryGUI Class Reference

Class ilRatingCategoryGUI. More...

+ Collaboration diagram for ilRatingCategoryGUI:

Public Member Functions

 __construct (int $a_parent_id, $a_export_callback=null, string $a_export_subobj_title=null)
 ilRatingCategoryGUI constructor. More...
 
 executeCommand ()
 execute command More...
 

Protected Member Functions

 listCategories ()
 
 initCategoryForm (int $a_id=null)
 
 add (ilPropertyFormGUI $a_form=null)
 
 save ()
 
 edit (ilPropertyFormGUI $a_form=null)
 
 update ()
 
 updateOrder ()
 
 confirmDelete ()
 
 delete ()
 
 export ()
 

Protected Attributes

ilLanguage $lng
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilToolbarGUI $toolbar
 
int $parent_id
 
 $export_callback
 
string $export_subobj_title = null
 
int $requested_cat_id
 
RequestInterface $request
 
int $cat_id
 

Detailed Description

Class ilRatingCategoryGUI.

User interface class for rating categories.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 26 of file class.ilRatingCategoryGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilRatingCategoryGUI::__construct ( int  $a_parent_id,
  $a_export_callback = null,
string  $a_export_subobj_title = null 
)

ilRatingCategoryGUI constructor.

Parameters
int$a_parent_id
?mixed$a_export_callback
?string$a_export_subobj_title

Definition at line 45 of file class.ilRatingCategoryGUI.php.

References $DIC, $params, $parent_id, ILIAS\Repository\ctrl(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilLanguage\loadLanguageModule(), and ILIAS\Repository\toolbar().

49  {
50  global $DIC;
51 
52  $this->lng = $DIC->language();
53  $this->ctrl = $DIC->ctrl();
54  $this->tpl = $DIC["tpl"];
55  $this->toolbar = $DIC->toolbar();
56  $this->request = $DIC->http()->request();
57  $lng = $DIC->language();
58 
59  $this->parent_id = $a_parent_id;
60  $this->export_callback = $a_export_callback;
61  $this->export_subobj_title = $a_export_subobj_title;
62 
63  $lng->loadLanguageModule("rating");
64 
65  $params = $this->request->getQueryParams();
66  $body = $this->request->getParsedBody();
67  $this->requested_cat_id = (int) ($body["cat_id"] ?? ($params["cat_id"] ?? 0));
68 
69  if ($this->requested_cat_id) {
70  $cat = new ilRatingCategory($this->requested_cat_id);
71  if ($cat->getParentId() == $this->parent_id) {
72  $this->cat_id = $cat->getId();
73  }
74  }
75  }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
loadLanguageModule(string $a_module)
Load language module.
global $DIC
Definition: feed.php:28
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:

Member Function Documentation

◆ add()

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

Definition at line 156 of file class.ilRatingCategoryGUI.php.

References $tpl, initCategoryForm(), and ilGlobalTemplateInterface\setContent().

Referenced by save(), and update().

156  : void
157  {
158  $tpl = $this->tpl;
159 
160  if (!$a_form) {
161  $a_form = $this->initCategoryForm();
162  }
163 
164  $tpl->setContent($a_form->getHTML());
165  }
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDelete()

ilRatingCategoryGUI::confirmDelete ( )
protected

Definition at line 245 of file class.ilRatingCategoryGUI.php.

References $ctrl, $lng, $tpl, listCategories(), ilGlobalTemplateInterface\setContent(), and ilLanguage\txt().

245  : void
246  {
247  $tpl = $this->tpl;
248  $ilCtrl = $this->ctrl;
249  $lng = $this->lng;
250 
251  if (!$this->cat_id) {
252  $this->listCategories();
253  return;
254  }
255 
256  $cgui = new ilConfirmationGUI();
257  $cgui->setHeaderText($lng->txt("rating_category_delete_sure") . "<br/>" .
258  $lng->txt("info_delete_warning_no_trash"));
259 
260  $cgui->setFormAction($ilCtrl->getFormAction($this));
261  $cgui->setCancel($lng->txt("cancel"), "listCategories");
262  $cgui->setConfirm($lng->txt("confirm"), "delete");
263 
264  $cat = new ilRatingCategory($this->cat_id);
265  $cgui->addItem("cat_id", $this->cat_id, $cat->getTitle());
266 
267  $tpl->setContent($cgui->getHTML());
268  }
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...
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.
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:

◆ delete()

ilRatingCategoryGUI::delete ( )
protected

Definition at line 270 of file class.ilRatingCategoryGUI.php.

References $ctrl, $lng, ilRatingCategory\delete(), ilRatingCategory\getAllForObject(), and ilLanguage\txt().

270  : void
271  {
272  $ilCtrl = $this->ctrl;
273  $lng = $this->lng;
274 
275  if ($this->cat_id) {
276  ilRatingCategory::delete($this->cat_id);
277  $this->tpl->setOnScreenMessage('success', $lng->txt("rating_category_deleted"), true);
278  }
279 
280  // fix order
281  $cnt = 0;
282  foreach (ilRatingCategory::getAllForObject($this->parent_id) as $item) {
283  $cnt += 10;
284 
285  $cat = new ilRatingCategory($item["id"]);
286  $cat->setPosition($cnt);
287  $cat->update();
288  }
289 
290  $ilCtrl->redirect($this, "listCategories");
291  }
static delete(int $a_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...
static getAllForObject(int $a_parent_obj_id)
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:

◆ edit()

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

Definition at line 188 of file class.ilRatingCategoryGUI.php.

References $ctrl, $tpl, initCategoryForm(), ilGlobalTemplateInterface\setContent(), and ilCtrl\setParameter().

188  : void
189  {
190  $tpl = $this->tpl;
191  $ilCtrl = $this->ctrl;
192 
193  $ilCtrl->setParameter($this, "cat_id", $this->cat_id);
194 
195  if (!$a_form) {
196  $a_form = $this->initCategoryForm($this->cat_id);
197  }
198 
199  $tpl->setContent($a_form->getHTML());
200  }
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
+ Here is the call graph for this function:

◆ executeCommand()

ilRatingCategoryGUI::executeCommand ( )

execute command

Definition at line 80 of file class.ilRatingCategoryGUI.php.

References $ctrl, and ilCtrl\getNextClass().

80  : void
81  {
82  $ilCtrl = $this->ctrl;
83 
84  $next_class = $ilCtrl->getNextClass($this);
85  $cmd = $ilCtrl->getCmd("listCategories");
86 
87  switch ($next_class) {
88  default:
89  $this->$cmd();
90  break;
91  }
92  }
getNextClass($a_gui_class=null)
+ Here is the call graph for this function:

◆ export()

ilRatingCategoryGUI::export ( )
protected

Definition at line 293 of file class.ilRatingCategoryGUI.php.

References $lng, ilObject\_lookupTitle(), ilObject\_lookupType(), ilRatingCategory\getAllForObject(), ilRating\getExportData(), IL_CAL_UNIX, and ilLanguage\txt().

293  : void
294  {
295  $lng = $this->lng;
296 
297  $excel = new ilExcel();
298  $excel->addSheet($lng->txt("rating_categories"));
299 
300  // restrict to currently active (probably not needed - see delete())
301  $active = array();
302  foreach (ilRatingCategory::getAllForObject($this->parent_id) as $item) {
303  $active[$item["id"]] = $item["title"];
304  }
305 
306  // title row
307  $row = 1;
308  $excel->setCell($row, 0, $this->export_subobj_title . " (" . $lng->txt("id") . ")");
309  $excel->setCell($row, 1, $this->export_subobj_title);
310  $excel->setCell($row, 2, $lng->txt("rating_export_category") . " (" . $lng->txt("id") . ")");
311  $excel->setCell($row, 3, $lng->txt("rating_export_category"));
312  $excel->setCell($row, 4, $lng->txt("rating_export_date"));
313  $excel->setCell($row, 5, $lng->txt("rating_export_rating"));
314  $excel->setBold("A1:F1");
315 
316  // content rows
317  foreach (ilRating::getExportData($this->parent_id, ilObject::_lookupType($this->parent_id), array_keys($active)) as $item) {
318  // overall rating?
319  if (!$item["sub_obj_id"]) {
320  continue;
321  }
322 
323  $row++;
324 
325  $sub_obj_title = $item["sub_obj_type"];
326  if ($this->export_callback) {
327  $sub_obj_title = call_user_func($this->export_callback, $item["sub_obj_id"], $item["sub_obj_type"]);
328  }
329 
330  $excel->setCell($row, 0, (int) $item["sub_obj_id"]);
331  $excel->setCell($row, 1, $sub_obj_title);
332  $excel->setCell($row, 2, (int) $item["category_id"]);
333  $excel->setCell($row, 3, $active[$item["category_id"]] ?? "");
334  $excel->setCell($row, 4, new ilDateTime($item["tstamp"] ?? null, IL_CAL_UNIX));
335  $excel->setCell($row, 5, $item["rating"] ?? "");
336  }
337 
338  $excel->sendToClient(ilObject::_lookupTitle($this->parent_id));
339  }
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 getExportData(int $a_obj_id, string $a_obj_type, array $a_category_ids=null)
Get export data.
const IL_CAL_UNIX
static _lookupTitle(int $obj_id)
static getAllForObject(int $a_parent_obj_id)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ initCategoryForm()

ilRatingCategoryGUI::initCategoryForm ( int  $a_id = null)
protected

Definition at line 118 of file class.ilRatingCategoryGUI.php.

References $ctrl, $lng, ilObject\LONG_DESC_LENGTH, ilTextAreaInputGUI\setCols(), and ilLanguage\txt().

Referenced by add(), edit(), save(), and update().

119  {
120  $lng = $this->lng;
121  $ilCtrl = $this->ctrl;
122 
123  $form = new ilPropertyFormGUI();
124  $form->setTarget("_top");
125  $form->setFormAction($ilCtrl->getFormAction($this, "save"));
126  $form->setTitle($lng->txt("rating_category_" . ($a_id ? "edit" : "create")));
127 
128  // title
129  $ti = new ilTextInputGUI($lng->txt("title"), "title");
130  $ti->setMaxLength(128);
131  $ti->setSize(40);
132  $ti->setRequired(true);
133  $form->addItem($ti);
134 
135  // description
136  $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
137  $ta->setCols(40);
138  $ta->setRows(2);
139  $ta->setMaxNumOfChars(ilObject::LONG_DESC_LENGTH);
140  $form->addItem($ta);
141 
142  if (!$a_id) {
143  $form->addCommandButton("save", $lng->txt("rating_category_add"));
144  } else {
145  $cat = new ilRatingCategory($a_id);
146  $ti->setValue($cat->getTitle());
147  $ta->setValue($cat->getDescription());
148 
149  $form->addCommandButton("update", $lng->txt("rating_category_update"));
150  }
151  $form->addCommandButton("listCategories", $lng->txt("cancel"));
152 
153  return $form;
154  }
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...
const LONG_DESC_LENGTH
This class represents a text area property in a property form.
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:
+ Here is the caller graph for this function:

◆ listCategories()

ilRatingCategoryGUI::listCategories ( )
protected

Definition at line 94 of file class.ilRatingCategoryGUI.php.

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

Referenced by confirmDelete().

94  : void
95  {
96  $tpl = $this->tpl;
97  $ilToolbar = $this->toolbar;
98  $lng = $this->lng;
99  $ilCtrl = $this->ctrl;
100 
101  $ilToolbar->addButton(
102  $lng->txt("rating_add_category"),
103  $ilCtrl->getLinkTarget($this, "add")
104  );
105 
106  $ilToolbar->addSeparator();
107 
108  $ilToolbar->addButton(
109  $lng->txt("export"),
110  $ilCtrl->getLinkTarget($this, "export")
111  );
112 
113  $table = new ilRatingCategoryTableGUI($this, "listCategories", $this->parent_id);
114  $tpl->setContent($table->getHTML());
115  }
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...
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.
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:
+ Here is the caller graph for this function:

◆ save()

ilRatingCategoryGUI::save ( )
protected

Definition at line 167 of file class.ilRatingCategoryGUI.php.

References $ctrl, $lng, add(), initCategoryForm(), and ilLanguage\txt().

167  : void
168  {
169  $ilCtrl = $this->ctrl;
170  $lng = $this->lng;
171 
172  $form = $this->initCategoryForm();
173  if ($form->checkInput()) {
174  $cat = new ilRatingCategory();
175  $cat->setParentId($this->parent_id);
176  $cat->setTitle($form->getInput("title"));
177  $cat->setDescription($form->getInput("desc"));
178  $cat->save();
179 
180  $this->tpl->setOnScreenMessage('success', $lng->txt("rating_category_created"));
181  $ilCtrl->redirect($this, "listCategories");
182  }
183 
184  $form->setValuesByPost();
185  $this->add($form);
186  }
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...
add(ilPropertyFormGUI $a_form=null)
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:

◆ update()

ilRatingCategoryGUI::update ( )
protected

Definition at line 202 of file class.ilRatingCategoryGUI.php.

References $ctrl, $lng, add(), initCategoryForm(), and ilLanguage\txt().

202  : void
203  {
204  $ilCtrl = $this->ctrl;
205  $lng = $this->lng;
206 
207  $form = $this->initCategoryForm($this->cat_id);
208  if ($form->checkInput()) {
209  $cat = new ilRatingCategory($this->cat_id);
210  $cat->setTitle($form->getInput("title"));
211  $cat->setDescription($form->getInput("desc"));
212  $cat->update();
213 
214  $this->tpl->setOnScreenMessage('success', $lng->txt("rating_category_updated"));
215  $ilCtrl->redirect($this, "listCategories");
216  }
217 
218  $form->setValuesByPost();
219  $this->add($form);
220  }
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...
add(ilPropertyFormGUI $a_form=null)
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:

◆ updateOrder()

ilRatingCategoryGUI::updateOrder ( )
protected

Definition at line 222 of file class.ilRatingCategoryGUI.php.

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

222  : void
223  {
224  $ilCtrl = $this->ctrl;
225  $lng = $this->lng;
226 
227  $body = $this->request->getParsedBody();
228  $order = $body["pos"];
229  asort($order);
230 
231  $cnt = 0;
232  foreach ($order as $id => $pos) {
233  $cat = new ilRatingCategory($id);
234  if ($cat->getParentId() == $this->parent_id) {
235  $cnt += 10;
236  $cat->setPosition($cnt);
237  $cat->update();
238  }
239  }
240 
241  $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
242  $ilCtrl->redirect($this, "listCategories");
243  }
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...
$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...
+ Here is the call graph for this function:

Field Documentation

◆ $cat_id

int ilRatingCategoryGUI::$cat_id
protected

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

◆ $ctrl

ilCtrl ilRatingCategoryGUI::$ctrl
protected

◆ $export_callback

ilRatingCategoryGUI::$export_callback
protected

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

◆ $export_subobj_title

string ilRatingCategoryGUI::$export_subobj_title = null
protected

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

◆ $lng

ilLanguage ilRatingCategoryGUI::$lng
protected

◆ $parent_id

int ilRatingCategoryGUI::$parent_id
protected

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

Referenced by __construct(), and updateOrder().

◆ $request

RequestInterface ilRatingCategoryGUI::$request
protected

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

◆ $requested_cat_id

int ilRatingCategoryGUI::$requested_cat_id
protected

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

◆ $toolbar

ilToolbarGUI ilRatingCategoryGUI::$toolbar
protected

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

Referenced by listCategories().

◆ $tpl

ilGlobalTemplateInterface ilRatingCategoryGUI::$tpl
protected

Definition at line 30 of file class.ilRatingCategoryGUI.php.

Referenced by add(), confirmDelete(), edit(), and listCategories().


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