<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created:	4/30/2018	ELL
// 

include ("check_session.php");

$document_root = $_SERVER['DOCUMENT_ROOT'];

if (BWB_BASE_DIR == "")
	$path = $document_root . "/" . BWB_SCRIPTS_DIR;
else
	$path = $document_root . "/" . BWB_BASE_DIR . "/" . BWB_SCRIPTS_DIR;

$last_file_minified = $_SESSION['last_file_minified'];

$file_arr = array();
$filter = ".js";

$no_minify = array();
$query = "SELECT * FROM " . BWB_TABLE_PREFIX . "no_minify";
$result = $bwb_dbh->query($query);
while ($row = $result->fetch(PDO::FETCH_ASSOC))
{
	$no_minify[] = $row["file_name"];
}
		   
if ($handle = opendir($path)) 
{
	while (false !== ($file = readdir($handle)))
	{
		if (!is_dir($path . "/" . $file))
		{
			if ((strpos($file, ".", 0) !== 0) || ($show_hidden == 1))	{
				if (($filter == "") || (strtolower(substr($file, strlen($file) - strlen($filter))) == $filter))	{
					if (!in_array($file, $no_minify))
						$file_arr[] = $file;
				}
			}
		}
	}
	closedir($handle);
	
	sort($file_arr);
	
	foreach($file_arr as $file)
	{
		if ($last_file_minified == $file)
			$selected = " down_sub";
		else
			$selected = "";
	
		echo "<div class='button_sub_level_1" . $selected . "' onClick=\"MinifyJS('" . $file . "');\"><span class='button_text_sub_level_1'>" . $file . "</span></div>\n";
	}
}
?>