|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* View |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Copyright (c) Gjero Krsteski (http://krsteski.de) |
|
6
|
|
|
* @license http://opensource.org/licenses/MIT MIT License |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Pimf\View; |
|
10
|
|
|
|
|
11
|
|
|
use Pimf\Contracts\Reunitable; |
|
12
|
|
|
use Pimf\View; |
|
13
|
|
|
use Pimf\Config; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* A view for HAANGA template engine that uses Django syntax - fast and secure template engine for PHP. |
|
17
|
|
|
* |
|
18
|
|
|
* For use please add the following code to the end of the config.app.php file: |
|
19
|
|
|
* |
|
20
|
|
|
* <code> |
|
21
|
|
|
* |
|
22
|
|
|
* 'view' => array( |
|
23
|
|
|
* |
|
24
|
|
|
* 'haanga' => array( |
|
25
|
|
|
* 'cache' => true, // if compilation caching should be used |
|
26
|
|
|
* 'debug' => false, // if set to true, you can display the generated nodes |
|
27
|
|
|
* 'auto_reload' => true, // useful to recompile the template whenever the source code changes |
|
28
|
|
|
* ), |
|
29
|
|
|
* |
|
30
|
|
|
* ), |
|
31
|
|
|
* |
|
32
|
|
|
* </code> |
|
33
|
|
|
* |
|
34
|
|
|
* @link http://haanga.org/documentation |
|
35
|
|
|
* @package View |
|
36
|
|
|
* @author Gjero Krsteski <[email protected]> |
|
37
|
|
|
* @codeCoverageIgnore |
|
38
|
|
|
*/ |
|
39
|
|
|
class Haanga extends View implements Reunitable |
|
40
|
|
|
{ |
|
41
|
|
|
/** |
|
42
|
|
|
* @param string $template |
|
43
|
|
|
* @param array $data |
|
44
|
|
|
*/ |
|
45
|
|
|
public function __construct($template, array $data = array()) |
|
46
|
|
|
{ |
|
47
|
|
|
parent::__construct($template, $data); |
|
48
|
|
|
|
|
49
|
|
|
$conf = Config::get('view.haanga'); |
|
50
|
|
|
|
|
51
|
|
|
$options = [ |
|
52
|
|
|
'debug' => $conf['debug'], |
|
53
|
|
|
'template_dir' => $this->path, |
|
54
|
|
|
'autoload' => $conf['auto_reload'], |
|
55
|
|
|
|
|
56
|
|
|
]; |
|
57
|
|
|
|
|
58
|
|
|
if ($conf['cache'] === true) { |
|
59
|
|
|
$options['cache_dir'] = $this->path . '/haanga_cache'; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
require_once BASE_PATH . "Haanga/lib/Haanga.php"; |
|
63
|
|
|
|
|
64
|
|
|
\Haanga::configure($options); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Puts the template an the variables together. |
|
69
|
|
|
* |
|
70
|
|
|
* @return NULL|string|void |
|
71
|
|
|
*/ |
|
72
|
|
|
public function reunite() |
|
73
|
|
|
{ |
|
74
|
|
|
return \Haanga::Load( |
|
75
|
|
|
$this->template, $this->data->getArrayCopy() |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|