-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclass.view.php
50 lines (46 loc) · 981 Bytes
/
class.view.php
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
<?php
class CSCF_View
{
/**
* Path of the view to render
*/
var $view = "";
/**
* Variables for the view
*/
var $vars = array();
/**
* Construct a view from a file in the
*/
public
function __construct($view)
{
if (file_exists(CSCF_PLUGIN_DIR . "/views/" . $view . ".view.php"))
{
$this->view = CSCF_PLUGIN_DIR . "/views/" . $view . ".view.php";
}
else
{
wp_die(__("View " . CSCF_PLUGIN_URL . "/views/" . $view . ".view.php" . " not found"));
}
}
/**
* set a variable which gets rendered in the view
*/
public
function Set($name, $value)
{
$this->vars[$name] = $value;
}
/**
* render the view
*/
public
function Render()
{
extract($this->vars, EXTR_SKIP);
ob_start();
include $this->view;
return ob_get_clean();
}
}