<?php
/**
 * The default template for displaying Document archive
 *
 * @package WordPress
 * @subpackage Charity
 * @since Charity 1.0
 */
?>
<?php get_header(); ?>
<?php $wplook_sidebar_position = 'right' ?>
	<div class="main">
		<div class="main-head">
			<div class="main-head-image fullscreener"></div>
			<div class="main-head-content">
				<div class="grid-container">
					<div class="grid-x grid-margin-x">
						<div class="cell small-12">
							<h1 class="main-title main-title-alt"><?php single_cat_title(); ?></h1><!-- /.main-title main-title-alt -->
							<?php if (ot_get_option('wpl_breadcrumbs_status') == 'on') : ?>
								<ul class="breadcrumbs">
									<?php wplook_breadcrumbs(); ?>
								</ul><!-- /.breadcrumbs -->
							<?php endif; ?>
						</div><!-- /.cell small-12 -->
					</div><!-- /.grid-x grid-margin-x -->
				</div><!-- /.grid-container -->
			</div><!-- /.main-head-content -->
		</div><!-- /.main-head -->

		<div class="main-body">
			<div class="grid-container">
				<div class="grid-x grid-margin-x">
					<div class="content cell small-12 <?php if ( $wplook_sidebar_position == 'right') { echo "large-8";} elseif ( $wplook_sidebar_position == 'disable' ) {echo "large-12"; } else { echo " large-8";} ?>">

						<div class="grid-x grid-margin-x">
							<?php
								if ( have_posts() ) : while ( have_posts() ) : the_post();

								$wplook_document_meta  = get_post_meta(get_the_ID());
								$wplook_document_file 	= isset($wplook_document_meta['wpl_document_file'][0]) ? $wplook_document_meta['wpl_document_file'][0] : false;
								$wplook_document_size 	= isset($wplook_document_meta['wpl_document_file_size'][0]) ? $wplook_document_meta['wpl_document_file_size'][0] : false;
								$wplook_document_page 	= isset($wplook_document_meta['wpl_document_pages'][0]) ? $wplook_document_meta['wpl_document_pages'][0] : false;
								$wpl_doc_link_to_single_page = isset($wplook_document_meta['wpl_doc_link_to_single_page'][0]) ? $wplook_document_meta['wpl_doc_link_to_single_page'][0] : false;
							?>

							<div class="cell small-12 medium-6 <?php if ( $wplook_sidebar_position == 'disable' ) { echo "large-4"; } else { echo "large-6";}?>">
								<div class="cptlist">
									<div class="cptlist-image docs-icons">
									<?php if ($wplook_document_file) : ?>
										<a target="_blank" href="<?php echo esc_url( $wplook_document_file ); ?>" download>
											<i class="<?php echo esc_attr( wplook_get_icon_name( $wplook_document_file ) ); ?>"></i>
										</a>
									<?php endif; ?>
									</div><!-- /.cptlist-image -->

									<h4 class="cptlist-title">
										<?php if ($wpl_doc_link_to_single_page != 'off') { ?>
											<a href="<?php the_permalink(); ?>" itemprop="name"><?php the_title(); ?></a>
										<?php } else { ?>
											<?php the_title(); ?>
										<?php } ?>
									</h4><!-- /.cptlist-title -->

									<div class="cptlist-meta">
										<span><i class="far fa-calendar-alt"></i> <?php the_time( get_option( 'date_format' ) ); ?></span>
										<span><i class="far fa-user"></i> <?php the_author(); ?></span>
									</div><!-- /.cptlist-meta -->

									<div class="cptlist-entry">
										<p itemprop="description">
											<?php echo wplook_short_excerpt(ot_get_option('wpl_docs_excerpt_limit')); ?>
										</p>
									</div><!-- /.cptlist-entry -->

								</div><!-- /.cptlist -->

							</div><!-- /.cell -->

							<?php endwhile; ?>
							<?php else : ?>
								<div class="cell small-12">
									<h2><?php _e('Sorry, no posts matched your criteria.', 'charity-wpl'); ?></h2>
									<p><?php _e('Try again later.', 'charity-wpl'); ?></p>
								</div><!-- /.cell -->
							<?php endif; ?>
							<?php wp_reset_postdata(); ?>

						</div><!-- /.grid-x grid-margin-x -->

						<div class="grid-x grid-margin-x">
							<div class="cell">
								<?php wplook_pagination() ?>
							</div>
						</div><!-- /.grid-x grid-margin-x -->

					</div><!-- /.cell small-12 -->
					<div id="sidebar" class="cell large-3 large-offset-1">
						<div class="sidebar">
							<?php dynamic_sidebar( 'document-1' ); ?>
						</div>
					</div>
				</div><!-- /.grid-x grid-margin-x -->
			</div><!-- /.grid-container -->
		</div><!-- /.main-body -->
	</div><!-- /.main -->
<?php get_footer(); ?>
