Skip to content

Commit 9c73ecc

Browse files
committed
Add support for embedded slides
1 parent 0dc0b2c commit 9c73ecc

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

src/Parameters/InsertDocumentParameters.php

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ public function __construct(protected string $meetingID)
3434
{
3535
}
3636

37-
public function addPresentation(string $url, string $filename, ?bool $downloadable = null, ?bool $removable = null): self
37+
public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null, ?bool $downloadable = null, ?bool $removable = null): self
3838
{
39-
$this->presentations[$url] = [
39+
$this->presentations[$nameOrUrl] = [
4040
'filename' => $filename,
41+
'content' => !$content ?: base64_encode($content),
4142
'downloadable' => $downloadable,
4243
'removable' => $removable,
4344
];
@@ -61,17 +62,27 @@ public function getPresentationsAsXML(): string|false
6162
$module = $xml->addChild('module');
6263
$module->addAttribute('name', 'presentation');
6364

64-
foreach ($this->presentations as $url => $content) {
65-
$presentation = $module->addChild('document');
66-
$presentation->addAttribute('url', $url);
67-
$presentation->addAttribute('filename', $content['filename']);
65+
foreach ($this->presentations as $nameOrUrl => $data) {
66+
$document = $module->addChild('document');
6867

69-
if (\is_bool($content['downloadable'])) {
70-
$presentation->addAttribute('downloadable', $content['downloadable'] ? 'true' : 'false');
68+
if (str_starts_with($nameOrUrl, 'http')) {
69+
$document->addAttribute('url', $nameOrUrl);
70+
} else {
71+
$document->addAttribute('name', $nameOrUrl);
72+
/* @phpstan-ignore-next-line */
73+
$document[0] = $data['content'];
7174
}
7275

73-
if (\is_bool($content['removable'])) {
74-
$presentation->addAttribute('removable', $content['removable'] ? 'true' : 'false');
76+
if (isset($data['filename'])) {
77+
$document->addAttribute('filename', $data['filename']);
78+
}
79+
80+
if (\is_bool($data['downloadable'])) {
81+
$document->addAttribute('downloadable', $data['downloadable'] ? 'true' : 'false');
82+
}
83+
84+
if (\is_bool($data['removable'])) {
85+
$document->addAttribute('removable', $data['removable'] ? 'true' : 'false');
7586
}
7687
}
7788
$result = $xml->asXML();

0 commit comments

Comments
 (0)