ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilRatingGUI Class Reference

Class ilRatingGUI. More...

+ Collaboration diagram for ilRatingGUI:

Public Member Functions

 __construct ()
executeCommand ()
 execute command
 setObject ($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="")
 Set Object.
 setUserId ($a_userid)
 Set User ID.
 getUserId ()
 Get User ID.
 setYourRatingText ($a_val)
 Set "Your Rating" text.
 getYourRatingText ()
 Get "Your Rating" text.
 getHTML ()
 Get HTML for rating of an object (and a user)
 saveRating ()
 Save Rating.

Protected Attributes

 $id = "rtg_"

Detailed Description

Class ilRatingGUI.

User interface class for rating.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

ilRatingGUI::__construct ( )

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

References $lng.

{
global $lng;
$lng->loadLanguageModule("rating");
}

Member Function Documentation

& ilRatingGUI::executeCommand ( )

execute command

Definition at line 28 of file class.ilRatingGUI.php.

References $cmd, and $ilCtrl.

{
global $ilCtrl;
$next_class = $ilCtrl->getNextClass($this);
$cmd = $ilCtrl->getCmd();
switch($next_class)
{
default:
return $this->$cmd();
break;
}
}
ilRatingGUI::getHTML ( )

Get HTML for rating of an object (and a user)

Definition at line 110 of file class.ilRatingGUI.php.

References $ilCtrl, $lng, ilTooltipGUI\addTooltip(), ilUtil\getImagePath(), ilRating\getOverallRatingForObject(), ilRating\getRatingForUserAndObject(), getUserId(), and getYourRatingText().

{
global $lng, $ilCtrl;
$ttpl = new ilTemplate("tpl.rating_input.html", true, true, "Services/Rating");
// user rating
$user_rating = 0;
if ($this->getUserId() != ANONYMOUS_USER_ID)
{
$user_rating = ilRating::getRatingForUserAndObject($this->obj_id, $this->obj_type,
$this->sub_obj_id, $this->sub_obj_type, $this->getUserId());
}
// (1) overall rating
$rating = ilRating::getOverallRatingForObject($this->obj_id, $this->obj_type,
$this->sub_obj_id, $this->sub_obj_type);
for($i = 1; $i <= 5; $i++)
{
if ($i == $user_rating)
{
$ttpl->setCurrentBlock("rating_mark");
$ttpl->setVariable("SRC_MARK",
ilUtil::getImagePath("icon_rate_marker.png"));
$ttpl->parseCurrentBlock();
}
$ttpl->setCurrentBlock("rating_icon");
if ($rating["avg"] >= $i)
{
$ttpl->setVariable("SRC_ICON",
ilUtil::getImagePath("icon_rate_on.png"));
}
else if ($rating["avg"] + 1 <= $i)
{
$ttpl->setVariable("SRC_ICON",
ilUtil::getImagePath("icon_rate_off.png"));
}
else
{
$nr = round(($rating["avg"] + 1 - $i) * 10);
$ttpl->setVariable("SRC_ICON",
ilUtil::getImagePath("icon_rate_$nr.png"));
}
$ttpl->setVariable("ALT_ICON", "(".$i."/5)");
$ttpl->parseCurrentBlock();
}
$ttpl->setCurrentBlock("rating_icon");
if ($rating["cnt"] == 0)
{
$tt = $lng->txt("rat_not_rated_yet");
}
else if ($rating["cnt"] == 1)
{
$tt = $lng->txt("rat_one_rating");
}
else
{
$tt =
sprintf($lng->txt("rat_nr_ratings"), $rating["cnt"]);
}
include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
ilTooltipGUI::addTooltip($this->id."_tt", $tt);
if ($rating["cnt"] > 0)
{
$ttpl->setCurrentBlock("rat_nr");
$ttpl->setVariable("RT_NR", $rating["cnt"]);
$ttpl->parseCurrentBlock();
}
if ($this->getUserId() != ANONYMOUS_USER_ID)
{
include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
$ov = new ilOverlayGUI($this->id);
$ov->setTrigger("tr_".$this->id, "click", "tr_".$this->id);
$ov->add();
$ttpl->setCurrentBlock("act_rat_start");
$ttpl->setVariable("ID", $this->id);
$ttpl->setVariable("SRC_ARROW", ilUtil::getImagePath("mm_down_arrow_dark.gif"));
$ttpl->parseCurrentBlock();
//$ttpl->touchBlock("act_rat_end");
$ttpl->setCurrentBlock("act_rat_end");
$ttpl->setVariable("SRC_ARROW", ilUtil::getImagePath("mm_down_arrow_dark.gif"));
$ttpl->parseCurrentBlock();
}
$ttpl->parseCurrentBlock();
// (2) user rating
if ($this->getUserId() != ANONYMOUS_USER_ID)
{
$rating = $user_rating;
// user rating links
for($i = 1; $i <= 5; $i++)
{
$ttpl->setCurrentBlock("rating_link");
$ilCtrl->setParameter($this, "rating", $i);
$ttpl->setVariable("HREF_RATING", $ilCtrl->getLinkTarget($this, "saveRating"));
if ($rating >= $i)
{
$ttpl->setVariable("SRC_ICON",
ilUtil::getImagePath("icon_rate_on.png"));
}
else
{
$ttpl->setVariable("SRC_ICON",
ilUtil::getImagePath("icon_rate_off.png"));
}
$ttpl->setVariable("ALT_ICON", "(".$i."/5)");
$ttpl->parseCurrentBlock();
}
$ttpl->setCurrentBlock("user_rating");
$ttpl->setVariable("ID", $this->id);
// user rating text
$rate_text = ($this->getYourRatingText() != "")
? $this->getYourRatingText()
: $lng->txt("rating_your_rating");
$ttpl->setVariable("TXT_YOUR_RATING", $rate_text);
$ttpl->parseCurrentBlock();
}
$ttpl->setVariable("TTID", $this->id);
return $ttpl->get();
}

