<?php
/**
 * @package DJ-Catalog2-Yootheme
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 */

defined ('_JEXEC') or die('Restricted access');
$item_id = $displayData['item_id'];
$item_name = $displayData['item_name'];
$item_author = $displayData['item_author'];
$review = $displayData['review'];
$params = $displayData['params'];
$context = $displayData['context'];
$created = $displayData['created'];

$rating = $displayData['rating'];
$rcount = (int)$displayData['rating_count'];
// Look for images in template if available

$starImageOn  = JHtml::_('image', 'system/rating_star.png', JText::_('COM_DJCATALOG2_ITEM_VOTE_STAR_ACTIVE'), null, true);
$starImageOff = JHtml::_('image', 'system/rating_star_blank.png', JText::_('COM_DJCATALOG2_ITEM_VOTE_STAR_INACTIVE'), null, true);


$ratingOnly = (bool)($params->get('product_rating') == '1');
$displayReviews = (bool)(!$ratingOnly && $context == 'com_djcatalog2.item' && $rcount > 0 && !empty($review));

?>
<?php if ($displayReviews) { ?>
	<div class="djc_star_rating--review" data-id="<?php echo $item_id; ?>" itemprop="review" itemscope itemtype="https://schema.org/Review">
			<?php $author = '<span itemprop="author">'.$item_author.'</span>'; ?>
			<?php $datetime = '<span itemprop="datePublished">'.Jhtml::_('date', $created, $params->get('date_format_datetime', 'd/m/Y H:i')).'</span>'; ?>
			<p class="djc_star_rating--single-review">
				<p class="djc_star_rating--review-content" itemprop="reviewBody"><?php echo nl2br($review); ?></p>
				<small><?php echo JText::sprintf('COM_DJCATALOG2_ITEM_REVIEW_AUTHOR', $author); ?>, <?php echo JText::sprintf('COM_DJCATALOG2_ITEM_REVIEW_DATE', $datetime); ?></small>
				<meta itemprop="reviewRating" content="<?php echo $review->rating; ?>" />
				<meta itemprop="name" content="<?php echo htmlspecialchars($item_name, ENT_COMPAT, 'UTF-8'); ?>" />
			</p>
	</div>
<?php } ?>
