<?php
/**
 * @copyright Copyright (c) 2016 AmyTheme (http://www.amytheme.com). All rights reserved.
 * @license  http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 */

get_header();

get_template_part( 'partials/page-header' );

$queried_object = get_queried_object();
$term_id 		= $queried_object->term_id;
$term 			= get_term( $term_id, 'amy_genre' );

$term_data 		= get_term_meta( $term_id, '_genre_options', true );

$single_genre_sidebar 	= isset( $term_data['genre_sidebar'] ) ? $term_data['genre_sidebar'] : '';
$single_genre_layout	= isset( $term_data['genre_layout'] ) ? $term_data['genre_layout'] : '';
$single_grid_layout		= isset( $term_data['grid_layout'] ) ? $term_data['grid_layout'] : '';
$single_column			= isset( $term_data['column'] ) ? $term_data['column'] : '';
$single_layout2_column	= isset( $term_data['layout2_column'] ) ? $term_data['layout2_column'] : '';

$layout			= ($single_genre_layout != 'global' && $single_genre_layout != '') ? $single_genre_layout : esc_attr( amy_get_option( 'genre_layout', 'list' ) );
$genre_sidebar	= ($single_genre_sidebar != 'global' && $single_genre_sidebar != '') ? $single_genre_sidebar : esc_attr( amy_get_option( 'genre_sidebar', 'right' ) );
$genre_column	= esc_attr( $genre_sidebar == 'full' ? '12' : '8' );

$genre_layout	= ($single_genre_layout != 'global' && $single_genre_layout != '') ? $single_genre_layout : amy_get_option( 'genre_layout' );
$grid_layout	= ($single_genre_layout != 'global' && $single_genre_layout != '') ? $single_grid_layout : amy_get_option( 'grid_layout' );
$column			= ($single_genre_layout != 'global' && $single_genre_layout != '') ? $single_column : amy_get_option( 'column' );
$layout2_column	= ($single_genre_layout != 'global' && $single_genre_layout != '') ? $single_layout2_column : amy_get_option( 'layout2_column' );

$movie_number	= amy_get_option( 'movie_number' );
$pagination		= amy_get_option( 'pagination' );

?>

<section class="amy-main-content amy-genre amy-<?php echo $layout; ?>">
	<div class="container">
		<div class="row">
			<?php amy_movie_page_sidebar( 'left', $genre_sidebar ); ?>

			<div class="col-md-<?php echo $genre_column; ?>">
			<?php
			if ( $genre_layout == 'list' ) {
				echo do_shortcode('[movielist genre="' . $term_id . '" 
									movie_number="' . $movie_number . '" 
									pagination="' . $pagination . '"]');
			} else if ( $genre_layout == 'grid' ) {
				echo do_shortcode('[moviegrid genre="' . $term_id . '" 
									movie_number="' . $movie_number . '" 
									pagination="' . $pagination . '" 
									layout="' . $grid_layout . '"
									column="' . $column . '"
									layout2_column="' . $layout2_column . '"]');
			}
			?>
			</div>

			<?php amy_movie_page_sidebar( 'right', $genre_sidebar ); ?>

		</div>
	</div>
</section>

<?php

get_footer();
