A new, object-oriented, better vesion of μForum
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

60 lines
1.2 KiB

<?php
/**
* @package uForum2
* @file inc/controller.class.php
* @copyright 2007-2015 (c) PioDer
* @link http://www.pioder.pl/
* @license see LICENSE.txt
**/
require_once('./inc/askModel.class.php');
require_once('./inc/view.class.php');
abstract class Controller extends AskModel {
protected $views = array();
protected $db;
abstract public function loadDefault(); //domyślna metoda
public function __call($m, $arg)
{
if(method_exists($this, $m))
$this->$m($arg);
else
$this->forward('index.php');
}
public function __construct(&$db)
{
$this->db = $db;
}
public function forward($address)
{
header('Location: ' . $address);
}
public function loadView($view)
{
if (file_exists('./inc/views/'.$view.'.class.php') && !array_key_exists($view, $this->views))
{
require_once('./inc/views/'.$view.'.class.php');
$this->views[$view] = new $view($this->db);
}
else
{
throw new Exception('Could not load selected view: '.$view);
}
}
public function getView($view)
{
if (array_key_exists($view, $this->views))
return $this->views[$view];
else
throw new Exception('Could not get selected view: '.$widok);
}
}
?>