<?php
echo '<nav id="edt">';
	if($_SESSION['user_droits'][2]=="2") {
		echo '<div class="nosmart">';
		include('nav_edt_items.php');
		echo '</div>';

		echo '<div class="smart smartnavdiv"><a href="javascript:;" onmousedown="toggleDiv(\'navitems\');"><i class="fa-solid fa-bars smartnavfa"></i></a><div id="navitems" style="display:none;font-size:0.8em;">';
		include('nav_edt_items.php');
		echo '</div></div>';
	}
	if(@$_GET['page']=='create'||!isset($_GET['page'])) {
		$check_imgmode = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom = 'edt_imgmode'");
		$check_imgmode_info = mysqli_fetch_assoc($check_imgmode);
		if($dossier = scandir('./img/edt/'.$prefix, SCANDIR_SORT_DESCENDING)) {
			$tab_save = array();
			$vignette_edt = array();
			$n=0;
			foreach($dossier as $fichier) {
				if($fichier != '.' && $fichier != '..' && substr($fichier,0,5) != 'nbins') {
					$line = '<div id="vig'.$n.'"><a href="./img/edt/'.$prefix.'/' . $fichier . '?'.date('Ymd').date('His').'">' . $fichier . '</a>';
					$vigline = '<br><img width="200" src="./img/edt/'.$prefix.'/' . $fichier . '?'.date('Ymd').date('His').'" />';
					if($_SESSION['user_droits'][2]=="2") { 
						$vigline .= '<i class="fa-regular fa-trash-can" onclick="novig'.$n.'(this);"></i>';
						$vigline .= '<script type="text/javascript">
							function novig'.$n.'(param) {
							var param = "delvig";
							document.getElementById("vig'.$n.'").style.display = "none";
							var file = "'.$fichier.'"; 
							$.ajax({
							    type: "POST",
							    data: { param: param, file: file },
							    url: "js/idl/edt_param_syn.php",
							   });
							}
						</script>';
						}
					$vigline.= '</div>';
					array_push($tab_save,$line);
					array_push($vignette_edt,$vigline);
					$n++;
				}
			}
			arsort($tab_save);
			$count = count($tab_save);
			if($count>0){
				echo '<p><b>'.EDTIMGDISP.'</b> ';
				for($i=($count-1);$i>-1;$i--) {
					echo $tab_save[$i];
					echo $vignette_edt[$i];
				}
				echo '</p>';
			}
		}
	}
	echo '</nav>';
?>
