ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilChatroomXMLWriter Class Reference

Class ilChatroomXMLWriter. More...

+ Inheritance diagram for ilChatroomXMLWriter:
+ Collaboration diagram for ilChatroomXMLWriter:

Public Member Functions

 __construct (protected ilObjChatroom $chat)
 
 start ()
 
 getXML ()
 
- Public Member Functions inherited from ilXmlWriter
 __construct (string $version="1.0", string $outEnc="utf-8", string $inEnc="utf-8")
 
 xmlSetDtdDef (string $dtdDef)
 Sets dtd definition. More...
 
 xmlSetGenCmt (string $genCmt)
 Sets generated comment. More...
 
 xmlFormatData (string $data)
 Indents text for better reading. More...
 
 xmlHeader ()
 Writes xml header. More...
 
 xmlStartTag (string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
 Writes a starttag. More...
 
 xmlEndTag (string $tag)
 Writes an endtag. More...
 
 xmlData (string $data, bool $encode=true, bool $escape=true)
 Writes data. More...
 
 xmlElement (string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile (string $file, bool $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem (bool $format=true)
 Returns xml document from memory. More...
 
 appendXML (string $a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr More...
 

Protected Attributes

ilChatroom $room
 

Private Member Functions

 exportData ()
 

Detailed Description

Class ilChatroomXMLWriter.

Definition at line 24 of file class.ilChatroomXMLWriter.php.

Constructor & Destructor Documentation

◆ __construct()

ilChatroomXMLWriter::__construct ( protected ilObjChatroom  $chat)

Definition at line 28 of file class.ilChatroomXMLWriter.php.

29 {
30 $this->room = ilChatroom::byObjectId($this->chat->getId());
31 if (!$this->room) {
32 $this->room = new ilChatroom();
33 $this->room->setSetting('object_id', $this->chat->getId());
34 }
35
37 }
Class ilChatroom.
static byObjectId(int $object_id)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), and ilChatroom\byObjectId().

+ Here is the call graph for this function:

Member Function Documentation

◆ exportData()

ilChatroomXMLWriter::exportData ( )
private

Definition at line 61 of file class.ilChatroomXMLWriter.php.

61 : void
62 {
63 $history = $this->room->getHistory(null, null, null, false);
64 if (count($history) > 0) {
65 $this->xmlStartTag('Messages');
66 foreach ($history as $entry) {
67 $this->xmlStartTag('Message');
68 $this->xmlElement('Body', null, json_encode($entry['message'], JSON_THROW_ON_ERROR));
69 $this->xmlElement('CreatedTimestamp', null, (string) ((int) $entry['timestamp']));
70 $this->xmlEndTag('Message');
71 }
72 $this->xmlEndTag('Messages');
73 }
74 }
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.

References ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getXML()

ilChatroomXMLWriter::getXML ( )

Definition at line 76 of file class.ilChatroomXMLWriter.php.

76 : string
77 {
78 // Replace ascii code 11 characters because of problems with xml sax parser
79 return str_replace('', '', $this->xmlDumpMem(false));
80 }
xmlDumpMem(bool $format=true)
Returns xml document from memory.

References ilXmlWriter\xmlDumpMem().

+ Here is the call graph for this function:

◆ start()

ilChatroomXMLWriter::start ( )

Definition at line 39 of file class.ilChatroomXMLWriter.php.

39 : void
40 {
41 $this->xmlStartTag('Chatroom');
42
43 $this->xmlElement('ObjId', null, (string) $this->chat->getId());
44 $this->xmlElement('RoomId', null, (string) $this->room->getRoomId());
45 $this->xmlElement('Title', null, $this->chat->getTitle());
46 $this->xmlElement('Description', null, $this->chat->getDescription());
47 $this->xmlElement('OnlineStatus', null, (string) ((int) (!$this->chat->getOfflineStatus())));
48 $this->xmlElement('AllowAnonymousAccess', null, (string) ((int) $this->room->getSetting('allow_anonymous')));
49 $this->xmlElement('AllowCustomUsernames', null, (string) ((int) $this->room->getSetting('allow_custom_usernames')));
50 $this->xmlElement('EnableHistory', null, (string) ((int) $this->room->getSetting('enable_history')));
51 $this->xmlElement('DisplayPastMessages', null, (string) ((int) $this->room->getSetting('display_past_msgs')));
52 $this->xmlElement('AutoGeneratedUsernameSchema', null, (string) $this->room->getSetting('autogen_usernames'));
53
54 if ($this->room->getRoomId() > 0) {
55 $this->exportData();
56 }
57
58 $this->xmlEndTag('Chatroom');
59 }

References exportData(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

Field Documentation

◆ $room

ilChatroom ilChatroomXMLWriter::$room
protected

Definition at line 26 of file class.ilChatroomXMLWriter.php.


The documentation for this class was generated from the following file: