1 | <?php |
||
32 | final class AframeDOMDocument extends DOMImplementation |
||
33 | { |
||
34 | |||
35 | /** |
||
36 | * A-Frame DOM Document type |
||
37 | * |
||
38 | * @var \DOMDocumentType |
||
39 | */ |
||
40 | protected $doctypeObj; |
||
41 | |||
42 | /** |
||
43 | * A-Frame DOM Document |
||
44 | * |
||
45 | * @var \DOMDocument |
||
46 | */ |
||
47 | protected $docObj; |
||
48 | |||
49 | /** |
||
50 | * Scene meta tile |
||
51 | * |
||
52 | * @var string $scene_title |
||
53 | */ |
||
54 | protected $scene_title = 'Untitled'; |
||
55 | |||
56 | /** |
||
57 | * Scene meta description |
||
58 | * |
||
59 | * @var string $scene_description |
||
60 | */ |
||
61 | protected $scene_description = ''; |
||
62 | |||
63 | /** |
||
64 | * CDN Of aframe.js |
||
65 | * |
||
66 | * @var string |
||
67 | */ |
||
68 | protected $aframe_cdn; |
||
69 | |||
70 | /** |
||
71 | * Whether to use CDN |
||
72 | * |
||
73 | * @var bool $use_cdn |
||
74 | */ |
||
75 | protected $use_cdn = false; |
||
76 | |||
77 | /** |
||
78 | * <head> |
||
79 | * |
||
80 | * @var \DOMElement $head |
||
81 | */ |
||
82 | protected $head; |
||
83 | |||
84 | /** |
||
85 | * <body> |
||
86 | * |
||
87 | * @var \DOMElement $body |
||
88 | */ |
||
89 | protected $body; |
||
90 | |||
91 | /** |
||
92 | * <a-scene> |
||
93 | * |
||
94 | * @var \DOMElement $scene |
||
95 | */ |
||
96 | protected $scene; |
||
97 | |||
98 | /** |
||
99 | * Nicely formats output with indentation and extra space. |
||
100 | * |
||
101 | * @var bool |
||
102 | */ |
||
103 | public $formatOutput = true; |
||
104 | |||
105 | /** |
||
106 | * A-Frame DOM |
||
107 | * |
||
108 | * @param Config $config |
||
109 | */ |
||
110 | 60 | public function __construct(Config $config) |
|
125 | |||
126 | /** |
||
127 | * Load aframe.in.js from CDN |
||
128 | * |
||
129 | * @return void |
||
130 | */ |
||
131 | 2 | public function useCDN() |
|
135 | |||
136 | /** |
||
137 | * Set CDN for aframe.js or min.js |
||
138 | * |
||
139 | * @param string $cdn |
||
140 | * @return void |
||
141 | */ |
||
142 | 60 | public function setCDN(string $cdn) |
|
146 | |||
147 | /** |
||
148 | * Render scene this DOM Object is attached to |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | 3 | public function render(): string |
|
164 | |||
165 | /** |
||
166 | * Set Scene meta title |
||
167 | * |
||
168 | * @param string $title |
||
169 | */ |
||
170 | 2 | public function setTitle(string $title) |
|
174 | |||
175 | /** |
||
176 | * Set Scene meta description |
||
177 | * |
||
178 | * @param string $description |
||
179 | */ |
||
180 | 2 | public function setDescription(string $description) |
|
184 | |||
185 | /** |
||
186 | * Append entities |
||
187 | * |
||
188 | * @param array $entities |
||
189 | * @return void |
||
190 | */ |
||
191 | 3 | public function appendEntities(array $entities) |
|
199 | |||
200 | /** |
||
201 | * Add entity |
||
202 | * |
||
203 | * @param Entity $entity |
||
204 | * @return void |
||
205 | */ |
||
206 | 1 | public function appendEntity(Entity $entity) |
|
210 | |||
211 | /** |
||
212 | * Get HTML of Scene only |
||
213 | * |
||
214 | * @return string |
||
215 | */ |
||
216 | 1 | public function renderSceneOnly() |
|
223 | |||
224 | /** |
||
225 | * Prepeare head |
||
226 | * |
||
227 | * @return void |
||
228 | */ |
||
229 | 3 | protected function renderHead() |
|
235 | |||
236 | /** |
||
237 | * Append deffault metatags |
||
238 | * |
||
239 | * @return void |
||
240 | */ |
||
241 | 3 | protected function appendDefaultMetaTags() |
|
246 | |||
247 | /** |
||
248 | * Get default meta tags |
||
249 | * |
||
250 | * @return array |
||
251 | */ |
||
252 | 3 | protected function getDefaultMetaTags(): array |
|
276 | |||
277 | /** |
||
278 | * If requested by user use aframe CDN |
||
279 | * |
||
280 | * @return void |
||
281 | */ |
||
282 | 3 | protected function appendCDN() |
|
290 | |||
291 | /** |
||
292 | * Prepare body |
||
293 | * |
||
294 | * @return void |
||
295 | */ |
||
296 | 3 | protected function renderBody() |
|
300 | |||
301 | /** |
||
302 | * Create meta tags |
||
303 | * |
||
304 | * @param array $attr |
||
305 | */ |
||
306 | 3 | protected function appendMetaTag(array $attr) |
|
313 | |||
314 | /** |
||
315 | * Create title tag |
||
316 | * |
||
317 | * @return void |
||
318 | */ |
||
319 | 3 | protected function appendTitle() |
|
324 | |||
325 | /** |
||
326 | * Creates an empty DOMDocumentType object |
||
327 | * |
||
328 | * @param string $doctype |
||
329 | * @return void |
||
330 | */ |
||
331 | 60 | protected function createDocType(string $doctype) |
|
335 | |||
336 | /** |
||
337 | * Creates a DOMDocument object of the specified type with its document element |
||
338 | * |
||
339 | * @return void |
||
340 | */ |
||
341 | 60 | protected function createAframeDocument() |
|
345 | |||
346 | /** |
||
347 | * Create <head> element node |
||
348 | * |
||
349 | * @return void |
||
350 | */ |
||
351 | 60 | protected function createHead() |
|
355 | |||
356 | /** |
||
357 | * Create <body> element node |
||
358 | * |
||
359 | * @return void |
||
360 | */ |
||
361 | 60 | protected function createBody() |
|
365 | |||
366 | /** |
||
367 | * Create <a-scene> element node |
||
368 | * |
||
369 | * @return void |
||
370 | */ |
||
371 | 60 | protected function createScene() |
|
375 | } |
||
376 |