<?php
// запрет прямого доступа
defined('_JEXEC') or die('Restricted access');

class ui_view{
	var $access = false;
	var $data;
	
	function __construct($controller, $task, $type){
		$this->access = $controller->access;
		
		if (!$this->access && $type != 'json'){
			$task = 'login';
		}
		if (!method_exists($controller, $task)){
			$task = 'view';
		}
		$this->data = $controller->$task();

		if ($type != 'json' && method_exists($this, $task)){
			require_once('header.php');
			$this->$task();				
			require_once('footer.php');
		}else{
			if ($this->data)
				echo json_encode($this->data);
		}
	}
	function login(){
		require_once('login.php');
	}
	function view(){
		require_once('all.php');
	}
}