ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilRatingCategoryGUI Class Reference

Class ilRatingCategoryGUI. More...

+ Inheritance diagram for ilRatingCategoryGUI:
+ 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...
 
 handleTableActions ()
 
 getRatingCategoryOrderingTable ()
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. 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

readonly 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
 

Private Attributes

readonly UIFactory $ui_factory
 
readonly UIRenderer $ui_renderer
 
readonly Refinery $refinery
 
readonly HttpServices $http
 

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 32 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
?mixed$a_export_callback
?string$a_export_subobj_title

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

58 {
59 global $DIC;
60
61 $this->tpl = $DIC["tpl"];
62 $this->http = $DIC->http();
63 $this->ctrl = $DIC->ctrl();
64 $this->lng = $DIC->language();
65 $this->toolbar = $DIC->toolbar();
66 $this->refinery = $DIC->refinery();
67 $this->request = $DIC->http()->request();
68 $this->ui_factory = $DIC->ui()->factory();
69 $this->ui_renderer = $DIC->ui()->renderer();
70
71 $lng = $DIC->language();
72
73 $this->parent_id = $a_parent_id;
74 $this->export_callback = $a_export_callback;
75 $this->export_subobj_title = $a_export_subobj_title;
76
77 $lng->loadLanguageModule("rating");
78
79 $params = $this->request->getQueryParams();
80 $body = $this->request->getParsedBody();
81 $this->requested_cat_id = (int) ($body["cat_id"] ?? ($params["cat_id"] ?? 0));
82
83 if ($this->requested_cat_id) {
84 $cat = new ilRatingCategory($this->requested_cat_id);
85 if ($cat->getParentId() === $this->parent_id) {
86 $this->cat_id = $cat->getId();
87 }
88 }
89 }
loadLanguageModule(string $a_module)
Load language module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

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

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

198 : void
199 {
201
202 if (!$a_form) {
203 $a_form = $this->initCategoryForm();
204 }
205
206 $tpl->setContent($a_form->getHTML());
207 }
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.

References $tpl, initCategoryForm(), and ILIAS\UICore\GlobalTemplate\setContent().

