<?php get_header(); ?>
<!-- ************ - BEGIN Content Wrapper - ************** -->
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <div class="title-caption-large">
            <h3><?php the_title(); ?></h3>
        </div><!--/ .title-caption-large-->


        <!-- ************** - Posts - ************** -->
        <section id="content-posts" class="detailed">

            <article class="post-item clearfix">

                <section class="post-thumb">
                    <?php
                    $terms = wp_get_post_terms($post->ID, 'cons');
                    $featured_image = "";
                    $permalink = get_permalink($post->ID);
                    $featured_image_width = 313;
                    $featured_image_height = 220;
                    if (has_post_thumbnail($post->ID)) {
                        $featured_image = ThemeMakersHelper::get_post_featured_image($post->ID, 'gallery_thumb');
                    }
                    ?>
                    <?php if (!empty($featured_image)): ?>
                        <a href="<?php echo $permalink ?>"><img src="<?php echo $featured_image ?>" width="<?php echo $featured_image_width ?>" height="<?php echo $featured_image_height ?>" alt="" /></a>
                    <?php endif; ?>

                    <div class="platform-teaser">
                        <?php if (!empty($terms)): ?>
                            <?php foreach ($terms as $term) : ?>
                                <?php $cons_color = get_taxonomy_term_type('cons', $term->term_id); ?>
                                <a style="background-color: <?php echo $cons_color ?>" class="game_console" href="<?php bloginfo('url') ?>/?cons=<?php echo $term->slug ?>"><?php echo $term->name ?></a>
                            <?php endforeach; ?>
                        <?php endif; ?>
                    </div><!--/ .platform-teaser-->

                </section><!--/ .post-thumb-->


                <section class="post-entry">
                    <div class="post-date"><?php echo get_the_date() ?></div><!--/ .post-date-->
                    <div class="post-title">
                        <h5><?php echo $post->post_title ?></h5>
                    </div><!--/ .post-title-->
                    <?php echo Thememakers_Entity_Rating::draw_rating($post->ID) ?>

                    <?php the_content(); ?>

                </section><!--/ .post-entry-->
            </article><!--/ .post-item-->

            
            
            <!-- ************ - VIDEOS - ************** -->
            <?php
            $video_width = 315;
            $video_height = 270;

            $videos = Thememakers_Entity_Preview::get_preview_videos($post->ID);

            if (!empty($videos)) {
                foreach ($videos as $key => $video_url) {

                    if (empty($video_url)) {
                        continue;
                    }

                    $video_type = 'youtube.com';
                    $allows_array = array('youtube.com', 'vimeo.com', '.mp4');

                    foreach ($allows_array as $key => $needle) {
                        $count = substr_count($video_url, $needle);
                        if ($count) {
                            $video_type = $allows_array[$key];
                        }
                    }

                    switch ($video_type) {
                        case $allows_array[0]:
                            $video_url = explode("?v=", $video_url);
                            $video_url = explode("&", $video_url[1]);
                            if (is_array($video_url)) {
                                $video_url = $video_url[0];
                            }
                            echo do_shortcode('[video type="youtube" html5_poster="" html5_video_url="" src_webm="" src_ogg="" width="' . $video_width . '" height="' . $video_height . '"]' . $video_url . '[/video]');
                            break;
                        case $allows_array[1]:
                            $video_url = explode("/", $video_url);
                            if (is_array($video_url)) {
                                $video_url = $video_url[count($video_url) - 1];
                            }
                            echo do_shortcode('[video type="vimeo" html5_poster="" html5_video_url="" src_webm="" src_ogg="" width="' . $video_width . '" height="' . $video_height . '"]' . $video_url . '[/video]');
                            break;

                        default:
                            $html5_poster = THEMEMAKERS_THEME_URI . "/images/video_poster.jpg";
                            if (has_post_thumbnail($post->ID)) {
                                $html5_poster = ThemeMakersHelper::get_post_featured_image($post->ID, 'gallery_thumb');
                            }
                            echo do_shortcode('[video type="html5" html5_poster="' . $html5_poster . '" html5_video_url="' . $video_url . '" src_webm="" src_ogg="" width="' . $video_width . '" height="' . $video_height . '"][/video]');
                            break;
                    }
                }
            }
            ?>
            <!-- ************ - END VIDEOS - ************** -->



            <!-- ************ - About the Author - ************** -->
            <?php
            if (ThemeMakersThemeModel::get_option('show_author_info')) {
                $user = get_userdata($post->post_author);
                if (isset($user->ID)) {
                    ?>
                    <div id="bio" class="clearfix">
                        <h5><?php _e('About the Author', THEMEMAKERS_THEME_FOLDER_NAME); ?></h5>
                        <?php echo get_avatar($user->ID, 54, THEMEMAKERS_THEME_URI . '/images/avatar.png'); ?>
                        <div class="bio-info">
                            <h5><?php echo stripslashes($user->display_name); ?></h5>
                            <p><?php echo stripslashes($user->description); ?></p>
                        </div><!--/ bio-info-->
                    </div><!--/ bio-->
                <?php }
            } ?>
            <!-- ************ - END About the Author - ************** -->



            <!-- ************ - Related - ************** -->
            <?php
            if (ThemeMakersThemeModel::get_option('enable_related_posts')) {

                $tags = wp_get_post_tags($post->ID);
                $tag_ids = array();

                if ($tags) {
                    foreach ($tags as $tag_item)
                        $tag_ids[] = $tag_item->term_id;
                }

                $query = new WP_Query(array(
                    'tag__in' => $tag_ids,
                    'post_type' => $post->post_type,
                    'post__not_in' => array($post->ID),
                    'showposts' => 4
                        )
                );
                ?>

                <div class="sep"></div>

                <div class="related">
                    <h5><?php _e('Related Posts', THEMEMAKERS_THEME_FOLDER_NAME) ?></h5>
                    <ul>
                        <?php
                        $i = 0;
                        if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
                                ?>
                                <li class="<?php if ($i == 3) echo 'last'; ?>">
                                    <?php if (has_post_thumbnail()) : ?>
                                        <a href="<?php the_permalink(); ?>"><img class="custom-frame" alt="" src="<?php echo ThemeMakersHelper::get_post_featured_image($post->ID, 'single_thumb'); ?>"></a>
                                    <?php else: ?>
                                        <a href="<?php the_permalink(); ?>"><img class="custom-frame" alt="" src="<?php echo THEMEMAKERS_THEME_URI . '/images/no_img_160x101.gif' ?>"></a>
                    <?php endif; ?>
                                    <div class="related-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
                                </li>
                                <?php
                                $i++;
                            endwhile;
                        endif;
                        ?>
                    </ul>
                    <div class="clear"></div>
                </div><!--/ related-->
            <?php } ?>
        <?php wp_reset_query(); ?>
            <!-- ************ - END Related - ************** -->

            <div class="sep"></div>

            <!-- ************ - Post Comments - ************** -->
            <?php
            if (!$_REQUEST['disable_blog_comments']) {
                comments_template();
            }
            ?>
            <!-- ************ - END Post Comments - ************** -->


        </section><!--/ #content-posts-->
        <!-- ************** - END Posts - ************** -->

        <?php
    endwhile;
endif;
?>

<!-- ************ - END Content Wrapper - ************** -->
<?php get_footer(); ?>

