<?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 = 0;
$currRow2 = 1;
$itemCount = 1;
$movCount = count($this->items);
$showCatResizeThumbs = $this->cparams->get('resize_thumbs');
$catMovShowName = $this->params->get('single_cat_show_mov_name', $this->cparams->get('cview_show_c_name'));
$catMovShowDate = $this->params->get('single_cat_show_mov_date', $this->cparams->get('cview_show_c_date'));
$catMovShowHits = $this->params->get('single_cat_show_mov_hits', $this->cparams->get('cview_show_c_hits'));
$catMovShowTags = $this->params->get('single_cat_show_mov_tags', $this->cparams->get('cview_show_tags'));
$catMovShowSubmitter = $this->params->get('single_cat_show_mov_submitter', $this->cparams->get('cview_show_c_submitter'));
$catMovPerRow = $this->params->get('single_mov_per_row', $this->cparams->get('cview_mov_per_row'));

?>

<?php 
foreach ($this->items as $movie) {
    $catalias = '&catid=' . $movie->catid . ':' . $movie->catidoa;
    $link = JRoute::_("index.php?option=com_xmovie&view=single{$catalias}&id={$movie->id}:{$movie->alias}&Itemid={$movie->itemId}");

    if ($currRow2 == 1) {
    ?>
<div class="row-fluid xmt">
	<?php
    }
    ?>
	<div class="movie-item text-center span<?php echo $this->div_width_mov; ?>">
		<a href="<?php echo $link ;?>">
		<?php 
            $imageThumb = parse_url($movie->thumb);
                                
            if (!isset($imageThumb['host']) || $imageThumb['host'] == '') {
                if ($showCatResizeThumbs) {
                    $movString = JURI::base(true)."/components/com_xmovie/helpers/img.php?file=".urlencode($movie->thumb)."&t=m";                                                    
                } else {
                    $movString = JURI::base(true). "/" . $this->movie_thumb_path . "/" . $movie->thumb;    
                }
            } else {
                $movString = $movie->thumb;                        
            }
                                    
            ?>
			<img class="thumbnail img-fluid" src="<?php echo $movString; ?>" alt="<?php echo htmlspecialchars($movie->title); ?>" />
		</a>
		<?php if ($catMovShowName) {?>
		<h4><?php echo htmlspecialchars($movie->title); ?></h4>
		<?php } ?>
		<?php if ($catMovShowDate) {?>
		<div class="movie-date">
			<strong><?php echo JTEXT::_('COM_XMOVIE_DATE_ADDED'); ?>:</strong> <?php echo JHTML::Date($movie->creation_date, 'm-d-Y'); ?>
		</div>
		<?php } ?>
		<?php if ($catMovShowHits) {?>
		<div class="movie-date">
			<strong><?php echo JTEXT::_('COM_XMOVIE_HITS'); ?>:</strong> <?php echo $movie->hits; ?>
		</div>
		<?php } ?>
		<?php if ($catMovShowSubmitter) {?>
		<div class="movie-submitter">
			<strong><?php echo JTEXT::_('COM_XMOVIE_SUBMITTER'); ?>:</strong> <?php echo $movie->submitter; ?>
		</div>
		<?php } ?>
		<?php if ($catMovShowTags) {
			$movie -> tags = new JHelperTags;
			$movie -> tags->getItemTags('com_xmovie.movie' , $movie -> id);
			$movie -> tagLayout = new JLayoutFile('joomla.content.tags');	
		?>
		<div class="movie-tags">
			<strong><?php echo JTEXT::_('TAGS'); ?>:</strong> <?php echo $movie->tagLayout->render($movie->tags->itemTags); ?>
		</div>
		<?php } ?>
	</div>			
	<?php                 
        if ($currRow2 < $catMovPerRow && $itemCount != $movCount) {
            $currRow2++;
        } else {
            echo '<div class="clearfix"></div>';
            echo '</div>';
            $currRow2 = 1;
        }
        $itemCount++;        
}
    ?>

