blob: cdd87aab273a1fab06d2de53964d71d3e8950cb5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?
class View
{
//hold our private data.
private $controller;
private $view;
//init and save our controller/view info.
public function __construct($controller, $view)
{
$this->controller = $controller;
$this->view = $view;
}
//placeholder functions for any special stuff you gotta do.
public function preRender() {}
public function postRender() {}
public function render($data = array())
{
//get our data variables into the local scope
if (!empty($data))
extract((array)$data, EXTR_OVERWRITE);
ob_start();
$view_file = strtolower(VIEWS_DIR . "{$this->controller}.{$this->view}.php");
if (file_exists($view_file))
include($view_file);
else
throw new ViewException("The {$this->controller}.{$this->view} page does not exist!");
return ob_get_clean();
}
}
?>
|