<?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 `RATING` DESC";
  $url = "&get=rating";
  
  ECHO "<a href='/modules/?path=communities' class='tmenu-33'>".LG('Новые')."</a>";
  ECHO "<a href='/modules/?path=communities&get=rating' class='tmenu-33 tmenu-33-o'>".LG('По рейтингу')."</a>";
  ECHO "<a href='/modules/?path=communities&section=categories' class='tmenu-33'>".LG('Категории')."</a>";
  
}ELSE{
  
  $sql = "ORDER BY `TIME` DESC";
  $url = NULL;
  
  ECHO "<a href='/modules/?path=communities' class='tmenu-33 tmenu-33-o'>".LG('Новые')."</a>";
  ECHO "<a href='/modules/?path=communities&get=rating' class='tmenu-33'>".LG('По рейтингу')."</a>";
  ECHO "<a href='/modules/?path=communities&section=categories' class='tmenu-33'>".LG('Категории')."</a>";
  
}

ECHO "</div>";

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

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

IF (ISSET($user)){
  
  ECHO "<a class='btn-o' href='/modules/?path=communities&section=users&id=".$user['ID']."'>".ICONS('user', 15, 'fa-fw')." ".LG('Мои сообщества')."</a>";
  
}

ECHO "</div>";

$column = DB::GET_COLUMN("SELECT COUNT(*) FROM `COMMUNITIES`");
$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'>"; 
  
}

$data = DB::GET_STRING_ALL("SELECT * FROM `COMMUNITIES` ".$sql." LIMIT ".$limit.", ".$page_settings."");

WHILE ($list = $data->FETCH())
{
  
  REQUIRE (ROOT.'/modules/communities/plugins/communities_list.php');

}

IF ($column > 0){

  ECHO "</div>";
  
}

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

IF (ISSET($user)){
  
  ECHO "<div class='list'>";
  ECHO "<a href='/modules/?path=communities&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>"; 
  
?>