+ class mw_template extends empty_class{
+
+ var $out;
+ var $ENV_SET;
+ var $template_infos;
+
+ function set_env(&$env){
+ $this->modules = array("env" => $env);
+ $this->ENV_SET = true;
+ $this->set_out_config($this->get_out_config());
+ $this->set_template_infos($this->get_template_infos());
+ }
+
+ function render_layout($layout = null){
+ if(!isset($this->ENV_SET) || !$this->ENV_SET) return false;
+ if(!isset($layout)) $layout = $this->init_layout();
+ $this->out = $this->get_out();
+ $this->init();
+ if(
+ ($init_script = $this->init_script())
+ && $this->out_file_exists($init_script)
+ ) require $this->out_file($init_script);
+ if($layout["page"]){
+ if($this->out_file_exists($layout["page"])) require $this->out_file($layout["page"]);
+ }
+ elseif($layout["content"]){
+ if($this->out_file_exists($layout["content"])) require $this->out_file($layout["content"]);
+ }
+ }
+
+ function get_template_info($key){
+ return isset($this->template_infos[$key]) ? $this->template_infos[$key] : "";
+ }
+
+ function init(){
+ return true;
+ }
+
+ function init_script(){
+ return false;
+ }
+
+ function get_out_config(){
+ return array();
+ }
+
+ function set_template_infos($template_infos){
+ $this->template_infos = $template_infos;
+ }
+
+ function get_template_infos(){
+ return array();
+ }
+
+ }
+