blob: 2641c95a703cf67ebc90826a01416e9ff9ad50bd (
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
require_once 'Smarty/Smarty.class.php';
class Piwik_View
{
private $template = '';
private $smarty = false;
private $variables = array();
public function __construct( $templateFile, $smConf = array())
{
$this->template = $templateFile;
$this->smarty = new Smarty();
if(count($smConf) == 0)
{
$smConf = Zend_Registry::get('config')->smarty;
}
foreach($smConf as $key => $value)
{
$this->smarty->$key = $value;
}
$this->smarty->template_dir = $smConf->template_dir->toArray();
$this->smarty->plugins_dir = $smConf->plugins_dir->toArray();
// $this->smarty->load_filter('output','trimwhitespace');
}
/**
* Directly assigns a variable to the view script.
* VAR names may not be prefixed with '_'.
* @param string $key The variable name.
* @param mixed $val The variable value.
* @return void
*/
public function __set($key, $val)
{
$this->smarty->assign($key, $val);
}
/**
* Retrieves an assigned variable.
* VAR names may not be prefixed with '_'.
* @param string $key The variable name.
* @return mixed The variable value.
*/
public function __get($key)
{
return $this->smarty->get_template_vars($key);
}
public function render()
{
$this->totalTimeGeneration = Zend_Registry::get('timer')->getTime();
// $this->smarty->assign('smarty', $this);
return $this->smarty->fetch($this->template);
}
public function addForm( $form )
{
// Create the renderer object
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($this->smarty);
// build the HTML for the form
$form->accept($renderer);
// assign array with form data
$this->smarty->assign('form_data', $renderer->toArray());
$this->smarty->assign('element_list', $form->getElementList());//$renderer->toArray());
}
public function assign($var, $value=null)
{
if (is_string($var))
{
$this->smarty->assign($var, $value);
}
elseif (is_array($var))
{
foreach ($var as $key => $value)
{
$this->smarty->assign($key, $value);
}
}
}
/* public function isCached($template)
{
if ($this->smarty->is_cached($template))
{
return true;
}
return false;
}
public function setCaching($caching)
{
$this->smarty->caching = $caching;
}
*/
}
?>
|