<?php
	$prio = array(
		"font"			=> 0,
		"layout"		=> 1,
		"global"		=> 2,
		"plugin"		=> 3,
		"module"		=> 4,
		"widget"		=> 5,
		"custom"		=> 6,
	);

	require_once "../../admin/lib/debug.php";
	require_once "../../admin/lib/include/file.php";
	require_once "../../admin/lib/include/dir.php";

	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function LoadFiles() {
		global $prio , $conf;

		$files = CDir::GetFiles("." , "css");

		if (is_array($files)) {
			foreach ($files as $key => $val) {
				$files[$key] = str_replace("./" , "" , str_replace(".css" , "" , $val));
			}

			sort($files);
	
			foreach ($files as $key => $val) {

				foreach ($prio as $k => $v) {
					if (substr($val , 0 , strlen($k)) == $k ) {
						$load[$v][] = $val;
					}					
				}
			}
			
		}

		ksort($load);
		$files = array();

		if (is_array($load)) {

			//process cache
			foreach ($load as $key => $val) {
				if (is_array($val)) {
					foreach ($val as $k => $v) {
						$files[] = $v . ".css";
					}					
				}				
			}			


			foreach ($files as $key => $val) {
				if (($tmp =filectime($val)) > $lasttime) {
					$lasttime = $tmp;
				}				
			}

			foreach ($files as $key => $val) {
				if (!stristr($val , "skin.")) {
					unset($files[$key]);
				}				
			}
			
			
			foreach ($files as $key => $val) {

				$content .=  "\n\n/*  " . basename($val) ."   */\n\n" . CFile::Get($val);	
			}
		}

		return $content;		
	}
	

	$content = LoadFiles();

		
	header("Content-type: text/css");
	header("Cache-Control: max-age=2692000, public");

    header("Content-Length: ".strlen($content)); 
	echo $content;
	die();
	

?>