<?php

class Admin_layout {
    
    private $CI;    
    private $layout_title = null;    
    private $layout_description = null;    
    private $layout_menu = array();
    
   
    
    public function __construct() {
        $this->CI =& get_instance();        
    }
    
    public function set_title($title){
        $this->layout_title = $title;
    }
    
    public function set_description($description){
        $this->layout_description = $description;
    }
    
    public function set_menu($menu){
       $this->layout_menu = $menu;
    }

    public function set_data($header_data){
        $this->layout_data = $header_data;
    }
   
    
    
    public function view($view_name,$layouts=array(),$params = array(),$default=true){
        
        if(is_array($layouts) && count($layouts) >=1) {
            foreach ($layouts as $layout_key=>$layout) {				
                $params[$layout_key] = $this->CI->load->view($layout,$params,true);
            }
            
        }
        
        if($default) {
            
            $header_params['layout_title']=$this->layout_title;
            $header_params['layout_description']=$this->layout_description;
            $header_params['header']=$this->layout_data;
            // $header_params['layout_menu']=$this->layout_menu;

            $this->CI->load->view('view_header', $header_params);          
            $this->CI->load->view($view_name, $params);
            // $this->CI->load->view('user/view_footer');
        }
        else {
            //render viewer
            $this->CI->load->view($view_name,$params);
        } 
    }
  
    public function view_dst($view_name,$layouts=array(),$params = array(),$default=true){
        
        if(is_array($layouts) && count($layouts) >=1) {
            foreach ($layouts as $layout_key=>$layout) {				
                $params[$layout_key] = $this->CI->load->view($layout,$params,true);
            }
            
        }
        
        if($default) {
            
            $header_params['layout_title']=$this->layout_title;
            $header_params['layout_description']=$this->layout_description;
            $header_params['header']=$this->layout_data;
            // $header_params['layout_menu']=$this->layout_menu;


            $this->CI->load->view('view_header_dst', $header_params);
            $this->CI->load->view($view_name, $params);
            // $this->CI->load->view('user/view_footer');
        }
        else {
            //render viewer
            $this->CI->load->view($view_name,$params);
        } 
    }    

  
    public function view_final($view_name,$layouts=array(),$params = array(),$default=true){
        
        if(is_array($layouts) && count($layouts) >=1) {
            foreach ($layouts as $layout_key=>$layout) {				
                $params[$layout_key] = $this->CI->load->view($layout,$params,true);
            }
            
        }
        
        if($default) {
            
            $header_params['layout_title']=$this->layout_title;
            $header_params['layout_description']=$this->layout_description;
            $header_params['header']=$this->layout_data;
            // $header_params['layout_menu']=$this->layout_menu;


            $this->CI->load->view('view_header_final', $header_params);
            $this->CI->load->view($view_name, $params);
            // $this->CI->load->view('user/view_footer');
        }
        else {
            //render viewer
            $this->CI->load->view($view_name,$params);
        } 
    }  

}

?>