<?php
  
$blog = DB::GET_STRING("SELECT `ID`,`NAME`,`USER_ID`,`ID_CATEGORY`,`MESSAGE` FROM `BLOGS` WHERE `ID` = '".$list['OBJECT_ID']."' LIMIT 1");
$account = DB::GET_STRING("SELECT `ID`,`SEX` FROM `USERS` WHERE `ID` = '".$list['OBJECT_ID_LIST']."' LIMIT 1");

USER::LOGIN($account['ID'], 1, 1);

IF ($account['SEX'] == 2){
  
  ECHO " ".LG('добавила запись в блог')."";
  
}ELSE{
  
  ECHO " ".LG('добавил запись в блог')."";
  
}

ECHO "<br /><span class='time'>".STIME($list['TIME'])."</span></br /></br />";

IF (!ISSET($blog['ID'])){
  
  ECHO "<font color='red'>".LG('Объект был удален')."</font>";
  
}ELSE{
  
  ECHO "<div style='margin-top: 8px; margin-bottom: 8px;'><a href='/modules/?path=blogs&section=show&id=".$blog['ID']."'><b>".CROP_TEXT(TEXT_ABSOLUTE($blog['NAME']), 0, 80)."</b></a></div>";
    
$data2 = DB::GET_STRING_ALL("SELECT * FROM `ATTACHMENTS` WHERE `USER_ID` = '".$blog['USER_ID']."' AND (`TYPE` = 'photos' OR `TYPE` = 'videos') AND `ID_POST` = '".$blog['ID']."' AND `BLOGS` = '1' AND `ACT` = '1' ORDER BY `TIME` DESC LIMIT 1");
WHILE ($list2 = $data2->FETCH()){
  
  REQUIRE (ROOT.'/users/attachments/plugins/inc_blogs_list.php');

}

ECHO "<div style='margin-top: 8px; margin-bottom: 8px;'>";

IF (STR($blog['MESSAGE']) > 120){
  
  ECHO "<div id='blogs".$blog['ID']."' style='margin-top: 5px;'>";
    
  ECHO CROP_TEXT(TEXT($blog['MESSAGE'], 1, 1, 1, 0, 0), 0, 120);
  
  ECHO "</div>";
    
  ECHO "<div id='blogs2".$blog['ID']."' style='display: none; margin-top: 5px;'>";
    
  ECHO CROP_TEXT(TEXT($blog['MESSAGE'], 1, 1, 1, 0, 0), 0, 1500);
    
  ECHO "</div>";
    
  ?><a onclick="show_or_hide('blogs<?=$blog['ID']?>', 'blogs2<?=$blog['ID']?>', 'chevron<?=$blog['ID']?>', 'opacity_message<?=$blog['ID']?>')" load="none"><?
      
  ECHO "<div id='chevron".$blog['ID']."' class='chevron'><i class='fa fa-chevron-down fa-fw'></i></div>";
    
  ECHO "</a>";

}ELSE{
  
  ECHO TEXT($blog['MESSAGE'], 1, 1, 1, 0, 0);

}

ECHO "</div>";

ECHO "<div style='padding: 5px; text-align: right; color: gray; font-size: 12px;'>";

$category = DB::GET_STRING("SELECT * FROM `BLOGS_CATEGORIES` WHERE `ID` = '".$blog['ID_CATEGORY']."' LIMIT 1");

IF (ISSET($category['ID'])){
  
  ECHO "<a href='/modules/?path=blogs&section=categories&id=".$category['ID']."'>".TEXT_ABSOLUTE($category['NAME'])."</a>";
  
}

ECHO "</div>";
  
$count_like = DB::GET_COLUMN("SELECT COUNT(*) FROM `BLOGS_LIKES` WHERE `BLOG_ID` = '".$blog['ID']."'");
$count_eye = DB::GET_COLUMN("SELECT COUNT(*) FROM `BLOGS_EYE` WHERE `BLOG_ID` = '".$blog['ID']."'");
$count_comments = DB::GET_COLUMN("SELECT COUNT(*) FROM `BLOGS_COMMENTS` WHERE `BLOG_ID` = '".$blog['ID']."'");
  
ECHO "<a href='/modules/?path=blogs&section=show&id=".$blog['ID']."' class='btn-o'>".ICONS('heart', 15, 'fa-fw')." ".$count_like."</a>";
  
ECHO "<a href='/modules/?path=blogs&section=show&id=".$blog['ID']."' class='btn-o'>".ICONS('comment', 15, 'fa-fw')." ".$count_comments."</a>";
  
ECHO "<a href='/modules/?path=blogs&section=show&id=".$blog['ID']."' class='btn-o' style='float: right;'>".ICONS('eye', 15, 'fa-fw')." ".$count_eye."</a>";
  
}
  
?>