<?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');
$showCatSingleCatShowMovHeading = $this->params->get('single_cat_show_mov_heading', $this->cparams->get('cview_show_movie_heading'));
$showCatSingleCatShowMovThumb = $this->params->get('single_cat_show_mov_thumb', $this->cparams->get('cview_show_c_thumb'));
$showCatResizeThumbs = $this->cparams->get('resize_thumbs');
$showCatSingleCatShowMovName = $this->params->get('single_cat_show_mov_name', $this->cparams->get('cview_show_c_name'));
$showCatSingleCatShowMovDate = $this->params->get('single_cat_show_mov_date', $this->cparams->get('cview_show_c_date'));
$showCatSingleCatShowMovHits = $this->params->get('single_cat_show_mov_hits', $this->cparams->get('cview_show_c_hits'));
$showCatSingleCatShowMovSubmitter = $this->params->get('single_cat_show_mov_submitter', $this->cparams->get('cview_show_c_submitter'));
$showCatSingleCatShowMovTags = $this->params->get('single_cat_show_mov_tags', $this->cparams->get('cview_show_tags'));
$showCatSingleCatShowMovDesc = $this->params->get('single_cat_show_mov_desc', $this->cparams->get('cview_show_c_quicktake'));
$showCatSingleCatDisplayMov = $this->params->get('single_cat_display_mov', $this->cparams->get('cview_display_mov_view'));
?>

<div id="xmovie-movie-container-list">
<?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}");
    ?>
	<div class="movie-item row-fluid">
		<?php if ($movie->thumb != '' && $showCatSingleCatShowMovThumb == 1) {?>
		<div class="span3">
			<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>
		</div>
		<?php 
} ?>
		<div class="span9 text-left">
			<?php if ($showCatSingleCatShowMovName) { ?>
			<div class="movie-name row-fluid">
				<h4>
				<?php if ($movie->thumb == '' || $showCatSingleCatShowMovName != 1) { ?>
				<a href="<?php echo $link; ?>">
					<?php echo $movie->title; ?>
				</a>
				<?php 
} else {     
                    echo $movie->title; 
} ?>
				</h4>
			</div>
			<?php 
} ?>
			<?php if ($showCatSingleCatShowMovDate || $showCatSingleCatShowMovHits || $showCatSingleCatShowMovSubmitter || $showCatSingleCatShowMovTags) {
			?>
			<div class="row-fluid">
			<ul class="inline">
			<?php
} ?>
			<?php if ($showCatSingleCatShowMovDate) {?>
			<li>
				<strong><?php echo JTEXT::_('COM_XMOVIE_DATE_ADDED'); ?>:</strong> <?php echo JHTML::Date($movie->creation_date, 'm-d-Y'); ?>
			</li>
			<?php 
} ?>
			<?php if ($showCatSingleCatShowMovHits) {?>
			<li>
				<strong><?php echo JTEXT::_('COM_XMOVIE_HITS'); ?>:</strong> <?php echo $movie->hits; ?>
			</li>
			<?php 
} ?>
			<?php if ($showCatSingleCatShowMovSubmitter) {?>
			<li>
				<strong><?php echo JTEXT::_('COM_XMOVIE_SUBMITTER'); ?>:</strong> <?php echo $movie->submitter; ?>
			</li>
			<?php 
} ?>
			<?php if ($showCatSingleCatShowMovTags) {
				$movie -> tags = new JHelperTags;
				$movie -> tags->getItemTags('com_xmovie.movie' , $movie -> id);
				$movie -> tagLayout = new JLayoutFile('joomla.content.tags');	
			?>
			<li>
				<strong><?php echo JTEXT::_('TAGS'); ?>:</strong> <?php echo $movie->tagLayout->render($movie->tags->itemTags); ?>
			</li>
			<?php 
} ?>
		<?php if ($showCatSingleCatShowMovDate || $showCatSingleCatShowMovHits || $showCatSingleCatShowMovSubmitter || $showCatSingleCatShowMovTags) {
			?>
			</ul>
		</div>
			<?php
} ?>
		</div>
		<?php if ($showCatSingleCatShowMovDesc && $showCatSingleCatDisplayMov == 'list') {?>
		<div class="row-fluid span9">
			<?php 
                if ($movie->introtext == '') {
                    echo $movie->fulltext;
                } else {
                    echo $movie->introtext;
                }        
            ?>	
		</div>
		<?php 
} ?>
	</div>
	<?php 
    } ?>
</div>
