4 include_once(
"./Services/Rating/classes/class.ilRating.php");
5 include_once(
"./Services/Rating/classes/class.ilRatingCategory.php");
19 protected $id =
"rtg_";
27 $lng->loadLanguageModule(
"rating");
37 $next_class = $ilCtrl->getNextClass($this);
38 $cmd = $ilCtrl->getCmd();
42 case "ilratingcategorygui":
43 include_once(
"./Services/Rating/classes/class.ilRatingCategoryGUI.php");
44 $gui =
new ilRatingCategoryGUI($this->obj_id, $this->export_callback, $this->export_subobj_title);
45 $ilCtrl->forwardCommand($gui);
62 function setObject($a_obj_id, $a_obj_type, $a_sub_obj_id = 0, $a_sub_obj_type =
"")
66 $this->obj_id = $a_obj_id;
67 $this->obj_type = $a_obj_type;
68 $this->sub_obj_id = $a_sub_obj_id;
69 $this->sub_obj_type = $a_sub_obj_type;
70 $this->
id =
"rtg_".$this->obj_id.
"_".$this->obj_type.
"_".$this->sub_obj_id.
"_".
83 $this->userid = $a_userid;
103 $this->your_rating_text = $a_val;
113 return $this->your_rating_text;
123 $this->enable_categories = (bool)$a_value;
134 protected function renderDetails($a_js_id, $a_may_rate, array $a_categories = null)
138 $ttpl =
new ilTemplate(
"tpl.rating_details.html",
true,
true,
"Services/Rating");
142 : $lng->txt(
"rating_your_rating");
150 $this->sub_obj_id, $this->sub_obj_type, $this->
getUserId(), 0);
153 for($i = 1; $i <= 5; $i++)
155 $ttpl->setCurrentBlock(
"rating_link_simple");
156 $ilCtrl->setParameter($this,
"rating", $i);
157 $ttpl->setVariable(
"HREF_RATING", $ilCtrl->getLinkTarget($this,
"saveRating"));
160 $ttpl->setVariable(
"SRC_ICON",
165 $ttpl->setVariable(
"SRC_ICON",
168 $ttpl->setVariable(
"ALT_ICON",
"(".$i.
"/5)");
169 $ttpl->parseCurrentBlock();
173 $ttpl->setCurrentBlock(
"user_rating_simple");
174 $ttpl->setVariable(
"TXT_RATING_SIMPLE", $rate_text);
175 $ttpl->parseCurrentBlock();
181 foreach($a_categories as $category)
184 $this->sub_obj_id, $this->sub_obj_type, $this->
getUserId(), $category[
"id"]));
187 $this->sub_obj_id, $this->sub_obj_type, $category[
"id"]);
189 for($i = 1; $i <= 5; $i++)
191 if ($a_may_rate && $i == $user_rating)
193 $ttpl->setCurrentBlock(
"rating_mark");
194 $ttpl->setVariable(
"SRC_MARK",
196 $ttpl->parseCurrentBlock();
199 $ttpl->setCurrentBlock(
"user_rating_icon");
200 if ($overall_rating[
"avg"] >= $i)
202 $ttpl->setVariable(
"SRC_ICON",
205 else if ($overall_rating[
"avg"] + 1 <= $i)
207 $ttpl->setVariable(
"SRC_ICON",
212 $nr = round(($overall_rating[
"avg"] + 1 - $i) * 10);
213 $ttpl->setVariable(
"SRC_ICON",
216 $ttpl->setVariable(
"ALT_ICON",
"(".$i.
"/5)");
220 $ttpl->setVariable(
"HREF_RATING",
"il.Rating.setValue(".$category[
"id"].
",".$i.
", '".$a_js_id.
"')");
221 $ttpl->setVariable(
"CATEGORY_ID", $category[
"id"]);
222 $ttpl->setVariable(
"ICON_VALUE", $i);
223 $ttpl->setVariable(
"JS_ID", $a_js_id);
224 $ttpl->setVariable(
"ICON_MOUSEACTION",
" onmouseover=\"il.Rating.toggleIcon(this,".$i.
")\"".
225 " onmouseout=\"il.Rating.toggleIcon(this,".$i.
",1)\"");
228 $ttpl->parseCurrentBlock();
233 $ttpl->setCurrentBlock(
"user_rating_category_column");
234 $ttpl->setVariable(
"JS_ID", $a_js_id);
235 $ttpl->setVariable(
"CATEGORY_ID", $category[
"id"]);
236 $ttpl->setVariable(
"CATEGORY_VALUE", $user_rating);
237 $ttpl->parseCurrentBlock();
241 $ttpl->setCurrentBlock(
"user_rating_category");
242 $ttpl->setVariable(
"TXT_RATING_CATEGORY", $category[
"title"]);
243 $ttpl->parseCurrentBlock();
246 if($overall_rating[
"cnt"])
248 $ttpl->setCurrentBlock(
"votes_number_bl");
249 $ttpl->setVariable(
"NUMBER_VOTES", sprintf($lng->txt(
"rating_number_votes"), $overall_rating[
"cnt"]));
250 $ttpl->parseCurrentBlock();
255 $ttpl->setVariable(
"FORM_ACTION", $ilCtrl->getFormAction($this,
"saveRating"));
256 $ttpl->setVariable(
"TXT_SUBMIT", $lng->txt(
"rating_overlay_submit"));
257 $ttpl->setVariable(
"CMD_SUBMIT",
"saveRating");
258 $ttpl->touchBlock(
"user_rating_categories_form_out");
261 $ttpl->setCurrentBlock(
"user_rating_categories");
262 $ttpl->setVariable(
"TXT_RATING_OVERALL", $lng->txt(
"rating_overlay_title_overall"));
263 $ttpl->parseCurrentBlock();
277 $categories = array();
278 if($this->enable_categories)
283 $may_rate = ($this->
getUserId() != ANONYMOUS_USER_ID);
285 $has_overlay =
false;
286 if($may_rate || $categories)
291 $ttpl =
new ilTemplate(
"tpl.rating_input.html",
true,
true,
"Services/Rating");
298 $this->sub_obj_id, $this->sub_obj_type, $this->
getUserId()));
303 $this->sub_obj_id, $this->sub_obj_type);
305 for($i = 1; $i <= 5; $i++)
307 if ($i == $user_rating)
309 $ttpl->setCurrentBlock(
"rating_mark");
310 $ttpl->setVariable(
"SRC_MARK",
312 $ttpl->parseCurrentBlock();
315 $ttpl->setCurrentBlock(
"rating_icon");
316 if ($rating[
"avg"] >= $i)
318 $ttpl->setVariable(
"SRC_ICON",
321 else if ($rating[
"avg"] + 1 <= $i)
323 $ttpl->setVariable(
"SRC_ICON",
328 $nr = round(($rating[
"avg"] + 1 - $i) * 10);
329 $ttpl->setVariable(
"SRC_ICON",
332 $ttpl->setVariable(
"ALT_ICON",
"(".$i.
"/5)");
333 $ttpl->parseCurrentBlock();
335 $ttpl->setCurrentBlock(
"rating_icon");
336 if ($rating[
"cnt"] == 0)
338 $tt = $lng->txt(
"rat_not_rated_yet");
340 else if ($rating[
"cnt"] == 1)
342 $tt = $lng->txt(
"rat_one_rating");
346 $tt = sprintf($lng->txt(
"rat_nr_ratings"), $rating[
"cnt"]);
348 include_once(
"./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
350 if ($rating[
"cnt"] > 0)
352 $ttpl->setCurrentBlock(
"rat_nr");
353 $ttpl->setVariable(
"RT_NR", $rating[
"cnt"]);
354 $ttpl->parseCurrentBlock();
360 include_once(
"./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
362 $ov->setTrigger(
"tr_".$this->
id,
"click",
"tr_".$this->
id);
365 $ttpl->setCurrentBlock(
"act_rat_start");
366 $ttpl->setVariable(
"ID", $this->
id);
368 $ttpl->parseCurrentBlock();
370 $ttpl->setCurrentBlock(
"act_rat_end");
372 $ttpl->parseCurrentBlock();
375 $ttpl->parseCurrentBlock();
382 $ttpl->setVariable(
"RATING_DETAILS",
385 $ttpl->setCurrentBlock(
"user_rating");
386 $ttpl->setVariable(
"ID", $this->
id);
387 $ttpl->parseCurrentBlock();
390 $ttpl->setVariable(
"TTID", $this->
id);
397 $categories = array();
398 if($this->enable_categories)
403 $may_rate = ($this->
getUserId() != ANONYMOUS_USER_ID);
405 $ttpl =
new ilTemplate(
"tpl.rating_block.html",
true,
true,
"Services/Rating");
407 $ttpl->setVariable(
"TITLE", $a_title);
409 $ttpl->setVariable(
"RATING_DETAILS",
423 $this->sub_obj_id, $this->sub_obj_type, $this->
getUserId(),
428 foreach(
$_POST[
"rating"] as $cat_id => $rating)
431 $this->sub_obj_id, $this->sub_obj_type, $this->
getUserId(),
439 $this->export_callback = $a_callback;
440 $this->export_subobj_title = $a_subobj_title;