From 8471ea65640e81f5afa2a0372bb6091787244a18 Mon Sep 17 00:00:00 2001 From: Stefan Auditor Date: Wed, 5 Aug 2020 09:31:35 +0200 Subject: [PATCH] Move xml generation to central place --- src/BigBlueButton/Member/Document.php | 28 ------------------------ src/BigBlueButton/Member/Meeting.php | 31 ++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/BigBlueButton/Member/Document.php b/src/BigBlueButton/Member/Document.php index 85861e8..a428245 100644 --- a/src/BigBlueButton/Member/Document.php +++ b/src/BigBlueButton/Member/Document.php @@ -13,10 +13,6 @@ class Document { - const XML_VERSION = '1.0'; - - const XML_ENCODING = 'UTF-8'; - /** * The URI. * @@ -156,30 +152,6 @@ public function setBase64($base64) return $this; } - /** - * Get XML representation of the document for upload. - * - * @return \DOMElement - */ - public function getXmlString() - { - $xml = new \DOMDocument(self::XML_VERSION, self::XML_ENCODING); - if ($this->isEmbedded()) { - if ($this->getBase64() === '') { - $this->setBase64(base64_encode(file_get_contents($this->getUri()))); - } - $document = $xml->createElement("document", $this->getBase64()); - $document->setAttribute('name', $this->getName()); - $xml->appendChild($document); - } else { - $document = $xml->createElement("document", $this->getBase64()); - $document->setAttribute('url', $this->getUri()); - $document->setAttribute('filename', $this->getName()); - $xml->appendChild($document); - } - return $xml->saveXML($xml->documentElement); - } - /** * Set the client. * diff --git a/src/BigBlueButton/Member/Meeting.php b/src/BigBlueButton/Member/Meeting.php index 1f85e47..bb32ac0 100644 --- a/src/BigBlueButton/Member/Meeting.php +++ b/src/BigBlueButton/Member/Meeting.php @@ -18,6 +18,10 @@ class Meeting const GUEST_POLICY_ASK_MODERATOR = 'ASK_MODERATOR'; + const XML_VERSION = '1.0'; + + const XML_ENCODING = 'UTF-8'; + /** * The meeting name. * @@ -394,7 +398,7 @@ class Meeting /** * The slides. * - * @var array + * @var \sanduhrs\BigBlueButton\Member\Document[] */ protected $slides; @@ -1601,14 +1605,35 @@ public function create() 'lockSettingsLockedLayout' => $this->getLockSettingsLockedLayout(), 'lockSettingsLockOnJoin' => $this->getLockSettingsLockOnJoin(), 'lockSettingsLockOnJoinConfigurable' => $this->getLockSettingsLockOnJoinConfigurable(), - 'body' => '', ]; foreach ($this->getMetadata() as $key => $value) { $parameters["meta_$key"] = $value; } - + $xml = new \DOMDocument(self::XML_VERSION, self::XML_ENCODING); + $modules = $xml->createElement("modules"); + $module = $xml->createElement("module"); + $module->setAttribute('name', 'presentation'); + $modules->appendChild($module); + foreach ($this->getSlides() as $slide) { + if ($slide->isEmbedded()) { + if ($slide->getBase64() === '') { + $slide->setBase64(base64_encode(file_get_contents($slide->getUri()))); + } + $document = $xml->createElement("document", $slide->getBase64()); + $document->setAttribute('name', $slide->getName()); + $module->appendChild($document); + } else { + $document = $xml->createElement("document", $slide->getBase64()); + $document->setAttribute('url', $slide->getUri()); + $document->setAttribute('filename', $slide->getName()); + $module->appendChild($document); + } + } + $xml->appendChild($modules); + $body = $xml->saveXML($xml->documentElement); + $parameters['body'] = $body; $response = $this->client->post('create', $parameters); $this->meetingID = $response->meetingID;