<?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
 */

defined( 'ABSPATH' ) or die;

global $post;

$post_id	= isset( $post ) ? $post->ID : 0;
$post_id	= is_home() ? get_option( 'page_for_posts' ) : $post_id;
$post_meta	= get_post_meta( $post_id, '_custom_page_options', true );

$post_title 	= isset( $post_meta['enable_page_title'] ) ? $post_meta['enable_page_title'] : true;
$post_position	= isset( $post_meta['title_position'] ) ? esc_attr( $post_meta['title_position'] ) : '';

if ( is_front_page() ) {
	return;
}

$class  = (isset( $post_meta['enable_page_title'] ) && $post_meta['enable_page_title'] == true)  ? 'has-page-title' : '';
$class .= (isset( $post_meta['title_background_image'] ) && $post_meta['title_background_image'] != null) ? ' type-image' : '';

@$movie_meta		= get_post_meta( $post->ID, '_movie_sidebar', true );
$movieclass = (is_singular( 'amy_movie' )) ? $movie_meta['movie_sidebar'] : '';
?>

<section id="amy-page-header" class="<?php echo esc_attr( $class ); ?> <?php echo esc_attr( $movieclass ); ?>">
	<?php
	if ( is_singular( 'amy_movie' ) ) {
		echo amy_movie_get_banner( $post_id, 'full' );
	} else if ( is_singular( 'amy_cinema' ) ) {
		$arr 	= get_post_meta( $post_id, '_cinema_block_options', true );

		echo '<div class="amy-page-cinema-title">';

		if ( isset( $arr['cinema_banner'] ) ) {
			$image	= wp_get_attachment_image( $arr['cinema_banner'], 'full' );

			echo $image;
		}

		echo '</div>';
	} else if ( is_single() ) {
		echo '<div class="amy-page-title amy-left"><div class="amy-inner container">';
		echo '<h1 class="page-title">' . get_the_title( $post_id ) . '</h1>';
		echo amy_movie_breadcrumb();
		echo '</div>';
		echo '</div>';
	} else if ( is_tax( 'amy_genre' ) ) {
		echo '<div class="amy-page-title amy-left"><div class="amy-inner container"><h1 class="page-title">';
		echo esc_html__( 'Genre: ', 'amy-movie' );
		echo single_term_title();
		echo '</h1>';
		echo amy_movie_breadcrumb();
		echo '</div>';
		echo '</div>';
	} else if ( is_search() ) {
		echo '<div class="amy-page-title amy-left"><div class="amy-inner container">';
		echo '<h1 class="page-title">' . esc_html__( 'Search: ', 'amy-movie' ) . esc_attr( $_GET['s'] ) . '</h1>';
		echo amy_movie_breadcrumb();
		echo '</div>';
		echo '</div>';
	} else if ( is_page_template( 'page-login.php' ) ) {
		echo '<div class="amy-page-title amy-center user-login"><div class="amy-inner container">';
		echo '<h1 class="page-title">' . esc_html__( 'Sign In', 'amy-movie' ) . '</h1>';
		echo amy_movie_breadcrumb();
		echo '</div>';
		echo '</div>';
	} else if ( is_category() ) {
		echo '<div class="amy-page-title amy-left"><div class="amy-inner container">';
		echo '<h1 class="page-title">' . esc_html__( 'Category Archives: ', 'amy-movie' ) . single_cat_title( '', false ) . '</h1>';
		echo amy_movie_breadcrumb();
		echo '</div>';
		echo '</div>';
	} else if ( is_author() ) {
		echo '<div class="amy-page-title amy-left"><div class="amy-inner container">';
		echo '<h1 class="page-title">' . esc_html__( 'Author Archives: ', 'amy-movie' ) . get_the_author() . '</h1>';
		echo amy_movie_breadcrumb();
		echo '</div>';
		echo '</div>';
	} else if ( is_404() ) {
		echo '<div class="amy-page-title amy-left"><div class="amy-inner container">';
		echo '<h1 class="page-title">' . esc_html__( 'Page not found: ', 'amy-movie' ) . '</h1>';
		echo amy_movie_breadcrumb();
		echo '</div>';
		echo '</div>';
	} else if ( is_archive() ) {
		echo '<div class="amy-page-title amy-left"><div class="amy-inner container"><h1 class="page-title">';

		if ( is_day() ) {
			echo '' . esc_html__( 'Daily Archives: ', 'amy-movie' ) . get_the_date() . '';
		} elseif ( is_month() ) {
			echo '' . esc_html__( 'Monthly Archives: ', 'amy-movie' ) . get_the_date( 'F Y' ) . '';
		} elseif ( is_year() ) {
			echo '' . esc_html__( 'Yearly Archives: ', 'amy-movie' ) . get_the_date( 'Y' ) . '';
		}

		echo '</h1>';
		echo amy_movie_breadcrumb();
		echo '</div>';
		echo '</div>';
	} else if ( is_tag() ) {
		echo '<div class="amy-page-title amy-left"><div class="amy-inner container">';
		echo '<h1 class="page-title">' . esc_html__( 'Tags Archives: ', 'amy-movie' ) . single_tag_title( '', false ) . '</h1>';
		echo amy_movie_breadcrumb();
		echo '</div>';
		echo '</div>';
	} else {
		if ( $post_title == true ) {
			echo '<div class="amy-page-title amy-' . $post_position . '"><div class="amy-inner container">';
			echo '<h1 class="page-title">' . esc_attr( get_the_title( $post_id ) ) . '</h1>';
			echo amy_movie_breadcrumb();
			echo '</div>';
			echo '</div>';
		}
	}

	?>
	<?php  ?>
</section>
