-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathview.php
More file actions
executable file
·55 lines (45 loc) · 1.8 KB
/
Copy pathview.php
File metadata and controls
executable file
·55 lines (45 loc) · 1.8 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/*
This file is part of BotQueue.
BotQueue is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BotQueue is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BotQueue. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}
public function render($data = array())
{
//get our data variables into the local scope
if (!empty($data))
extract((array)$data, EXTR_OVERWRITE);
//Turn on output buffering - no output is sent from the script. Output is instead stored in an internal buffer.
ob_start();
//include the appropriate {controller}.{view}.php file, e.g. item.newest.php
$view_file = VIEWS_DIR . strtolower("{$this->controller}/{$this->view}.php");
if (file_exists($view_file))
//include actually echos stuff the the buffer - for example, check htmltemplate.header.php
//You'll see this file dropping in and out of php code all over the place
//Anytime you see the <?php echo tag, this is telling php to echo whatever is to the right of this tag
include($view_file);
else
throw new ViewException("The {$this->controller}.{$this->view} page does not exist!");
//Get the buffer contents and turn off buffering
return ob_get_clean();
}
}