<?php
/*
*  Template Name: Blog
*/
get_header();
$sDateAndTimeFormat = get_option( 'date_format' ).' '.get_option( 'time_format' ); ?>

	<section class="uni-container">
		<div class="blogPostWrap">

		<div class="blogCategoryList">
            <ul>
			<?php wp_list_categories( array('title_li' => '') ); ?>
            </ul>
		</div>

        <?php
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        $aBlogArgs = array(
            'post_type' => 'post',
            'paged' => $paged
        );

        $oBlogQuery = new wp_query( $aBlogArgs );
        if ( $oBlogQuery->have_posts() ) :
        while ( $oBlogQuery->have_posts() ) : $oBlogQuery->the_post();
        ?>
			<div id="post-<?php the_ID(); ?>" <?php post_class('postItem'); ?>>
				<a href="<?php the_permalink() ?>" class="postItemImg">
                        <?php if ( has_post_thumbnail() ) { ?>
                            <?php the_post_thumbnail( 'unithumb-blog', array( 'alt' => the_title_attribute('echo=0') ) ); ?>
                        <?php } else { ?>
						    <img src="http://placehold.it/408x272/5FC7AE/FFFFFF" alt="<?php the_title_attribute() ?>" width="408" height="272">
                        <?php } ?>
				</a>
                <time class="postItemTime" datetime="<?php the_time('Y-m-d'); ?>"><?php the_time( $sDateAndTimeFormat ); ?></time>
				<h4><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h4>
				<?php uni_excerpt(12, '', true) ?>
			</div>
        <?php
        endwhile;
        else :
        ?>

            <?php get_template_part( 'no-results', 'archive' ); ?>

        <?php
        endif;
        ?>
		</div>

		<div class="pagination clear"<?php if ( ot_get_option('uni_ajax_scroll_enable_posts') == 'on' ) { echo ' style="display:none;"'; } ?>>
	    <?php
        $big = 999999999;
		echo paginate_links( array(
			'base'         => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
			'format'       => '?paged=%#%',
			'add_args'     => '',
			'current'      => max( 1, get_query_var( 'paged' ) ),
			'total'        => $oBlogQuery->max_num_pages,
			'prev_text'    => '<i>
								<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="&#1057;&#1083;&#1086;&#1081;_1" x="0px" y="0px" width="7px" height="11px" viewBox="0 0 7 11" enable-background="new 0 0 7 11" xml:space="preserve">
									<path fill="#c3c3c3" class="paginationArrowIcon" d="M0.95 4.636L6.049 0L7 0.864L1.899 5.5L7 10.136L6.049 11L0 5.5L0.95 4.636z"/>
								</svg>
							</i>'.esc_html__('previous', 'asana'),
			'next_text'    => esc_html__('next', 'asana').'<i>
								<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="&#1057;&#1083;&#1086;&#1081;_1" x="0px" y="0px" width="7px" height="11px" viewBox="0 0 7 11" enable-background="new 0 0 7 11" xml:space="preserve">
									<path fill="#c3c3c3" class="paginationArrowIcon" d="M6.05 6.364L0.951 11L0 10.136L5.102 5.5L0 0.864L0.951 0L7 5.5L6.05 6.364z"/>
								</svg>
							</i>',
			'type'         => 'list',
			'end_size'     => 3,
			'mid_size'     => 3
		) );
	    ?>
		</div>

	</section>

<?php get_footer(); ?>