|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (c) 2016-2024 BigBlueButton Inc. and by respective authors (see below). |
|
7
|
|
|
* |
|
8
|
|
|
* This program is free software; you can redistribute it and/or modify it under the |
|
9
|
|
|
* terms of the GNU Lesser General Public License as published by the Free Software |
|
10
|
|
|
* Foundation; either version 3.0 of the License, or (at your option) any later |
|
11
|
|
|
* version. |
|
12
|
|
|
* |
|
13
|
|
|
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY |
|
14
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
15
|
|
|
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU Lesser General Public License along |
|
18
|
|
|
* with BigBlueButton; if not, see <https://www.gnu.org/licenses/>. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace BigBlueButton\Parameters; |
|
22
|
|
|
|
|
23
|
|
|
use BigBlueButton\Parameters\Config\DocumentOptionsStore; |
|
24
|
|
|
|
|
25
|
|
|
trait DocumentableTrait |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @var array<string, mixed> |
|
29
|
|
|
*/ |
|
30
|
|
|
protected array $presentations = []; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @return array<string, mixed> |
|
34
|
|
|
*/ |
|
35
|
|
|
public function getPresentations(): array |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->presentations; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function addPresentation(string $nameOrUrl, $content = null, ?string $filename = null, DocumentOptionsStore $attributes = null): self |
|
41
|
|
|
{ |
|
42
|
|
|
$this->presentations[$nameOrUrl] = [ |
|
43
|
|
|
'content' => !$content ?: base64_encode($content), |
|
44
|
|
|
'filename' => $filename, |
|
45
|
|
|
'attributes' => $attributes |
|
46
|
|
|
]; |
|
47
|
|
|
|
|
48
|
|
|
return $this; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function getPresentationsAsXML(): string |
|
52
|
|
|
{ |
|
53
|
|
|
$result = ''; |
|
54
|
|
|
if (!empty($this->presentations)) { |
|
55
|
|
|
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><modules/>'); |
|
56
|
|
|
$module = $xml->addChild('module'); |
|
57
|
|
|
$module->addAttribute('name', 'presentation'); |
|
58
|
|
|
|
|
59
|
|
|
foreach ($this->presentations as $nameOrUrl => $data) { |
|
60
|
|
|
$presentation = $module->addChild('document'); |
|
61
|
|
|
if (0 === mb_strpos($nameOrUrl, 'http')) { |
|
62
|
|
|
$presentation->addAttribute('url', $nameOrUrl); |
|
63
|
|
|
} else { |
|
64
|
|
|
$presentation->addAttribute('name', $nameOrUrl); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
if (!empty($data['filename'])) { |
|
68
|
|
|
$presentation->addAttribute('filename', $data['filename']); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
if (!empty($data['content'])) { |
|
72
|
|
|
$presentation[0] = $data['content']; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
// Add attributes using DocumentAttributes class |
|
76
|
|
|
foreach ($data['attributes']->getAttributes() as $attrName => $attrValue) { |
|
77
|
|
|
$presentation->addAttribute($attrName, $attrValue); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
$result = $xml->asXML(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
if (!is_string($result)) { |
|
84
|
|
|
throw new \RuntimeException('String expected, but ' . gettype($result) . ' received.'); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
return $result; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|