<?php 
/*
	template name: 我的投稿
	description: template for mobantu.com Monkey theme 
*/
if(!is_user_logged_in()){
	echo "<script>window.location.href='".get_permalink(get_page_id_from_template('page-login.php'))."';</script>";
}else{
get_header();
global $wpdb;
global $current_user; 
get_currentuserinfo();
$uid = $current_user->ID;
?>
<link rel="stylesheet" href="<?php bloginfo("template_url")?>/static/css/user.css">
<div class="content main-content-wrap ng-scope">
  <div class="user-center-wrapper ng-scope">
    <div class="container">
      <div class="row">
        <?php include('modules/pageUserSide.php');?>
        <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
          <div class="favorite-wrapper ng-scope">
            <?php 
				$counts = $wpdb->get_var("SELECT COUNT(1) FROM " . $wpdb->posts . " WHERE post_author=" . $uid . " AND post_type='post' and post_status='publish'");
				$perpage = 10;
				$pagess = ceil((int)$counts / $perpage);
				$paged = (get_query_var('paged')) ? $wpdb->escape(get_query_var('paged')) : 1;
				$args = array('caller_get_posts' => 1, 'showposts' => 10, 'paged' => $paged, 'orderby' => 'date', 'author' => $uid, 'post_status' =>'publish');
				query_posts($args);
			?>
            <ul class="nav nav-tabs" role="tablist">
              <li class="active"><a>已通过的投稿<span class="badge ng-binding ng-scope"><?php echo (int)$counts;?></span></a></li>
            </ul>
            <div class="ng-isolate-scope loading-content-wrap loading-show loading-show-active">
              <?php if(have_posts()) {?>
              <div class="list-group ng-scope">
                <div class="list-group-item content-list-item ng-scope">
                  <?php while (have_posts()) { the_post();?>
                  <section class="news-item"> <a class="pic" target="_blank" href="<?php echo get_permalink();?>"> <img alt="<?php the_title();?>" src="<?php echo MThemes_thumbnail_custom(95,63,get_the_ID())?>"> </a>
                    <div class="actions"> <span class="time ng-binding"><?php echo get_the_time('Y-m-d G:i')?> 发布</span> </div>
                    <div class="desc"> <a class="title ng-binding" target="_blank" href="<?php echo get_permalink();?>"><?php the_title();?></a> <span class="brief ng-binding"><?php echo mb_strimwidth( mbthemes_strip_tags( get_post(get_the_ID())->post_content ), 0, 100,"...");?></span> </div>
                  </section>
                  <?php }?>
                </div>
              </div>
              <div class="text-center">
                <nav class="text-center comp-pagination">
                  <?php MBT_monkey_page_pagination($paged,$pagess);?>
                </nav>
              </div>
			  <?php }wp_reset_query();?>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
</div>
</div>
<?php get_footer();}?>
