<?php
/*
 * @package Joomla 3.0
 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 *
 * @component XMovie Component
 * @copyright Copyright (C) Dana Harris optikool.com
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */ 
defined('_JEXEC') or die('Restricted access');
    
$currRow = 1;
$itemCatCount = 1;
$catCount = count($this->subcat);    
$showCatSingleCatShowThumb = $this->params->get('single_cat_show_thumb', $this->cparams->get('cview_cat_show_thumb'));
$showCatResizeThumbs = $this->cparams->get('resize_thumbs');
$showCatSingleCatShowName = $this->params->get('single_cat_show_name', $this->cparams->get('cview_cat_show_name'));
$showCatSingleCatShowDate = $this->params->get('single_cat_show_date', $this->cparams->get('cview_cat_show_date'));
$showCatSingleCatShowHits = $this->params->get('single_cat_show_hits', $this->cparams->get('cview_show_hits'));
$showCatSingleCatShowTags = $this->params->get('single_cat_show_tags', $this->cparams->get('cview_cat_show_tags'));
$catThumbsPerRow = $this->params->get('single_cat_mov_per_row', $this->cparams->get('cview_cat_mov_per_row'));

?>

<?php foreach ($this->subcat as $subCategory) { 
    $link = JRoute::_($subCategory['link']);    
    $categoryParams = json_decode($subCategory['params']);
    $thumbnail = $categoryParams->image;

    if ($currRow == 1) {
    ?>
<div class="row-fluid xgt">
	<?php
    }
    ?>
	<div class="movie-item text-center span<?php echo $this->div_width_cat; ?>">
		<?php if ($thumbnail != '' && $showCatSingleCatShowThumb == 1) {?>
		<a href="<?php echo $link; ?>">
			<img class="thumbnail img-fluid" src="<?php echo $thumbnail; ?>" alt="<?php echo htmlspecialchars($subCategory['title']); ?>" />
		</a>
		<?php } ?>
		<?php if ($showCatSingleCatShowName == 1) {?>
		<h4>
			<?php if ($thumbnail == '' || $showCatSingleCatShowThumb != 1) { ?>
			<a href="<?php echo $link; ?>">
				<?php echo $subCategory['title']; ?>
			</a>
			<?php } else { 
                echo $subCategory['title']; 
			} ?>
		</h4>
		<?php } ?>
		<?php if ($showCatSingleCatShowDate == 1) {?>
		<div class="movie-date">
			<strong><?php echo JTEXT::_('DATE'); ?>:</strong> <?php echo JHTML::Date($subCategory['created_time'], 'm-d-Y'); ?>
		</div>
		<?php } ?>
		<?php if ($showCatSingleCatShowHits == 1) {?>
		<div class="movie-hits">
			<strong><?php echo JTEXT::_('Hits'); ?>:</strong> <?php echo $subCategory['hits']; ?>
		</div>
		<?php } ?>
		<?php if ($showCatSingleCatShowTags) {?>
		<div class="movie-tags">
		<?php
			$subCategory['tags'] = new JHelperTags;
			$subCategory['tags']->getItemTags('com_xmovie.category' , $subCategory['id']);
			$subCategory['tagLayout'] = new JLayoutFile('joomla.content.tags');
        ?>
			<strong><?php echo JTEXT::_('TAGS'); ?>:</strong> <?php echo $subCategory['tagLayout']->render($subCategory['tags']->itemTags); ?>
		</div>
		<?php } ?>
	</div>			
	<?php 
        if ($currRow < $catThumbsPerRow && $itemCatCount != $catCount) {
            $currRow++;
        } else {
            echo '<div class="clearfix"></div>';
            echo '</div>';
            $currRow = 1;
        }
        $itemCatCount++;
}
    ?>
