ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

 $lng
 
 $ctrl
 
 $tpl
 
 $toolbar
 
 $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 40 of file class.ilRatingCategoryGUI.php.

41 {
42 global $DIC;
43
44 $this->lng = $DIC->language();
45 $this->ctrl = $DIC->ctrl();
46 $this->tpl = $DIC["tpl"];
47 $this->toolbar = $DIC->toolbar();
48 $lng = $DIC->language();
49
50 $this->parent_id = (int) $a_parent_id;
51 $this->export_callback = $a_export_callback;
52 $this->export_subobj_title = $a_export_subobj_title;
53
54 $lng->loadLanguageModule("rating");
55
56 if ($_REQUEST["cat_id"]) {
57 $cat = new ilRatingCategory($_REQUEST["cat_id"]);
58 if ($cat->getParentId() == $this->parent_id) {
59 $this->cat_id = $cat->getId();
60 }
61 }
62 }
Class ilRatingCategory.
global $DIC
Definition: saml.php:7

References $DIC, and $lng.

Member Function Documentation

◆ add()

ilRatingCategoryGUI::add (   $a_form = null)
protected

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

145 {
147
148 if (!$a_form) {
149 $a_form = $this->initCategoryForm();
150 }
151
152 $tpl->setContent($a_form->getHTML());
153 }

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

235 {
239
240 if (!$this->cat_id) {
241 return $this->listCategories();
242 }
243
244 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
245 $cgui = new ilConfirmationGUI();
246 $cgui->setHeaderText($lng->txt("rating_category_delete_sure") . "<br/>" .
247 $lng->txt("info_delete_warning_no_trash"));
248
249 $cgui->setFormAction($ilCtrl->getFormAction($this));
250 $cgui->setCancel($lng->txt("cancel"), "listCategories");
251 $cgui->setConfirm($lng->txt("confirm"), "delete");
252
253 $cat = new ilRatingCategory($this->cat_id);
254 $cgui->addItem("cat_id", $this->cat_id, $cat->getTitle());
255
256 $tpl->setContent($cgui->getHTML());
257 }
Confirmation screen class.
global $ilCtrl
Definition: ilias.php:18

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

+ Here is the call graph for this function:

◆ delete()

ilRatingCategoryGUI::delete ( )
protected

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

260 {
263
264 if ($this->cat_id) {
265 ilRatingCategory::delete($this->cat_id);
266 ilUtil::sendSuccess($lng->txt("rating_category_deleted"), true);
267 }
268
269 // fix order
270 $cnt = 0;
271 foreach (ilRatingCategory::getAllForObject($this->parent_id) as $item) {
272 $cnt += 10;
273
274 $cat = new ilRatingCategory($item["id"]);
275 $cat->setPosition($cnt);
276 $cat->update();
277 }
278
279 $ilCtrl->redirect($this, "listCategories");
280 }
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 $ctrl, $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 177 of file class.ilRatingCategoryGUI.php.

178 {
181
182 $ilCtrl->setParameter($this, "cat_id", $this->cat_id);
183
184 if (!$a_form) {
185 $a_form = $this->initCategoryForm($this->cat_id);
186 }
187
188 $tpl->setContent($a_form->getHTML());
189 }

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

+ Here is the call graph for this function:

◆ executeCommand()

ilRatingCategoryGUI::executeCommand ( )

execute command

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

68 {
70
71 $next_class = $ilCtrl->getNextClass($this);
72 $cmd = $ilCtrl->getCmd("listCategories");
73
74 switch ($next_class) {
75 default:
76 return $this->$cmd();
77 break;
78 }
79 }

References $ctrl, and $ilCtrl.

◆ export()

ilRatingCategoryGUI::export ( )
protected

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

