ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilRatingCategoryGUI Class Reference

Class ilRatingCategoryGUI. More...

+ Collaboration diagram for ilRatingCategoryGUI:

Public Member Functions

 __construct ($a_parent_id, $a_export_callback=null, $a_export_subobj_title=null)
 
 executeCommand ()
 execute command More...
 

Protected Member Functions

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

Protected Attributes

 $parent_id
 
 $export_callback
 
 $export_subobj_title
 

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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $lng, and $parent_id.

21  {
22  global $lng;
23 
24  $this->parent_id = (int)$a_parent_id;
25  $this->export_callback = $a_export_callback;
26  $this->export_subobj_title = $a_export_subobj_title;
27 
28  $lng->loadLanguageModule("rating");
29 
30  if($_REQUEST["cat_id"])
31  {
32  $cat = new ilRatingCategory($_REQUEST["cat_id"]);
33  if($cat->getParentId() == $this->parent_id)
34  {
35  $this->cat_id = $cat->getId();
36  }
37  }
38  }
global $lng
Definition: privfeed.php:17
Class ilRatingCategory.

Member Function Documentation

◆ add()

ilRatingCategoryGUI::add (   $a_form = null)
protected

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

References $tpl, and initCategoryForm().

Referenced by save(), and update().

117  {
118  global $tpl;
119 
120  if(!$a_form)
121  {
122  $a_form = $this->initCategoryForm();
123  }
124 
125  $tpl->setContent($a_form->getHTML());
126  }
global $tpl
Definition: ilias.php:8
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDelete()

ilRatingCategoryGUI::confirmDelete ( )
protected

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

References $ilCtrl, $lng, $tpl, and listCategories().

209  {
210  global $tpl, $ilCtrl, $lng;
211 
212  if(!$this->cat_id)
213  {
214  return $this->listCategories();
215  }
216 
217  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
218  $cgui = new ilConfirmationGUI();
219  $cgui->setHeaderText($lng->txt("rating_category_delete_sure")."<br/>".
220  $lng->txt("info_delete_warning_no_trash"));
221 
222  $cgui->setFormAction($ilCtrl->getFormAction($this));
223  $cgui->setCancel($lng->txt("cancel"), "listCategories");
224  $cgui->setConfirm($lng->txt("confirm"), "delete");
225 
226  $cat = new ilRatingCategory($this->cat_id);
227  $cgui->addItem("cat_id", $this->cat_id, $cat->getTitle());
228 
229  $tpl->setContent($cgui->getHTML());
230  }
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
Class ilRatingCategory.
Confirmation screen class.
+ Here is the call graph for this function:

◆ delete()

ilRatingCategoryGUI::delete ( )
protected

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

References $ilCtrl, $lng, ilRatingCategory\delete(), ilRatingCategory\getAllForObject(), and ilUtil\sendSuccess().

