<?php
/*
  Template Name: Consoles (Review)
 */
get_header();

$excerpt_symbols_count = ThemeMakersThemeModel::get_option('excerpt_symbols_count');
if (!$excerpt_symbols_count) {
    $excerpt_symbols_count = 140;
}
$show_full_content = ThemeMakersThemeModel::get_option('show_full_content');
$reviews_counter = 0;
?>
<!-- ************ - BEGIN Content Wrapper - ************** -->

<div class="title-caption-large">
    <h3><?php _e('Reviews', THEMEMAKERS_THEME_FOLDER_NAME); ?></h3>
</div><!--/ .title-caption-large-->

<?php $consoles=get_the_terms($post->ID, "cons"); ?>


<div class="reviews-content">
    <div class="gamelist">
        <ul class="clearfix">
			<?php 
			foreach ($consoles as $cons){
			$args=array(
				'post_type' => 'review',
				'paged' => $paged,
								
				'tax_query' => array(  
								array( 	'taxonomy' => 'cons',  
										'field' => 'slug',  
										'terms' => $cons->slug,
										)  
									) 
					);
			
			}
			?>
			<?php query_posts($args);?>
			
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>


                    <?php
                    $terms = wp_get_post_terms($post->ID, 'category');
                   		
                    $permalink = get_permalink($post->ID);
					
                    ?>
							

                    <?php if ($reviews_counter == 0) { ?>
							
                        <li>
                            <a href="<?php echo $permalink ?>">
							<?php 
							echo wp_get_attachment_image(get_post_thumbnail_id($post->ID), array(646,453)); 
							$featured_image=get_post_thumbnail_id($post->ID);
								if (empty($featured_image)) {
									$featured_image = THEMEMAKERS_THEME_URI . '/images/no-image.jpg';			
							 		$featured_image_width='646px';
									$featured_image_height='453px';
									?>
									<img src="<?php echo $featured_image ?>" width="<?php echo $featured_image_width ?>" height="<?php echo $featured_image_height ?>" alt="<?php echo $post->post_title ?>" />
								<?php } ?>
							</a>
                            <div class="caption">
                                <span class="date"><?php echo get_the_date() ?></span>
                                <h5 class="title"><a href="<?php the_permalink() ?>"><?php echo $post->post_title ?></a></h5>
								<div class="clear"></div>
                                <div class="description">
                                    <?php if ($show_full_content) : ?>
                                        <?php the_content(); ?>
                                    <?php else: ?>

                                        <?php
                                        if ($excerpt_symbols_count) {
                                            echo substr(get_the_excerpt(), 0, $excerpt_symbols_count) . " ...";
                                        } else {
                                            the_excerpt();
                                        }
                                        ?>
                                    <?php endif; ?>
                                </div>
                                <a href="<?php the_permalink() ?>" class="button medium gray align-btn-left"><?php _e('Read More', THEMEMAKERS_THEME_FOLDER_NAME); ?></a>
                                <?php if (!$_REQUEST['disable_blog_comments']): ?>
                                <div class="comments-icon"><a href="<?php the_permalink(); ?>#comments"><?php comments_number('0', '1', '%'); ?> <?php _e('comments', THEMEMAKERS_THEME_FOLDER_NAME); ?></a></div><!--/ comments-icon-->                            
                                <?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-->
									
                                <?php echo Thememakers_Entity_Rating::draw_rating($post->ID) ?>
                            </div><!--/ .caption-->							   
                            <div class="clear"></div>
                        </li>
						
						<?php } else if (($reviews_counter <= 2)and ($reviews_counter > 0)) { ?>
						
                        <li>
                            <a href="<?php echo $permalink ?>">
								<?php 
								echo wp_get_attachment_image(get_post_thumbnail_id($post->ID), array(313,220)); 
								$featured_image=get_post_thumbnail_id($post->ID);
								if (empty($featured_image)) {
									$featured_image = THEMEMAKERS_THEME_URI . '/images/no-image.jpg';			
							 		$featured_image_width='313px';
									$featured_image_height='220px';
									?>
									<img src="<?php echo $featured_image ?>" width="<?php echo $featured_image_width ?>" height="<?php echo $featured_image_height ?>" alt="<?php echo $post->post_title ?>" />
								<?php } ?>
								
							</a>
                            <div class="caption">
                                <span class="date"><?php echo get_the_date() ?></span>
                                <h5 class="title"><a href="<?php the_permalink() ?>"><?php echo $post->post_title ?></a></h5>
								<div class="clear"></div>
                                <div class="description">
                                    <?php if ($show_full_content) : ?>
                                        <?php the_content(); ?>
                                    <?php else: ?>

                                        <?php
                                        if ($excerpt_symbols_count) {
                                            echo substr(get_the_excerpt(), 0, $excerpt_symbols_count) . " ...";
                                        } else {
                                            the_excerpt();
                                        }
                                        ?>
                                    <?php endif; ?>
                                </div>
                                <a href="<?php the_permalink() ?>" class="button medium gray align-btn-left"><?php _e('Read More', THEMEMAKERS_THEME_FOLDER_NAME); ?></a>
                                <?php if (!$_REQUEST['disable_blog_comments']): ?>
                                <div class="comments-icon"><a href="<?php the_permalink(); ?>#comments"><?php comments_number('0', '1', '%'); ?> <?php _e('comments', THEMEMAKERS_THEME_FOLDER_NAME); ?></a></div><!--/ comments-icon-->                            
                                <?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-->
									
                                <?php echo Thememakers_Entity_Rating::draw_rating($post->ID) ?>
                            </div><!--/ .caption-->							   
                            <div class="clear"></div>
                        </li>
						
			
                    <?php } else { ?>
						
                        <li class="reviews-more">
                            <span class="date"><?php echo get_the_date() ?></span>
                            <h5 class="title"><a href="<?php the_permalink() ?>"><?php echo $post->post_title ?></a></h5>
                            <div class="description">
                                <?php if ($show_full_content) : ?>
                                    <?php the_content(); ?>
                                <?php else: ?>

                                    <?php
                                    if ($excerpt_symbols_count) {
                                        echo substr(get_the_excerpt(), 0, $excerpt_symbols_count) . " ...";
                                    } else {
                                        the_excerpt();
                                    }
                                    ?>
                                <?php endif; ?>
                            </div>
                            <?php echo Thememakers_Entity_Rating::draw_rating($post->ID) ?>
                            <?php if (!$_REQUEST['disable_blog_comments']): ?>
                            <div class="comments-icon"><a href="<?php the_permalink(); ?>#comments"><?php comments_number('0', '1', '%'); ?> <?php _e('comments', THEMEMAKERS_THEME_FOLDER_NAME); ?></a></div><!--/ comments-icon-->                            
                            <?php endif; ?>
                            <div class="clear"></div>
                        </li>

                    <?php }; ?>


                    <?php $reviews_counter++; ?>


                <?php endwhile; ?>
            <?php else : ?>

                <article id="post-0" class="post-item no-results not-found">
                    <header class="entry-header">
                        <h1 class="entry-title"><?php _e('Nothing Found', THEMEMAKERS_THEME_FOLDER_NAME); ?></h1>
                    </header><!-- .entry-header -->

                    <div class="entry-content">
                        <p><?php _e('Sorry, but nothing matched your search criteria. Please try again with some different keywords.', THEMEMAKERS_THEME_FOLDER_NAME); ?></p>
                        <?php get_search_form(); ?>
                    </div><!-- .entry-content -->
                </article><!-- #post-0 -->
            <?php endif; ?>
        </ul>
    </div><!--/ .gamelist-->
</div><!--/ .top-games-->






<!-- ************ - END Content Wrapper - ************** -->
<div class="pagenavi">
    <?php
    ThemeMakersHelper::pagenavi();
    wp_reset_query();
    ?>
</div><!--/ pagenavi -->
<!-- ************ - END Page navigation - ************** -->
<?php get_footer(); ?>

