initial commit with snapshot 20140213

This commit is contained in:
2015-02-14 12:01:53 +01:00
commit 12cd5888c5
93 changed files with 7038 additions and 0 deletions

53
inc/controller.class.php Normal file
View File

@@ -0,0 +1,53 @@
<?php
require_once('./inc/askModel.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);
}
}
?>