ILIAS  Release_4_1_x_branch Revision 61804
 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.
 getHTML ()
 Get HTML for rating of an object (and a user)
 saveRating ()
 Save Rating.

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 34 of file class.ilRatingGUI.php.

Constructor & Destructor Documentation

ilRatingGUI::__construct ( )

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

References $lng.

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

Member Function Documentation

& ilRatingGUI::executeCommand ( )

execute command

Definition at line 46 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 106 of file class.ilRatingGUI.php.

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

{
global $lng, $ilCtrl;
$ttpl = new ilTemplate("tpl.rating_input.html", true, true, "Services/Rating");
// (1) overall rating
$rating = ilRating::getOverallRatingForObject($this->obj_id, $this->obj_type,
$this->sub_obj_id, $this->sub_obj_type);
if ($rating["cnt"] >= 1)
{
for($i = 1; $i <= 5; $i++)
{
$ttpl->setCurrentBlock("rating_icon");
if ($rating["avg"] >= $i)
{
$ttpl->setVariable("SRC_ICON",
ilUtil::getImagePath("icon_rate_on.gif"));
}
else if ($rating["avg"] + 1 <= $i)
{
$ttpl->setVariable("SRC_ICON",
ilUtil::getImagePath("icon_rate_off.gif"));
}
else
{
$nr = round(($rating["avg"] + 1 - $i) * 10);
$ttpl->setVariable("SRC_ICON",
ilUtil::getImagePath("icon_rate_$nr.gif"));
}
$ttpl->setVariable("ALT_ICON", "(".$i."/5)");
$ttpl->parseCurrentBlock();
}
$ttpl->setCurrentBlock("rating_icon");
$ttpl->setVariable("TXT_OVERALL_RATING", $lng->txt("rating_average_rating"));
$ttpl->setVariable("NR_USERS",
sprintf($lng->txt("rating_nr_users"), $rating["cnt"]));
$ttpl->setVariable("VAL_OVERALL_RATING", "(".round($rating["avg"], 1)."/5)");
$ttpl->parseCurrentBlock();
}
// (2) user rating
if ($this->getUserId() != ANONYMOUS_USER_ID)
{
$rating = ilRating::getRatingForUserAndObject($this->obj_id, $this->obj_type,
$this->sub_obj_id, $this->sub_obj_type, $this->getUserId());
// 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.gif"));
}
else
{
$ttpl->setVariable("SRC_ICON",
ilUtil::getImagePath("icon_rate_off.gif"));
}
$ttpl->setVariable("ALT_ICON", "(".$i."/5)");
$ttpl->parseCurrentBlock();
}
$ttpl->setCurrentBlock("user_rating");
// user rating text
$ttpl->setVariable("TXT_YOUR_RATING", $lng->txt("rating_your_rating"));
if ($rating > 0)
{
$ttpl->setVariable("VAL_RATING", "(".$rating."/5)");
}
$ttpl->parseCurrentBlock();
}
return $ttpl->get();
}

+ Here is the call graph for this function:

ilRatingGUI::getUserId ( )

Get User ID.

Returns
int User ID

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

Referenced by getHTML(), and saveRating().

{
return $this->userid;
}

+ Here is the caller graph for this function:

ilRatingGUI::saveRating ( )

Save Rating.

Definition at line 189 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 69 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->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 88 of file class.ilRatingGUI.php.

Referenced by setObject().

{
$this->userid = $a_userid;
}

+ Here is the caller graph for this function:


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