<?php
  
ECHO "<div id='_smiles' style='display: none;'>";

ECHO "<div class='".$fbs_cf."'>";

ECHO "<div class='smiles_section_optimize' id='smop'>";

$data = DB::GET_STRING_ALL("SELECT * FROM `SMILES_DIR` ORDER BY `ID` ASC LIMIT 0, 5");

$s = 0;

WHILE ($list = $data->FETCH()){
  
  $s++;
  
  $smile = DB::GET_STRING("SELECT * FROM `SMILES` WHERE `ID_DIR` = '".$list['ID']."' ORDER BY `ID` ASC LIMIT 1");
  
  IF (ISSET($smile['ID'])){
    
    ?><div class="smile-optimize" onclick="smiles_upgd('/system/AJAX/php/smiles.php?id=<?=$list['ID']?>')"><?
    ECHO "<span class='_smile'>";
    ECHO "<img src='/files/upload/smiles/".$smile['ID'].".".$smile['EXT']."' style='max-width: 25px;'>";
    ECHO "</span>";
    ECHO "</div>";
    
  }ELSE{
    
    ?><div class="smile-optimize" style="line-height: 40px; color: white;" onclick="smiles_upgd('/system/AJAX/php/smiles.php?id=<?=$list['ID']?>')"><?
    ECHO "".ICONS('smile-o', 25, 'fa-fw')."";
    ECHO "</div>";
    
  }
  
}

IF ($s == 0){
  
  ECHO "<div class='smile-optimize' style='width: 50%; line-height: 40px;'>";
  ECHO LG('Пока нет смайлов');
  ECHO "</div>";
  
}

IF ($s >= 5){

ECHO "<div class='smile-optimize' onclick='smiles_section_show()' id='ud_sm' style='line-height: 40px;'>";
ECHO "".ICONS('chevron-down', 17, 'fa-fw')."";
ECHO "</div>";
  
}

ECHO "<div class='smile-optimize' onclick='smiles_hide()' style='line-height: 40px; color: white;'>";
ECHO "".ICONS('times', 21, 'fa-fw')."";
ECHO "</div>";

IF ($s >= 5){
  
  ECHO "<div id='section_sm' style='display: none;'>";
  
  $data = DB::GET_STRING_ALL("SELECT * FROM `SMILES_DIR` ORDER BY `ID` ASC LIMIT 5, 25");
  
  WHILE ($list = $data->FETCH()){
    
    $smile = DB::GET_STRING("SELECT * FROM `SMILES` WHERE `ID_DIR` = '".$list['ID']."' ORDER BY `ID` ASC LIMIT 1");
    
    IF (ISSET($smile['ID'])){
      
      ?><div class="smile-optimize" onclick="smiles_upgd('/system/AJAX/php/smiles.php?id=<?=$list['ID']?>')"><?
      ECHO "<span class='_smile'>";
      ECHO "<img src='/files/upload/smiles/".$smile['ID'].".".$smile['EXT']."' style='max-width: 25px;'>";
      ECHO "</span>";
      ECHO "</div>";
    
    }ELSE{
      
      ?><div class="smile-optimize" style="line-height: 40px; color: white;" onclick="smiles_upgd('/system/AJAX/php/smiles.php?id=<?=$list['ID']?>')"><?
      ECHO "".ICONS('smile-o', 25, 'fa-fw')."";
      ECHO "</div>";
    
    }
  
  }
  
  ECHO "</div>";
  
}

ECHO "</div>";

ECHO "<div class='smile-spis'>";

ECHO "<div id='smile-spis'>";

ECHO "</div>";

ECHO "</div>";

ECHO "</div>";

ECHO "</div>";

?>