<?php
/**
 * @package bloggr
 */
?>
<div id="post_<?php $post->ID; ?>" class="masonry-post"  onmouseover="mostrar_footer(<?php  '\''.$post->ID.'\'';?>)" onmouseout="ocultar_footer(<?php  '\''.$post->ID.'\'';?>)">
<article id="<?php $post->ID; ?>" <?php post_class(); ?>>
	<header class="entry-header">
	<div>
		<?php  $permalink=home_url($post->post_name);?>
		<a href="<?php echo $permalink; ?>" title="<? echo $post->post_title;?>"> 
		<?php 
		//$titulo=explode('.', get_the_title());
		$titulo=$post->post_title;
		 $current_user=get_current_user_id();
		$temp=explode(' ', $titulo);
		$titulo_reducido=$titulo;		
		if (strlen($titulo)>90){
			$palabras=sizeof($temp);			
			$palabras_sobrantes= round((strlen($titulo)-90)/8);
			$palabras=$palabras-$palabras_sobrantes;
			if ($palabras<10) $palabras=10;
			$titulo_reducido = wp_trim_words( $titulo, $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 -->
      
	 			 
	
	</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( $post->post_content, $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 );
  					 
		?>			 
			 <div class="action_source" style="background-color:white;padding-top:5px;">
			
			<?php 
				$fuente_link=home_url('fuente/'.$post->fuente_slug);
		
			echo '<b>'.__( 'Fuente: ', 'bloggr' ).'</b>';?> <a href="<?php echo $fuente_link?>"><?php echo $post->fuente_name;?></a>  

			 </div>			 
			 
			 
		<?php
		if ( 'post' == get_post_type() ) {
			
			 $categories_list=explode("¬¬,",$post->categoria_name);	
  			 $slugs=explode("¬¬,",$post->categoria_slug);
  			 //$clean_product_name =str_replace("¬¬", "", $post->product_name);
			/* translators: used between list items, there is a space after the comma */
  			 /*<a href="http://213.229.136.105/iwatch/ecoembes/category/cart-n-ondulado/" rel="category tag">cartón ondulado</a> */
			//$categories_list = get_the_category_list( __( ', ', 'bloggr' ) );
			if ( $categories_list  ) {
				echo '<span class="cat-links" style="background-color:white"><i class="fa fa-pencil"></i> ';
				$i=0;
				foreach ($categories_list as $category_name){
					//echo 'NAME'.$category_name.'NAME';
					$category_link=home_url('category/'.str_replace("¬¬", "", $slugs[$i]));
					
					if($i>0){
						echo ', ';
					}
					$i=$i+1;
					echo '<a href="'.$category_link.'" rel="category tag">'.str_replace("¬¬", "",$category_name).'</a>';
		
				}
				 echo '</span><br>';
			}
		
			/* translators: used between list items, there is a space after the comma */
			//$tags_list = get_the_tag_list( '', __( ', ', 'bloggr' ) );
			 $tags_list=explode("¬¬,",$post->etiqueta_name);	
  			 $slugs_etiqueta=explode("¬¬,",$post->etiqueta_slug);
			if ( $tags_list ) {
				echo '<span class="cat-links" style="background-color:white"><i class="fa fa-tag"></i> ';
				$i=0;
				foreach ($tags_list as $tag_name){
					$tag_link=home_url('tag/'.str_replace("¬¬", "", $slugs_etiqueta[$i]));
					
					if($i>0){
						echo ', ';
					}
					$i=$i+1;
					echo '<a href="'.$tag_link.'" rel="tag">'.str_replace("¬¬", "",$tag_name).'</a>';
		
				}
				 echo '</span><br>';
			}
		}?>
		<?php
		
		$rel = $post->favorito;
		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_ID($post->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 echo $post->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 $post->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');

			
			 $dd_id='user_'.$post->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>