<?php

/*
 * Template name: Press
 *
 * @package far_loop
 *
 */

get_header();

$fields = array_fill_keys( array(
	'press_sections',
	'contact_email',
	'contact_phone',
	'accreditation',
	'video_stills_loop_2016',
	'images_loop_2015',
	'logos'
), null );

foreach ( $fields as $field => $value )
	$fields[$field] = get_field( $field );

?>

<div class="u_pt-3 u_pt-md-6">
    <div class="l_container u_mv-5">
      <div class="grid u_mh-min1p5 u_mt-md-4">
        <div data-sticky-sidebar class="col--sm--one--third u_ph-1p5">
          <!-- page-title module-->
          <div class="page-title u_mb-3 u_mb-md-4">
            <!-- Page title-->
            <h1 class="page-title__apex-title u_mb-0p5"><?php the_title();?></h1>
          </div>
          <!-- share-module-->
          <?php share_module();?>
        </div>
        <div class="col--sm--two--third u_ph-1p5">
	        
<?php

if( $fields['press_sections'] ) :

foreach ( $fields['press_sections'] as $section ) : ?>

<div class="press-section">
	<h3 class="press-section__name"><?php echo $section['section_title'];?></h3>
	
	<?php if( $section['section_content'] ) : ?>
	
	<p class="press-section__text"><?php echo $section['section_content'];?></p>
	
	<?php endif;?>
	
	<?php 
	
	if( $section['section_links'] ) :
	
	echo '<ul class="press-section__link-list">';
	
	foreach ( $section['section_links'] as $link ) :
	
	echo '<li class="press-section__link-list--item"><a href="' . $link['link_url'] . '" target="_blank" class="press-section__link">';
	
	if ( preg_match( '/dropbox/', $link['link_url'] ) ) {
		echo '<span class="icon icon--dropbox"></span>';
	} elseif ( preg_match( '/docs.google.com/', $link['link_url'] ) ) {
		echo '<span class="icon icon--document"></span>';
	}
	
	echo '<span class="press-section__link-text u_bd-bottom-dotted">' . $link['link_text'] . '</span>'; 
	echo '</a></li>';
	
	endforeach;
	
	echo '</ul>';
	
	endif;?>	
	
	
</div>


<?php endforeach; endif; ?>
	      
          <?php if ( $fields['logos'] ) :?>
          <!-- press-section module-->
          <div class="press-section">
            <h3 class="press-section__name"><?php _e( 'Logo', 'far_loop' );?></h3>
            
            <?php if ( is_array( $fields['logos'] ) ) : ?>
            <div class="press-section__logo-grid">
              
              <?php foreach ( $fields['logos'] as $logo ) : ?>
              
              <div class="press-section__logo"><img src="<?php echo $logo['jpg_format']['sizes']['large'];?>" alt="<?php _e( 'Logo', 'far_loop' );?>">
                <ul class="press-section__logo-links">
                  <li class="press-section__logo-links-icon"><span class="icon icon--download"></span></li>
                  
                  <?php foreach ( $logo as $format ) : if (!$format) continue; //var_dump($format); ?>
                  
                  <li><a href="<?php echo $format['url'];?>" download="download"><?php echo '.' . pathinfo( $format['url'], PATHINFO_EXTENSION );?></a></li>
                  
                  <?php endforeach; // format ?>

                </ul>
              </div>
              
              <?php endforeach; // logo ?>
              
            </div>
            
            <?php endif; ?>
          </div>
          <?php endif;?>
        </div>
      </div>
    </div>
  </div>

<?php get_footer();
