<?php
/**
 * @package bloggr
 */
?>
<div id="post_<?php the_ID(); ?>" class="masonry-post" style="height:250px"; onmouseover="mostrar_footer(<?php  '\''.the_ID().'\'';?>)" onmouseout="ocultar_footer(<?php  '\''.the_ID().'\'';?>)">
<article id="<?php the_ID(); ?>" <?php post_class(); ?>>
	<header class="entry-header">
	<div>
		<a href="<?php the_permalink(); ?>" title="<?php the_title();?>"> 
		<?php 
			//$titulo=explode('.', get_the_title());
		$titulo=get_the_title();
		$temp=explode(' ', $titulo);
		$titulo_reducido=$titulo;
	//	echo strlen($titulo[0]);
		if (strlen($titulo)>90){
			$palabras=sizeof($temp);
			$palabras_sobrantes= round((strlen($titulo[0])-86)/5);
			$palabras=$palabras-$palabras_sobrantes;
			$titulo_reducido = wp_trim_words( $post->post_title, $num_words = $palabras, $more = '...' );
		} 
		echo '<h1 class="entry-title">'.$titulo_reducido.'</h1>';
		 ?>
        </a>
        </div>
    	<div class="entry-meta">
		<?php bloggr_child_posted_on(); ?>
		</div><!-- .entry-meta -->
        <a href="<?php the_permalink(); ?>" title="<?php the_title();?>"> 
        <?php
        	$imagen_ainia=get_post_meta($post->ID,'url_picture');
		//echo $post->ID.'-ID-';
		//echo $imagen_ainia[0];
		list($width, $height) = getimagesize($imagen_ainia[0]);
		//echo $width;
		if(sizeof($imagen_ainia[0]) >0 && $width > 120 ){
			echo "<img src=". $imagen_ainia[0]." >";
		} ?>
        </a>
	 			 
	
	</header><!-- .entry-header -->

	<div class="archive-entry-content">
				 <?php
				 
		$imagen_ainia=get_post_meta($post->ID,'url_picture');
		//echo $post->ID.'-ID-';
		//echo $imagen_ainia[0];
		list($width, $height) = getimagesize($imagen_ainia[0]);
		//echo $width;
		if(sizeof($imagen_ainia[0]) <1 || $width < 120 ){
				$contenido_reducido=wp_trim_words( get_field('descripcion'), $num_words = 80, $more = '...' );
				$temp=explode(' ', $contenido_reducido);
			if (strlen($contenido_reducido)>350){
				$palabras=sizeof($temp);
				$palabras_sobrantes= round((strlen($contenido_reducido)-340)/5);
				//echo $palabras_sobrantes;
			//	echo $strlen($contenido_reducido);
				$palabras=$palabras-$palabras_sobrantes;
				$contenido_reducido = wp_trim_words( $post->post_content, $num_words = $palabras, $more = '...' );
		} 
				echo '<span class="meta-nav">'.$contenido_reducido.'</span>';

		}
		?> 
             <?php
			 $url_article = get_post_meta( $post->ID, 'url_article', true );
  			 $terms=wp_get_post_terms($post->ID,"fuente");			 
			 if(count($terms)):?>			 
			 <div class="action_source" style="background-color:white;padding-top:5px;">
			
			<?php echo '<b>'.__( 'Fuente: ', 'bloggr' ).'</b>';?> <a href="<?php echo get_term_link($terms[0],'fuente')?>"><?php echo $terms[0]->name;?></a>  

			 </div>			 
			 <?php endif;?>		
			 
		<?php
		if ( 'post' == get_post_type() ) {
			/* translators: used between list items, there is a space after the comma */
			$categories_list = get_the_category_list( __( ', ', 'bloggr' ) );
			if ( $categories_list && bloggr_categorized_blog() ) {
				printf( '<span class="cat-links" style="background-color:white"><i class="fa fa-pencil"></i> ' . __( '%1$s', 'bloggr' ) . '</span><br>', $categories_list );
			}
		
			/* translators: used between list items, there is a space after the comma */
			$tags_list = get_the_tag_list( '', __( ', ', 'bloggr' ) );
			if ( $tags_list ) {
				printf( '<span class="tags-links" style="background-color:white;"><i class="fa fa-tag"></i> ' . __( '%1$s', 'bloggr' ) . '</span>', $tags_list );
			}
		}?>
		<?php
		
		$rel = get_user_relation_id( get_current_user_id() , 0, get_the_ID(), 'favorite' );
		if($rel):?>
			<i  id="icon_favourite_<?php echo $ID;?>" class="fa fa-heart" style="margin-left:25px;font-size:24px;color:red;cursor:pointer;" ></i>			 					
					 	    
			 <?php endif; ?>


		<?php
			wp_link_pages( array(
				'before' => '<div class="page-links">' . __( 'Pages:', 'bloggr' ),
				'after'  => '</div>',
			) );
		?>
	</div><!-- .entry-content -->

	<footer class="entry-footer-float" style= "visibility:hidden;" id="entry_footer_<?php the_ID();?>">
		<?php bloggr_entry_footer_reduced_ID(get_the_ID()); ?>
	</footer><!-- .entry-footer -->
	<div class="entry-footer-float-hidden" id="entry_footer_float_hidden_<?php the_ID();?>" style="visibility:hidden;">
				
		<div id="send_to_panel_<?php the_ID();?>"	style="visibility:hidden;" class="entry-footer-float-hidden-panel">
		   <p class="action_email"  >
		   	<?php the_title( '<h2 class="entry-title">', '</h2>' ); ?><br>
			 <?php _e('Enviar a:','ainia');?>
		   <input type="text" placeholder="e-mail destino" id="email_<?php the_ID();?>"  style="width:auto" size="20">
		    <input type="button" value="<?php _e('Enviar','ainia');?>" onclick="enviaPorEmail(<?php the_ID();?>)">
		     <input type="button" value="<?php _e('Cerrar','ainia');?>" onclick="ocultar_enviar_a(<?php the_ID();?>)">
		   <div id="mail_ok_<?php echo $post->ID;?>"  style="visibility:hidden;color:green;align:left;"><b>El envío se ha realizado correctamente.</b></div>
		     <div id="mail_nok_<?php echo $post->ID;?>" style="visibility:hidden;color:red;align:left"><b>No se ha podido realizar el envío.</b></div>
		
		   </p>
		  </div>
		 <div id="recommend_to_panel_<?php the_ID();?>"	style="visibility:hidden;" class="entry-footer-float-hidden-panel">
		 	<p class="action_recommend"  >
		 		<?php the_title( '<h2 class="entry-title">', '</h2>' ); ?><br>
			 <?php _e('Recomendar a:','ainia');

			 $current_user=get_current_user_id();
			 $dd_id='user_'.get_the_ID();
			 ?>
			 <?php wp_dropdown_users(array('show_option_none' => '-','exclude'=>array($current_user),'id'=>$dd_id));?>
			 <input type="button" value="<?php _e('Enviar','ainia');?>" onclick="recomendarPost(<?php the_ID();?>)">
			  <input type="button" value="<?php _e('Cerrar','ainia');?>" onclick="ocultar_recomendar_a(<?php the_ID();?>)">
			
			 </p>
			 </div>
			  <?php echo get_loading_spiner($post->ID);?>
	</div>
</article><!-- #post-## -->
</div>