<table class="white">
	<tr>
		<th>Type</th><th>Name</th><th>Size</th><th>&nbsp;</th>
	</tr>
<?php
if(isset($files) && is_array($files)):
	$total = 0;
	$dir_count = 0;
	$file_count = 0;
	/*
	* Render directory
	*/
	foreach($files as $file):
		/*
		* Check is the file dir or not
		*/
		if(is_dir($realpath.DIRECTORY_SEPARATOR.$file['name'])):
			$dir_count++;
			/*
			* If folder is a sym link
			*/
			if(is_link($realpath.DIRECTORY_SEPARATOR.$file['name']))
			{
				$icon = 'folder_link';
				$dir = $path.DIRECTORY_REPLACE.$file['name'];
			}
			elseif($file['name']=='..')
			{
				/*
				* If folder is .. move back then delete the end of the path
				*/
				$dir = move_path_back($path);
				$icon = 'folder';
			}
			else
			{
				/*
				* Normal folder
				*/
				$dir = $path.DIRECTORY_REPLACE.$file['name'];
				$icon = 'folder';
			}
			/*
			* If the folder is not readable
			*/
			if(is_readable($realpath.DIRECTORY_SEPARATOR.$file['name']) == false)
			{
				$icon = 'folder_error';
			}
?>
	<tr>
		<td><?=icon_tag($icon)?></td>
		<td><a href="<?=$this->Request->constructUrl(array(DIR=>$dir));?>"><?=$file['name'];?></a></td>
		<td><?=$file['size']?></td>
	</tr>
<?php
	/*
	* If it's file
	*/
		;else:
			$total = $total + $file['size'];
			$file_count++;
?>
	<tr>
		<td><?=image_tag(file_extention($file['name']));?></td>
		<td><a href="<?=$file['name'];?>"><?=$file['name'];?></a></td>
		<td><?=number_to_size($file['size'])?></td>
		<td><a href="<?=$this->Request->constructUrl(array(PAGE=>'DirectoryBrowser.export','rsargs'=>$path.DIRECTORY_REPLACE.$file['name']),false)?>">Export</a></td>
	</tr>
<?php
		;endif;
	;endforeach;
;else:
	?>
		No files
	<?php
;endif;
?>
	<tr>
		<td><b>Total</b></td>
		<td><b><?=$dir_count?> <?=image_tag('folders')?> / <?=$file_count?> <?=icon_tag('page_copy')?></b></td>
		<td><b><?=number_to_size($total)?></b	></td>
	</tr>
</table>