<?php
/**
 * Copyright © 2015 PlazaThemes.com. All rights reserved.

 * @author PlazaThemes Team <contact@plazathemes.com>
 */
?>
<?php
/**
 * Blog sidebar recent posts template
 *
 * @var $block \Plazathemes\Blog\Block\Sidebar\Recent
 */
?>

<?php
	$enable = $this->getConfig('enable_frontend');
	$auto = $this->getConfig('auto');
	$speed = $this->getConfig('speed');
	$pagination = $this->getConfig('pagination');
	$show_next_back = $this->getConfig('show_next_back');
	$show_navigation_control = $this->getConfig('show_navigation_control');
	$title = $this->getConfig('title');
	if($show_next_back)
		$show_next_back = 'true';
	else
		$show_next_back = 'false';
	$show_navigation_control = $this->getConfig('show_navigation_control');
	if($show_navigation_control)
		$show_navigation_control = 'true';
	else
		$show_navigation_control = 'false';
	$_postCollection = $block->getPostCollection();
?>
<?php if ($_postCollection->count() && $enable) { ?>
<div class="widget box-section block-recent-posts" data-bind="scope: 'recemt-posts'">
	<div class="container-inner">
		<h3 class="ma-title blog-title">
			<?php echo __($title) ?>
			<span class="text1">Do you want to present posts in the best way to highlight interesting moments of your blog?</span> 
		<span>Focus on the latest news!</span> 
		</h3>
		<div class="row">
			<div class="ptowl">
				<?php foreach ($_postCollection as $_post) { ?>
					<div class="item">
						<div class="item-inner">
							<div class="blog-image">
								<a class="image" href="<?php echo $_post->getPostUrl() ?>">
									<img src="<?php echo $this->getMediaFolder().$_post->getThumbnailimage() ?>" alt="blog-image"/>
								</a>
								
							</div>
							
							<div class="blog-content">
								 <h3 class="title"><a href="<?php echo $_post->getPostUrl() ?>"><?php echo $block->escapeHtml($_post->getTitle()) ?></a></h3> 
								<div class="time-conment">
									<?php 
										$date = $_post->getPublishTime();
									?>
									<span class="date-time"><span class="date"><?php echo (date("d", strtotime($date))) ?></span><span class="separator">/</span><span class="month"><?php echo (date("F", strtotime($date))) ?></span>/</span><span class="year"><?php echo __(date("Y", strtotime($date))) ?></span>
								</div>	
								 
								<p class="short-des"><?php echo $_post->getShortContent() ?></p>
								
								<a class="readmore" href="<?php echo $_post->getPostUrl() ?>">
									<?php echo __('Continue reading') ?>
								</a>
							</div>
							
						</div>
					</div>
				<?php } ?>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
require([
  "jquery",
  "owlcarousel/minjs"
 ], function($,owlCarousel){
		$(document).ready(function(){
			$(".block-recent-posts .ptowl").owlCarousel({
				<?php
					if(($auto== 'true') && $speed):
				?>
				autoPlay : <?php echo $speed; ?>,
				<?php
					endif;
				?>
				items : 3,
				itemsDesktop : [1199,3],
				itemsDesktopSmall : [980,2],
				itemsTablet: [768,2],
				itemsMobile : [479,1],
				slideSpeed : <?php echo $pagination; ?>,
				paginationSpeed : <?php echo $pagination; ?>,
				rewindSpeed : <?php echo $pagination; ?>,
				addClassActive: true,
				navigation : false,
				stopOnHover : true,
				pagination : true,
				scrollPerPage:true,
			});
		});
	});
</script>
<?php } ?>