<?php


    class View{
        
        public static $i;
        public $request_type = false;
        
        public function __construct(){
            
            if( $_SERVER['HTTP_X_REQUESTED_WITH'] AND strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ){
                
                $this->request_type = 'xmlhttprequest';
                
            } else {
                
                $this->request_type = 'http';
                
            }
            
            self::$i = $this;
        }
        
        public function exec(){
            
            global $tpl;
            
            switch( $this->request_type ){
                
                case 'xmlhttprequest':
                    
                    js::$i->setJSON( 'status' , 'ok' );
                    js::$i->setJSON( 'content' , $tpl->fetch( admin::$i->dir . core::$i->mode . '/' . core::$i->function . '.tpl' ) );
                    die( js::$i->getJSON() );
                    
                break;
                
                case 'http':
                    
                    page::$i->val( $tpl->fetch( admin::$i->dir . core::$i->mode . '/' . core::$i->function . '.tpl' ) );
                    
                break;
                
            }
            
        }
        
        
    }




?>