-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
142 lines (127 loc) · 3.45 KB
/
index.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
include 'vendor/autoload.php';
use pte\CustomRender;
use pte\exception\PteException;
use pte\Parts;
use pte\Pte;
class Sidebar extends Parts
{
/**
* @param array $data
* @param string $template
* @param bool $templateBinary
* @return string
* @throws PteException
*/
public function Parse($data = null, $template = '', $templateBinary = false)
{
$this->pte->SetHtml('template/sidebar.html');
$this->pte->SetValue($this->data);
return $this->pte->Output(null, Pte::VIEW_HTML);
}
}
class Base implements CustomRender
{
var $tags;
var $fnName;
protected $assets;
protected $data;
protected $paramArray;
/**
* @param string $data
* @param string $template
* @param bool $templateBinary
* @return string
*/
public function Parse($data = null, $template = '', $templateBinary = false)
{
if ($this->fnName === 'url') {
return 'localhost' . $this->paramArray;
}
if ($this->fnName === 'lang') {
if ($data !== null && !$templateBinary) {
$resource = str_replace('.html', '.json', $template);
if (file_exists($resource)) {
$resource = json_decode(file_get_contents($resource), true);
return isset($resource[$data]) ? $resource[$data] : $data;
}
}
}
return '';
}
/**
* @param $fnName
* @param $paramArray
*/
public function RegisterFunction($fnName, $paramArray)
{
$this->fnName = $fnName;
$this->paramArray = $paramArray;
}
/**
* @param $assets
*/
public function RegisterAssets($assets)
{
$this->assets = $assets;
}
}
$pte = new Pte(true, true, true);
$pte->SetMaster('template/master.html');
$pte->SetHtml('template/view.html');
$pte->SetValue(array(
'version' => '1.6',
'FirstCircle' => 'Selamat Datang !',
'WishList' => array(
array(
'Lingkaran' => 'Bulat Sempurna 1',
'Anak' => array(
array(
'Umur' => 20,
'Anak2' => array(
array('Umur2' => 41),
array('Umur2' => 42),
array('Umur2' => 43),
),
)
),
),
array(
'Lingkaran' => 'Bulat Sempurna 2',
'Anak' => array(
array(
'Umur' => 46,
'Anak2' => array(
array('Umur2' => 9),
),
),
),
),
),
'Wishlist2' => array(
'val' => 'DARI CONTROLLER',
),
'namaband' => 'Didit Velliz Band',
'Umur' => 23,
'Author' => 'Didit Velliz',
'Member' => array(
array(
'NamaMember' => 'Asus A451LB',
'Alamat' => 'JL Sukamekar 2 no 14',
'Hobi' => array(
array('List' => 'Berenang'),
array('List' => 'Nyuci'),
array('List' => 'Masak'),
),
)
),
'NamaMember' => 'Asus A451LB',
//the implementation of Parts abstract class
'tables' => new Sidebar('tables', array('Tab' => 'XYZ')),
));
//the implementation of CustomRenderer interface
$base = new Base();
echo $pte->Output($base, Pte::VIEW_HTML, array(
'template/sidebar.html'
));
echo $pte->GetElapsedTime();