233  {
234  global $ilCtrl, $lng;
235 
236  if($this->cat_id)
237  {
238  ilRatingCategory::delete($this->cat_id);
239  ilUtil::sendSuccess($lng->txt("rating_category_deleted"), true);
240  }
241 
242  // fix order
243  $cnt = 0;
244  foreach(ilRatingCategory::getAllForObject($this->parent_id) as $item)
245  {
246  $cnt += 10;
247 
248  $cat = new ilRatingCategory($item["id"]);
249  $cat->setPosition($cnt);
250  $cat->update();
251  }
252 
253  $ilCtrl->redirect($this, "listCategories");
254  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static getAllForObject($a_parent_obj_id)
Get all categories for object.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
static delete($a_id)
Delete db entry.
Class ilRatingCategory.
+ Here is the call graph for this function:

◆ edit()

ilRatingCategoryGUI::edit (   $a_form = null)
protected

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

References $ilCtrl, $tpl, and initCategoryForm().

151  {
152  global $tpl, $ilCtrl;
153 
154  $ilCtrl->setParameter($this, "cat_id", $this->cat_id);
155 
156  if(!$a_form)
157  {
158  $a_form = $this->initCategoryForm($this->cat_id);
159  }
160 
161  $tpl->setContent($a_form->getHTML());
162  }
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:

◆ executeCommand()

ilRatingCategoryGUI::executeCommand ( )

execute command

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

References $cmd, and $ilCtrl.

44  {
45  global $ilCtrl;
46 
47  $next_class = $ilCtrl->getNextClass($this);
48  $cmd = $ilCtrl->getCmd("listCategories");
49 
50  switch($next_class)
51  {
52  default:
53  return $this->$cmd();
54  break;
55  }
56  }
$cmd
Definition: sahs_server.php:35
global $ilCtrl
Definition: ilias.php:18

◆ export()

ilRatingCategoryGUI::export ( )
protected

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

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

257  {
258  global $lng;
259 
260  include_once "./Services/Excel/classes/class.ilExcel.php";
261  $excel = new ilExcel();
262  $excel->addSheet($lng->txt("rating_categories"));
263 
264  // restrict to currently active (probably not needed - see delete())
265  $active = array();
266  foreach(ilRatingCategory::getAllForObject($this->parent_id) as $item)
267  {
268  $active[$item["id"]] = $item["title"];
269  }
270 
271  // title row
272  $row = 1;
273  $excel->setCell($row, 0, $this->export_subobj_title." (".$lng->txt("id").")");
274  $excel->setCell($row, 1, $this->export_subobj_title);
275  $excel->setCell($row, 2, $lng->txt("rating_export_category")." (".$lng->txt("id").")");
276  $excel->setCell($row, 3, $lng->txt("rating_export_category"));
277  $excel->setCell($row, 4, $lng->txt("rating_export_date"));
278  $excel->setCell($row, 5, $lng->txt("rating_export_rating"));
279  $excel->setBold("A1:F1");
280 
281  // content rows
282  foreach(ilRating::getExportData($this->parent_id, ilObject::_lookupType($this->parent_id), array_keys($active)) as $item)
283  {
284  // overall rating?
285  if(!$item["sub_obj_id"])
286  {
287  continue;
288  }
289 
290  $row++;
291 
292  $sub_obj_title = $item["sub_obj_type"];
293  if($this->export_callback)
294  {
295  $sub_obj_title = call_user_func($this->export_callback, $item["sub_obj_id"], $item["sub_obj_type"]);
296  }
297 
298  $excel->setCell($row, 0, (int)$item["sub_obj_id"]);
299  $excel->setCell($row, 1, $sub_obj_title);
300  $excel->setCell($row, 2, (int)$item["category_id"]);
301  $excel->setCell($row, 3, $active[$item["category_id"]]);
302  $excel->setCell($row, 4, new ilDateTime($item["tstamp"], IL_CAL_UNIX));
303  $excel->setCell($row, 5, $item["rating"]);
304  }
305 
306  $excel->sendToClient(ilObject::_lookupTitle($this->parent_id));
307  }
static _lookupTitle($a_id)
lookup object title
const IL_CAL_UNIX
static getAllForObject($a_parent_obj_id)
Get all categories for object.
static getExportData($a_obj_id, $a_obj_type, array $a_category_ids=null)
Get export data.
Date and time handling
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ initCategoryForm()

ilRatingCategoryGUI::initCategoryForm (   $a_id = null)
protected

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

References $ilCtrl, $lng, ilTextAreaInputGUI\setCols(), and ilTextInputGUI\setMaxLength().

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

77  {
78  global $lng, $ilCtrl;
79 
80  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
81  $form = new ilPropertyFormGUI();
82  $form->setTarget("_top");
83  $form->setFormAction($ilCtrl->getFormAction($this, "save"));
84  $form->setTitle($lng->txt("rating_category_".($a_id ? "edit" : "create")));
85 
86  // title
87  $ti = new ilTextInputGUI($lng->txt("title"), "title");
88  $ti->setMaxLength(128);
89  $ti->setSize(40);
90  $ti->setRequired(true);
91  $form->addItem($ti);
92 
93  // description
94  $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
95  $ta->setCols(40);
96  $ta->setRows(2);
97  $form->addItem($ta);
98 
99  if(!$a_id)
100  {
101  $form->addCommandButton("save", $lng->txt("rating_category_add"));
102  }
103  else
104  {
105  $cat = new ilRatingCategory($a_id);
106  $ti->setValue($cat->getTitle());
107  $ta->setValue($cat->getDescription());
108 
109  $form->addCommandButton("update", $lng->txt("rating_category_update"));
110  }
111  $form->addCommandButton("listCategories", $lng->txt("cancel"));
112 
113  return $form;
114  }
This class represents a property form user interface.
global $ilCtrl
Definition: ilias.php:18
This class represents a text property in a property form.
setMaxLength($a_maxlength)
Set Max Length.
global $lng
Definition: privfeed.php:17
This class represents a text area property in a property form.
Class ilRatingCategory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listCategories()

ilRatingCategoryGUI::listCategories ( )
protected

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

References $ilCtrl, $lng, and $tpl.

Referenced by confirmDelete().

59  {
60  global $tpl, $ilToolbar, $lng, $ilCtrl;
61 
62  $ilToolbar->addButton($lng->txt("rating_add_category"),
63  $ilCtrl->getLinkTarget($this, "add"));
64 
65  $ilToolbar->addSeparator();
66 
67  $ilToolbar->addButton($lng->txt("export"),
68  $ilCtrl->getLinkTarget($this, "export"));
69 
70  include_once "Services/Rating/classes/class.ilRatingCategoryTableGUI.php";
71  $table = new ilRatingCategoryTableGUI($this, "listCategories", $this->parent_id);
72  $tpl->setContent($table->getHTML());
73  }
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ save()

ilRatingCategoryGUI::save ( )
protected

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

References $ilCtrl, $lng, add(), initCategoryForm(), and ilUtil\sendSuccess().

129  {
130  global $ilCtrl, $lng;
131 
132  $form = $this->initCategoryForm("create");
133  if($form->checkInput())
134  {
135  include_once "Services/Rating/classes/class.ilRatingCategory.php";
136  $cat = new ilRatingCategory();
137  $cat->setParentId($this->parent_id);
138  $cat->setTitle($form->getInput("title"));
139  $cat->setDescription($form->getInput("desc"));
140  $cat->save();
141 
142  ilUtil::sendSuccess($lng->txt("rating_category_created"));
143  $ilCtrl->redirect($this, "listCategories");
144  }
145 
146  $form->setValuesByPost();
147  $this->add($form);
148  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
Class ilRatingCategory.
+ Here is the call graph for this function:

◆ update()

ilRatingCategoryGUI::update ( )
protected

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

References $ilCtrl, $lng, add(), initCategoryForm(), and ilUtil\sendSuccess().

165  {
166  global $ilCtrl, $lng;
167 
168  $form = $this->initCategoryForm($this->cat_id);
169  if($form->checkInput())
170  {
171  include_once "Services/Rating/classes/class.ilRatingCategory.php";
172  $cat = new ilRatingCategory($this->cat_id);
173  $cat->setTitle($form->getInput("title"));
174  $cat->setDescription($form->getInput("desc"));
175  $cat->update();
176 
177  ilUtil::sendSuccess($lng->txt("rating_category_updated"));
178  $ilCtrl->redirect($this, "listCategories");
179  }
180 
181  $form->setValuesByPost();
182  $this->add($form);
183  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
Class ilRatingCategory.
+ Here is the call graph for this function:

◆ updateOrder()

ilRatingCategoryGUI::updateOrder ( )
protected

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

References $_POST, $ilCtrl, $lng, $parent_id, and ilUtil\sendSuccess().

186  {
187  global $ilCtrl, $lng;
188 
189  $order = $_POST["pos"];
190  asort($order);
191 
192  $cnt = 0;
193  foreach($order as $id => $pos)
194  {
195  $cat = new ilRatingCategory($id);
196  if($cat->getParentId() == $this->parent_id)
197  {
198  $cnt += 10;
199  $cat->setPosition($cnt);
200  $cat->update();
201  }
202  }
203 
204  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
205  $ilCtrl->redirect($this, "listCategories");
206  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
Class ilRatingCategory.
$_POST["username"]
+ Here is the call graph for this function:

Field Documentation

◆ $export_callback

ilRatingCategoryGUI::$export_callback
protected

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

◆ $export_subobj_title

ilRatingCategoryGUI::$export_subobj_title
protected

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

◆ $parent_id

ilRatingCategoryGUI::$parent_id
protected

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

Referenced by __construct(), and updateOrder().


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