Referenced by save(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDelete()

ilRatingCategoryGUI::confirmDelete ( )
protected

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

293 : void
294 {
296 $ilCtrl = $this->ctrl;
298
299 $cat_id = $this->http->wrapper()->query()->has('rating_category_ordering_rating_ids') ?
300 $this->http->wrapper()->query()->retrieve(
301 'rating_category_ordering_rating_ids',
302 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
303 ) : 0;
304 $cat_id = $cat_id[0] ?? 0;
305
306 if (!$cat_id) {
307 $this->listCategories();
308
309 return;
310 }
311
312 $cgui = new ilConfirmationGUI();
313 $cgui->setHeaderText($lng->txt('rating_category_delete_sure') . '<br/>' .
314 $lng->txt('info_delete_warning_no_trash'));
315
316 $cgui->setFormAction($ilCtrl->getFormAction($this));
317 $cgui->setCancel($lng->txt('cancel'), 'listCategories');
318 $cgui->setConfirm($lng->txt('confirm'), 'delete');
319
320 $cat = new ilRatingCategory($cat_id);
321 $cgui->addItem('cat_id', $cat_id, $cat->getTitle());
322
323 $tpl->setContent($cgui->getHTML());
324 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...

References $cat_id, $ctrl, $lng, $tpl, ILIAS\FileDelivery\http(), listCategories(), ILIAS\Repository\refinery(), ILIAS\UICore\GlobalTemplate\setContent(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ delete()

ilRatingCategoryGUI::delete ( )
protected

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

326 : void
327 {
328 $ilCtrl = $this->ctrl;
330
331 if ($this->cat_id) {
332 ilRatingCategory::delete($this->cat_id);
333 $this->tpl->setOnScreenMessage('success', $lng->txt("rating_category_deleted"), true);
334 }
335
336 // fix order
337 $cnt = 0;
338 foreach (ilRatingCategory::getAllForObject($this->parent_id) as $item) {
339 $cnt += 10;
340
341 $cat = new ilRatingCategory($item["id"]);
342 $cat->setPosition($cnt);
343 $cat->update();
344 }
345
346 $ilCtrl->redirect($this, "listCategories");
347 }
static getAllForObject(int $a_parent_obj_id)
static delete(int $a_id)

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

+ Here is the call graph for this function:

◆ edit()

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

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

230 : void
231 {
233 $ilCtrl = $this->ctrl;
234
235 $cat_id = $this->http->wrapper()->query()->has('rating_category_ordering_rating_ids') ?
236 $this->http->wrapper()->query()->retrieve(
237 'rating_category_ordering_rating_ids',
238 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
239 ) : 0;
240 $cat_id = $cat_id[0] ?? 0;
241
242 $ilCtrl->setParameter($this, 'cat_id', $cat_id);
243
244 if (!$a_form) {
245 $a_form = $this->initCategoryForm($cat_id);
246 }
247
248 $tpl->setContent($a_form->getHTML());
249 }

References $cat_id, $ctrl, $tpl, ILIAS\FileDelivery\http(), initCategoryForm(), ILIAS\Repository\refinery(), and ILIAS\UICore\GlobalTemplate\setContent().

+ Here is the call graph for this function:

◆ executeCommand()

ilRatingCategoryGUI::executeCommand ( )

execute command

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

94 : void
95 {
96 $ilCtrl = $this->ctrl;
97
98 $next_class = $ilCtrl->getNextClass($this);
99 $cmd = $ilCtrl->getCmd('listCategories');
100
101 switch ($next_class) {
102 default:
103 $this->$cmd();
104 break;
105 }
106 }
getNextClass($a_gui_class=null)
@inheritDoc

References $ctrl, and ilCtrl\getNextClass().

+ Here is the call graph for this function:

◆ export()

ilRatingCategoryGUI::export ( )
protected

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

349 : void
350 {
352
353 $excel = new ilExcel();
354 $excel->addSheet($lng->txt("rating_categories"));
355
356 // restrict to currently active (probably not needed - see delete())
357 $active = array();
358 foreach (ilRatingCategory::getAllForObject($this->parent_id) as $item) {
359 $active[$item["id"]] = $item["title"];
360 }
361
362 // title row
363 $row = 1;
364 $excel->setCell($row, 0, $this->export_subobj_title . " (" . $lng->txt("id") . ")");
365 $excel->setCell($row, 1, $this->export_subobj_title);
366 $excel->setCell($row, 2, $lng->txt("rating_export_category") . " (" . $lng->txt("id") . ")");
367 $excel->setCell($row, 3, $lng->txt("rating_export_category"));
368 $excel->setCell($row, 4, $lng->txt("rating_export_date"));
369 $excel->setCell($row, 5, $lng->txt("rating_export_rating"));
370 $excel->setBold("A1:F1");
371
372 // content rows
373 foreach (ilRating::getExportData($this->parent_id, ilObject::_lookupType($this->parent_id), array_keys($active)) as $item) {
374 // overall rating?
375 if (!$item["sub_obj_id"]) {
376 continue;
377 }
378
379 $row++;
380
381 $sub_obj_title = $item["sub_obj_type"];
382 if ($this->export_callback) {
383 $sub_obj_title = call_user_func($this->export_callback, $item["sub_obj_id"], $item["sub_obj_type"]);
384 }
385
386 $excel->setCell($row, 0, (int) $item["sub_obj_id"]);
387 $excel->setCell($row, 1, $sub_obj_title);
388 $excel->setCell($row, 2, (int) $item["category_id"]);
389 $excel->setCell($row, 3, $active[$item["category_id"]] ?? "");
390 $excel->setCell($row, 4, new ilDateTime($item["tstamp"] ?? null, IL_CAL_UNIX));
391 $excel->setCell($row, 5, $item["rating"] ?? "");
392 }
393
394 $excel->sendToClient(ilObject::_lookupTitle($this->parent_id));
395 }
const IL_CAL_UNIX
@classDescription Date and time handling
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
static getExportData(int $a_obj_id, string $a_obj_type, ?array $a_category_ids=null)
Get export data.

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

+ Here is the call graph for this function:

◆ getRatingCategoryOrderingTable()

ilRatingCategoryGUI::getRatingCategoryOrderingTable ( )

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

148 {
150 $this->parent_id,
151 $this->ui_factory,
152 $this->lng,
153 $this->ctrl,
154 new DataFactory(),
155 $this->http->request()
156 )
157 ;
158 }

References ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

Referenced by updateOrder().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSafePostCommands()

ilRatingCategoryGUI::getSafePostCommands ( )

This method must return a list of safe POST commands.

Safe post commands returned by this method will no longer be CSRF protected and will NOT be appended by an ilCtrlToken.

Returns
string[]

Implements ilCtrlSecurityInterface.

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

402 : array
403 {
404 return [];
405 }

◆ getUnsafeGetCommands()

ilRatingCategoryGUI::getUnsafeGetCommands ( )

This method must return a list of unsafe GET commands.

Unsafe get commands returned by this method will now be CSRF protected, which means an ilCtrlToken is appended each time a link-target is generated to the class implementing this interface with a command from that list.

Tokens will be validated in

See also
ilCtrlInterface::getCmd(), whereas the fallback command will be used if the CSRF validation fails.
Returns
string[]

Implements ilCtrlSecurityInterface.

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

397 : array
398 {
399 return ['handleTableActions'];
400 }

◆ handleTableActions()

ilRatingCategoryGUI::handleTableActions ( )

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

108 : void
109 {
110 $cmd = $this->http->wrapper()->query()->retrieve(
111 'rating_category_ordering_table_action',
112 $this->refinery->byTrying(
113 [
114 $this->refinery->kindlyTo()->string(),
115 $this->refinery->always('')
116 ]
117 )
118 );
119
120 if ($cmd !== '') {
121 $this->$cmd();
122 }
123 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ initCategoryForm()

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

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

161 {
163 $ilCtrl = $this->ctrl;
164
165 $form = new ilPropertyFormGUI();
166 $form->setTarget("_top");
167 $form->setFormAction($ilCtrl->getFormAction($this, "save"));
168 $form->setTitle($lng->txt("rating_category_" . ($a_id ? "edit" : "create")));
169
170 // title
171 $ti = new ilTextInputGUI($lng->txt("title"), "title");
172 $ti->setMaxLength(128);
173 $ti->setSize(40);
174 $ti->setRequired(true);
175 $form->addItem($ti);
176
177 // description
178 $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
179 $ta->setCols(40);
180 $ta->setRows(2);
181 $ta->setMaxNumOfChars(ilObject::LONG_DESC_LENGTH);
182 $form->addItem($ta);
183
184 if (!$a_id) {
185 $form->addCommandButton("save", $lng->txt("rating_category_add"));
186 } else {
187 $cat = new ilRatingCategory($a_id);
188 $ti->setValue($cat->getTitle());
189 $ta->setValue($cat->getDescription());
190
191 $form->addCommandButton("update", $lng->txt("rating_category_update"));
192 }
193 $form->addCommandButton("listCategories", $lng->txt("cancel"));
194
195 return $form;
196 }
const LONG_DESC_LENGTH
This class represents a property form user interface.
This class represents a text area property in a property form.
This class represents a text property in a property form.

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listCategories()

ilRatingCategoryGUI::listCategories ( )
protected

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

125 : void
126 {
128 $ilToolbar = $this->toolbar;
130 $ilCtrl = $this->ctrl;
131
132 $ilToolbar->addButton(
133 $lng->txt("rating_add_category"),
134 $ilCtrl->getLinkTarget($this, "add")
135 );
136
137 $ilToolbar->addSeparator();
138
139 $ilToolbar->addButton(
140 $lng->txt("export"),
141 $ilCtrl->getLinkTarget($this, "export")
142 );
143
144 $tpl->setContent($this->ui_renderer->render($this->getRatingCategoryOrderingTable()->getComponent()));
145 }

References $ctrl, $lng, $toolbar, $tpl, ILIAS\UICore\GlobalTemplate\setContent(), and ilLanguage\txt().

Referenced by confirmDelete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilRatingCategoryGUI::save ( )
protected

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

209 : void
210 {
211 $ilCtrl = $this->ctrl;
213
214 $form = $this->initCategoryForm();
215 if ($form->checkInput()) {
216 $cat = new ilRatingCategory();
217 $cat->setParentId($this->parent_id);
218 $cat->setTitle($form->getInput("title"));
219 $cat->setDescription($form->getInput("desc"));
220 $cat->save();
221
222 $this->tpl->setOnScreenMessage('success', $lng->txt("rating_category_created"));
223 $ilCtrl->redirect($this, "listCategories");
224 }
225
226 $form->setValuesByPost();
227 $this->add($form);
228 }
add(?ilPropertyFormGUI $a_form=null)

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

+ Here is the call graph for this function:

◆ update()

ilRatingCategoryGUI::update ( )
protected

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

251 : void
252 {
253 $ilCtrl = $this->ctrl;
255
256 $form = $this->initCategoryForm($this->cat_id);
257 if ($form->checkInput()) {
258 $cat = new ilRatingCategory($this->cat_id);
259 $cat->setTitle($form->getInput("title"));
260 $cat->setDescription($form->getInput("desc"));
261 $cat->update();
262
263 $this->tpl->setOnScreenMessage('success', $lng->txt("rating_category_updated"));
264 $ilCtrl->redirect($this, "listCategories");
265 }
266
267 $form->setValuesByPost();
268 $this->add($form);
269 }

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

+ Here is the call graph for this function:

◆ updateOrder()

ilRatingCategoryGUI::updateOrder ( )
protected

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

271 : void
272 {
273 $ilCtrl = $this->ctrl;
275
276 $table = $this->getRatingCategoryOrderingTable();
277 $data = $table->getComponent()->getData();
278
279 $cnt = 0;
280 foreach ($data as $id) {
281 $cat = new ilRatingCategory($id);
282 if ($cat->getParentId() === $this->parent_id) {
283 $cnt += 10;
284 $cat->setPosition($cnt);
285 $cat->update();
286 }
287 }
288
289 $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
290 $ilCtrl->redirect($this, 'listCategories');
291 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

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

+ Here is the call graph for this function:

Field Documentation

◆ $cat_id

int ilRatingCategoryGUI::$cat_id
protected

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

Referenced by confirmDelete(), and edit().

◆ $ctrl

ilCtrl ilRatingCategoryGUI::$ctrl
protected

◆ $export_callback

ilRatingCategoryGUI::$export_callback
protected

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

◆ $export_subobj_title

string ilRatingCategoryGUI::$export_subobj_title = null
protected

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

◆ $http

readonly HttpServices ilRatingCategoryGUI::$http
private

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

◆ $lng

readonly ilLanguage ilRatingCategoryGUI::$lng
protected

◆ $parent_id

int ilRatingCategoryGUI::$parent_id
protected

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

◆ $refinery

readonly Refinery ilRatingCategoryGUI::$refinery
private

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

◆ $request

RequestInterface ilRatingCategoryGUI::$request
protected

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

◆ $requested_cat_id

int ilRatingCategoryGUI::$requested_cat_id
protected

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

◆ $toolbar

ilToolbarGUI ilRatingCategoryGUI::$toolbar
protected

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

Referenced by listCategories().

◆ $tpl

ilGlobalTemplateInterface ilRatingCategoryGUI::$tpl
protected

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

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

◆ $ui_factory

readonly UIFactory ilRatingCategoryGUI::$ui_factory
private

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

◆ $ui_renderer

readonly UIRenderer ilRatingCategoryGUI::$ui_renderer
private

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


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