@@ -26,6 +26,12 @@ class TemplateGenerator
26
26
*/
27
27
protected $ template ;
28
28
29
+ /**
30
+ * The image to use as a logo
31
+ * @var string
32
+ */
33
+ protected $ image ;
34
+
29
35
/**
30
36
* The base URl of the API
31
37
* @var
@@ -42,10 +48,12 @@ class TemplateGenerator
42
48
* TemplateGenerator constructor.
43
49
*
44
50
* @param string $template name of the template to load
51
+ * @param string $image Image to use as Logo
45
52
*/
46
- public function __construct ($ template )
53
+ public function __construct ($ template, $ image )
47
54
{
48
55
$ this ->template = $ template ;
56
+ $ this ->image = $ image ;
49
57
}
50
58
51
59
/**
@@ -57,20 +65,34 @@ public function __construct($template)
57
65
*/
58
66
public function get ($ object )
59
67
{
68
+ $ include = NULL ;
69
+ if (stream_resolve_include_path ($ this ->template . DIRECTORY_SEPARATOR . $ this ->template . '.php ' ))
70
+ {
71
+ $ include = $ this ->template . DIRECTORY_SEPARATOR . $ this ->template . '.php ' ;
72
+ }
73
+
74
+ if (stream_resolve_include_path ($ this ->template . '.php ' ))
75
+ {
76
+ $ include = $ this ->template . '.php ' ;
77
+ }
78
+
79
+ if (stream_resolve_include_path ('PHPDraft/Out/HTML/ ' . $ this ->template . '.php ' ))
80
+ {
81
+ $ include = 'PHPDraft/Out/HTML/ ' . $ this ->template . '.php ' ;
82
+ }
83
+ if ($ include === NULL )
84
+ {
85
+ file_put_contents ('php://stderr ' , "Couldn't find template ' $ this ->template ' \n" );
86
+ exit (1 );
87
+ }
88
+
60
89
//Prepare base data
61
90
if (is_array ($ object ->content [0 ]->content ))
62
91
{
63
92
foreach ($ object ->content [0 ]->attributes ->meta as $ meta )
64
93
{
65
94
$ this ->base_data [$ meta ->content ->key ->content ] = $ meta ->content ->value ->content ;
66
95
}
67
-
68
- $ this ->base_data ['TITLE ' ] = $ object ->content [0 ]->meta ->title ;
69
- }
70
-
71
- //Parse specific data
72
- if (is_array ($ object ->content [0 ]->content ))
73
- {
74
96
foreach ($ object ->content [0 ]->content as $ value )
75
97
{
76
98
if ($ value ->element === 'copy ' )
@@ -88,9 +110,11 @@ public function get($object)
88
110
$ this ->base_structures = $ cat ->structures ;
89
111
}
90
112
}
113
+
114
+ $ this ->base_data ['TITLE ' ] = $ object ->content [0 ]->meta ->title ;
91
115
}
92
116
93
- include_once ' PHPDraft/Out/HTML/ ' . $ this -> template . ' .php ' ;
117
+ include_once $ include ;
94
118
}
95
119
96
120
/**
0 commit comments