-
Notifications
You must be signed in to change notification settings - Fork 14
Refactor presentation files #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 8 commits
a38b553
f38162c
475ba3e
8d0d32c
c3c79b5
54bdd9b
bee9f1f
807a026
a62a2f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. | ||
| * | ||
| * Copyright (c) 2016-2018 BigBlueButton Inc. and by respective authors (see below). | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify it under the | ||
| * terms of the GNU Lesser General Public License as published by the Free Software | ||
| * Foundation; either version 3.0 of the License, or (at your option) any later | ||
| * version. | ||
| * | ||
| * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
| * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License along | ||
| * with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| namespace BigBlueButton\Core; | ||
|
|
||
| use BigBlueButton\Util\SimpleXMLElementExtended; | ||
|
|
||
| class InlinePresentation extends Presentation | ||
| { | ||
| public function __construct(private readonly string $content, string $filename) | ||
| { | ||
| $this->filename = $filename; | ||
| } | ||
|
|
||
| public function getArrayKey(): string | ||
| { | ||
| return $this->filename; | ||
| } | ||
|
|
||
| public function addDocumentToXML(SimpleXMLElementExtended $module): ?SimpleXMLElementExtended | ||
| { | ||
| $document = parent::addDocumentToXML($module); | ||
|
|
||
| /* @phpstan-ignore-next-line */ | ||
| $document[0] = base64_encode($this->content); | ||
|
|
||
| if (isset($this->filename)) { | ||
| $document->addAttribute('name', $this->filename); | ||
| } | ||
|
|
||
| return $document; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. | ||
| * | ||
| * Copyright (c) 2016-2018 BigBlueButton Inc. and by respective authors (see below). | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify it under the | ||
| * terms of the GNU Lesser General Public License as published by the Free Software | ||
| * Foundation; either version 3.0 of the License, or (at your option) any later | ||
| * version. | ||
| * | ||
| * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
| * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License along | ||
| * with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| namespace BigBlueButton\Core; | ||
|
|
||
| use BigBlueButton\Util\SimpleXMLElementExtended; | ||
|
|
||
| abstract class Presentation | ||
| { | ||
| protected ?string $filename = null; | ||
|
|
||
| protected ?bool $current = null; | ||
|
|
||
| protected ?bool $downloadable = null; | ||
|
|
||
| protected ?bool $removable = null; | ||
|
|
||
| public function addDocumentToXML(SimpleXMLElementExtended $module): ?SimpleXMLElementExtended | ||
| { | ||
| $document = $module->addChild('document'); | ||
|
|
||
| if (\is_bool($this->downloadable)) { | ||
| $document->addAttribute('downloadable', $this->downloadable ? 'true' : 'false'); | ||
| } | ||
|
|
||
| if (\is_bool($this->removable)) { | ||
| $document->addAttribute('removable', $this->removable ? 'true' : 'false'); | ||
| } | ||
|
|
||
| if (\is_bool($this->current)) { | ||
| $document->addAttribute('current', $this->current ? 'true' : 'false'); | ||
| } | ||
|
|
||
| return $document; | ||
| } | ||
|
|
||
| abstract public function getArrayKey(): string; | ||
|
|
||
| public function getFilename(): ?string | ||
| { | ||
| return $this->filename; | ||
| } | ||
|
|
||
| public function setFilename(string $filename): self | ||
| { | ||
| $this->filename = $filename; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function getCurrent(): ?bool | ||
| { | ||
| return $this->current; | ||
| } | ||
|
|
||
| public function setCurrent(bool $current): self | ||
| { | ||
| $this->current = $current; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function getDownloadable(): ?bool | ||
| { | ||
| return $this->downloadable; | ||
| } | ||
|
|
||
| public function setDownloadable(bool $downloadable): self | ||
| { | ||
| $this->downloadable = $downloadable; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function getRemovable(): ?bool | ||
| { | ||
| return $this->removable; | ||
| } | ||
|
|
||
| public function setRemovable(bool $removable): self | ||
| { | ||
| $this->removable = $removable; | ||
|
|
||
| return $this; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. | ||
| * | ||
| * Copyright (c) 2016-2018 BigBlueButton Inc. and by respective authors (see below). | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify it under the | ||
| * terms of the GNU Lesser General Public License as published by the Free Software | ||
| * Foundation; either version 3.0 of the License, or (at your option) any later | ||
| * version. | ||
| * | ||
| * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
| * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License along | ||
| * with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| namespace BigBlueButton\Core; | ||
|
|
||
| use BigBlueButton\Util\SimpleXMLElementExtended; | ||
|
|
||
| class UrlPresentation extends Presentation | ||
|
samuelwei marked this conversation as resolved.
Outdated
|
||
| { | ||
| public function __construct(private readonly string $url) | ||
| { | ||
| } | ||
|
|
||
| public function getArrayKey(): string | ||
| { | ||
| return $this->url; | ||
| } | ||
|
|
||
| public function addDocumentToXML(SimpleXMLElementExtended $module): ?SimpleXMLElementExtended | ||
| { | ||
| $document = parent::addDocumentToXML($module); | ||
| $document->addAttribute('url', $this->url); | ||
|
|
||
| if (isset($this->filename)) { | ||
| $document->addAttribute('filename', $this->filename); | ||
| } | ||
|
|
||
| return $document; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,9 @@ | |
|
|
||
| namespace BigBlueButton\Parameters; | ||
|
|
||
| use BigBlueButton\Core\InlinePresentation; | ||
| use BigBlueButton\Core\Presentation; | ||
| use BigBlueButton\Core\UrlPresentation; | ||
| use BigBlueButton\Enum\Feature; | ||
| use BigBlueButton\Enum\GuestPolicy; | ||
| use BigBlueButton\Enum\MeetingLayout; | ||
|
|
@@ -247,9 +250,7 @@ class CreateMeetingParameters extends MetaParameters | |
| protected ?bool $allowOverrideClientSettingsOnCreateCall = null; | ||
| protected ?string $clientSettingsOverride = null; | ||
|
|
||
| /** | ||
| * @var array<string,string> | ||
| */ | ||
| /** @var array<string,Presentation> */ | ||
| private array $presentations = []; | ||
|
|
||
| public function __construct(protected string $meetingID, protected string $name) | ||
|
|
@@ -351,12 +352,30 @@ public function setGuestPolicyAlwaysAccept(): self | |
| return $this; | ||
| } | ||
|
|
||
| public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null): self | ||
| /** | ||
| * @return $this | ||
| */ | ||
| public function addPresentation(string|Presentation $nameOrUrlOrPresentation, ?string $content = null, ?string $filename = null): self | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sadly: Breaking change :/ . I need to think about a solution. Maybe we must move this to a new major version or add a new method.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also need a major version for #243, as the parameter and return type changed |
||
| { | ||
| if (!$filename) { | ||
| $this->presentations[$nameOrUrl] = !$content ?: base64_encode($content); | ||
| if ($nameOrUrlOrPresentation instanceof Presentation) { | ||
| $this->presentations[$nameOrUrlOrPresentation->getArrayKey()] = $nameOrUrlOrPresentation; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| @trigger_error(\sprintf('Calling addPresentation in "%s" with any parameters other than a single Presentation object is deprecated and will throw an exception in 7.0.', self::class), \E_USER_DEPRECATED); | ||
|
|
||
| if ($content) { | ||
| $presentation = new InlinePresentation($content, $nameOrUrlOrPresentation); | ||
| $this->presentations[$presentation->getArrayKey()] = $presentation; | ||
| } else { | ||
| $this->presentations[$nameOrUrl] = $filename; | ||
| $presentation = new UrlPresentation($nameOrUrlOrPresentation); | ||
|
|
||
| if ($filename != null) { | ||
| $presentation->setFilename($filename); | ||
| } | ||
|
|
||
| $this->presentations[$presentation->getArrayKey()] = $presentation; | ||
| } | ||
|
|
||
| return $this; | ||
|
|
@@ -382,7 +401,7 @@ public function addBreakoutRoomsGroup(string $id, ?string $name, array $roster): | |
| return $this; | ||
| } | ||
|
|
||
| /** @return array<string,string> */ | ||
| /** @return array<string,Presentation> */ | ||
| public function getPresentations(): array | ||
| { | ||
| return $this->presentations; | ||
|
|
@@ -423,18 +442,9 @@ public function addPresentationsModule(SimpleXMLElementExtended $xml): void | |
| $module = $xml->addChild('module'); | ||
| $module->addAttribute('name', 'presentation'); | ||
|
|
||
| foreach ($this->presentations as $nameOrUrl => $content) { | ||
| if (str_starts_with($nameOrUrl, 'http')) { | ||
| $presentation = $module->addChild('document'); | ||
| $presentation->addAttribute('url', $nameOrUrl); | ||
| if (\is_string($content)) { | ||
| $presentation->addAttribute('filename', $content); | ||
| } | ||
| } else { | ||
| $document = $module->addChild('document'); | ||
| $document->addAttribute('name', $nameOrUrl); | ||
| /* @phpstan-ignore-next-line */ | ||
| $document[0] = $content; | ||
| foreach ($this->presentations as $data) { | ||
| if ($data instanceof Presentation) { | ||
| $data->addDocumentToXML($module); | ||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.