ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.

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 }
Class ilRatingCategory.
global $lng
Definition: privfeed.php:40
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7

References $_REQUEST, and $lng.

Member Function Documentation

◆ add()

ilRatingCategoryGUI::add (   $a_form = null)
protected

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

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

References $tpl, and initCategoryForm().

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 208 of file class.ilRatingCategoryGUI.php.

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 }
Confirmation screen class.
global $ilCtrl
Definition: ilias.php:18

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

+ Here is the call graph for this function:

◆ delete()

ilRatingCategoryGUI::delete ( )
protected

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

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 delete($a_id)
Delete db entry.
static getAllForObject($a_parent_obj_id)
Get all categories for object.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.

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

+ Here is the call graph for this function:

◆ edit()

ilRatingCategoryGUI::edit (   $a_form = null)
protected

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

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 }

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

+ Here is the call graph for this function:

◆ executeCommand()

& ilRatingCategoryGUI::executeCommand ( )

execute command

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

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

References $cmd, and $ilCtrl.

◆ export()

ilRatingCategoryGUI::export ( )
protected

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

257 {
258 global $lng;
259
260 $title = ilObject::_lookupTitle($this->parent_id);
261 include_once "./Services/Excel/classes/class.ilExcelUtils.php";
262 include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
263 $adapter = new ilExcelWriterAdapter($title.".xls", true);
264
265 // restrict to currently active (probably not needed - see delete())
266 $active = array();
267 foreach(ilRatingCategory::getAllForObject($this->parent_id) as $item)
268 {
269 $active[$item["id"]] = $item["title"];
270 }
271
272 ob_start();
273 $workbook = $adapter->getWorkbook();
274 $worksheet = $workbook->addWorksheet();
275
276 var_dump();
277
278 // title row
279 $row = 0;
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"));
286
287 // content rows
288 foreach(ilRating::getExportData($this->parent_id, ilObject::_lookupType($this->parent_id), array_keys($active)) as $item)
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 $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"]);
304 }
305
306 ob_end_clean();
307
308 $workbook->close();
309 }
Class ilExcelWriterAdapter.
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
static getExportData($a_obj_id, $a_obj_type, array $a_category_ids=null)
Get export data.

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

+ Here is the call graph for this function:

◆ initCategoryForm()

ilRatingCategoryGUI::initCategoryForm (   $a_id = null)
protected

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

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.
This class represents a text area property in a property form.
This class represents a text property in a property form.

References $ilCtrl, and $lng.

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

+ Here is the caller graph for this function:

◆ listCategories()

ilRatingCategoryGUI::listCategories ( )
protected

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

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 }

References $ilCtrl, $lng, and $tpl.

Referenced by confirmDelete().

+ Here is the caller graph for this function:

◆ save()

ilRatingCategoryGUI::save ( )
protected

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

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 }

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

+ Here is the call graph for this function:

◆ update()

ilRatingCategoryGUI::update ( )
protected

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

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 }

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

+ Here is the call graph for this function:

◆ updateOrder()

ilRatingCategoryGUI::updateOrder ( )
protected

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

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 }
$_POST['username']
Definition: cron.php:12

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

+ 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.


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