<?php
class control{
	public function __get($var) {
		if($var == 'view') {
			return $this->view = new view();
		}elseif($var == 'db') {
			$db = 'db_'.$_ENV['_config']['db']['type'];
			return $this->db = new $db($_ENV['_config']['db']);
		}else{
			return $this->$var = core::model($var);
		}
	}
	public function assign($k, &$v) {
		$this->view->assign($k, $v);
	}
	public function assign_value($k, $v) {
		$this->view->assign_value($k, $v);
	}
	public function display($filename = null) {
		$this->view->display($filename);
	}
	public function message($status, $message, $jumpurl = '', $delay = 2) {
		if(R('ajax')) {
			echo json_encode(array('fine_status'=>$status, 'message'=>$message, 'jumpurl'=>$jumpurl, 'delay'=>$delay));
		}else{
			if(empty($jumpurl)) {
				$jumpurl = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
			}
			include FINE_PATH.'tpl/sys_message.php';
		}
		exit;
	}
	public function __call($method, $args) {
		core::error404();
	}
}
