<?php
/**
 * The Template for displaying all single posts.
 *
 * @package Serpentsoft
 * @subpackage Adams_News 1.0
 * @since Adams News 1.0
 */
get_header(); ?>

<!-- main content -->
<article class="article-container" itemscope itemtype="http://schema.org/Article" role="main">
    <div class="row-fluid">

        <?php while (have_posts()) : the_post(); ?>

            <div id="post-<?php the_ID(); ?>" class="article-content">
                <header>
                    <h1 itemprop="headline"><?php the_title(); ?></h1>
                    
                    <footer class="post-info">
                        <?php $metadata = wp_get_attachment_metadata(); ?>
                        <div class="post-meta">
                            <ul>
                                <li title="Publish Time" itemprop="datePublished"><i class="bo-icon-time"></i><?php the_time( get_option('date_format') ); ?>, <?php the_time( get_option('time_format') ); ?></li>
								
                                <li><i class="bo-icon-folder-open"></i><a href="<?php echo esc_url( get_permalink( $post->post_parent ) ) ?>" title="Return to <?php echo esc_attr( strip_tags( get_the_title($post->post_parent) ) ); ?>"><?php echo get_the_title( $post->post_parent ); ?></a></li>

    <?php if (comments_open()) : ?>
                                <li><a href="<?php comments_link(); ?>" itemprop="interactionCount" title="User Comments: <?php comments_number(); ?>"><i class="bo-icon-comment"></i><?php comments_number(); ?></a></li>
    <?php endif; ?>

                                <li><i class="bo-icon-fullscreen"></i>
                                    <?php printf( __('<a href="%1$s" title="Link to full-size image">%2$s &times; %3$s</a>', 'serpentsoft'),
                                            esc_url( wp_get_attachment_url() ), $metadata['width'], $metadata['height'] ); ?>
                                </li>
                                
                                <li itemprop="interactionCount" title="<?php echo 'Views: ' . serpentsoft_get_post_views($post->ID); ?>"><i class="bo-icon-eye-open"></i><?php echo serpentsoft_get_post_views($post->ID); ?></li>
                                
                            </ul>
                        </div>
                    </footer>
                    
                </header>

                <span class="clearfix"></span>

                <div class="post-entry" itemprop="articleBody">
                    <?php
                        /**
                         * Grab the IDs of all the image attachments in a gallery so we can get the URL of the next adjacent image in a gallery,
                         * or the first image (if we're looking at the last image in a gallery), or, in a gallery of one, just the link to that image file
                         */
                        $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
                        foreach ( $attachments as $k => $attachment ) :
                                if ( $attachment->ID == $post->ID )
                                        break;
                        endforeach;

                        $k++;
                        // If there is more than 1 attachment in a gallery
                        if ( count( $attachments ) > 1 ) :
                            if ( isset( $attachments[ $k ] ) ) :
                                // get the URL of the next image attachment
                                $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
                            else :
                                // or get the URL of the first image attachment
                                $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
                            endif;
                        else :
                            // or, if there's only 1 image, get the URL of the image
                            $next_attachment_url = wp_get_attachment_url();
                        endif;
                    ?>
                    
                    <div class="figure-container">
                        <figure class="featured-post-figure" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
                        <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment">
                            <?php $attachment_size = apply_filters( 'serpentsoft_attachment_size', array( 960, 960 ) ); 
                            echo wp_get_attachment_image( $post->ID, $attachment_size ); ?></a>
                        
                        <figcaption itemprop="description">
                            <?php if ( ! empty( $post->post_excerpt ) ) { the_excerpt(); } ?>
                        </figcaption>
                        </figure>
                    </div>
                    
                    <div class="entry-description"><?php the_content(); ?></div>
                    
                    <div class="row-fluid paging-footer"><?php serpentsoft_bootstrap_pagination(); ?></div>
                    
                </div>

                <div class="clearfix"></div>

                <?php serpentsoft_post_social_share_buttons(); ?>
            </div>

        <!-- Article Footer Start from author bio to comments box  -->
        <footer>

                <!-- Posts Navigator -->
    <?php if ( serpentsoft_get_data('serpentsoft_switch_box_prev_next') ): ?>
            <nav class="row-fluid post-navigation">
                <h3 class="hidden">Posts Next/Prev</h3>
                <div class="row-fluid">
                    <div class="span6 prev-post"><?php previous_image_link( false, __( 'Previous Image', 'serpentsoft' ) ); ?></div>
                
                    <div class="span6 next-post text-right"><?php next_image_link( false, __( 'Next Image', 'serpentsoft' ) ); ?></div>
                </div>
            </nav>
    <?php endif; // End-of Next/Prev Box  ?>

        <!-- Members Comments -->
        <?php serpentsoft_comments_box(); ?>

        </footer>

    <?php endwhile; // end of the loop.  ?>
    
    </div>
</article>

<!-- Closing Span6 Main Content -->       

<?php get_footer(); ?>