2020
2121namespace BigBlueButton \Parameters ;
2222
23+ use BigBlueButton \Parameters \Config \DocumentOptionsStore ;
24+
2325trait DocumentableTrait
2426{
2527 /**
@@ -35,40 +37,44 @@ public function getPresentations(): array
3537 return $ this ->presentations ;
3638 }
3739
38- /**
39- * @param mixed $content
40- */
41- public function addPresentation (string $ nameOrUrl , $ content = null , ?string $ filename = null ): self
40+ public function addPresentation (string $ nameOrUrl , $ content = null , ?string $ filename = null , DocumentOptionsStore $ attributes = null ): self
4241 {
43- if (! $ filename ) {
44- $ this -> presentations [ $ nameOrUrl ] = !$ content ?: base64_encode ($ content );
45- } else {
46- $ this -> presentations [ $ nameOrUrl ] = $ filename ;
47- }
42+ $ this -> presentations [ $ nameOrUrl ] = [
43+ ' content ' => !$ content ?: base64_encode ($ content ),
44+ ' filename ' => $ filename ,
45+ ' attributes ' => $ attributes
46+ ];
4847
4948 return $ this ;
5049 }
5150
5251 public function getPresentationsAsXML (): string
5352 {
5453 $ result = '' ;
55-
5654 if (!empty ($ this ->presentations )) {
5755 $ xml = new \SimpleXMLElement ('<?xml version="1.0" encoding="UTF-8"?><modules/> ' );
5856 $ module = $ xml ->addChild ('module ' );
5957 $ module ->addAttribute ('name ' , 'presentation ' );
6058
61- foreach ($ this ->presentations as $ nameOrUrl => $ content ) {
59+ foreach ($ this ->presentations as $ nameOrUrl => $ data ) {
60+ $ presentation = $ module ->addChild ('document ' );
6261 if (0 === mb_strpos ($ nameOrUrl , 'http ' )) {
63- $ presentation = $ module ->addChild ('document ' );
6462 $ presentation ->addAttribute ('url ' , $ nameOrUrl );
65- if (is_string ($ content )) {
66- $ presentation ->addAttribute ('filename ' , $ content );
67- }
6863 } else {
69- $ document = $ module ->addChild ('document ' );
70- $ document ->addAttribute ('name ' , $ nameOrUrl );
71- $ document [0 ] = $ content ;
64+ $ presentation ->addAttribute ('name ' , $ nameOrUrl );
65+ }
66+
67+ if (!empty ($ data ['filename ' ])) {
68+ $ presentation ->addAttribute ('filename ' , $ data ['filename ' ]);
69+ }
70+
71+ if (!empty ($ data ['content ' ])) {
72+ $ presentation [0 ] = $ data ['content ' ];
73+ }
74+
75+ // Add attributes using DocumentAttributes class
76+ foreach ($ data ['attributes ' ]->getAttributes () as $ attrName => $ attrValue ) {
77+ $ presentation ->addAttribute ($ attrName , $ attrValue );
7278 }
7379 }
7480 $ result = $ xml ->asXML ();
0 commit comments