<?


class class_page {

	var $tags;

	var $modultype;

	var $template;

	var $contents;

	var $config;

	function __construct($config,$modultype) {

		$this->config = $config;
		$this->modultype = $modultype;		
		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();
		}

		ob_end_clean();

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

		echo $echo;
	}
}

?>