<?php
/**
 * The Portfolio template to display the content
 *
 * Used for index/archive/search.
 *
 * @package TOURIMO
 * @since TOURIMO 1.0
 */

$tourimo_template_args = get_query_var( 'tourimo_template_args' );
if ( is_array( $tourimo_template_args ) ) {
	$tourimo_columns    = empty( $tourimo_template_args['columns'] ) ? 2 : max( 1, $tourimo_template_args['columns'] );
	$tourimo_blog_style = array( $tourimo_template_args['type'], $tourimo_columns );
} else {
	$tourimo_blog_style = explode( '_', tourimo_get_theme_option( 'blog_style' ) );
	$tourimo_columns    = empty( $tourimo_blog_style[1] ) ? 2 : max( 1, $tourimo_blog_style[1] );
}

$tourimo_post_format = get_post_format();
$tourimo_post_format = empty( $tourimo_post_format ) ? 'standard' : str_replace( 'post-format-', '', $tourimo_post_format );

?><div class="
<?php
if ( ! empty( $tourimo_template_args['slider'] ) ) {
	echo ' slider-slide swiper-slide';
} else {
	echo ( tourimo_is_blog_style_use_masonry( $tourimo_blog_style[0] ) ? 'masonry_item masonry_item' : 'column' ) . '-1_' . esc_attr( $tourimo_columns );
}
?>
"><article id="post-<?php the_ID(); ?>" 
	<?php
	post_class(
		'post_item post_item_container post_format_' . esc_attr( $tourimo_post_format )
		. ' post_layout_portfolio'
		. ' post_layout_portfolio_' . esc_attr( $tourimo_columns )
		. ( 'portfolio' != $tourimo_blog_style[0] ? ' ' . esc_attr( $tourimo_blog_style[0] )  . '_' . esc_attr( $tourimo_columns ) : '' )
		. ( is_sticky() && ! is_paged() ? ' sticky' : '' )
	);
	tourimo_add_blog_animation( $tourimo_template_args );
	?>
>
<?php

	// Sticky label
	if ( is_sticky() && ! is_paged() ) {
		?>
		<span class="post_label label_sticky"></span>
		<?php
	}

	$tourimo_hover   = ! empty( $tourimo_template_args['hover'] ) && ! tourimo_is_inherit( $tourimo_template_args['hover'] )
								? $tourimo_template_args['hover']
								: tourimo_get_theme_option( 'image_hover' );

	if ( 'icon' == $tourimo_hover ) {
		$tourimo_post_link = empty( $tourimo_template_args['no_links'] )
								? ( ! empty( $tourimo_template_args['link'] )
									? $tourimo_template_args['link']
									: get_permalink()
									)
								: '';
		$tourimo_target    = ! empty( $tourimo_post_link ) && false === strpos( $tourimo_post_link, home_url() )
								? ' target="_blank" rel="nofollow"'
								: '';
	}
	
	// Meta parts
	$tourimo_components = ! empty( $tourimo_template_args['meta_parts'] )
							? ( is_array( $tourimo_template_args['meta_parts'] )
								? $tourimo_template_args['meta_parts']
								: explode( ',', $tourimo_template_args['meta_parts'] )
								)
							: tourimo_array_get_keys_by_value( tourimo_get_theme_option( 'meta_parts' ) );

	// Featured image
	tourimo_show_post_featured(
		array(
			'hover'         => $tourimo_hover,
			'no_links'      => ! empty( $tourimo_template_args['no_links'] ),
			'thumb_size'    => tourimo_get_thumb_size(
									tourimo_is_blog_style_use_masonry( $tourimo_blog_style[0] )
										? (	strpos( tourimo_get_theme_option( 'body_style' ), 'full' ) !== false || $tourimo_columns < 3
											? 'masonry-big'
											: 'masonry'
											)
										: (	strpos( tourimo_get_theme_option( 'body_style' ), 'full' ) !== false || $tourimo_columns < 3
											? 'big'
											: 'med'
											)
								),
			'show_no_image' => true,
			'meta_parts'    => $tourimo_components,
			'class'         => 'icon' == $tourimo_hover ? 'hover_with_info' : '',
			'post_info'     => 'icon' == $tourimo_hover
										? '<div class="post_info"><h5 class="post_title">'
											. ( ! empty( $tourimo_post_link )
												? '<a href="' . esc_url( $tourimo_post_link ) . '"' . ( ! empty( $target ) ? $target : '' ) . '>'
												: ''
												)
												. esc_html( get_the_title() ) 
											. ( ! empty( $tourimo_post_link )
												? '</a>'
												: ''
												)
											. '</h5></div>'
										: '',
		)
	);
	?>
</article></div><?php
// Need opening PHP-tag above, because <article> is a inline-block element (used as column)!