<?php 
defined('_JEXEC') or die();


/**
 * @package		Joomla Bamboo Zen Grid Framework
 * @Type        Core Framework Files
 * @version		v1.0
 * @author		Joomal Bamboo http://www.joomlabamboo.com
 * @copyright 	Copyright (C) 2007 - 2010 Joomla Bamboo
 * @license		http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */
	

	// This files loads the core js for the Zen Grid Framework and then parses it via the  JS Min compressor

	
	// Include JS MIn
	include_once (dirname(__FILE__).DS.'jsmin-1.1.1.php');
	
	// The files to include
    $cssfiles = array(JPATH_ROOT."/templates/system/css/system.css");

	
   	$cssfiles[] = JPATH_ROOT."/templates/system/css/general.css";
	$cssfiles[] = JPATH_ROOT."/templates/zengridframework/css/joomla.css";
	$cssfiles[] = JPATH_ROOT."/templates/zengridframework/css/template_css.css";
	$cssfiles[] = JPATH_ROOT."/templates/zengridframework/css/fonts.css";

	if ($tabs) {
	$cssfiles[] = JPATH_ROOT."/templates/zengridframework/css/jbtabs.css";		
	}
	
	if($fonts =="1" or $fonts =="3") {
			$cssfiles[] = JPATH_ROOT."/templates/zengridframework/css/fonts.css";
	}
 

    // Load core popup
    $css = "";

	
	// If we are only combining scripts.
	//	if (!($compresscripts) && !($cachejs)) {
		
	foreach($cssfiles as $file) {
	
		$css .= JFile::read($file); 
	
	}
	
		// Create the js file
    //	JFile::write(JPATH_ROOT.'/cache/zengridframework/css/zengrid.css', $css);
		
			
//	}

// If we are combining, compressing and not caching
//	if ($compresscripts && !($cachejs)) {
    
		// Run through the files
    	//foreach($cssfiles as $file) {
        //	$css .= JSMin::minify(file_get_contents($file));
    	//}

	   
		
	
	
//	}


/*	// If we are caching and or combining or compressing
//	else if ($cachejs && !($compresscripts) || $cachejs && $compresscripts) {
		
		// Set up the md5 hash
		$md5sum = '';
		foreach($cssfiles as $css)
		{
			$md5sum .= md5($css);
		}
	
		// Setting up the file name and path to the file
		$path = "cache/zengridframework/css/";
		$cache_filename = "js-".md5($md5sum).".php";
	    $cache_fullpath = $path.DS.$cache_filename;
		
		// Grab the cache tiem from the template parameters				
		$cache_time = $this->params->get('cachetime', '1' );
		
		
		// Set up the check to see if the file exists already or hasnt expired
		if (JFile::exists($cache_fullpath)) {
		    $diff = (time()-filectime($cache_fullpath));
		} else {
		    $diff = $cache_time+1;
		} 
		
	
		if ( $diff > $cache_time )
		{
			$outfile='<?php 
ob_start ("ob_gzhandler");
header("Content-type: text/css; charset: UTF-8");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " . 
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
		?>';
			

			foreach($cssfiles as $file)
			{
	
				if (JFile::exists($file)) {
					$outfile .= JFile::read($file); 
				}
			}
			
			
			// Output the combined but not compressed file
			if ($cachejs && !($compresscripts)) {
				JFile::write($cache_fullpath,$outfile);
			}
			
			
			// Output the combined and compressed file
			else if ($cachejs && $compresscripts) {
	
				JFile::write(JPATH_ROOT.'/cache/zengridframework/css/zengridtemp.css', $outfile);
				$newcss = JSMin::minify(file_get_contents(JPATH_ROOT.'/cache/zengridframework/css/zengridtemp.css'));
	
				// Create the js file
			    JFile::write($cache_fullpath,$newcss);
			}
	}
	
			// Set the ZengridJS variable which gets output in the zgf index
			$zengridCSS = '<link rel="stylesheet" type="text/css" media="screen" href="$this->baseurl/cache/zengridframework/css/$cache_filename" />';
	
//} */

 	// Create the js file
   JFile::write(JPATH_ROOT.'/cache/zengridframework/css/zengrid.css', $css);
	
	// Set the zengridcss variable which gets output via the index.php file
	$zengridCSS = "<link href='$this->baseurl/cache/zengridframework/css/zengrid.css' rel='stylesheet' type='text/css' media='screen' />";
?>