1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2016-2022 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 <http://www.gnu.org/licenses/>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace BigBlueButton\Parameters; |
22
|
|
|
|
23
|
|
|
trait DocumentableTrait |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var array |
27
|
|
|
*/ |
28
|
|
|
protected $presentations = []; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @return array |
32
|
|
|
*/ |
33
|
|
|
public function getPresentations() |
34
|
|
|
{ |
35
|
|
|
return $this->presentations; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param $nameOrUrl |
40
|
|
|
* @param null $content |
|
|
|
|
41
|
|
|
* @param null $filename |
|
|
|
|
42
|
|
|
* |
43
|
|
|
* @return $this |
44
|
|
|
*/ |
45
|
|
|
public function addPresentation($nameOrUrl, $content = null, $filename = null) |
46
|
|
|
{ |
47
|
|
|
if (!$filename) { |
|
|
|
|
48
|
|
|
$this->presentations[$nameOrUrl] = !$content ?: base64_encode($content); |
|
|
|
|
49
|
|
|
} else { |
50
|
|
|
$this->presentations[$nameOrUrl] = $filename; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
return $this; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return mixed |
58
|
|
|
*/ |
59
|
|
|
public function getPresentationsAsXML() |
60
|
|
|
{ |
61
|
|
|
$result = ''; |
62
|
|
|
|
63
|
|
|
if (!empty($this->presentations)) { |
64
|
|
|
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><modules/>'); |
65
|
|
|
$module = $xml->addChild('module'); |
66
|
|
|
$module->addAttribute('name', 'presentation'); |
67
|
|
|
|
68
|
|
|
foreach ($this->presentations as $nameOrUrl => $content) { |
69
|
|
|
if (0 === mb_strpos($nameOrUrl, 'http')) { |
70
|
|
|
$presentation = $module->addChild('document'); |
71
|
|
|
$presentation->addAttribute('url', $nameOrUrl); |
72
|
|
|
if (is_string($content)) { |
73
|
|
|
$presentation->addAttribute('filename', $content); |
74
|
|
|
} |
75
|
|
|
} else { |
76
|
|
|
$document = $module->addChild('document'); |
77
|
|
|
$document->addAttribute('name', $nameOrUrl); |
78
|
|
|
$document[0] = $content; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
$result = $xml->asXML(); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
return $result; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|