Skip to content

Commit

Permalink
Update document class
Browse files Browse the repository at this point in the history
  • Loading branch information
sanduhrs committed Aug 4, 2020
1 parent a6abadb commit 84fb932
Showing 1 changed file with 65 additions and 5 deletions.
70 changes: 65 additions & 5 deletions src/BigBlueButton/Member/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
*/
class Document
{

const XML_VERSION = '1.0';

const XML_ENCODING = 'UTF-8';

/**
* The URI.
*
Expand All @@ -33,6 +38,13 @@ class Document
*/
protected $embed;

/**
* The base64 representation.
*
* @var string
*/
protected $base64;

/**
* The BigBlueButton client.
*
Expand All @@ -43,15 +55,17 @@ class Document
/**
* Document constructor.
*
* @param $uri
* @param $url
* @param string $name
* @param bool $embed
* @param string $base64
*/
public function __construct($uri, $name = '', $embed = false)
public function __construct($url = '', $name = '', $embed = false, $base64 = '')
{
$this->uri = new Uri($uri);
$this->name = $name;
$this->embed = $embed;
$this->setUri(new Uri($url));
$this->setName($name);
$this->setEmbed($embed);
$this->setBase64($base64);
}

/**
Expand Down Expand Up @@ -120,6 +134,52 @@ public function setEmbed($embed)
return $this;
}

/**
* Get the base64 representation.
*
* @return string
*/
public function getBase64()
{
return $this->base64;
}

/**
* Set the base64 representation.
*
* @param string $base64
* @return Document
*/
public function setBase64($base64)
{
$this->base64 = $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.
*
Expand Down

0 comments on commit 84fb932

Please sign in to comment.