Location: PHPKode > projects > Simple Way to Usenet > swun/libs/core/themes/thm_mediaq.class.php
<?php
/**
 *  
 * @author  Benjamin Gillissen <hide@address.com>
 * 
 *	**************************************************************

	Copyright (C) 2009  Benjamin Gillissen
	
	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details at:
	http://www.gnu.org/copyleft/gpl.html

 *	**************************************************************
 */
class thm_mediaq {
	
	private static $CSS=Array();
	private static $JS=Array();
	

	public static function append_css_file($file){
		if ( FALSE !== array_search($file, self::$CSS) ){ return TRUE; }	//already done. 
		self::$CSS[] = $file;
		//TODO check in active theme css skin folder for file
	}
	public static function append_css_string($rule){
		//TODO direct to tempfile, set static to true.
	}
	public static function flush_css(){
		$p =  themes::get_active_conf('css'); 
		foreach(self::$CSS as $k => &$file){ 
			$o[$k] = $p.'/'.$file.'.css';
			unset(self::$CSS[$k]); 
		}
		//we put them into tempfile, and add that file to FILES queue on flush
		//so new special event ?css=$hash =>  read_file, remove file.
		//$o[] = '?css=';
		return $o;
	}
	

	public static function append_js_file($file){
		foreach(self::$JS as $k => &$data){
			if ( $data[0] == 'file' AND $data[1] == $file ){ return TRUE; }
		}
		self::$JS[] = Array('file', $file);
	}
	public static function append_js_string($source){
		self::$JS[] = Array('src', $source);
	}
	
	public static function flush_js(){
		$o = self::$JS;
		foreach($o as $k => &$data){
			if ( $data[0] == 'file' AND FALSE === ereg('.js', $data[1]) ){
				$data[1] = themes::get_active_conf('js').'/'.$data[1].'.js';
			}
		}
		self::$JS=Array();
		return $o;
	}
}
Return current item: Simple Way to Usenet