blob: ff5fbbe8c1de762eb9a7f22d0fdbf6079f4f9c3f (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<?php
/**
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
* @author Christian Weiske <cweiske@cweiske.de>
* @author Eric Dane <ericdane@users.sourceforge.net>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
/**
* SemanticScuttle HTML templating system.
* This templating system is really, really simple and based
* on including php files while proving a set of
* variables in the template scope.
* When rendering templates, they are directly echoed to the
* browser. There is no in-built way to capture their output.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
* @author Christian Weiske <cweiske@cweiske.de>
* @author Eric Dane <ericdane@users.sourceforge.net>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
class SemanticScuttle_Model_Template
{
/**
* Array of variables to be available in template
* scope.
*
* @var array
*/
protected $vars = array();
/**
* File name of template
*/
protected $file = '';
/**
* Template service instance
*
* @var SemanticScuttle_Service_Template
*/
protected $ts;
/**
* Create a new template instance
*
* @param string $file Template filename,
* full path
* @param array $vars Template variables
* @param SemanticScuttle_Service_Template $ts Template service
*/
public function __construct(
$file, $vars = null,
SemanticScuttle_Service_Template $ts = null
) {
$this->vars = $vars;
$this->file = $file;
$this->ts = $ts;
}
/**
* Sets variables and includes the template file,
* causing it to be rendered.
*
* @return void
*/
public function parse()
{
if (isset($this->vars)) {
extract($this->vars);
}
include $this->file;
}
/**
* Loads another template
*
* @param string $file Filename of template, relative
* to template directory
*
* @return SemanticScuttle_Service_Template Template object
*/
public function includeTemplate($file)
{
return $this->ts->loadTemplate($file, $this->vars);
}
}
?>
|