<?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');
$image_directory = JComponentHelper::getParams('com_media') -> get('image_path', 'images') . '/';

$mainXMShowThumb = $this -> params -> get('show_thumb');
$mainXMResizeThumbs = $this -> cparams -> get('resize_thumbs');
$mainXMShowName = $this -> params -> get('show_name');
$mainXMShowDate = $this -> params -> get('show_date');
$mainXMShowHits = $this -> params -> get('show_hits');
$mainXMShowSubmitter = $this -> params -> get('show_submitter');
$mainXMShowTags = $this -> params -> get('show_tags');
$mainXMShowDescription = $this -> params -> get('show_description');
$mainXMDisplayViewMain = $this -> params -> get('display_view_main');
?>

<div id="xmovie-movie-container-list">
	<?php
foreach ($this->items as $movie) {
$link = JRoute::_("index.php?option=com_xmovie&view=single&catid={$movie->catid}:{$movie->catalias}&id={$movie->id}:{$movie->alias}&Itemid={$movie->itemId}");
    ?>
	<div class="movie-item row-fluid">
		<?php if ($movie->thumb != '' && $mainXMShowThumb == 1) {
        ?>
		<div class="span3">
			<a href="<?php echo $link; ?>">
			<?php
            $imageThumb = parse_url($movie -> thumb);

            if (!isset($imageThumb['host']) || $imageThumb['host'] == '') {
                if ($mainXMResizeThumbs) {
                    $movString = "components/com_xmovie/helpers/img.php?file=" . urlencode($movie -> thumb) . "&t=m";
                } else {
                    $movString = JURI::base(true) . $image_directory . $this -> cparams -> get('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 ($mainXMShowName == 1) {
            ?>
			<div class="row-fluid">
				<h4>
				<?php if ($movie->thumb == '' || $mainXMShowThumb != 1) {
                ?>
				<a href="<?php echo $link; ?>"> <?php echo $movie -> title; ?> </a>
				<?php 
} else {
                    echo $movie->title; 
}
                ?></h4>
			</div>
			<?php 
} ?>
			<?php if ($mainXMShowDate || $mainXMShowHits || $mainXMShowSubmitter || $mainXMShowTags) {
			?>
			<div class="row-fluid">
			<ul class="inline">
			<?php
} ?>
			<?php if ($mainXMShowDate) {
            ?>
			<li>
				<strong><?php echo JTEXT::_('DATE_ADDED'); ?>:</strong> <?php echo JHTML::Date($movie -> creation_date, 'm-d-Y'); ?>
			</li>
			<?php 
} ?>
			<?php if ($mainXMShowHits) {
            ?>
			<li>
				<strong><?php echo JTEXT::_('HITS'); ?>:</strong> <?php echo $movie -> hits; ?>
			</li>
			<?php 
} ?>
			<?php if ($mainXMShowSubmitter) {
            ?>
			<li>
				<strong><?php echo JTEXT::_('SUBMITTER'); ?>:</strong> <?php echo $movie -> submitter; ?>
			</li>
			<?php 
} ?>
			<?php if ($mainXMShowTags) {
				$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 ($mainXMShowDate || $mainXMShowHits || $mainXMShowSubmitter || $mainXMShowTags) {
			?>
			</ul>
			</div>
			<?php
} ?>
			</div>
			<?php if ($mainXMShowDescription && $mainXMDisplayViewMain == 'list') {
			?>
			<div class="span9 row-fluid">
			<?php
			if ($movie -> introtext == '') {
				echo $movie -> fulltext;
			} else {
				echo $movie -> introtext;
			}
			?>
			</div>
			<?php 
	} ?>
	</div>
	<?php 
} ?>
</div>
