<?php
 include("lang.php");
 $msg_id=$data['msg_id'];
 $orimessage=$data['message'];
 $message=htmlcode($orimessage);
 $time=$data['created'];
 $mtime=date("c", $time);
 $username=$data['username'];
  $option_pr=$data['secret_option'];
 $pr_text_bold0='';
 $pr_text_bold1='';
 $pr_text_bold2='';
 $pr_icon='';
 if($option_pr == '0'){
	 $pr_text_bold0='bold';
	 $pr_icon= 'icon-globe';
  }else if($option_pr == '1'){
	 $pr_text_bold1='bold';
	 $pr_icon= 'icon-contacs'; 
  }else if($option_pr == '2'){
	 $pr_text_bold2='bold';
	 $pr_icon= 'icon-lock-1';  
	  }
 // instead check if it is set or use null:
 $video = isset($data['video']) ? $data['video'] : NULL;
 $uploads = isset($data['uploads']) ? $data['uploads'] : NULL;
 $privacy  = isset($data['secret_option']) ? $data['secret_option'] : NULL;
 $msg_uid = isset($data['uid_fk']) ? $data['uid_fk'] : NULL;
 $like_count = isset($data['like_count']) ? $data['like_count'] : NULL;
 $omsg_id=$msg_id;	
 $like=$Mat->Like_Check($msg_id,$uid);
 if($like) {
	// If user not liked the update
	$like_status='Like'; // show the status Like
	$like_statusicon='icon-heart-empty-1'; // and show the css icon 1
  } else {
	  // else if user liked the update
	  $like_status='Unlike'; // show the status Unlike
	  $like_statusicon='icon-heart-2'; // and show the css icon 2
  }	
  /* User Avatar*/
  $face = $Mat->User_Profilepic($msg_uid,$base_url); 
  /* End Avatar */ 				
?>
<div class="user-post bottompad" id="stbody<?php echo $msg_id;?>">
   <div class="user-post-area">
     <div class="who-posted">
     <a href="<?php echo $base_url.$username;?>"><div class="user-pimg"><img src="<?php echo $face;?>" /></div>
     <div class="user-pname"><?php echo htmlspecialchars($Mat->UserFullName($username));?></div></a>
     <div class="posted-time ShowStatus" data-id="<?php echo $msg_id;?>">
      <div class="icon-time icon-clock-3"></div>
       <a href='#' class="timeago" title='<?php echo $mtime; ?>'></a></div>
       <?php if($uid == $msg_uid) { ?>
      <div class="p_change" tabindex="0" id="<?php echo $msg_id;?>">
        <div class="pr_icon first_click"><div class="icon-kr <?php echo $pr_icon;?>"></div></div>
        <div class="pr_type first_click_content">
          <div class="type_s change_pri md-ripple" data-id="0" style="font-weight:<?php echo $pr_text_bold0;?>;"><div class="icon-pr icon-globe"></div><?php echo $strings['everyone'];?></div>
          <div class="type_s change_pri md-ripple" data-id="1" style="font-weight:<?php echo $pr_text_bold1;?>;"><div class="icon-pr icon-contacs"></div><?php echo $strings['following'];?></div>
          <div class="type_s change_pri md-ripple" data-id="2" style="font-weight:<?php echo $pr_text_bold2;?>;"><div class="icon-pr icon-lock-1"></div><?php echo $strings['onlyme'];?></div>
        </div>
      </div>
      <?php }?>
      <div tabindex="0" class="edit-delete">
<?php 
if($uid==$msg_uid) { 
?>
  <div class="icon-edit-delete-post icon-down-open"></div>
  <div class="d-z-w"><a class="stdelete" href="#" id="<?php echo $omsg_id;?>" rel="<?php echo $msg_id;?>" title="<?php echo $strings['delete_update'];?>">
  <div class="y-d-si" id="<?php echo $msg_id;?>"><div class="icon-s-k-y-t icon-trash"></div> <?php echo $strings['post_delete'];?></div></a>
  </div>
<?php 
} 
?>
     </div>
</div>
<div class="posted-photo">
<?php
if($uploads){
   echo '<div class="photo">';
   $s = explode(",", $uploads); // Explode the images string value
   $r=1;
   $f=count($s);
   // Add to array the available images
   foreach($s as $a) {
	 // Get the uploaded image ids
     $newdata=$Mat->Get_Upload_Image_Id($a);
     if($newdata) {
		 // The path to be parsed
        $final_image=$base_url."uploads/".$newdata['image_path'];
         echo '<div class="fphoto-item"><a href="'.$final_image.'" data-lightbox="lightbox'.$msg_id.'"><img src="'.$final_image.'" class="imgpreview" id="'.$omsg_id.'" rel="'.$msg_id.'"/></a></div>';
      }
      $r=$r+1;
      }
      echo '</div>';
   }
