<?php
/*
 * This file belongs to the YIT Framework.
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-3.0.txt
 */

global $post;
$terms                  = $portfolio->terms_list( ', ' );
$previous_post          = get_adjacent_post( false, '', true );
$next_post              = get_adjacent_post( false, '', false );
$previous_post_terms    = is_object( $previous_post ) ? yit_get_terms_list_by_id( $previous_post->ID,$taxonomy ) : false;
$next_post_terms        = is_object( $next_post )     ? yit_get_terms_list_by_id( $next_post->ID, $taxonomy ) : false;
$post_attachment_id     = get_post_thumbnail_id();

$featured_image_size    = apply_filters( 'yit_portfolio_single_image_size', ( $is_lookbook ? yit_size_xl('portfolio_single_big_lookbook') : yit_size_xl('portfolio_single_big_featured') ) );

?>

<div id="post-<?php the_ID(); ?>" <?php post_class( 'portfolio_' . $layout ) ?> >
    <div class="meta clearfix portfolio single">
        <div id="portfolio_nav">
            <!-- PREV -->
            <?php if( ! empty( $previous_post ) ) : ?>
                <a href="<?php echo get_permalink( $previous_post->ID ); ?>" rel="prev">
                    <span class="icon-wrap shade-3"><?php _e( 'Prev', 'yit' ) ?></span>
                    <div class="prev-post">
                        <?php echo get_the_post_thumbnail( $previous_post->ID, 'portfolio_thumb', array( 'class' => 'img-responsive portfolio_thumb' ) );; ?>
                        <div class="info shade-2">
                            <h5 class="prev_title"><?php echo $previous_post->post_title ?></h5>
                            <span class="prev_terms"><?php echo $previous_post_terms ?></span>
                        </div>
                    </div>
                </a>
            <?php endif; ?>

            <!-- NEXT -->
            <?php if( ! empty( $next_post ) ) : ?>
                <a href="<?php echo get_permalink( $next_post->ID ); ?>" rel="next">
                    <span class="icon-wrap shade-3"><?php _e( 'Next', 'yit' ) ?></span>
                    <div class="next-post">
                        <?php echo get_the_post_thumbnail( $next_post->ID, 'portfolio_thumb', array( 'class' => 'img-responsive portfolio_thumb' ) ); ?>
                        <div class="info shade-2">
                            <h5 class="next_title"><?php echo $next_post->post_title ?></h5>
                            <span class="next_terms"><?php echo $next_post_terms ?></span>
                        </div>
                    </div>
                </a>
            <?php endif; ?>

            <div class="title">
                <h1 class="portfolios-title"><?php the_title() ?></h1>
                <?php if ( $enable_categories ) : ?>
                    <div class="categories">
                        <?php echo $terms ?>
                    </div>
                <?php endif; ?>
            </div>
        </div>

        <div id="portfolio_content" class="row">
            <?php if ( has_post_thumbnail() || ! empty( $attachments ) ) : ?>
                <div class="col-sm-8 col-sm-push-4">
                    <div class="row">
                        <div class="portfolio-single-thumb col-sm-12">
                            <?php echo $portfolio->get_image( $featured_image_size, array( 'class' => 'img-responsive' ) ); ?>
                        </div>
                        <?php foreach ( $attachments as $key => $attachment ) : ?>
                            <div class="portfolio-single-thumb col-sm-12">
                                <?php yit_image( "id=$attachment->ID&size=$featured_image_size&class=img-responsive" ); ?>
                            </div>
                        <?php endforeach; ?>
                    </div>
                </div>
            <?php endif; ?>

            <div class="col-sm-<?php echo has_post_thumbnail() || ! empty( $attachments ) ? '4 col-sm-pull-8' : 12 ?> ">
                <?php if( $enable_extra_info ) : ?>
                    <?php yit_get_template( 'portfolios/common/extra_info.php', $extra_info_variables ); ?>
                <?php endif; ?>
                <div class="the_content <?php echo ( $show_testimonial || $show_share ) ? 'with-border': 'no-border' ?>">
                    <?php the_content() ?>
                </div>
                <?php if( $show_testimonial ) : ?>
                    <div class="testimonial-box <?php echo ( $show_share ) ? 'with-border': 'no-border' ?>">
                        <?php if( ! empty( $testimonial_title ) ) : ?>
                            <h3 class="testimonial-section-title">
                                <?php echo $testimonial_title ?>
                            </h3>
                        <?php endif; ?>
                        <div class="testimonial-wrapper">
                            <div class="testimonial-cit">
                                <span class="testimonial-text">
                                    <?php echo $testimonial->post_content ?>
                                </span>
                                <h4 class="title">
                                    <?php echo $testimonial->post_title ?>
                                </h4>
                            </div>
                        </div>
                    </div>
                <?php endif; ?>
                <?php if( $show_share ) : ?>
                    <?php if( !empty( $share_title ) ) : ?>
                        <h3 class="share-section-title" >
                            <?php echo $share_title ?>
                        </h3>
                    <?php endif; ?>
                    <?php yit_get_social_share( 'square', 'portfolio-share content-style-social', $share_socials )?>
                <?php endif; ?>
            </div>
            
        </div>
    </div>
</div>
