<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<?php
/*
Template Name: Most Viewed
*/
?>
<?php else: ?>
<?php
/*
Template Name: Most Played
*/
?>
<?php endif; ?>
<?php get_header(); ?>

<!-- START MOST PLAYED GAMES -->
    <div id="main">
<div class="grids_box_sidebar"><div class="widget-title"><h1>
<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<?php _e('Most Viewed Posts', 'Gameleon'); ?>
<?php else: ?>
<?php _e('Most Played Games', 'Gameleon'); ?>
<?php endif; ?>
</h1></div></div>

    <div class="block">
    <div class="grid-category-page">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="pagecont">
<div class="post-entry">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; endif; ?>

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
<?php $mostplayed = new WP_Query('&paged='.$paged); ?>
<?php
 $mostplayed = new WP_Query();
 $mostplayed->query('meta_key=post_views_count&orderby=meta_value_num&cat='.-get_option('tigu_exclude_mostplayed').'&posts_per_page='.get_option('tigu_mostviewed_post_number') . '&paged='.$paged);
if (have_posts()) :
while ($mostplayed->have_posts()) : $mostplayed->the_post();
?>
<div class="category-games-page">
<div class="content">

<?php if(has_post_thumbnail() || is_myarcade_game()): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image-thumb'); ?>
<?php if ( empty($image[0]) ) $image[0] = myarcade_get_thumbnail_url(); ?>
<div class="grid-image"><a class=<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>"hover_play_small-wp"<?php else: ?>"hover_play_small"<?php endif; ?> href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<img src="<?php echo $image[0]; ?>" width="76" height="60" alt="<?php the_title(); ?>" />
</a></div>
<?php else: ?>
<div class="grid-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail-76.png" width="76" height="60" alt="<?php the_title(); ?>" />
</a></div>
<?php endif; ?>

   <h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<?php if(get_option('tigu_shorten_titles') == 'true'): ?>
<?php $shorttitle = substr(the_title('','',FALSE),0,26); ?><?php echo $shorttitle; if (strlen($shorttitle) >25){ echo '&hellip;'; } ?>
<?php else: ?>
<?php the_title(); ?>
<?php endif; ?>
</a></h2>

    <p style="padding-top:6px"><?php echo get_excerpt(get_option('tigu_mostviewed_post_excerpt', '93')); ?></p>
<div class="clear"></div>
<div class="somepadd-archive block-meta">

<?php if(get_option('tigu_postdatetime_mostviewed', 'true') == 'true'): ?>
<span class="postdatetime-wp">
<?php the_time('Y-m-d') ?>
</span>
<?php endif; ?>

<?php if(get_option('tigu_mostplayed_mostviewed', 'true') == 'true'): ?>
<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<span class="postviews-wp" title="<?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?></span>
<?php else: ?>
<span class="clubs" title="<?php _e('Played', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php echo getMostPlayed(get_the_ID()); ?> <?php _e('plays', 'Gameleon'); ?></span>
<?php endif; ?>
<?php endif; ?>

<?php if(get_option('tigu_likes_mostviewed', 'true') == 'true'): ?>
<span class="minilikes">
<?php _e('Likes', 'Gameleon'); ?>: <?php echo $wp_superlike->show_likes($post->ID);?>
</span>
<?php endif; ?>

<?php if(get_option('tigu_comments_mostviewed', 'false') == 'true'): ?>
<?php $comment_count = get_comment_count($post->ID); ?>
<?php if ($comment_count['approved'] > 0) : ?>
<span class="heading-comments-exist">
<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>
<?php comments_popup_link('0','1','%'); ?>
<?php else: ?>
<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count>
<?php endif; ?>
</span>
<?php else: ?>
<span class="heading-comments">
<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>
<?php comments_popup_link('0','1','%'); ?>
<?php else: ?>
<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count>
<?php endif; ?>
</span>
<?php endif; ?>
<?php endif; ?>
</div>


    </div>
    </div>
<?php endwhile; wp_reset_query(); endif; ?>
    </div>

<?php kriesi_pagination($mostplayed->max_num_pages, $range = 2); ?>
    </div>
    </div>
<!-- END MOST PLAYEDGAMES -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>