/** * * @param int $rating_group Rating Group ID * @param string $object_type Type of an object, eg. com_content, com_content.article * @param string $object_name Friendly name, title * @param string $object_link Object's URL, eg. link to an article * @param int $entry_id rated object's ID * @throws RuntimeException */ public function __construct($rating_group, $object_type, $object_name, $object_link, $entry_id, $params = false) { if (!(int) $rating_group) { throw new RuntimeException('Missing rating group'); } $object_type = strtolower(preg_replace('#[^a-z0-9\\.\\_\\-]#i', '.', $object_type)); if (!$object_type) { throw new RuntimeException('Missing object type'); } if (!$object_name) { throw new RuntimeException('Missing object name'); } if (!$object_link) { throw new RuntimeException('Missing object link'); } if (!(int) $entry_id) { throw new RuntimeException('Missing or invalid object ID'); } $this->rating_group_id = $rating_group; $this->object_type = $object_type; $this->entry_id = $entry_id; $this->name = $object_name; $this->link = $object_link; require_once JPath::clean(JPATH_ROOT . '/components/com_djreviews/helpers/djreviews.php'); if (!$params) { $params = DJReviewsHelper::getParams($this->rating_group_id); } $this->params = $params; if (!self::$assets) { self::recalculate(); $lang = JFactory::getLanguage(); $lang->load('com_djreviews', JPATH_ROOT, 'en-GB', false, false); $lang->load('com_djreviews', JPATH_ROOT . JPath::clean('/components/com_djreviews'), 'en-GB', false, false); $lang->load('com_djreviews', JPATH_ROOT, null, true, false); $lang->load('com_djreviews', JPATH_ROOT . JPath::clean('/components/com_djreviews'), null, true, false); JHtml::_('behavior.tooltip', '.djrv_tooltip'); $theme = $this->params->get('theme', 'bootstrap'); JFactory::getDocument()->addStyleSheet(JUri::base() . 'components/com_djreviews/themes/' . $theme . '/css/theme.css'); self::$assets = true; } }