<?php

/* This is functions define blocks to display post */

if ( ! function_exists( 'helium_content_thumbnail' ) ) {
  function helium_content_thumbnail( $size ) {
    if ( has_post_thumbnail()  && ! post_password_required() || has_post_format( 'image') )  :
      the_post_thumbnail( $size, array('class'=> 'img-responsive' ));
    endif;
  }
}

if ( ! function_exists( 'helium_postformat_video' ) ) {
  function helium_postformat_video( ) { ?>
    <?php if(has_post_format('video') && wp_oembed_get(get_post_meta(get_the_id(), "helium_met_embed_media", true))){ ?>
	    <div class="js-video postformat_video">
	        <?php echo wp_oembed_get(get_post_meta(get_the_id(), "helium_met_embed_media", true)); ?>
	    </div>
    <?php } ?>
  <?php }
}

if ( ! function_exists( 'helium_postformat_audio ') ) {
  function helium_postformat_audio( ) { ?>
    <?php if(has_post_format('audio') && wp_oembed_get(get_post_meta(get_the_id(), "helium_met_embed_media", true))){ ?>
	    <div class="js-video postformat_audio">
	        <?php echo wp_oembed_get(get_post_meta(get_the_id(), "helium_met_embed_media", true)); ?>
	    </div>
    <?php } ?>
  <?php }
}

if ( ! function_exists( 'helium_content_title' ) ) {
  function helium_content_title() { ?>

    <?php if ( is_single() ) : ?>
      <h1 class="post-title">
        <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
          <?php the_title(); ?>
        </a>
      </h1>
    <?php else : ?>
      <h2 class="post-title">
        <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
          <?php the_title(); ?>
        </a>
      </h2>
      <?php endif; ?>

 <?php }
}


if ( ! function_exists( 'helium_content_meta' ) ) {
  function helium_content_meta( ) { ?>
	        <span>
	        	<i class="fa fa-user"></i>
	        	<?php _e('By: ', 'helium'); ?>
		        <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php the_author_meta( 'display_name' ); ?>
		        </a>
	        </span>
		    &nbsp;
		    <span>
		    	<i class="fa fa-folder-open"></i>
		    	<?php _e('Category: ', 'helium'); ?> 
		    	<?php $categories = get_the_category(get_the_ID()); ?>
        			<?php if($categories!=null && count($categories) >0) {?>
        				<?php $link_cate=get_category_link($categories[0]->cat_ID) ?>
	        			<a href="<?php echo esc_attr($link_cate);?>">
	        				<?php echo esc_html($categories[0]->name); ?>
	        			</a>
        			<?php }?>
		    </span>
		    <span>
		        <i class="fa fa-comments"></i>
		        <a href="<?php the_permalink();?>">                  
		           <?php comments_number( esc_html__('Comment: 0', 'helium'), esc_html__( 'Comment: 1', 'helium' ), esc_html__( 'Comments: %', 'helium' ) ); ?>
		        </a>             
		    </span>
	
  <?php }
}

if ( ! function_exists( 'helium_content_body' ) ) {
  function helium_content_body( ) { ?>
  	<div class="post-excerpt">
		<?php if(is_single()){
		    the_content();
		    wp_link_pages();                
		}else{
			the_excerpt();
		}?>
	</div>

	<?php 
	}
}

if ( ! function_exists( 'helium_content_readmore' ) ) {
  function helium_content_readmore( ) { ?>
  	<div class="post-footer">
		<div class="post-readmore">
		    <a class="rmore btn btn-default btn-xs" href="<?php the_permalink(); ?>"><?php  _e('Read more', 'helium'); ?></a>
		</div>
	</div>
 <?php }
}

if ( ! function_exists( 'helium_content_tag' ) ) {
  function helium_content_tag( ) { ?>
	
	    <footer class="post-tag">
	        <?php if(has_tag()){ ?>
	            <span class="post-tags"><i class="fa fa-tag"></i> 
	                <?php the_tags('',',&nbsp;',''); ?>
	            </span> &nbsp;
	        <?php } ?>
	        <?php if(has_category( )){ ?>
	            <span class="post-categories"><i class="fa fa-folder-open"></i> 
	                <?php the_category(','); ?>
	            </span>
	        <?php } ?>
	    </footer>
	
 <?php }
}

if ( ! function_exists( 'helium_content_gallery' ) ) {
 	function helium_content_gallery( ) {

		if(has_post_format('gallery')){

			$gallery = get_post_meta(get_the_ID(), 'helium_met_file_list', true)?get_post_meta(get_the_ID(), 'helium_met_file_list', true):'';




		    $k = 0;
		    if($gallery){
		        $i=0;

		        ?>

		        <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
				  <!-- Indicators -->
				  <ol class="carousel-indicators">
				  	<?php foreach ($gallery as $key => $value) { ?>
				    	<li data-target="#carousel-example-generic" data-slide-to="<?php echo esc_attr($i); ?>" class="<?php echo ($i==0) ? 'active':''; ?>"></li>
				    <?php $i++; } ?>
				  </ol>

				  <!-- Wrapper for slides -->
				  <div class="carousel-inner" role="listbox">
				  	<?php foreach ($gallery as $key => $value) { ?>
					    <div class="item <?php echo esc_attr($k==0)?'active':'';$k++; ?>">
					      <img class="img-responsive" src="<?php  echo esc_attr($value); ?>" alt="<?php echo get_the_title(); ?>">
					    </div>
				   	<?php } ?>
				   </div>

				</div>

		       
		        <?php
		    }
		}

	}
}



//Custom comment List:
if ( ! function_exists( 'helium_theme_comment' ) ) {
function helium_theme_comment($comment, $args, $depth) {

   $GLOBALS['comment'] = $comment; ?>   
   <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
	     <div class="media v-align-children" id="comment-<?php comment_ID(); ?>">
			<a class="pull-left " href="#">
				<?php echo get_avatar($comment,$size='70', $default = 'mysteryman' ); ?>
			</a>
			<div class="media-body">
				<h4 class="media-heading"> <?php printf('%s', get_comment_author_link()) ?>&nbsp;
					<small>&#8212; <?php printf(get_comment_date()) ?></small>
				</h4>
				<?php comment_text() ?>
				<div class="realy-comment">
	             	<span>
	             	<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
	             	</span>
             	</div>
			</div>
			<?php if ($comment->comment_approved == '0') : ?>
	             <em><?php esc_html_e('Your comment is awaiting moderation.', 'helium') ?></em>
	             <br />
          	<?php endif; ?>
		</div>
    </li>
<?php
}
}






