<?php
function smarty_function_admin_get_asset_files($params, &$smarty) {
	//
	clearstatcache();
	global $section;
	global $data;
	$spool = array();
	$mime = array();

	//
	$dir = HOME_DIR."data/".$section."/assets/";
	if (@$handle = opendir($dir)) {
		while (false !== ($file = readdir($handle))) {
			if (!is_dir($dir.$file) && $file != "." && $file != ".." && substr($file, 0, 1) != ".") {
				array_push($spool, $file);
				$identify = exec("/usr/bin/identify -format %m ".$dir.$file);
				$mime[$file] = strtolower($identify);
			}
		}
		closedir($handle);
	}
	
	//
	sort($spool);
	$smarty->assign("asset_spool", $spool);
	$smarty->assign("asset_mime", $mime);
}
?>