f976ed51a33c73d9a54b9e63a4cbd6ddcdf56c28
1 <?php
3 class TemplateEngine
4 {
5 private $config;
6 private $data = array();
7 private $template = "";
9 private $itemType = '';
11 function __construct($config)
12 {
13 $this->config = &$config;
14 }
16 function setValues($array)
17 {
18 # print_a($array);
19 }
21 function setType($name)
22 {
23 $this->itemType = $name;
24 $this->widgets = array();
26 $data = $this->data[$this->itemType];
27 if(isset($data['options']) && count($data['options'])){
28 foreach($data['options'] as $name => $item){
29 $this->widgets[] = new TemplateWidget($this->config, $name, $item['value']);
30 }
31 }
32 }
34 function load($array)
35 {
36 $this->data = $array;
37 }
39 function setTemplate($tmpl)
40 {
41 $this->template = $tmpl;
42 }
44 function getWidgets()
45 {
46 return($this->widgets);
47 }
49 function render()
50 {
51 $smarty = get_smarty();
52 $smarty->assign("type", $this->itemType);
53 foreach($this->getWidgets() as $widget){
54 $smarty->assign($widget->getName(), $widget->render());
55 }
56 return($smarty->fetch(get_template_path("goto/Config/{$this->template}", TRUE)));
57 }
58 }
61 ?>