<?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 id="post-<?php the_ID(); ?>" <?php post_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');
                    }
                   
                     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>
                  
					<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-->
						
						
					   <?php } else {
					?>
						
					<div class="platform-teaser-noimage">
                        <?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-->
					
					<?php } ?>
						
                   

                </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) ?>
					<br><br>
                    <?php the_content(); ?>

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



            <!-- ************ - About the Author - ************** -->
            <?php
            if (ThemeMakersThemeModel::get_option('show_author_info')) {
                $user = get_userdata($post->post_author);
                ?>
                <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><a href="<?php bloginfo('url') ?>/?author=<?php echo $user->ID ?>"><?php echo stripslashes($user->display_name); ?></a></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>

            <?php if ($post->post_type == 'games'): ?>
                <div class="related">
                    <h5><?php _e('Users plays this game', THEMEMAKERS_THEME_FOLDER_NAME); ?></h5>

                    <?php
                    $users_play_this_game = Thememakers_Entity_Game::get_users_play_this_game($post->ID);
                    if (!empty($users_play_this_game)) {
                        $users_string = "";
                        foreach ($users_play_this_game as $key => $value) {
                            if ($key > 0) {
                                $users_string.=",";
                            }
							
                            $users_string.='<a href="'.get_bloginfo('url').'/'.ThemeMakersUser::get_profile_url($value->ID).'">' . $value->display_name.'</a>';
                        }

                        echo $users_string;
                    }
                    ?>

                </div>
                <div class="sep"></div>
            <?php endif; ?>

            <!-- ************ - 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(); ?>

