<?


class class_page {

	var $tags;

	var $modul;

	var $template;

	var $contents;

	var $config;

	var $css_file;

	function __construct($modul) {

		global $config;
		$this->config = $config;
		$this->modul = $modul;
		$this->css_file=$this->config["webroot_path"].$this->config["css_path"]."/".$this->modul["name"].".css";
		ob_start();
	}


	function setTemplate($value) {
		if(!$value){
			return FALSE;
		}
		$this->template = $value;
	}


	function getAppropriateTemplate($filename=NULL) {
				 

		return $this->getFile($filename);
	}

	function setTag($name, $value) {
		if(!$name){
			return FALSE;
		}
		$this->tags[$name] = $value;
	}

	function appendTag($name, $value) {
		if(!$name){
			return FALSE;
		}
		$this->tags[$name].= $value;
	}

	function getTag($name){
		if(!$name){
			return "";
		}
		return $this->tags[$name];
	}


	function getFile($file) {
		if(!is_file($file)){
			return FALSE;
		}

		if (is_array($this->tags)) {
			foreach($this->tags as $key=>$value) {
				$$key = $value;
			}
		}
		ob_start();
		require($file);
		$value = ob_get_contents();
		ob_end_clean();

		return $value;
	}

	function out() {

		if ($this->getTag("content") != "") {
			$this->tags["content"].= ob_get_contents();
		}else {
			$this->setTag("content", ob_get_contents());
		}

		ob_end_clean();

		$echo = $this->getFile($this->template);

		echo $echo;
	}
}

?>