<?php
  
$sql = "SELECT `VIDEOS`.`ID`,`VIDEOS`.`ID_DIR` FROM `VIDEOS` LEFT JOIN `VIDEOS_DIR` ON (`VIDEOS_DIR`.`ID` = `VIDEOS`.`ID_DIR` OR `VIDEOS_DIR`.`ID_DIR` = `VIDEOS`.`ID_DIR`) WHERE `PRIVATE` = '0' GROUP BY `VIDEOS`.`ID`";
  
$count = DB::GET_STRING_ALL($sql);

$video_i = 0;

WHILE ($count->FETCH()){ $video_i++; }
  
$data = DB::GET_STRING_ALL($sql." ORDER BY `VIDEOS`.`TIME` DESC LIMIT 15");
  
ECHO "<div class='list-body'>";
  
ECHO "<div class='list-menu list-menu-title'>".ICONS('film', 15, 'fa-fw')." ".LG('Видео пользователей')." <a href='/modules/?path=videos' style='float: right;'>".LG('Все')." ".ICONS('chevron-right', 15, 'fa-fw')."</a></div>";

IF ($video_i == 0){
  
  ECHO "<div class='list-menu'>".LG('Пока нет видео').". "; 
  
  IF (ISSET($user)){
    
    ECHO "<a href='/modules/?path=videos&section=users&id=".$user['ID']."'>".LG('Желаете добавить видео первым?')."</a>";
    
  }
  
  ECHO "</div>";
  
}ELSE{
  
  ECHO "<div class='menu-list-optimize'>";
  
  WHILE ($list = $data->FETCH()){
    
    ECHO "<a href='/modules/?path=videos&section=show&video_id=".$list['ID']."'>";
    
    IF (IS_FILE(ROOT.'/files/upload/videos/screen/'.$list['ID'].'.jpg') && CONFIG('VIDEO_SCREEN') == 1){
      
      $vv = "/files/upload/videos/screen/".$list['ID'].".jpg";
    
    }ELSE{
      
      $vv = "/files/upload/videos/screen/no_video.jpg";
    
    }
    
    ECHO " <img src='".$vv."' style='border-radius: 4px; width: 75px; height: 75px; margin: 1px;'> ";
    
    ECHO "</a>";
  
  }
  
  IF ($video_i > 5){  
    
    ECHO " <a class='menu-list-all' href='/modules/?path=videos'><b>".LG('ВСЕ')."</b> ".ICONS('chevron-right', 15, 'fa-fw')."</a> ";
  
  }
  
  ECHO "</div>";
  
}

ECHO "</div>";
  
?>