?>
<?php
// This is the Mat_Expand.php statemnt
// If the update (orimessage = message) have a link
if(textlink($orimessage)) {
	$codesrc='';
    $code='';
	$link =textlink($orimessage);
    $em = new Mat_Expand($link);
	// Get the link size
    $site = $em->get_site();
    if($site != ""){
		// If code is iframe then show the link in iframe
       $code = $em->get_iframe();
       if($code == ""){
		   // If code is embed then show the link in embed
          $code = $em->get_embed();
          if($code == "") {
			  // If code is thumb then show the link medium
             $codesrc=$em->get_thumb("medium");
           }
        }
        if($codesrc) {
			// Get the codesrc medium thumb (image)
           echo '<div class="img_container"><img src='.$codesrc.' class="imgpreview" /></div>';
          } else if($code)
                   echo $code;
          }
     }
?>		
<?php if($video){
    echo '<div class="photo">';
         $s = explode(",", $video);
         $r=1;
         $f=count($s);
          foreach($s as $a)
           {
           $newdata=$Mat->Get_Upload_Video_Id($a);
            if($newdata)
               {
                $final_image=$base_url."uploads/".$newdata['video_name'];
                $vidyo_extension=$newdata['video_ext'];
                 echo "<div class='video_area'>
                 <video id='my_video_1'  class='video-js vjs-default-skin' controls preload='none' poster='".$final_image.".jpg' width='100%' height='267px' data-setup='{}'>
                   <source src='".$final_image.".".$vidyo_extension."' type='video/mp4' />
                 </video>
                 </div>";
               }
                $r=$r+1;
               }
               echo '</div>';
  } ?>
<?php 
if($message) {
	// If the update have a text then show the text 
    echo '<div class="post-text">'.$message.'</div>';
  }
?>
</div>
<div class="post-like-unlike-comment">
  <div class="like-post openCommentArea" id='<?php echo $omsg_id;?>' title='Comment' rel='<?php echo $msg_id;?>' data-id="<?php echo $msg_id;?>"><div class="icon-like-comment icon-talk-chat-bubble"></div></div>
  <div class="like-it like_button"  id='like<?php echo $omsg_id;?>' rel='<?php echo $like_status;?>' title='<?php echo $like_status;?>' data=''><div class="icon-like-comment <?php echo $like_statusicon;?>" ></div></div>
  </div>
<?php 
if($like_count>0) { 
   // If like cound is not 0 
   // Check the liked user
   $likesuserdata=$Mat->Like_Users($msg_id);
   if($likesuserdata){
	   // Show the liked user data
      echo '<div class="who-likes-this-post likes" id="likes'.$omsg_id.'">';
      $i=1;
      $j=count($likesuserdata);
	  // Add to array the like user data
      foreach($likesuserdata as $likesdata) {
         $you="likeuser".$omsg_id;
         $likeusername=$likesdata['username'];
         if($likeusername == $session_username) {
			 // If like username is current username then show
            $you="you".$omsg_id;
          }
		  // Liked user echoing
           echo '<a href="'.$base_url.$likeusername.'">
		   <span class="b-renk" id="'.$you.'">'.htmlspecialchars($Mat->UserFullName($likeusername)).'</span>
		   </a>';
           if($j!=$i) {
              echo ', ';
             }
             $i=$i+1;
             }
             if($like_count>3) {
				 // If total like is greater than 3 then collapse the next like
                $like_count=$like_count-3;
				// and show the echo
                echo ' and <span id="like_count'.$omsg_id.'" class="numcount">'.$like_count.'</span> other people like this.'; 
              } else {
                  echo ' like this.'; 
              }
               echo '</div>';
              }
              } else {
            echo '<div class="likes" id="elikes'.$omsg_id.'" style="display:none"></div>';
    }
?>
</div>
<div class="comments-area" id="commentload<?php echo $omsg_id;?>">
<?php 
$x=1;
// Load all comments
include('comment_load.php');
?>
</div>
<div class="comment_it commentupdate" style='display:none' id='commentbox<?php echo $omsg_id;?>'>
<div class="up_img"><img src="<?php echo $session_face;?>" width="35" height="35" /></div>
<form method="post" action="">
<div class="comments-text-post-area"><textarea class="add-y-comment" name="comment" id="ctextarea<?php echo $omsg_id;?>"></textarea></div>
<div class="comment-post-wall">
<div class="cancel-comment"><input type="button" class="comment-cancel commentopen_button" id='<?php echo $omsg_id;?>' rel='<?php echo $msg_id;?>' value="CANCEL" /></div>
<div class="send-comment"><input type="submit" class="send-comment comment_button commentopen" id="<?php echo $omsg_id;?>" rel="<?php echo $msg_id;?>" value="SEND" /></div>
</div>
</form>   
</div>
 </div>