+ Here is the call graph for this function:

ilRatingGUI::getUserId ( )

Get User ID.

Returns
int User ID

Definition at line 82 of file class.ilRatingGUI.php.

Referenced by getHTML(), and saveRating().

{
return $this->userid;
}

+ Here is the caller graph for this function:

ilRatingGUI::getYourRatingText ( )

Get "Your Rating" text.

Returns
string text

Definition at line 102 of file class.ilRatingGUI.php.

Referenced by getHTML().

{
return $this->your_rating_text;
}

+ Here is the caller graph for this function:

ilRatingGUI::saveRating ( )

Save Rating.

Definition at line 245 of file class.ilRatingGUI.php.

References $_GET, getUserId(), ilUtil\stripSlashes(), and ilRating\writeRatingForUserAndObject().

{
ilRating::writeRatingForUserAndObject($this->obj_id, $this->obj_type,
$this->sub_obj_id, $this->sub_obj_type, $this->getUserId(),
}

+ Here is the call graph for this function:

ilRatingGUI::setObject (   $a_obj_id,
  $a_obj_type,
  $a_sub_obj_id = 0,
  $a_sub_obj_type = "" 
)

Set Object.

Parameters
int$a_obj_idObject ID
string$a_obj_typeObject Type
int$a_sub_obj_idSubobject ID
string$a_sub_obj_typeSubobject Type

Definition at line 51 of file class.ilRatingGUI.php.

References setUserId().

{
global $ilUser;
$this->obj_id = $a_obj_id;
$this->obj_type = $a_obj_type;
$this->sub_obj_id = $a_sub_obj_id;
$this->sub_obj_type = $a_sub_obj_type;
$this->id = "rtg_".$this->obj_id."_".$this->obj_type."_".$this->sub_obj_id."_".
$this->sub_obj_type;
//$this->setSaveCmd("saveTags");
$this->setUserId($ilUser->getId());
//$this->setInputFieldName("il_tags");
}

+ Here is the call graph for this function:

ilRatingGUI::setUserId (   $a_userid)

Set User ID.

Parameters
int$a_useridUser ID

Definition at line 72 of file class.ilRatingGUI.php.

Referenced by setObject().

{
$this->userid = $a_userid;
}

+ Here is the caller graph for this function:

ilRatingGUI::setYourRatingText (   $a_val)

Set "Your Rating" text.

Parameters
string$a_valtext

Definition at line 92 of file class.ilRatingGUI.php.

{
$this->your_rating_text = $a_val;
}

Field Documentation

ilRatingGUI::$id = "rtg_"
protected

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


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