283 {
285
286 include_once "./Services/Excel/classes/class.ilExcel.php";
287 $excel = new ilExcel();
288 $excel->addSheet($lng->txt("rating_categories"));
289
290 // restrict to currently active (probably not needed - see delete())
291 $active = array();
292 foreach (ilRatingCategory::getAllForObject($this->parent_id) as $item) {
293 $active[$item["id"]] = $item["title"];
294 }
295
296 // title row
297 $row = 1;
298 $excel->setCell($row, 0, $this->export_subobj_title . " (" . $lng->txt("id") . ")");
299 $excel->setCell($row, 1, $this->export_subobj_title);
300 $excel->setCell($row, 2, $lng->txt("rating_export_category") . " (" . $lng->txt("id") . ")");
301 $excel->setCell($row, 3, $lng->txt("rating_export_category"));
302 $excel->setCell($row, 4, $lng->txt("rating_export_date"));
303 $excel->setCell($row, 5, $lng->txt("rating_export_rating"));
304 $excel->setBold("A1:F1");
305
306 // content rows
307 foreach (ilRating::getExportData($this->parent_id, ilObject::_lookupType($this->parent_id), array_keys($active)) as $item) {
308 // overall rating?
309 if (!$item["sub_obj_id"]) {
310 continue;
311 }
312
313 $row++;
314
315 $sub_obj_title = $item["sub_obj_type"];
316 if ($this->export_callback) {
317 $sub_obj_title = call_user_func($this->export_callback, $item["sub_obj_id"], $item["sub_obj_type"]);
318 }
319
320 $excel->setCell($row, 0, (int) $item["sub_obj_id"]);
321 $excel->setCell($row, 1, $sub_obj_title);
322 $excel->setCell($row, 2, (int) $item["category_id"]);
323 $excel->setCell($row, 3, $active[$item["category_id"]]);
324 $excel->setCell($row, 4, new ilDateTime($item["tstamp"], IL_CAL_UNIX));
325 $excel->setCell($row, 5, $item["rating"]);
326 }
327
328 $excel->sendToClient(ilObject::_lookupTitle($this->parent_id));
329 }
const IL_CAL_UNIX
@classDescription Date and time handling
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(), ilRating\getExportData(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ initCategoryForm()

ilRatingCategoryGUI::initCategoryForm (   $a_id = null)
protected

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

107 {
110
111 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
112 $form = new ilPropertyFormGUI();
113 $form->setTarget("_top");
114 $form->setFormAction($ilCtrl->getFormAction($this, "save"));
115 $form->setTitle($lng->txt("rating_category_" . ($a_id ? "edit" : "create")));
116
117 // title
118 $ti = new ilTextInputGUI($lng->txt("title"), "title");
119 $ti->setMaxLength(128);
120 $ti->setSize(40);
121 $ti->setRequired(true);
122 $form->addItem($ti);
123
124 // description
125 $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
126 $ta->setCols(40);
127 $ta->setRows(2);
128 $form->addItem($ta);
129
130 if (!$a_id) {
131 $form->addCommandButton("save", $lng->txt("rating_category_add"));
132 } else {
133 $cat = new ilRatingCategory($a_id);
134 $ti->setValue($cat->getTitle());
135 $ta->setValue($cat->getDescription());
136
137 $form->addCommandButton("update", $lng->txt("rating_category_update"));
138 }
139 $form->addCommandButton("listCategories", $lng->txt("cancel"));
140
141 return $form;
142 }
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.
if(isset($_POST['submit'])) $form

References $ctrl, $form, $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 81 of file class.ilRatingCategoryGUI.php.

82 {
84 $ilToolbar = $this->toolbar;
87
88 $ilToolbar->addButton(
89 $lng->txt("rating_add_category"),
90 $ilCtrl->getLinkTarget($this, "add")
91 );
92
93 $ilToolbar->addSeparator();
94
95 $ilToolbar->addButton(
96 $lng->txt("export"),
97 $ilCtrl->getLinkTarget($this, "export")
98 );
99
100 include_once "Services/Rating/classes/class.ilRatingCategoryTableGUI.php";
101 $table = new ilRatingCategoryTableGUI($this, "listCategories", $this->parent_id);
102 $tpl->setContent($table->getHTML());
103 }
if(empty($password)) $table
Definition: pwgen.php:24

References $ctrl, $ilCtrl, $lng, $table, $toolbar, and $tpl.

Referenced by confirmDelete().

+ Here is the caller graph for this function:

◆ save()

ilRatingCategoryGUI::save ( )
protected

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

156 {
159
160 $form = $this->initCategoryForm("create");
161 if ($form->checkInput()) {
162 include_once "Services/Rating/classes/class.ilRatingCategory.php";
163 $cat = new ilRatingCategory();
164 $cat->setParentId($this->parent_id);
165 $cat->setTitle($form->getInput("title"));
166 $cat->setDescription($form->getInput("desc"));
167 $cat->save();
168
169 ilUtil::sendSuccess($lng->txt("rating_category_created"));
170 $ilCtrl->redirect($this, "listCategories");
171 }
172
173 $form->setValuesByPost();
174 $this->add($form);
175 }

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

+ Here is the call graph for this function:

◆ update()

ilRatingCategoryGUI::update ( )
protected

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

192 {
195
196 $form = $this->initCategoryForm($this->cat_id);
197 if ($form->checkInput()) {
198 include_once "Services/Rating/classes/class.ilRatingCategory.php";
199 $cat = new ilRatingCategory($this->cat_id);
200 $cat->setTitle($form->getInput("title"));
201 $cat->setDescription($form->getInput("desc"));
202 $cat->update();
203
204 ilUtil::sendSuccess($lng->txt("rating_category_updated"));
205 $ilCtrl->redirect($this, "listCategories");
206 }
207
208 $form->setValuesByPost();
209 $this->add($form);
210 }

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

+ Here is the call graph for this function:

◆ updateOrder()

ilRatingCategoryGUI::updateOrder ( )
protected

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

213 {
216
217 $order = $_POST["pos"];
218 asort($order);
219
220 $cnt = 0;
221 foreach ($order as $id => $pos) {
222 $cat = new ilRatingCategory($id);
223 if ($cat->getParentId() == $this->parent_id) {
224 $cnt += 10;
225 $cat->setPosition($cnt);
226 $cat->update();
227 }
228 }
229
230 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
231 $ilCtrl->redirect($this, "listCategories");
232 }
$_POST["username"]
if(!array_key_exists('StateId', $_REQUEST)) $id

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

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilRatingCategoryGUI::$ctrl
protected

◆ $export_callback

ilRatingCategoryGUI::$export_callback
protected

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

◆ $export_subobj_title

ilRatingCategoryGUI::$export_subobj_title
protected

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

◆ $lng

ilRatingCategoryGUI::$lng
protected

◆ $parent_id

ilRatingCategoryGUI::$parent_id
protected

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

◆ $toolbar

ilRatingCategoryGUI::$toolbar
protected

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

Referenced by listCategories().

◆ $tpl

ilRatingCategoryGUI::$tpl
protected

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

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


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