<?php
$t = "Настройка менеджера файлов";
include_once '../core/core.php';
include_once '../core/_navbar_policy.php';
$navbar["config_filemgr.lm"]["active"] = true;
if (!$user->auth()){
	$core->GoToPage("/login.lm");
	die();
}
$la = glob(ROOT.'/media/ace/theme-*.js');
$current_theme = $user->currentDesign()=="dark"?'clouds_midnight':'chrome';
if (isset($_POST["save"])){
	$dirhead = isset($_POST["dirhead"]) && !empty($_POST["dirhead"]) && is_numeric($_POST["dirhead"])?1:0;
	$zipShowNoSupport = isset($_POST["zipShowNoSupport"]) && !empty($_POST["zipShowNoSupport"]) && is_numeric($_POST["zipShowNoSupport"])?1:0;
	$ace_panel = isset($_POST["ace_panel"]) && !empty($_POST["ace_panel"]) && is_numeric($_POST["ace_panel"])?1:0;
	$ace_theme = isset($_POST["ace_theme"]) && !empty($_POST["ace_theme"]) && file_exists(ROOT.'/media/ace/theme-'.$core->FilterString($_POST["ace_theme"]).'.js')?$core->FilterString($_POST["ace_theme"]):'system';
	$db->Query("UPDATE `sites` SET `dirhead`='".$dirhead."',`zipShowNoSupport`='".$zipShowNoSupport."',`ace_panel`='".$ace_panel."',`ace_theme`='".$ace_theme."' WHERE `id` = '".$user->uid."'");
	include_once '../core/head.php';
	echo '<div class="alert alert-success">Настройки менеджера файлов сохранены.</div>';
}
include_once '../core/head.php';
echo '<div class="panel panel-default"><div class="panel-body"><form method="POST">';
echo 'Отображать папки сверху:<br><select name="dirhead" class="form-control">';
echo '<option value="0" '.($user->getData()->dirhead == 0?'selected':null).'>Нет</option>';
echo '<option value="1" '.($user->getData()->dirhead == 1?'selected':null).'>Да</option>';
echo '</select><br>';
echo 'Отображать панель настроек ACE:<br><select name="ace_panel" class="form-control">';
echo '<option value="0" '.($user->getData()->ace_panel == 0?'selected':null).'>Нет</option>';
echo '<option value="1" '.($user->getData()->ace_panel == 1?'selected':null).'>Да</option>';
echo '</select><br>';
echo 'Тема редактора ACE:<br><select name="ace_theme" class="form-control">';
echo '<option value="system" '.($user->getData()->ace_theme == "system"?'selected':null).'>(стандартный)</option>';
foreach ($la as $l){
	$l = str_replace(ROOT."/media/ace/","",$l);
	$l = str_replace("theme-","",$l);
	$l = str_replace(".js","",$l);
	echo '<option value="'.$l.'" '.($user->getData()->ace_theme == $l?'selected':null).'>'.$l.'</option>';
}
echo '</select><br>';

echo 'Отображать недопустимые файлы для распаковки архивов:<br><select name="zipShowNoSupport" class="form-control">';
echo '<option value="0" '.($user->getData()->zipShowNoSupport == 0?'selected':null).'>Нет</option>';
echo '<option value="1" '.($user->getData()->zipShowNoSupport == 1?'selected':null).'>Да</option>';
echo '</select><br>';

echo '<input type="submit" name="save" value="Сохранить" class="btn btn-primary"></form></div>';
include_once '../core/foot.php';
?>