<?php
get_header();
$nav_h = cls_nav_height();
$term_id = isset($_GET['term_id']) ? $_GET['term_id'] : false;
$user_id = get_current_user_id();
$base_url = '';
$total_pages = '';
$current = 1;

if($term_id){
    $mo_owner = get_term_meta($term_id, 'mo_owner', true);
    $img = get_term_meta( $term_id, 'mo_cat_img' , true);
    $img = $img ? $img : THEME_URL.'/img/modef.png';
    $term_data = get_term_by('id',$term_id,'moments');
    $name = $term_data->name;
    $des = $term_data->description ? $term_data->description : '暂无介绍';
    $joined_dot = mo_wait_join_notice($term_id); 
    $pending_dot = mo_posts_notice($term_id);
    $join_type = get_term_meta($term_id, 'mo_free_join_type', true);
}

?>

<div class="pix-content moment-edit-warp home-classic" uk-height-viewport>
    <div class="uk-flex-center uk-grid-collapse" uk-grid>

    <?php if(is_active_sidebar( 'moment-left' )){ ?>	
            <div class="left uk-width-expand">			
                <div class="widget_inner moment_left_inner">
                    <div uk-sticky="offset: <?php echo $nav_h ?>">
                        <?php dynamic_sidebar( 'moment-left' ); ?>
                    </div>    
                </div>	
            </div>			
        <?php } ?>

    <div class="center-content">
        <div class="moment-edit-manage">
           <?php if(moment_auth('',$user_id,$term_id) && $term_id){ ?>
                <div class="manage-page-title">
                    <div class="cat-info">
                        <div class="cat-thum"><img src="<?php echo $img; ?>" alt="" /></div>
                        <div class="cat-name"><span><?php echo $name; ?></span><small><?php echo $des ?></small></div>
                    </div>
                    <div class="cat-nav" term_id="<?php echo $term_id; ?>">
                        <a class="review-mo review-page-btn active" type="review_mo"><?php echo esc_html(ppo_moment_label('moment')); ?>待审<?php echo $pending_dot ?></a>
                        <?php if($join_type == 'verify') { ?>
                            <a class="review-join review-page-btn" type="review_join">申请待审<?php echo $joined_dot ?></a>
                        <?php } ?>    
                        <a class="mo-user-manage review-page-btn" type="review_mo_user"><?php echo esc_html(ppo_moment_label('user')); ?>管理</a>
                    </div>
                </div>
                <div class="moment-manage-inner">
                    <?php echo get_pending_moment($term_id,$base_url,$total_pages,$current); ?>
                </div>
            <?php } else { ?>
                <div class="edit-page-title nodata"><img src="<?php echo THEME_URL.'/img/limits.png'?>"><span>你没有权限访问此页面</span></div>
            <?php } ?>
        </div>
    </div>

        <?php if(is_active_sidebar( 'moment-right' )){ ?>		
                <div class="right uk-width-expand">		
                    <div class="widget_inner moment_right_inner">
                        <div uk-sticky="offset: <?php echo $nav_h ?>">
                            <?php dynamic_sidebar( 'moment-right' ); ?>
                        </div>    
                    </div>	
                </div>			
            <?php } ?>
    
    </div>
</div>

<?php
get_footer();


