<?php
  
//Навигация
ECHO "<div class='navigation'>";
ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "".LG('Видео')."</a>";
ECHO "</div>";

ECHO "<div class='tmenu_body'>";

IF (GET('get') == 'rating'){
  
  $sql = "ORDER BY `VIDEOS`.`RATING` DESC";
  $url = "&get=rating";
  
  ECHO "<a href='/modules/?path=videos' class='tmenu-33'>".LG('Новые')."</a>";
  ECHO "<a href='/modules/?path=videos&get=all' class='tmenu-33'>".LG('Все')."</a>";
  ECHO "<a href='/modules/?path=videos&get=rating' class='tmenu-33 tmenu-33-o'>".LG('По рейтингу')."</a>";
  
}ELSEIF (GET('get') == 'all'){
  
  $sql = NULL;
  $url = "&get=all";
  
  ECHO "<a href='/modules/?path=videos' class='tmenu-33'>".LG('Новые')."</a>";
  ECHO "<a href='/modules/?path=videos&get=all' class='tmenu-33 tmenu-33-o'>".LG('Все')."</a>";
  ECHO "<a href='/modules/?path=videos&get=rating' class='tmenu-33'>".LG('По рейтингу')."</a>";
  
}ELSE{
  
  $sql = "ORDER BY `VIDEOS`.`TIME` DESC";
  $url = NULL;
  
  ECHO "<a href='/modules/?path=videos' class='tmenu-33 tmenu-33-o'>".LG('Новые')."</a>";
  ECHO "<a href='/modules/?path=videos&get=all' class='tmenu-33'>".LG('Все')."</a>";
  ECHO "<a href='/modules/?path=videos&get=rating' class='tmenu-33'>".LG('По рейтингу')."</a>";
  
}

ECHO "</div>";

//Поиск
REQUIRE (ROOT.'/modules/search/plugins/form/videos.php');

$data2 = DB::GET_STRING_ALL("SELECT `VIDEOS`.`ID` 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`");

$column = 0;

WHILE ($data2->FETCH())
{
  
  $column++;
  
}

$spage = SPAGE($column, $page_settings);
$page = PAGE($spage);
$limit = $page_settings * $page - $page_settings;

IF ($column == 0){ 
  
  HTML::EMPTY();
  
}ELSE{
  
  ECHO "<div class='list-body'>"; 
  ECHO "<ul class='files-body'>";
  
}

$data = DB::GET_STRING_ALL("SELECT `VIDEOS`.`ID`,`VIDEOS`.`ID_DIR`,`VIDEOS`.`EXT`,`VIDEOS`.`NAME`,`VIDEOS`.`DURATION` 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` ".$sql." LIMIT ".$limit.", ".$page_settings."");

WHILE ($list = $data->FETCH())
{
  
   ECHO "<li class='files-wrapper'><a href='/modules/?path=videos&section=show&video_id=".$list['ID']."' class='__files'>";
    
   IF (IS_FILE(ROOT.'/files/upload/videos/screen/'.$list['ID'].'.jpg') && CONFIG('VIDEO_SCREEN') == 1){
     
     ECHO "<img src='/files/upload/videos/screen/240x240/".$list['ID'].".jpg' style='max-width: 100%; position: absolute;'>";
     
   }ELSE{
     
     ECHO "<img src='/files/upload/videos/screen/no_video.jpg' style='max-width: 100%; position: absolute;'>";
     
   }
    
   ECHO "<span class='files-or-dir'>".ICONS('film', 12, 'fa-fw')." ".$list['EXT']."</span>";
    
   ECHO "<span class='files-like_'><small>".$list['DURATION']."</small></span>";
    
   ECHO "<span class='files-or-dir-text'>".CROP_TEXT(TEXT_ABSOLUTE($list['NAME']), 0, 14)."</span>";
    
   ECHO "</a></li>";
  
}

IF ($column > 0){
  
  ECHO "</ul>";
  ECHO "</div>";
  
}

IF ($spage > 1){ ECHO STR_PAGE('/modules/?path=videos'.$url.'&', $spage, $page); }

IF (ISSET($user)){
  
  ECHO "<div class='list'>";
  ECHO "<a href='/modules/?path=videos&section=users&id=".$user['ID']."'>".ICONS('arrow-left', 15, 'fa-fw')." ".LG('К моим альбомам')."</a>";
  ECHO "</div>";
  
}

//Навигация
ECHO "<div class='navigation'>";
ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "".LG('Видео')."</a>";
ECHO "</div>"; 
  
?>