ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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:31
loadLanguageModule(string $a_module)
Load language module.
global $DIC
Definition: shib_login.php:22
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 155 of file class.ilRatingCategoryGUI.php.

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

Referenced by save(), and update().

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

◆ confirmDelete()

ilRatingCategoryGUI::confirmDelete ( )
protected

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

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

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

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

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

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

187  : void
188  {
189  $tpl = $this->tpl;
190  $ilCtrl = $this->ctrl;
191 
192  $ilCtrl->setParameter($this, "cat_id", $this->cat_id);
193 
194  if (!$a_form) {
195  $a_form = $this->initCategoryForm($this->cat_id);
196  }
197 
198  $tpl->setContent($a_form->getHTML());
199  }
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
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 292 of file class.ilRatingCategoryGUI.php.

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

292  : void
293  {
294  $lng = $this->lng;
295 
296  $excel = new ilExcel();
297  $excel->addSheet($lng->txt("rating_categories"));
298 
299  // restrict to currently active (probably not needed - see delete())
300  $active = array();
301  foreach (ilRatingCategory::getAllForObject($this->parent_id) as $item) {
302  $active[$item["id"]] = $item["title"];
303  }
304 
305  // title row
306  $row = 1;
307  $excel->setCell($row, 0, $this->export_subobj_title . " (" . $lng->txt("id") . ")");
308  $excel->setCell($row, 1, $this->export_subobj_title);
309  $excel->setCell($row, 2, $lng->txt("rating_export_category") . " (" . $lng->txt("id") . ")");
310  $excel->setCell($row, 3, $lng->txt("rating_export_category"));
311  $excel->setCell($row, 4, $lng->txt("rating_export_date"));
312  $excel->setCell($row, 5, $lng->txt("rating_export_rating"));
313  $excel->setBold("A1:F1");
314 
315  // content rows
316  foreach (ilRating::getExportData($this->parent_id, ilObject::_lookupType($this->parent_id), array_keys($active)) as $item) {
317  // overall rating?
318  if (!$item["sub_obj_id"]) {
319  continue;
320  }
321 
322  $row++;
323 
324  $sub_obj_title = $item["sub_obj_type"];
325  if ($this->export_callback) {
326  $sub_obj_title = call_user_func($this->export_callback, $item["sub_obj_id"], $item["sub_obj_type"]);
327  }
328 
329  $excel->setCell($row, 0, (int) $item["sub_obj_id"]);
330  $excel->setCell($row, 1, $sub_obj_title);
331  $excel->setCell($row, 2, (int) $item["category_id"]);
332  $excel->setCell($row, 3, $active[$item["category_id"]] ?? "");
333  $excel->setCell($row, 4, new ilDateTime($item["tstamp"] ?? null, IL_CAL_UNIX));
334  $excel->setCell($row, 5, $item["rating"] ?? "");
335  }
336 
337  $excel->sendToClient(ilObject::_lookupTitle($this->parent_id));
338  }
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 IL_CAL_UNIX
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _lookupTitle(int $obj_id)
static getAllForObject(int $a_parent_obj_id)
static getExportData(int $a_obj_id, string $a_obj_type, ?array $a_category_ids=null)
Get export data.
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, 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  $form->addItem($ta);
140 
141  if (!$a_id) {
142  $form->addCommandButton("save", $lng->txt("rating_category_add"));
143  } else {
144  $cat = new ilRatingCategory($a_id);
145  $ti->setValue($cat->getTitle());
146  $ta->setValue($cat->getDescription());
147 
148  $form->addCommandButton("update", $lng->txt("rating_category_update"));
149  }
150  $form->addCommandButton("listCategories", $lng->txt("cancel"));
151 
152  return $form;
153  }
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...
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, ILIAS\UICore\GlobalTemplate\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...
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
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 166 of file class.ilRatingCategoryGUI.php.

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

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

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

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

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

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